• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_RSS_STAT_TRACKER_H_
18 #define SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_RSS_STAT_TRACKER_H_
19 
20 #include "perfetto/ext/base/flat_hash_map.h"
21 #include "perfetto/protozero/field.h"
22 #include "src/trace_processor/storage/trace_storage.h"
23 
24 namespace perfetto {
25 namespace trace_processor {
26 
27 class TraceProcessorContext;
28 
29 class RssStatTracker {
30  public:
31   using ConstBytes = protozero::ConstBytes;
32 
33   explicit RssStatTracker(TraceProcessorContext*);
34 
35   void ParseRssStat(int64_t ts,
36                     int32_t field_id,
37                     uint32_t pid,
38                     ConstBytes blob);
39   void ParseRssStat(int64_t ts,
40                     uint32_t pid,
41                     int64_t size,
42                     uint32_t member,
43                     std::optional<bool> curr,
44                     std::optional<int64_t> mm_id);
45 
46  private:
47   std::optional<UniqueTid> FindUtidForMmId(int64_t mm_id,
48                                            bool is_curr,
49                                            uint32_t pid);
50 
51   base::FlatHashMap<int64_t, UniqueTid> mm_id_to_utid_;
52   std::vector<StringId> rss_members_;
53   TraceProcessorContext* const context_;
54 };
55 
56 }  // namespace trace_processor
57 }  // namespace perfetto
58 
59 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_RSS_STAT_TRACKER_H_
60