diff --git a/src/apps/debugger/ThreadHandler.cpp b/src/apps/debugger/ThreadHandler.cpp index 023bad1bf2..5f3f9bbe78 100644 --- a/src/apps/debugger/ThreadHandler.cpp +++ b/src/apps/debugger/ThreadHandler.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2010, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -589,6 +590,33 @@ ThreadHandler::_HandleSingleStepStep(CpuState* cpuState) if (fStepStatement->ContainsAddress(cpuState->InstructionPointer())) { _SingleStepThread(cpuState->InstructionPointer()); return true; + } else { + StackTrace* stackTrace = fThread->GetStackTrace(); + Reference stackTraceReference(stackTrace); + + if (stackTrace == NULL && cpuState != NULL) { + if (fDebuggerInterface->GetArchitecture()->CreateStackTrace( + fThread->GetTeam(), this, cpuState, stackTrace) == B_OK) { + stackTraceReference.SetTo(stackTrace, true); + } + } + + if (stackTrace != NULL) { + StackFrame *frame = stackTrace->FrameAt(0); + Image* image = frame->GetImage(); + ImageDebugInfo* info = NULL; + if (GetImageDebugInfo(image, info) != B_OK) + return false; + + Reference(info, true); + + if (info->GetAddressSectionType( + cpuState->InstructionPointer()) + == ADDRESS_SECTION_TYPE_PLT) { + _SingleStepThread(cpuState->InstructionPointer()); + return true; + } + } } return false; } diff --git a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp index d127cfb4f0..faffbb2951 100644 --- a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp @@ -86,6 +86,13 @@ DebuggerImageDebugInfo::GetType(GlobalTypeCache* cache, } +AddressSectionType +DebuggerImageDebugInfo::GetAddressSectionType(target_addr_t address) +{ + return ADDRESS_SECTION_TYPE_UNKNOWN; +} + + status_t DebuggerImageDebugInfo::CreateFrame(Image* image, FunctionInstance* functionInstance, CpuState* cpuState, diff --git a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h index b94872c4d2..563dc9ecf3 100644 --- a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h +++ b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h @@ -29,6 +29,7 @@ public: BObjectList& functions); virtual status_t GetType(GlobalTypeCache* cache, const BString& name, Type*& _type); + virtual AddressSectionType GetAddressSectionType(target_addr_t address); virtual status_t CreateFrame(Image* image, FunctionInstance* functionInstance, CpuState* cpuState, diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp index 097de4f6c4..7a3cab8b86 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp @@ -429,6 +429,30 @@ DwarfImageDebugInfo::GetType(GlobalTypeCache* cache, } +AddressSectionType +DwarfImageDebugInfo::GetAddressSectionType(target_addr_t address) +{ + address -= fRelocationDelta; + ElfFile* file = fFile->GetElfFile(); + + ElfSection* section = file->GetSection(".text"); + if (section != NULL && address >= section->LoadAddress() + && address < section->LoadAddress() + section->Size()) { + file->PutSection(section); + return ADDRESS_SECTION_TYPE_FUNCTION; + } + + section = file->GetSection(".plt"); + if (section != NULL && address >= section->LoadAddress() + && address < section->LoadAddress() + section->Size()) { + file->PutSection(section); + return ADDRESS_SECTION_TYPE_PLT; + } + + return ADDRESS_SECTION_TYPE_UNKNOWN; +} + + status_t DwarfImageDebugInfo::CreateFrame(Image* image, FunctionInstance* functionInstance, CpuState* cpuState, diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.h b/src/apps/debugger/debug_info/DwarfImageDebugInfo.h index 158359f0b3..5dff7d7a03 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.h +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2010, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef DWARF_IMAGE_DEBUG_INFO_H @@ -10,6 +11,7 @@ #include +#include "AddressSectionTypes.h" #include "ImageInfo.h" #include "SpecificImageDebugInfo.h" #include "Type.h" @@ -50,6 +52,9 @@ public: BObjectList& functions); virtual status_t GetType(GlobalTypeCache* cache, const BString& name, Type*& _type); + + virtual AddressSectionType GetAddressSectionType(target_addr_t address); + virtual status_t CreateFrame(Image* image, FunctionInstance* functionInstance, CpuState* cpuState, diff --git a/src/apps/debugger/debug_info/ImageDebugInfo.cpp b/src/apps/debugger/debug_info/ImageDebugInfo.cpp index b7115fc187..bc84e7d183 100644 --- a/src/apps/debugger/debug_info/ImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/ImageDebugInfo.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2010, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -90,6 +91,21 @@ ImageDebugInfo::GetType(GlobalTypeCache* cache, const BString& name, } +AddressSectionType +ImageDebugInfo::GetAddressSectionType(target_addr_t address) const +{ + AddressSectionType type = ADDRESS_SECTION_TYPE_UNKNOWN; + for (int32 i = 0; SpecificImageDebugInfo* specificInfo + = fSpecificInfos.ItemAt(i); i++) { + type = specificInfo->GetAddressSectionType(address); + if (type != ADDRESS_SECTION_TYPE_UNKNOWN) + break; + } + + return type; +} + + int32 ImageDebugInfo::CountFunctions() const { diff --git a/src/apps/debugger/debug_info/ImageDebugInfo.h b/src/apps/debugger/debug_info/ImageDebugInfo.h index c54f41623b..0971806421 100644 --- a/src/apps/debugger/debug_info/ImageDebugInfo.h +++ b/src/apps/debugger/debug_info/ImageDebugInfo.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2010, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef IMAGE_DEBUG_INFO_H @@ -11,6 +12,7 @@ #include #include +#include "AddressSectionTypes.h" #include "ImageInfo.h" #include "Types.h" @@ -39,6 +41,8 @@ public: status_t GetType(GlobalTypeCache* cache, const BString& name, Type*& _type); // returns a reference + AddressSectionType GetAddressSectionType(target_addr_t address) + const; int32 CountFunctions() const; FunctionInstance* FunctionAt(int32 index) const; diff --git a/src/apps/debugger/debug_info/SpecificImageDebugInfo.h b/src/apps/debugger/debug_info/SpecificImageDebugInfo.h index 54da08de92..a4b807544c 100644 --- a/src/apps/debugger/debug_info/SpecificImageDebugInfo.h +++ b/src/apps/debugger/debug_info/SpecificImageDebugInfo.h @@ -9,6 +9,7 @@ #include #include +#include "AddressSectionTypes.h" #include "Types.h" @@ -43,6 +44,8 @@ public: virtual status_t GetType(GlobalTypeCache* cache, const BString& name, Type*& _type) = 0; // returns a reference + virtual AddressSectionType GetAddressSectionType(target_addr_t address) + = 0; virtual status_t CreateFrame(Image* image, FunctionInstance* functionInstance, diff --git a/src/apps/debugger/types/AddressSectionTypes.h b/src/apps/debugger/types/AddressSectionTypes.h new file mode 100644 index 0000000000..6c79b49e10 --- /dev/null +++ b/src/apps/debugger/types/AddressSectionTypes.h @@ -0,0 +1,16 @@ +/* + * Copyright 2010, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ +#ifndef ADDRESS_SECTION_TYPES_H +#define ADDRESS_SECTION_TYPES_H + + +enum AddressSectionType { + ADDRESS_SECTION_TYPE_UNKNOWN = 0, + ADDRESS_SECTION_TYPE_FUNCTION, + ADDRESS_SECTION_TYPE_PLT +}; + + +#endif // ADDRESS_SECTION_TYPES_H