summaryrefslogtreecommitdiffstats
path: root/src/readDwarf.h
diff options
context:
space:
mode:
authorNeeraj Singh <neerajsi@microsoft.com>2021-11-30 05:03:58 (GMT)
committerNeeraj Singh <neerajsi@microsoft.com>2021-12-02 05:50:55 (GMT)
commit594cf2b96458448b7bfe721bb1d9786fcf90bc0d (patch)
tree5ac177e11023451c8ab8c511dffb4dd204ee57ff /src/readDwarf.h
parent28d3fad41817310b8fc2fd6d9e46137249d65fad (diff)
downloadcv2pdb-594cf2b96458448b7bfe721bb1d9786fcf90bc0d.zip
cv2pdb-594cf2b96458448b7bfe721bb1d9786fcf90bc0d.tar.gz
cv2pdb-594cf2b96458448b7bfe721bb1d9786fcf90bc0d.tar.bz2
carry contextual information with the DIECursor
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.
Diffstat (limited to 'src/readDwarf.h')
-rw-r--r--src/readDwarf.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/readDwarf.h b/src/readDwarf.h
index 41724f6..bb78285 100644
--- a/src/readDwarf.h
+++ b/src/readDwarf.h
@@ -8,9 +8,9 @@
#include <unordered_map>
#include "mspdb.h"
-class PEImage;
-
typedef unsigned char byte;
+class PEImage;
+class DIECursor;
enum DebugLevel : unsigned {
DbgBasic = 0x1,
@@ -406,8 +406,8 @@ typedef std::unordered_map<std::pair<unsigned, unsigned>, byte*> abbrevMap_t;
// as either an absolute value, a register, or a register-relative address.
Location decodeLocation(const PEImage& img, const DWARF_Attribute& attr, const Location* frameBase = 0, int at = 0);
-void mergeAbstractOrigin(DWARF_InfoData& id, DWARF_CompilationUnit* cu);
-void mergeSpecification(DWARF_InfoData& id, DWARF_CompilationUnit* cu);
+void mergeAbstractOrigin(DWARF_InfoData& id, const DIECursor& parent);
+void mergeSpecification(DWARF_InfoData& id, const DIECursor& parent);
// Debug Information Entry Cursor
class DIECursor
@@ -433,6 +433,9 @@ public:
// Create a new DIECursor
DIECursor(DWARF_CompilationUnit* cu_, byte* ptr);
+ // Create a child DIECursor
+ DIECursor(const DIECursor& parent, byte* ptr_);
+
// Goto next sibling DIE. If the last read DIE had any children, they will be skipped over.
void gotoSibling();
@@ -447,6 +450,15 @@ public:
// If stopAtNull is true, readNext() will stop upon reaching a null DIE (end of the current tree level).
// Otherwise, it will skip null DIEs and stop only at the end of the subtree for which this DIECursor was created.
bool readNext(DWARF_InfoData& id, bool stopAtNull = false);
+
+ // Read an address from p according to the ambient pointer size.
+ uint64_t RDAddr(byte* &p) const
+ {
+ if (cu->address_size == 4)
+ return RD4(p);
+
+ return RD8(p);
+ }
};
// iterate over DWARF debug_line information