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 SRC_PROFILING_MEMORY_UNWOUND_MESSAGES_H_ 18 #define SRC_PROFILING_MEMORY_UNWOUND_MESSAGES_H_ 19 20 #include <unwindstack/Maps.h> 21 #include <unwindstack/Unwinder.h> 22 23 #include "src/profiling/memory/wire_protocol.h" 24 25 namespace perfetto { 26 namespace profiling { 27 28 // A wrapper of libunwindstack FrameData that also includes the build_id. 29 struct FrameData { FrameDataFrameData30 FrameData(unwindstack::FrameData f, std::string b) 31 : frame(std::move(f)), build_id(std::move(b)) {} 32 33 unwindstack::FrameData frame; 34 std::string build_id; 35 }; 36 37 // Single allocation with an unwound callstack. 38 struct AllocRecord { 39 pid_t pid; 40 bool error = false; 41 bool reparsed_map = false; 42 uint64_t unwinding_time_us = 0; 43 uint64_t data_source_instance_id; 44 uint64_t timestamp; 45 AllocMetadata alloc_metadata; 46 std::vector<FrameData> frames; 47 }; 48 49 // Batch of deallocations. 50 struct FreeRecord { 51 pid_t pid; 52 uint64_t data_source_instance_id; 53 uint64_t timestamp; 54 FreeBatch free_batch; 55 }; 56 57 } // namespace profiling 58 } // namespace perfetto 59 60 #endif // SRC_PROFILING_MEMORY_UNWOUND_MESSAGES_H_ 61