From df9cc7340c2434eefbad8589ae4b5d2e7061fdca Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 30 Jun 2009 12:57:41 +0000 Subject: [PATCH] Retrieve the source file declaration locations for functions and attach them to the DwarfFunctionDebugInfo objects. The functions do now appear organized by source file in the function list view. Unfortunately the list view is too small to look as clear as it should. Got to think of something else I'm afraid. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31326 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../debug_info/DwarfFunctionDebugInfo.cpp | 13 +++++++----- .../debug_info/DwarfFunctionDebugInfo.h | 9 ++++++-- .../debug_info/DwarfImageDebugInfo.cpp | 21 ++++++++++++++++++- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.cpp index 6a396a8459..6ab6651b91 100644 --- a/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.cpp @@ -12,11 +12,14 @@ DwarfFunctionDebugInfo::DwarfFunctionDebugInfo( DwarfImageDebugInfo* imageDebugInfo, DIESubprogram* subprogramEntry, - TargetAddressRangeList* addressRanges, const BString& name) + TargetAddressRangeList* addressRanges, const BString& name, + const BString& sourceFile, const SourceLocation& sourceLocation) : fImageDebugInfo(imageDebugInfo), fAddressRanges(addressRanges), - fName(name) + fName(name), + fSourceFile(sourceFile), + fSourceLocation(sourceLocation) { fImageDebugInfo->AddReference(); fAddressRanges->AddReference(); @@ -68,19 +71,19 @@ DwarfFunctionDebugInfo::PrettyName() const const char* DwarfFunctionDebugInfo::SourceFileName() const { - return NULL; + return fSourceFile.Length() > 0 ? fSourceFile.String() : NULL; } SourceLocation DwarfFunctionDebugInfo::SourceStartLocation() const { - return SourceLocation(); + return fSourceLocation; } SourceLocation DwarfFunctionDebugInfo::SourceEndLocation() const { - return SourceLocation(); + return fSourceLocation; } diff --git a/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.h b/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.h index 4f7f025f0b..32e660a458 100644 --- a/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.h +++ b/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.h @@ -8,6 +8,7 @@ #include #include "FunctionDebugInfo.h" +#include "SourceLocation.h" class DIESubprogram; @@ -21,7 +22,9 @@ public: DwarfImageDebugInfo* imageDebugInfo, DIESubprogram* subprogramEntry, TargetAddressRangeList* addressRanges, - const BString& name); + const BString& name, + const BString& sourceFile, + const SourceLocation& sourceLocation); virtual ~DwarfFunctionDebugInfo(); virtual SpecificImageDebugInfo* GetSpecificImageDebugInfo() const; @@ -37,7 +40,9 @@ public: private: DwarfImageDebugInfo* fImageDebugInfo; TargetAddressRangeList* fAddressRanges; - const BString fName; + BString fName; + BString fSourceFile; + SourceLocation fSourceLocation; }; diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp index 8090654e74..594b258613 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp @@ -117,10 +117,29 @@ printf(" %ld compilation units\n", fFile->CountCompilationUnits()); rangeListReference.SetTo(rangeList, true); } + // get the source location + const char* directory = NULL; + const char* file = NULL; + uint32 line = 0; + uint32 column = 0; + DwarfUtils::GetDeclarationLocation(fFile, subprogramEntry, + directory, file, line, column); + BString fileName; + if (file != NULL) { + if (directory != NULL) + fileName << directory << '/' << file; + else + fileName << file; + } + // TODO: Avoid unnessecary string allocation! The source file name + // is the same for all contained functions, so they could share the + // string. + // create and add the functions DwarfFunctionDebugInfo* function = new(std::nothrow) DwarfFunctionDebugInfo(this, - subprogramEntry, rangeList, name); + subprogramEntry, rangeList, name, fileName, + SourceLocation(line, column)); if (function == NULL || !functions.AddItem(function)) { delete function; return B_NO_MEMORY;