From 8d716cdba3f29887a443ff0cc2cc337034dce8f3 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 20 Jul 2009 01:05:10 +0000 Subject: [PATCH] Added support for several variable and lexical block entry attributes and child handling for lexical blocks (at least for nesting and variables). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31646 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/debugger/dwarf/DebugInfoEntries.cpp | 117 ++++++++++++++++++- src/apps/debugger/dwarf/DebugInfoEntries.h | 58 +++++++-- 2 files changed, 167 insertions(+), 8 deletions(-) diff --git a/src/apps/debugger/dwarf/DebugInfoEntries.cpp b/src/apps/debugger/dwarf/DebugInfoEntries.cpp index 300e10dca1..ec4772ff26 100644 --- a/src/apps/debugger/dwarf/DebugInfoEntries.cpp +++ b/src/apps/debugger/dwarf/DebugInfoEntries.cpp @@ -893,6 +893,11 @@ DIELabel::Tag() const DIELexicalBlock::DIELexicalBlock() + : + fLowPC(0), + fHighPC(0), + fAddressRangesOffset(-1), + fAbstractOrigin(NULL) { } @@ -904,6 +909,65 @@ DIELexicalBlock::Tag() const } +DebugInfoEntry* +DIELexicalBlock::AbstractOrigin() const +{ + return fAbstractOrigin; +} + + +status_t +DIELexicalBlock::AddChild(DebugInfoEntry* child) +{ + switch (child->Tag()) { + case DW_TAG_variable: + fVariables.Add(child); + return B_OK; + case DW_TAG_lexical_block: + fBlocks.Add(child); + return B_OK; + default: + return DIENamedBase::AddChild(child); + } +} + + +status_t +DIELexicalBlock::AddAttribute_low_pc(uint16 attributeName, + const AttributeValue& value) +{ + fLowPC = value.address; + return B_OK; +} + + +status_t +DIELexicalBlock::AddAttribute_high_pc(uint16 attributeName, + const AttributeValue& value) +{ + fHighPC = value.address; + return B_OK; +} + + +status_t +DIELexicalBlock::AddAttribute_ranges(uint16 attributeName, + const AttributeValue& value) +{ + fAddressRangesOffset = value.pointer; + return B_OK; +} + + +status_t +DIELexicalBlock::AddAttribute_abstract_origin(uint16 attributeName, + const AttributeValue& value) +{ + fAbstractOrigin = dynamic_cast(value.reference); + return fAbstractOrigin != NULL ? B_OK : B_BAD_DATA; +} + + // #pragma mark - DIEMember @@ -1745,6 +1809,12 @@ DIESubprogram::AddChild(DebugInfoEntry* child) case DW_TAG_unspecified_parameters: fParameters.Add(child); return B_OK; + case DW_TAG_variable: + fVariables.Add(child); + return B_OK; + case DW_TAG_lexical_block: + fBlocks.Add(child); + return B_OK; default: return DIEDeclaredNamedBase::AddChild(child); } @@ -1984,7 +2054,10 @@ DIEVariantPart::AddAttribute_type(uint16 attributeName, DIEVariable::DIEVariable() : - fType(NULL) + fType(NULL), + fSpecification(NULL), + fAbstractOrigin(NULL), + fStartScope(0) { } @@ -1996,6 +2069,21 @@ DIEVariable::Tag() const } +DebugInfoEntry* +DIEVariable::Specification() const +{ + return fSpecification; +} + + + +DebugInfoEntry* +DIEVariable::AbstractOrigin() const +{ + return fAbstractOrigin; +} + + LocationDescription* DIEVariable::GetLocationDescription() { @@ -2020,6 +2108,33 @@ DIEVariable::AddAttribute_type(uint16 attributeName, } +status_t +DIEVariable::AddAttribute_specification(uint16 attributeName, + const AttributeValue& value) +{ + fSpecification = dynamic_cast(value.reference); + return fSpecification != NULL ? B_OK : B_BAD_DATA; +} + + +status_t +DIEVariable::AddAttribute_abstract_origin(uint16 attributeName, + const AttributeValue& value) +{ + fAbstractOrigin = dynamic_cast(value.reference); + return fAbstractOrigin != NULL ? B_OK : B_BAD_DATA; +} + + +status_t +DIEVariable::AddAttribute_start_scope(uint16 attributeName, + const AttributeValue& value) +{ + fStartScope = value.constant; + return B_OK; +} + + // #pragma mark - DIEVolatileType diff --git a/src/apps/debugger/dwarf/DebugInfoEntries.h b/src/apps/debugger/dwarf/DebugInfoEntries.h index 6451106ab2..701dbe8137 100644 --- a/src/apps/debugger/dwarf/DebugInfoEntries.h +++ b/src/apps/debugger/dwarf/DebugInfoEntries.h @@ -585,11 +585,38 @@ public: virtual uint16 Tag() const; + virtual DebugInfoEntry* AbstractOrigin() const; + + off_t AddressRangesOffset() const + { return fAddressRangesOffset; } + + target_addr_t LowPC() const { return fLowPC; } + target_addr_t HighPC() const { return fHighPC; } + + const DebugInfoEntryList Variables() const { return fVariables; } + const DebugInfoEntryList Blocks() const { return fBlocks; } + + virtual status_t AddChild(DebugInfoEntry* child); + + virtual status_t AddAttribute_low_pc(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_high_pc(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_ranges(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_abstract_origin( + uint16 attributeName, + const AttributeValue& value); + +protected: + DebugInfoEntryList fVariables; + DebugInfoEntryList fBlocks; + target_addr_t fLowPC; + target_addr_t fHighPC; + off_t fAddressRangesOffset; + DIELexicalBlock* fAbstractOrigin; + // TODO: -// DW_AT_abstract_origin -// DW_AT_high_pc -// DW_AT_low_pc -// DW_AT_ranges // DW_AT_segment }; @@ -1125,6 +1152,8 @@ public: const LocationDescription* FrameBase() const { return &fFrameBase; } const DebugInfoEntryList Parameters() const { return fParameters; } + const DebugInfoEntryList Variables() const { return fVariables; } + const DebugInfoEntryList Blocks() const { return fBlocks; } bool IsPrototyped() const { return fPrototyped; } uint8 Inline() const { return fInline; } @@ -1156,6 +1185,8 @@ public: protected: DebugInfoEntryList fParameters; + DebugInfoEntryList fVariables; + DebugInfoEntryList fBlocks; target_addr_t fLowPC; target_addr_t fHighPC; off_t fAddressRangesOffset; @@ -1289,6 +1320,9 @@ public: virtual uint16 Tag() const; + virtual DebugInfoEntry* Specification() const; + virtual DebugInfoEntry* AbstractOrigin() const; + virtual LocationDescription* GetLocationDescription(); DIEType* GetType() const { return fType; } @@ -1296,23 +1330,33 @@ public: const ConstantAttributeValue* ConstValue() const { return &fValue; } + uint64 StartScope() const { return fStartScope; } + virtual status_t AddAttribute_const_value(uint16 attributeName, const AttributeValue& value); virtual status_t AddAttribute_type(uint16 attributeName, const AttributeValue& value); + virtual status_t AddAttribute_specification(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_abstract_origin( + uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_start_scope( + uint16 attributeName, + const AttributeValue& value); // TODO: -// DW_AT_abstract_origin // DW_AT_endianity // DW_AT_external // DW_AT_segment -// DW_AT_specification -// DW_AT_start_scope private: LocationDescription fLocationDescription; ConstantAttributeValue fValue; DIEType* fType; + DIEVariable* fSpecification; + DIEVariable* fAbstractOrigin; + uint64 fStartScope; };