summaryrefslogtreecommitdiffstats
path: root/src/cv2pdb.cpp
Commit message (Collapse)AuthorAgeFilesLines
* DWARF tree for fully-qualified name constructionAlex Budovski2023-03-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 constants for BASE_{USER/DWARF}_TYPEAlex Budovski2023-03-241-28/+33
| | | | | We had a lot of magic numbers throughout the code. Introducing two constants to make it clearer what they refer to. No functional changes.
* Refactor PE image section handling. Add debug logging.Neeraj Singh2021-12-021-3/+17
| | | | | | | | | | | 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.
* adapt wchar/dchar to newer versions of dmd, add cent/ucentRainer Schuetze2020-03-091-1/+4
|
* DWARF: fix writing info for aggregates larger than 32kBRainer Schuetze2019-07-181-4/+4
|
* emit "elemtype[keytype]" instead of "dAssocArray"Rainer Schuetze2018-12-161-37/+43
| | | | always convert S_BPREL_V1 to S_BPREL_V3 (no longer supported by mspdb 14.16.27012/VS 15.9)
* Debug directory aligning moved to PEImage::replaceDebugSection.AlexWhiter2018-04-081-3/+0
|
* Fixed misspelled identifier.AlexWhiter2018-04-071-1/+1
|
* Cleanup of RSDS block after allocation.AlexWhiter2018-04-071-3/+3
|
* 1. If exe-file consisted of just a disk letter and a file name (i.e. ↵AlexWhiter2018-04-051-4/+7
| | | | | | c:file.exe), AV occured. 2. Aligning the debug section offset to the closest 16-byte boundary.
* RSDS section writing into EXE with symbols in DBG file.AlexWhiter2018-03-301-5/+5
|
* CV2PDB::appendModifierType: uncomment code to add paddingPierre-Marie de Rodat2018-03-231-2/+2
| | | | | This prevents the generation of corrupt TPI streams, as padding is required at the end of leaves.
* Fix LF_ENUMERATE emission for values > 0x8000Pierre-Marie de Rodat2018-03-231-6/+10
|
* Reduce complexity of best CFA lookupsPierre-Marie de Rodat2018-03-231-0/+1
| | | | | This turns a linear lookup into a logarithmic binary search, which improves a lot DWARF to PDB conversion for big programs.
* * DWARF: fix crash with AUX data in symbol tableRainer Schuetze2017-11-301-3/+9
| | | | * improve reallocation strategy
* * search VS2017 registry entries to find mspdb140.dllRainer Schuetze2017-09-021-31/+251
| | | | | | | * when using mspdb140.dll (VS2015) or later, use symbols to emit line numbers * translate S_UDT_V1 to V3 version * translate S_BLOCK_V1 to V3 version * remove "this" from delegate parameter list if inconsistent with procedure type
* * when using mspdb120.dll (VS2013) or later, do not emit view helpersRainer Schuetze2017-06-181-21/+63
| | | | * remove method declarations from struct or class records (they confuse mspdb*.dll if having forward references?)
* add mago support for AA with dmd >= 2.068Rainer Schuetze2017-05-141-33/+71
| | | | | | prefer struct over class for internal structs handle class/struct property "uniquename" mark source language as 'D' for dmd >= 2.072
* Version 0.39: do not assume sorted line numbers per segmentRainer Schuetze2017-01-201-2/+6
|
* * do not uncompress names in field listsRainer Schuetze2016-08-091-2/+4
| | | | * copy symbol unmodified if uncompression fails
* Truncate symbols that are too longMarc Aldorasi2016-03-141-1/+1
|
* allow anonymous typedefsRainer Schuetze2015-09-071-1/+1
|
* add -debug option, some whitespace cleanupRainer Schuetze2015-09-071-36/+44
|
* write correct machine type for x64Rainer Schuetze2015-06-131-1/+1
|
* add support for VS 2015Rainer Schuetze2015-06-031-0/+1
|
* Updated mscvpdb.h with latest from WINE.Vadim Chugunov2014-12-051-78/+78
|
* 2013-11-16 Version 0.28sagitario2013-11-251-0/+1
| | | | | | * added searching mspdb120.dll for VS 2013 * changed search order for mspdb*.dll: trying to load through PATH first newest VS versions preferred, then trying through installation paths for VS 2013-2005 * dviewhelper.dll now avoids being reloaded for every expression
* v0.25sagitario2012-06-181-6/+7
| | | | * new option -p allows to specify the embedded PDB reference in the binary * added support for VS2012
* Version 0.24sagitario2012-05-011-4/+12
| | | | * supports unicode characters in file names * improve interpretation of DWARF location expression
* tabifysagitario2012-03-031-43/+43
|
* * disabled named enumerator for D basic types to avoid debugger troubles ↵sagitario2012-02-121-28/+82
| | | | | | | displaying arrays * added command line switch -e to enable using named enumerator for D basic types * added DWARF support * added x64 support
* * fixed decoding of compressed symbolssagitario2011-05-081-9/+40
| | | | | * added command line switch * fixed crash with more than 32767 types
* now converting only class pointers to references, not pointers to structs or ↵sagitario2010-12-031-1/+8
| | | | void
* * more fixes for names longer than 300 characterssagitario2010-10-251-8/+8
|
* * fixed error with nested types longer than 255 characterssagitario2010-10-241-14/+16
|
* (no commit message)sagitario2010-09-041-2/+3
|
* fixed crash when working with -C (introduced in last version)sagitario2010-08-101-0/+2
|
* Version 0.15sagitario2010-08-081-126/+442
| | | | | | | | | | | | | * thanks to patches by Z3N, the resulting pdb is now usable by more debuggers * now uses shared file access to executable * incomplete structs/classes are now added as user defined types to avoid confusing debugger for following symbols * fixed name demangling of very long names * added name demangling support for @safe/@trusted/@property/pure/nothrow/ref * base classes are added to D/cpp-interfaces to allow viewing the virtual function table pointer * structs, classes and interfaces now have an internal qualifier attached that allows the preview in autoexp.dat to show better info for structs and interfaces
* * improved support for 64-integer types sagitario2010-06-231-23/+111
| | | | | * now adding properties "has nested type" and "is nested type" to class/struct/union/enum types * better support for enumerators: now added as user defined types (DMD patch needed)
* when a dynamic array type is detected for a DMC compiled executable ↵sagitario2010-06-141-2/+12
| | | | (command option -C is used), it is converted to int64 (fixing DMC bug)
* Version 0.13sagitario2010-06-041-4/+28
| | | | | | * adapted to mspdb100.dll which comes with VS2010 * tweaked autoexp.dat modifications to be more stable with uninitialized data * autoexp.snippet now split into two files
* (no commit message)sagitario2010-04-131-11/+31
|
* * names of local function are now demangledsagitario2010-03-121-1605/+1605
| | | * added managed C++ project to integrate cv2pdb with CLR
* added patch to convert binaries produced by Metroworks CodeWarriorsagitario2010-02-111-3/+7
|
* Version 0.11sagitario2009-12-291-7/+135
| | | | | | | * basic types now show with their D names, not as C types * "enum" prefix removed from type names of enumerator types * added type information for complex data types * dmd-patch needed for long/ulong support * experimental hack to add lexical scope to local variables
* now converting entries LF_FRIENDCLS, LF_VBCLASS and LF_IVBCLASSsagitario2009-07-171-10/+39
| | | | struct_v2.derived now always set to 0
* * entries LF_FRIENDCLS, LF_FRIENDFCN, LF_VBCLASS and LF_IVBCLASS written ↵sagitario2009-07-161-0/+15
| | | | by DMC are now removed
* skip friend function declarationssagitario2009-07-161-0/+8
|
* v0.9:sagitario2009-06-191-5/+132
| | | | | * fixed line number info at the end of a segment or when switching to another file because of inline expansion * fixed line numbers > 32767 and sections with 0 line number entries
* v0.8:sagitario2009-06-111-1/+1
| | | | | - tweaked visualizer macros to detect uninitialized associative arrays and to limit expansion to arrays with less than 1024 entries - renamed "data" pointer member of dynamic arrays to "ptr"