From 7d82c6dd73468afbd2eb531ff0decd283ac18061 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 27 Sep 2009 04:25:23 +0000 Subject: [PATCH] * Clarified the location expression evaluation semantics -- the ValueLocations returned by the DWARF layer need to be translated to be usable in the generic code. * DwarfFile::EvaluateDynamicValue(): Added optional parameter to return the type of the evaluated value, if available. * Added source language info attribute to CompilationUnit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33313 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/debugger/dwarf/CompilationUnit.cpp | 7 +++ src/apps/debugger/dwarf/CompilationUnit.h | 7 +++ .../debugger/dwarf/DwarfExpressionEvaluator.h | 3 + src/apps/debugger/dwarf/DwarfFile.cpp | 59 +++++++++++++++---- src/apps/debugger/dwarf/DwarfFile.h | 5 +- 5 files changed, 69 insertions(+), 12 deletions(-) diff --git a/src/apps/debugger/dwarf/CompilationUnit.cpp b/src/apps/debugger/dwarf/CompilationUnit.cpp index e5ea67fd08..08dccaa443 100644 --- a/src/apps/debugger/dwarf/CompilationUnit.cpp +++ b/src/apps/debugger/dwarf/CompilationUnit.cpp @@ -80,6 +80,13 @@ CompilationUnit::SetUnitEntry(DIECompileUnitBase* entry) } +void +CompilationUnit::SetSourceLanguage(const SourceLanguageInfo* language) +{ + fSourceLanguage = language; +} + + void CompilationUnit::SetAddressRanges(TargetAddressRangeList* ranges) { diff --git a/src/apps/debugger/dwarf/CompilationUnit.h b/src/apps/debugger/dwarf/CompilationUnit.h index 3dc0ebbdd7..3fc6ddd2ac 100644 --- a/src/apps/debugger/dwarf/CompilationUnit.h +++ b/src/apps/debugger/dwarf/CompilationUnit.h @@ -18,6 +18,7 @@ class AbbreviationTable; class DebugInfoEntry; class DIECompileUnitBase; +class SourceLanguageInfo; class TargetAddressRangeList; @@ -53,6 +54,11 @@ public: DIECompileUnitBase* UnitEntry() const { return fUnitEntry; } void SetUnitEntry(DIECompileUnitBase* entry); + const SourceLanguageInfo* SourceLanguage() const + { return fSourceLanguage; } + void SetSourceLanguage( + const SourceLanguageInfo* language); + TargetAddressRangeList* AddressRanges() const { return fAddressRanges; } void SetAddressRanges( @@ -91,6 +97,7 @@ private: off_t fAbbreviationOffset; AbbreviationTable* fAbbreviationTable; DIECompileUnitBase* fUnitEntry; + const SourceLanguageInfo* fSourceLanguage; TargetAddressRangeList* fAddressRanges; Array fEntries; Array fEntryOffsets; diff --git a/src/apps/debugger/dwarf/DwarfExpressionEvaluator.h b/src/apps/debugger/dwarf/DwarfExpressionEvaluator.h index cc337724a5..c1edb40252 100644 --- a/src/apps/debugger/dwarf/DwarfExpressionEvaluator.h +++ b/src/apps/debugger/dwarf/DwarfExpressionEvaluator.h @@ -58,6 +58,9 @@ public: target_addr_t& _result); status_t EvaluateLocation(const void* expression, size_t size, ValueLocation& _location); + // The returned location will have DWARF + // semantics regarding register numbers and + // bit offsets/sizes (cf. bit pieces). private: struct EvaluationException; diff --git a/src/apps/debugger/dwarf/DwarfFile.cpp b/src/apps/debugger/dwarf/DwarfFile.cpp index d014091ca2..a5e31d2b3c 100644 --- a/src/apps/debugger/dwarf/DwarfFile.cpp +++ b/src/apps/debugger/dwarf/DwarfFile.cpp @@ -702,14 +702,19 @@ DwarfFile::EvaluateDynamicValue(CompilationUnit* unit, DIESubprogram* subprogramEntry, const DynamicAttributeValue* value, const DwarfTargetInterface* targetInterface, target_addr_t instructionPointer, target_addr_t framePointer, - BVariant& _result) + BVariant& _result, DIEType** _type) { if (!value->IsValid()) return B_BAD_VALUE; + DIEType* dummyType; + if (_type == NULL) + _type = &dummyType; + switch (value->attributeClass) { case ATTRIBUTE_CLASS_CONSTANT: _result.SetTo(value->constant); + *_type = NULL; return B_OK; case ATTRIBUTE_CLASS_REFERENCE: @@ -725,28 +730,50 @@ DwarfFile::EvaluateDynamicValue(CompilationUnit* unit, return B_BAD_VALUE; const ConstantAttributeValue* constantValue = NULL; + DIEType* type = NULL; switch (entry->Tag()) { case DW_TAG_constant: - constantValue = dynamic_cast(entry) - ->ConstValue(); + { + DIEConstant* constantEntry + = dynamic_cast(entry); + constantValue = constantEntry->ConstValue(); + type = constantEntry->GetType(); break; + } case DW_TAG_enumerator: constantValue = dynamic_cast(entry) ->ConstValue(); + if (DIEEnumerationType* enumerationType + = dynamic_cast( + entry->Parent())) { + type = enumerationType->GetType(); + } break; case DW_TAG_formal_parameter: - constantValue = dynamic_cast(entry) - ->ConstValue(); + { + DIEFormalParameter* parameterEntry + = dynamic_cast(entry); + constantValue = parameterEntry->ConstValue(); + type = parameterEntry->GetType(); break; + } case DW_TAG_template_value_parameter: - constantValue = dynamic_cast( - entry)->ConstValue(); + { + DIETemplateValueParameter* parameterEntry + = dynamic_cast(entry); + constantValue = parameterEntry->ConstValue(); + type = parameterEntry->GetType(); break; + } case DW_TAG_variable: - constantValue = dynamic_cast(entry) - ->ConstValue(); + { + DIEVariable* variableEntry + = dynamic_cast(entry); + constantValue = variableEntry->ConstValue(); + type = variableEntry->GetType(); break; + } default: return B_BAD_VALUE; } @@ -754,8 +781,14 @@ DwarfFile::EvaluateDynamicValue(CompilationUnit* unit, if (constantValue == NULL || !constantValue->IsValid()) return B_BAD_VALUE; - return EvaluateConstantValue(unit, subprogramEntry, constantValue, - targetInterface, instructionPointer, framePointer, _result); + status_t error = EvaluateConstantValue(unit, subprogramEntry, + constantValue, targetInterface, instructionPointer, + framePointer, _result); + if (error != B_OK) + return error; + + *_type = type; + return B_OK; } case ATTRIBUTE_CLASS_BLOCK: @@ -768,6 +801,7 @@ DwarfFile::EvaluateDynamicValue(CompilationUnit* unit, return error; _result.SetTo(result); + *_type = NULL; return B_OK; } @@ -962,6 +996,9 @@ DwarfFile::_FinishCompilationUnit(CompilationUnit* unit) } } + // set the compilation unit's source language + unit->SetSourceLanguage(entryInitInfo.languageInfo); + // resolve the compilation unit's address range list if (TargetAddressRangeList* ranges = ResolveRangeList(unit, unit->UnitEntry()->AddressRangesOffset())) { diff --git a/src/apps/debugger/dwarf/DwarfFile.h b/src/apps/debugger/dwarf/DwarfFile.h index 41c2d8ffa7..1b39d0b17a 100644 --- a/src/apps/debugger/dwarf/DwarfFile.h +++ b/src/apps/debugger/dwarf/DwarfFile.h @@ -68,6 +68,9 @@ public: target_addr_t objectPointer, target_addr_t framePointer, ValueLocation& _result); + // The returned location will have DWARF + // semantics regarding register numbers and + // bit offsets/sizes (cf. bit pieces). status_t EvaluateConstantValue(CompilationUnit* unit, DIESubprogram* subprogramEntry, @@ -82,7 +85,7 @@ public: const DwarfTargetInterface* targetInterface, target_addr_t instructionPointer, target_addr_t framePointer, - BVariant& _result); + BVariant& _result, DIEType** _type = NULL); private: struct ExpressionEvaluationContext;