From d24e0386a3d6cc15762f57093870857e5ae3b733 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 15 Jul 2009 16:49:08 +0000 Subject: [PATCH] * Added LocationDescription class. * Handle DW_AT_location attributes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31591 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/debugger/dwarf/AttributeValue.h | 49 ++++++++++++++++++++ src/apps/debugger/dwarf/DebugInfoEntries.cpp | 35 ++++++++++++++ src/apps/debugger/dwarf/DebugInfoEntries.h | 30 +++++++++--- src/apps/debugger/dwarf/DebugInfoEntry.cpp | 30 +++++++++++- src/apps/debugger/dwarf/DebugInfoEntry.h | 13 ++++-- 5 files changed, 145 insertions(+), 12 deletions(-) diff --git a/src/apps/debugger/dwarf/AttributeValue.h b/src/apps/debugger/dwarf/AttributeValue.h index e4a096f5f1..72c2b2d206 100644 --- a/src/apps/debugger/dwarf/AttributeValue.h +++ b/src/apps/debugger/dwarf/AttributeValue.h @@ -200,6 +200,55 @@ struct ConstantAttributeValue { }; +struct LocationDescription { + union { + off_t listOffset; // location list + struct { + const void* data; + off_t length; + } expression; // location expression + }; + uint8 attributeClass; + + LocationDescription() + : + attributeClass(ATTRIBUTE_CLASS_BLOCK) + { + expression.data = NULL; + expression.length = 0; + } + + bool IsExpression() const + { + return attributeClass == ATTRIBUTE_CLASS_BLOCK + && expression.data != NULL; + } + + bool IsLocationList() const + { + return attributeClass == ATTRIBUTE_CLASS_LOCLISTPTR; + } + + bool IsValid() const + { + return IsExpression() || IsLocationList(); + } + + void SetToLocationList(off_t offset) + { + listOffset = offset; + attributeClass = ATTRIBUTE_CLASS_LOCLISTPTR; + } + + void SetToExpression(const void* data, off_t length) + { + expression.data = data; + expression.length = length; + attributeClass = ATTRIBUTE_CLASS_BLOCK; + } +}; + + struct DeclarationLocation { uint32 file; uint32 line; diff --git a/src/apps/debugger/dwarf/DebugInfoEntries.cpp b/src/apps/debugger/dwarf/DebugInfoEntries.cpp index d8a54df97d..d41e9ab68f 100644 --- a/src/apps/debugger/dwarf/DebugInfoEntries.cpp +++ b/src/apps/debugger/dwarf/DebugInfoEntries.cpp @@ -788,6 +788,13 @@ DIEFormalParameter::Tag() const } +LocationDescription* +DIEFormalParameter::GetLocationDescription() +{ + return &fLocationDescription; +} + + // #pragma mark - DIEImportedDeclaration @@ -1085,6 +1092,13 @@ DIECommonBlock::Tag() const } +LocationDescription* +DIECommonBlock::GetLocationDescription() +{ + return &fLocationDescription; +} + + // #pragma mark - DIECommonInclusion @@ -1294,6 +1308,13 @@ DIEWithStatement::Tag() const } +LocationDescription* +DIEWithStatement::GetLocationDescription() +{ + return &fLocationDescription; +} + + // #pragma mark - DIEAccessDeclaration @@ -1738,6 +1759,13 @@ DIEVariable::Tag() const } +LocationDescription* +DIEVariable::GetLocationDescription() +{ + return &fLocationDescription; +} + + // #pragma mark - DIEVolatileType @@ -1795,6 +1823,13 @@ DIEDwarfProcedure::Tag() const } +LocationDescription* +DIEDwarfProcedure::GetLocationDescription() +{ + return &fLocationDescription; +} + + // #pragma mark - DIERestrictType diff --git a/src/apps/debugger/dwarf/DebugInfoEntries.h b/src/apps/debugger/dwarf/DebugInfoEntries.h index 0cccb7a2ed..3a57e0ddfe 100644 --- a/src/apps/debugger/dwarf/DebugInfoEntries.h +++ b/src/apps/debugger/dwarf/DebugInfoEntries.h @@ -504,6 +504,8 @@ public: virtual uint16 Tag() const; + virtual LocationDescription* GetLocationDescription(); + // TODO: // DW_AT_abstract_origin // DW_AT_artificial @@ -511,10 +513,12 @@ public: // DW_AT_default_value // DW_AT_endianity // DW_AT_is_optional -// DW_AT_location // DW_AT_segment // DW_AT_type // DW_AT_variable_parameter + +private: + LocationDescription fLocationDescription; }; @@ -704,9 +708,13 @@ public: virtual uint16 Tag() const; + virtual LocationDescription* GetLocationDescription(); + // TODO: -// DW_AT_location // DW_AT_segment + +private: + LocationDescription fLocationDescription; }; @@ -849,17 +857,21 @@ public: virtual uint16 Tag() const; + virtual LocationDescription* GetLocationDescription(); + // TODO: // DW_AT_accessibility // DW_AT_address_class // DW_AT_declaration // DW_AT_high_pc -// DW_AT_location // DW_AT_low_pc // DW_AT_ranges // DW_AT_segment // DW_AT_type // DW_AT_visibility + +private: + LocationDescription fLocationDescription; }; @@ -1160,16 +1172,20 @@ public: virtual uint16 Tag() const; + virtual LocationDescription* GetLocationDescription(); + // TODO: // DW_AT_abstract_origin // DW_AT_const_value // DW_AT_endianity // DW_AT_external -// DW_AT_location // DW_AT_segment // DW_AT_specification // DW_AT_start_scope // DW_AT_type + +private: + LocationDescription fLocationDescription; }; @@ -1197,8 +1213,10 @@ public: virtual uint16 Tag() const; -// TODO: -// DW_AT_location + virtual LocationDescription* GetLocationDescription(); + +private: + LocationDescription fLocationDescription; }; diff --git a/src/apps/debugger/dwarf/DebugInfoEntry.cpp b/src/apps/debugger/dwarf/DebugInfoEntry.cpp index ee5d063d8a..792585b383 100644 --- a/src/apps/debugger/dwarf/DebugInfoEntry.cpp +++ b/src/apps/debugger/dwarf/DebugInfoEntry.cpp @@ -94,6 +94,13 @@ DebugInfoEntry::AbstractOrigin() const } +LocationDescription* +DebugInfoEntry::GetLocationDescription() +{ + return NULL; +} + + bool DebugInfoEntry::GetDeclarationFile(uint32& _file) const { @@ -180,6 +187,28 @@ DebugInfoEntry::AddAttribute_decl_column(uint16 attributeName, } +status_t +DebugInfoEntry::AddAttribute_location(uint16 attributeName, + const AttributeValue& value) +{ + if (LocationDescription* location = GetLocationDescription()) { + if (value.attributeClass == ATTRIBUTE_CLASS_LOCLISTPTR) { + location->SetToLocationList(value.pointer); + return B_OK; + } + + if (value.attributeClass == ATTRIBUTE_CLASS_BLOCK) { + location->SetToExpression(value.block.data, value.block.length); + return B_OK; + } + return B_BAD_DATA; + + } + + return ATTRIBUTE_NOT_HANDLED; +} + + status_t DebugInfoEntry::AddAttribute_sibling(uint16 attributeName, const AttributeValue& value) @@ -190,7 +219,6 @@ DebugInfoEntry::AddAttribute_sibling(uint16 attributeName, } -DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(location) DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(name) DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(ordering) DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(byte_size) diff --git a/src/apps/debugger/dwarf/DebugInfoEntry.h b/src/apps/debugger/dwarf/DebugInfoEntry.h index 838a2291dd..7efa3709b6 100644 --- a/src/apps/debugger/dwarf/DebugInfoEntry.h +++ b/src/apps/debugger/dwarf/DebugInfoEntry.h @@ -22,10 +22,11 @@ enum { }; -class AttributeValue; -class ConstantAttributeValue; -class DeclarationLocation; -class DynamicAttributeValue; +struct AttributeValue; +struct ConstantAttributeValue; +struct DeclarationLocation; +struct DynamicAttributeValue; +struct LocationDescription; struct SourceLanguageInfo; @@ -58,6 +59,7 @@ public: virtual const char* Description() const; virtual DebugInfoEntry* Specification() const; virtual DebugInfoEntry* AbstractOrigin() const; + virtual LocationDescription* GetLocationDescription(); bool GetDeclarationFile(uint32& _file) const; bool GetDeclarationLine(uint32& _line) const; @@ -71,12 +73,13 @@ public: const AttributeValue& value); virtual status_t AddAttribute_decl_column(uint16 attributeName, const AttributeValue& value); + virtual status_t AddAttribute_location(uint16 attributeName, + const AttributeValue& value); virtual status_t AddAttribute_sibling(uint16 attributeName, const AttributeValue& value); // TODO: Handle (ignore?) DW_AT_description here? - DECLARE_DEBUG_INFO_ENTRY_ATTR_SETTER(location) DECLARE_DEBUG_INFO_ENTRY_ATTR_SETTER(name) DECLARE_DEBUG_INFO_ENTRY_ATTR_SETTER(ordering) DECLARE_DEBUG_INFO_ENTRY_ATTR_SETTER(byte_size)