1 /* 2 * Copyright (C) 2017 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_TRACED_PROBES_FTRACE_FTRACE_METADATA_H_ 18 #define SRC_TRACED_PROBES_FTRACE_FTRACE_METADATA_H_ 19 20 #include <stdint.h> 21 #include <sys/stat.h> 22 #include <unistd.h> 23 24 #include <utility> 25 #include <vector> 26 27 #include "perfetto/base/logging.h" 28 29 namespace perfetto { 30 31 using BlockDeviceID = decltype(stat::st_dev); 32 using Inode = decltype(stat::st_ino); 33 34 struct FtraceMetadata { 35 FtraceMetadata(); 36 37 uint32_t overwrite_count = 0; 38 BlockDeviceID last_seen_device_id = 0; 39 #if PERFETTO_DCHECK_IS_ON() 40 bool seen_device_id = false; 41 #endif 42 int32_t last_seen_common_pid = 0; 43 44 // A vector not a set to keep the writer_fast. 45 std::vector<std::pair<Inode, BlockDeviceID>> inode_and_device; 46 std::vector<int32_t> pids; 47 std::vector<int32_t> rename_pids; 48 49 void AddDevice(BlockDeviceID); 50 void AddInode(Inode); 51 void AddPid(int32_t); 52 void AddCommonPid(int32_t); 53 void AddRenamePid(int32_t); 54 void Clear(); 55 void FinishEvent(); 56 }; 57 58 } // namespace perfetto 59 60 #endif // SRC_TRACED_PROBES_FTRACE_FTRACE_METADATA_H_ 61