Debugger: Extend FunctionDebugInfo interface.

- Add hook to FunctionDebugInfo to determine if the represented function
is the main function of the program. Adjust
{Basic,Dwarf}FunctionDebugInfo accordingly.

- {Team,Image}DebugInfo: When loading, see if the current image contains
the main function. If so, cache it for later retrieval.
This commit is contained in:
Rene Gollent 2013-07-12 20:31:40 -04:00
parent e89d7992e5
commit d3a795bcb4
9 changed files with 40 additions and 2 deletions

View File

@ -63,6 +63,13 @@ BasicFunctionDebugInfo::PrettyName() const
}
bool
BasicFunctionDebugInfo::IsMain() const
{
return false;
}
LocatableFile*
BasicFunctionDebugInfo::SourceFile() const
{

View File

@ -26,6 +26,8 @@ public:
virtual const BString& Name() const;
virtual const BString& PrettyName() const;
virtual bool IsMain() const;
virtual LocatableFile* SourceFile() const;
virtual SourceLocation SourceStartLocation() const;
virtual SourceLocation SourceEndLocation() const;

View File

@ -78,6 +78,13 @@ DwarfFunctionDebugInfo::PrettyName() const
}
bool
DwarfFunctionDebugInfo::IsMain() const
{
return fSubprogramEntry->IsMain();
}
LocatableFile*
DwarfFunctionDebugInfo::SourceFile() const
{

View File

@ -35,6 +35,8 @@ public:
virtual const BString& Name() const;
virtual const BString& PrettyName() const;
virtual bool IsMain() const;
virtual LocatableFile* SourceFile() const;
virtual SourceLocation SourceStartLocation() const;
virtual SourceLocation SourceEndLocation() const;

View File

@ -27,6 +27,8 @@ public:
virtual const BString& Name() const = 0;
virtual const BString& PrettyName() const = 0;
virtual bool IsMain() const = 0;
virtual LocatableFile* SourceFile() const = 0;
virtual SourceLocation SourceStartLocation() const = 0;
virtual SourceLocation SourceEndLocation() const = 0;

View File

@ -17,7 +17,8 @@
ImageDebugInfo::ImageDebugInfo(const ImageInfo& imageInfo)
:
fImageInfo(imageInfo)
fImageInfo(imageInfo),
fMainFunction(NULL)
{
}
@ -68,6 +69,9 @@ ImageDebugInfo::FinishInit(DebuggerInterface* interface)
error = B_NO_MEMORY;
break;
}
if (function->IsMain())
fMainFunction = instance;
}
// Remove references returned by the specific debug info -- the

View File

@ -53,6 +53,9 @@ public:
FunctionInstance* FunctionAtAddress(target_addr_t address) const;
FunctionInstance* FunctionByName(const char* name) const;
FunctionInstance* MainFunction() const
{ return fMainFunction; }
status_t AddSourceCodeInfo(LocatableFile* file,
FileSourceCode* sourceCode) const;
@ -73,6 +76,7 @@ private:
ImageInfo fImageInfo;
SpecificInfoList fSpecificInfos;
FunctionList fFunctions;
FunctionInstance* fMainFunction;
};

View File

@ -267,7 +267,8 @@ TeamDebugInfo::TeamDebugInfo(DebuggerInterface* debuggerInterface,
fSpecificInfos(10, true),
fFunctions(NULL),
fSourceFiles(NULL),
fTypeCache(NULL)
fTypeCache(NULL),
fMainFunction(NULL)
{
fDebuggerInterface->AcquireReference();
}
@ -452,6 +453,12 @@ TeamDebugInfo::LoadImageDebugInfo(const ImageInfo& imageInfo,
if (error != B_OK)
return error;
if (fMainFunction == NULL) {
FunctionInstance* instance = imageDebugInfo->MainFunction();
if (instance != NULL)
fMainFunction = instance;
}
_imageDebugInfo = imageDebugInfoReference.Detach();
return B_OK;
}

View File

@ -63,6 +63,8 @@ public:
FunctionInstance* functionInstance,
DisassembledCode*& _sourceCode);
// returns reference
FunctionInstance* MainFunction() const
{ return fMainFunction; }
// team is locked
status_t AddImageDebugInfo(
@ -99,6 +101,7 @@ private:
FunctionTable* fFunctions;
SourceFileTable* fSourceFiles;
GlobalTypeCache* fTypeCache;
FunctionInstance* fMainFunction;
};