1 // Copyright 2021 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_DEBUG_DWARF_LINE_NO_H_ 6 #define BASE_DEBUG_DWARF_LINE_NO_H_ 7 8 #include <cstddef> 9 #include <cstdint> 10 11 namespace base { 12 namespace debug { 13 14 // Finds the compile unit offset in .debug_info for each frame in `trace`. 15 // 16 // Expects `trace` and `cu_offsets` to be `num_frames` in size. If a frame 17 // cannot be found, the corresponding value stored in `cu_offsets` is 0. 18 void GetDwarfCompileUnitOffsets(const void* const* trace, 19 uint64_t* cu_offsets, 20 size_t num_frames); 21 22 // Formats the source file, line number and column for `pc` and into `out`. 23 // 24 // The `cu_offsets` is the offset in the .debug_info section for the compile 25 // unit or partial unit DIE corresponding to the `pc`. It can be found using 26 // GetDwarfCompileUnitOffsets() and must not be 0. 27 // 28 // Example: 29 // ../../base/debug/stack_trace_unittest.cc:120,16 30 // 31 // This means `pc` was from line 120, column 16, of stack_trace_unittest.cc. 32 bool GetDwarfSourceLineNumber(const void* pc, 33 uint64_t cu_offsets, 34 char* out, 35 size_t out_size); 36 } // namespace debug 37 } // namespace base 38 39 #endif // BASE_DEBUG_DWARF_LINE_NO_H_ 40