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;