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
This commit is contained in:
Ingo Weinhold 2009-06-30 12:57:41 +00:00
parent 91c6759f30
commit df9cc7340c
3 changed files with 35 additions and 8 deletions

View File

@ -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;
}

View File

@ -8,6 +8,7 @@
#include <String.h>
#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;
};

View File

@ -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;