1 /* 2 * Copyright (C) 2018 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 INCLUDE_PERFETTO_EXT_TRACED_DATA_SOURCE_TYPES_H_ 18 #define INCLUDE_PERFETTO_EXT_TRACED_DATA_SOURCE_TYPES_H_ 19 20 #include <sys/stat.h> 21 #include <sys/types.h> 22 #include <set> 23 #include <string> 24 25 namespace perfetto { 26 27 // On ARM, st_ino is not ino_t but unsigned long long. 28 using Inode = decltype(stat::st_ino); 29 30 // On ARM, st_dev is not dev_t but unsigned long long. 31 using BlockDeviceID = decltype(stat::st_dev); 32 33 using InodeBlockPair = std::pair<Inode, BlockDeviceID>; 34 35 // From inode_file_map.pbzero.h 36 using InodeFileMap_Entry_Type = int32_t; 37 38 class InodeMapValue { 39 public: InodeMapValue(InodeFileMap_Entry_Type entry_type,std::set<std::string> paths)40 InodeMapValue(InodeFileMap_Entry_Type entry_type, std::set<std::string> paths) 41 : entry_type_(entry_type), paths_(std::move(paths)) {} 42 InodeMapValue()43 InodeMapValue() {} 44 type()45 InodeFileMap_Entry_Type type() const { return entry_type_; } paths()46 const std::set<std::string>& paths() const { return paths_; } SetType(InodeFileMap_Entry_Type entry_type)47 void SetType(InodeFileMap_Entry_Type entry_type) { entry_type_ = entry_type; } SetPaths(std::set<std::string> paths)48 void SetPaths(std::set<std::string> paths) { paths_ = std::move(paths); } AddPath(std::string path)49 void AddPath(std::string path) { paths_.emplace(std::move(path)); } 50 51 bool operator==(const perfetto::InodeMapValue& rhs) const { 52 return type() == rhs.type() && paths() == rhs.paths(); 53 } 54 55 private: 56 InodeFileMap_Entry_Type entry_type_; 57 std::set<std::string> paths_; 58 }; 59 60 } // namespace perfetto 61 62 #endif // INCLUDE_PERFETTO_EXT_TRACED_DATA_SOURCE_TYPES_H_ 63