summaryrefslogtreecommitdiffstats
path: root/src/readDwarf.h
Commit message (Collapse)AuthorAgeFilesLines
* move mergeAbstractOrigin() and mergeSpecification() from readDwarf.cpp to ↵Rainer Schuetze2023-04-021-3/+0
| | | | dwarf2pdb.cpp, so they don't create a dependency for dumplines.exe
* Fix bug in DWARF v4 location decodingAlex Budovski2023-03-241-3/+17
| | | | | | | | | | This fixes a long standing bug in the DWARF v4 location decoding logic. Previously, the logic would not recognize "base address selection" entries at all and assume an entry was either an end-of-list or a location list entry thus resulting in incorrect decoding in release builds, and an assert in debug builds. See DWARF v4 spec section 2.6.2 for details.
* Add support for anon types in FQN generationAlex Budovski2023-03-241-0/+2
| | | | | | | | This fixes a bug in the fully qualified name generation we encounter a segment that has no name, such as when a proc is really a C++ lambda expression, which internally generates an anonymous class to house the function. In this case, we generate a unique name based on the DIE's offset to serve as the segment's name.
* DWARF tree for fully-qualified name constructionAlex Budovski2023-03-241-17/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Windows debuggers expect PDB symbol names to be fully qualified. I.e., if a class Foo has a constructor, its name should be emitted as `Foo::Foo`, not simply `Foo` as is the case today. Linux debuggers like GDB dynamically reconstruct the symbol tree at runtime each time a program is debugged. Windows debuggers on the other hand do not, and expect the name to be fully qualified from the outset. Failing this, the constructor function `Foo` would have the same name as the class `Foo` in the PDB, and WinDbg will get confused about what to dump (e.g. using `dt Foo`) and arbitrarily pick the largest item, which might be the constructor. Therefore you end up dumping the wrong thing and being completely unable to inspect the contents of a `Foo` object. This commit aims to fix that by introducing a DWARF tree during the conversion process which allows us to efficiently reconstruct such fully qualified names during the conversion. A note about DWARF: the DWARF format does not explicitly record the parent of any given DIE record. It is instead implicit in how the records are layed out. Any record may have a "has children" flag, and if it does, then the records following it are its children, terminated by a special NULL record, popping back up one level of the tree. The DIECursor already recognized this structure but did not capture it in memory for later use. In order to construct fully-qualified names for functions, enums, classes, etc. (i.e. taking into account namespaces, nesting, etc), we need a way to efficienctly lookup a node's parent. Thus the DWARF tree was born. At a high level, we take advantage of the fact that the DWARF sections were already scanned in two passes. We hook into the first pass (where the typeIDs were being reserved) and build the DWARF tree. Then, in the second pass (where the CV symbols get emitted), we look up the tree to figure out the correct fully-qualified symbol names. NOTE: The first phase of this work focuses on subroutines only. Later work will enable support for structs/classes/enums. On the subroutine front, I also added a flag to capture whether a DIE is a "declaration" or definition (based on the DW_AT_declaration attribute). This is needed to consolidate function decl+defn into one PDB symbol, as otherwise WinDbg will get confused. This also matches what the MSVC toolset produces. A few other related additions: - Added helper to format a fully qualified function name by looking up the tree added in this commit. - Added helper to print the DWARF tree for debugging purposes and a flag to control it.
* Add comments to various filesAlex Budovski2023-03-241-0/+13
| | | | | This is just a preparatory change to improve the documentation in the code. No functional changes.
* Fix file names in dwarf5 line tablesNeeraj Singh2021-12-021-5/+4
|
* DWARF5 rnglists and loclistsNeeraj Singh2021-12-021-0/+11
| | | | | Add support for the new opcode-based format for location lists and range lists.
* read all dwarf5 main DIE formsNeeraj Singh2021-12-021-1/+22
| | | | | Fill in Dwarf_InfoData for all DWARF5 forms excluding the new rnglists and loclists representations.
* Read DWARF5 header and add DWARF5 constants.Neeraj Singh2021-12-021-6/+7
| | | | | Handle the new DWARF5 compilation unit header and add new constants to dwarf.h. We still don't decode the new forms though.
* more pre-DWARF5 refactoring: unit headers, location cursor, range cursorNeeraj Singh2021-12-021-17/+83
| | | | | | | | | | | Read the compilation unit header byte-by-byte rather than by casting the data to a structure. Add the currentBaseAddress contextual info to the compilation unit data. Move the LOCCursor into readDwarf.cpp. Implement a RangeCursor similar to the LOCCursor. Add more debug printing.
* carry contextual information with the DIECursorNeeraj Singh2021-12-021-4/+16
| | | | | | | | | | DWARF5 has more contextual information that is associated with the compilation unit. As a preparation for using such information, carry it with the DIECursor and eliminate places where we're passing in the parent compilation unit. Also add the RDAddr helper to read a target-address according to the specification in the compilation unit.
* Refactor PE image section handling. Add debug logging.Neeraj Singh2021-12-021-4/+26
| | | | | | | | | | | Encapsulate dwarf-related PE sections into the PESection class. Remove some unused sections. Add helpers for common section operations. Move the context set via DIECursor::setContext to be static members of the class and add a debug context there. Add a standard method of enabling debug logging across the dwarf and PDB code.
* Add rudimentary support for DWARF5Johannes Schindelin2021-10-291-0/+23
| | | | | | | | | | | This allows `cv2pdb` to process executables produced by the mingw-w64 version of GCC v11.x. The symptoms of the fixed issue would look like this: error: cannot add line number info to module Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* fix #61: implement DWARF4 line number headersv0.48Rainer Schuetze2020-05-081-0/+16
|
* Delay adding lines until we know the end of the line's address rangeMarc Aldorasi2019-02-131-23/+2
|
* Improve merging DWARF_InfoDataMarc Aldorasi2019-02-061-2/+5
|
* Exclude artificial functions and inherit attributes from abstract originsMarc Aldorasi2019-02-041-21/+27
|
* Try harder to get function entry pointsMarc Aldorasi2019-02-041-0/+4
|
* DWARF: fixed converting unnamed structs/unions as part of other structsRainer Schuetze2019-01-251-0/+2
|
* fix issue #43: initialize DWARF_LineState's members file_ptr and last_addrRainer Schuetze2018-12-211-0/+3
|
* DWARF:Rainer Schuetze2018-04-211-4/+4
| | | | | | - fix code only executed in debug builds - fix evaluation of DW_OP_const1u/DW_OP_const1s not advancing pointer - add support for local variables with location list via DW_FORM_sec_offset
* fix signed/unsigned warningsRainer Schuetze2018-03-301-3/+3
|
* dwarflines: fix last insn. address computation for DW_LNE_end_sequencePierre-Marie de Rodat2018-03-231-2/+11
|
* CV2PDB::addDWARFEnum: new, first attempt at enum types translationPierre-Marie de Rodat2018-03-231-0/+4
|
* CV2PDB::getDWARFSubrangeInfo: use language-specific default lower boundPierre-Marie de Rodat2018-03-231-0/+2
|
* DWARF_InfoData: track the DW_AT_language attributePierre-Marie de Rodat2018-03-231-0/+2
|
* DIECursor::readNext: use -1u for missing DW_AT_ranges attributesPierre-Marie de Rodat2018-03-211-2/+3
| | | | | 0 is actually a valid .debug_ranges offset, so use something really unlikely for the "no value" special constant instead.
* fix DWARF for gcc 4.9.0 and clang 3.6Rainer Schuetze2015-06-121-0/+1
|
* DWARF: fix struct/class conversion, array limits, replace '.' with '@' in namesRainer Schuetze2015-06-091-1/+1
|
* DWARF: fix displaying locals if there are no function argumentsRainer Schuetze2015-06-091-0/+3
|
* fix regression https://github.com/rainers/cv2pdb/issues/5: do not ignore ↵Rainer Schuetze2015-06-011-0/+1
| | | | | | virtual size of sections avoid assertions for DW_AT_ranges with constant data
* - new tool dumplines to display the debug line number infoRainer Schuetze2015-05-081-1/+7
|
* Build with Visual Studio 10 Compiler (Windows SDK 7.1)Mirko Scholz2015-01-221-0/+1
|
* Revamped location expression evaluator.Vadim Chugunov2014-12-051-4/+20
|
* Converted the remaining uses of the old decodeLocation().Vadim Chugunov2014-12-051-8/+23
|
* Fix decodeLocation.Vadim Chugunov2014-12-051-0/+10
|
* Revamped DIE reading.Vadim Chugunov2014-12-051-46/+65
| | | | My decodeLocation.
* Fixed O^n abbrev search.Vadim Chugunov2014-12-051-0/+308
DIE tree navigation without requiring DW_AT_sibling attributes, moved navigation logic into DIECursor class.