diff --git a/src/apps/debugger/debug_info/BasicFunctionDebugInfo.cpp b/src/apps/debugger/debug_info/BasicFunctionDebugInfo.cpp index c8f939a943..c2baf40670 100644 --- a/src/apps/debugger/debug_info/BasicFunctionDebugInfo.cpp +++ b/src/apps/debugger/debug_info/BasicFunctionDebugInfo.cpp @@ -63,6 +63,13 @@ BasicFunctionDebugInfo::PrettyName() const } +bool +BasicFunctionDebugInfo::IsMain() const +{ + return false; +} + + LocatableFile* BasicFunctionDebugInfo::SourceFile() const { diff --git a/src/apps/debugger/debug_info/BasicFunctionDebugInfo.h b/src/apps/debugger/debug_info/BasicFunctionDebugInfo.h index 3136014d11..a5e4884b21 100644 --- a/src/apps/debugger/debug_info/BasicFunctionDebugInfo.h +++ b/src/apps/debugger/debug_info/BasicFunctionDebugInfo.h @@ -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; diff --git a/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.cpp index 2aee31ef8b..68b9fb3afa 100644 --- a/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.cpp @@ -78,6 +78,13 @@ DwarfFunctionDebugInfo::PrettyName() const } +bool +DwarfFunctionDebugInfo::IsMain() const +{ + return fSubprogramEntry->IsMain(); +} + + LocatableFile* DwarfFunctionDebugInfo::SourceFile() const { diff --git a/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.h b/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.h index b9f1345c1a..a35bcbe60e 100644 --- a/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.h +++ b/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.h @@ -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; diff --git a/src/apps/debugger/debug_info/FunctionDebugInfo.h b/src/apps/debugger/debug_info/FunctionDebugInfo.h index 2a03b696f8..3d6ab3bc27 100644 --- a/src/apps/debugger/debug_info/FunctionDebugInfo.h +++ b/src/apps/debugger/debug_info/FunctionDebugInfo.h @@ -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; diff --git a/src/apps/debugger/debug_info/ImageDebugInfo.cpp b/src/apps/debugger/debug_info/ImageDebugInfo.cpp index feeb5df0ff..c5038734d8 100644 --- a/src/apps/debugger/debug_info/ImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/ImageDebugInfo.cpp @@ -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 diff --git a/src/apps/debugger/debug_info/ImageDebugInfo.h b/src/apps/debugger/debug_info/ImageDebugInfo.h index 395dfe2347..00a5f9a194 100644 --- a/src/apps/debugger/debug_info/ImageDebugInfo.h +++ b/src/apps/debugger/debug_info/ImageDebugInfo.h @@ -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; }; diff --git a/src/apps/debugger/debug_info/TeamDebugInfo.cpp b/src/apps/debugger/debug_info/TeamDebugInfo.cpp index 802f4a7094..700caa4d76 100644 --- a/src/apps/debugger/debug_info/TeamDebugInfo.cpp +++ b/src/apps/debugger/debug_info/TeamDebugInfo.cpp @@ -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; } diff --git a/src/apps/debugger/debug_info/TeamDebugInfo.h b/src/apps/debugger/debug_info/TeamDebugInfo.h index d267f5db7f..06b7fe0399 100644 --- a/src/apps/debugger/debug_info/TeamDebugInfo.h +++ b/src/apps/debugger/debug_info/TeamDebugInfo.h @@ -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; };