[PATCH] D74450: Add a DWARF transformer class that converts DWARF to GSYM.

Greg Clayton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 16:20:24 PST 2020


clayborg created this revision.
clayborg added reviewers: aprantl, dblaikie, probinson.
Herald added subscribers: hiraditya, mgorny.
Herald added a project: LLVM.

The DWARF transformer is added as a class so it can be unit tested fully.

The DWARF is converted to GSYM format and handles many special cases for functions:

- omit functions in compile units with 4 byte addresses whose address is UINT32_MAX (dead stripped)
- omit functions in compile units with 8 byte addresses whose address is UINT64_MAX (dead stripped)
- omit any functions whose high PC is <= low PC (dead stripped)
- StringTable builder doesn't copy strings, so we need to make backing copies of strings but only when needed. Many strings come from sections in object files and won't need to have backing copies, but some do.
- When a function doesn't have a mangled name, store the fully qualified name by creating a string by traversing the parent decl context DIEs and then. If we don't do this, we end up having cases where some function might appear in the GSYM as "erase" instead of "std::vector<int>::erase".
- omit any functions whose address isn't in the optional TextRanges member variable of DwarfTransformer. This allows object file to register address ranges that are known valid code ranges and can help omit functions that should have been dead stripped, but just had their low PC values set to zero. In this case we have many functions that all appear at address zero and can omit these functions by making sure they fall into good address ranges on the object file. Many compilers do this when the DWARF has a DW_AT_low_pc with a DW_FORM_addr, and a DW_AT_high_pc with a DW_FORM_data4 as the offset from the low PC. In this case the linker can't write the same address to both the high and low PC since there is only a relocation for the DW_AT_low_pc, so many linkers tend to just zero it out.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74450

Files:
  llvm/include/llvm/DebugInfo/GSYM/DwarfTransformer.h
  llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
  llvm/include/llvm/DebugInfo/GSYM/GsymReader.h
  llvm/include/llvm/DebugInfo/GSYM/LineTable.h
  llvm/include/llvm/MC/StringTableBuilder.h
  llvm/lib/DebugInfo/GSYM/CMakeLists.txt
  llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
  llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp
  llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
  llvm/lib/DebugInfo/GSYM/GsymReader.cpp
  llvm/lib/DebugInfo/GSYM/InlineInfo.cpp
  llvm/unittests/DebugInfo/GSYM/CMakeLists.txt
  llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74450.244030.patch
Type: text/x-patch
Size: 88052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200212/8625342d/attachment.bin>


More information about the llvm-commits mailing list