diff --git a/src/apps/debugger/arch/Architecture.cpp b/src/apps/debugger/arch/Architecture.cpp index 42fd88eea9..ecae506adb 100644 --- a/src/apps/debugger/arch/Architecture.cpp +++ b/src/apps/debugger/arch/Architecture.cpp @@ -95,7 +95,8 @@ status_t Architecture::CreateStackTrace(Team* team, ImageDebugInfoProvider* imageInfoProvider, CpuState* cpuState, StackTrace*& _stackTrace, target_addr_t returnFunctionAddress, - int32 maxStackDepth, bool useExistingTrace, bool getFullFrameInfo) + CpuState* returnFunctionState, int32 maxStackDepth, bool useExistingTrace, + bool getFullFrameInfo) { BReference cpuStateReference(cpuState); @@ -163,7 +164,8 @@ Architecture::CreateStackTrace(Team* team, if (function != NULL) { status_t error = functionDebugInfo->GetSpecificImageDebugInfo() ->CreateFrame(image, function, cpuState, getFullFrameInfo, - nextFrame == NULL ? returnFunctionAddress : 0, frame, + nextFrame == NULL ? returnFunctionAddress : 0, + nextFrame == NULL ? returnFunctionState : 0, frame, previousCpuState); if (error != B_OK && error != B_UNSUPPORTED) break; diff --git a/src/apps/debugger/arch/Architecture.h b/src/apps/debugger/arch/Architecture.h index d9610ba77f..e39077400b 100644 --- a/src/apps/debugger/arch/Architecture.h +++ b/src/apps/debugger/arch/Architecture.h @@ -111,6 +111,7 @@ public: CpuState* cpuState, StackTrace*& _stackTrace, target_addr_t returnFunctionAddress, + CpuState* returnFunctionState, int32 maxStackDepth = -1, bool useExistingTrace = false, bool getFullFrameInfo = true); diff --git a/src/apps/debugger/controllers/ThreadHandler.cpp b/src/apps/debugger/controllers/ThreadHandler.cpp index 6a2fe948fb..af647cb1c5 100644 --- a/src/apps/debugger/controllers/ThreadHandler.cpp +++ b/src/apps/debugger/controllers/ThreadHandler.cpp @@ -253,7 +253,7 @@ ThreadHandler::HandleThreadAction(uint32 action) if (stackTrace == NULL && cpuState != NULL) { if (fDebuggerInterface->GetArchitecture()->CreateStackTrace( - fThread->GetTeam(), this, cpuState, stackTrace, 0, 1, + fThread->GetTeam(), this, cpuState, stackTrace, 0, NULL, 1, false, false) == B_OK) { stackTraceReference.SetTo(stackTrace, true); } @@ -485,6 +485,7 @@ ThreadHandler::_DoStepOver(CpuState* cpuState) "%#" B_PRIx64 "\n", info.Address() + info.Size()); fThread->SetExecutedSubroutine(info.TargetAddress()); + fThread->SetSubroutineCpuState(cpuState); if (_InstallTemporaryBreakpoint(info.Address() + info.Size()) != B_OK) return false; @@ -566,8 +567,8 @@ ThreadHandler::_HandleBreakpointHitStep(CpuState* cpuState) if (stackTrace == NULL && cpuState != NULL) { if (fDebuggerInterface->GetArchitecture()->CreateStackTrace( - fThread->GetTeam(), this, cpuState, stackTrace, 0, 1, - false, false) == B_OK) { + fThread->GetTeam(), this, cpuState, stackTrace, 0, + NULL, 1, false, false) == B_OK) { stackTraceReference.SetTo(stackTrace, true); } } @@ -653,8 +654,8 @@ ThreadHandler::_HandleSingleStepStep(CpuState* cpuState) if (stackTrace == NULL && cpuState != NULL) { if (fDebuggerInterface->GetArchitecture()->CreateStackTrace( - fThread->GetTeam(), this, cpuState, stackTrace, 0, 1, - false, false) == B_OK) { + fThread->GetTeam(), this, cpuState, stackTrace, 0, + NULL, 1, false, false) == B_OK) { stackTraceReference.SetTo(stackTrace, true); } } @@ -686,7 +687,7 @@ ThreadHandler::_HandleSingleStepStep(CpuState* cpuState) if (stackTrace == NULL && cpuState != NULL) { if (fDebuggerInterface->GetArchitecture()->CreateStackTrace( fThread->GetTeam(), this, cpuState, stackTrace, 0, - 1, false, false) == B_OK) { + NULL, 1, false, false) == B_OK) { stackTraceReference.SetTo(stackTrace, true); } } diff --git a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp index b40e08c998..c7a77e1603 100644 --- a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp @@ -69,7 +69,8 @@ status_t DebuggerImageDebugInfo::CreateFrame(Image* image, FunctionInstance* functionInstance, CpuState* cpuState, bool getFullFrameInfo, target_addr_t returnFunctionAddress, - StackFrame*& _previousFrame, CpuState*& _previousCpuState) + CpuState* returnFunctionState, StackFrame*& _previousFrame, + CpuState*& _previousCpuState) { return B_UNSUPPORTED; } diff --git a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h index bcafebc0f3..91d0c1bc63 100644 --- a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h +++ b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h @@ -37,6 +37,7 @@ public: CpuState* cpuState, bool getFullFrameInfo, target_addr_t returnFunctionAddress, + CpuState* returnFunctionState, StackFrame*& _previousFrame, CpuState*& _previousCpuState); virtual status_t GetStatement(FunctionDebugInfo* function, diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp index b96814da88..4c0247fb66 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp @@ -523,7 +523,8 @@ status_t DwarfImageDebugInfo::CreateFrame(Image* image, FunctionInstance* functionInstance, CpuState* cpuState, bool getFullFrameInfo, target_addr_t returnFunctionAddress, - StackFrame*& _frame, CpuState*& _previousCpuState) + CpuState* returnFunctionState, StackFrame*& _frame, + CpuState*& _previousCpuState) { DwarfFunctionDebugInfo* function = dynamic_cast( functionInstance->GetFunctionDebugInfo()); @@ -1091,7 +1092,8 @@ DwarfImageDebugInfo::_CreateLocalVariables(CompilationUnit* unit, status_t DwarfImageDebugInfo::_CreateReturnValue(target_addr_t returnFunctionAddress, - Image* image, StackFrame* frame, DwarfStackFrameDebugInfo& factory) + CpuState* returnFunctionState, Image* image, StackFrame* frame, + DwarfStackFrameDebugInfo& factory) { if (!image->ContainsAddress(returnFunctionAddress)) { // our current image doesn't contain the target function, diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.h b/src/apps/debugger/debug_info/DwarfImageDebugInfo.h index 203920b11a..7dab0fbffa 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.h +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.h @@ -65,6 +65,7 @@ public: CpuState* cpuState, bool getFullFrameInfo, target_addr_t returnFunctionAddress, + CpuState* returnFunctionState, StackFrame*& _frame, CpuState*& _previousCpuState); virtual status_t GetStatement(FunctionDebugInfo* function, @@ -106,6 +107,7 @@ private: status_t _CreateReturnValue( target_addr_t returnFunctionAddress, + CpuState* returnFunctionState, Image* image, StackFrame* frame, DwarfStackFrameDebugInfo& factory); diff --git a/src/apps/debugger/debug_info/SpecificImageDebugInfo.h b/src/apps/debugger/debug_info/SpecificImageDebugInfo.h index ac655cdf16..595d2383ab 100644 --- a/src/apps/debugger/debug_info/SpecificImageDebugInfo.h +++ b/src/apps/debugger/debug_info/SpecificImageDebugInfo.h @@ -57,6 +57,7 @@ public: CpuState* cpuState, bool getFullFrameInfo, target_addr_t returnFunctionAddress, + CpuState* returnFunctionState, StackFrame*& _Frame, CpuState*& _previousCpuState) = 0; // returns reference to previous frame diff --git a/src/apps/debugger/jobs/GetStackTraceJob.cpp b/src/apps/debugger/jobs/GetStackTraceJob.cpp index 23ce2fc102..c3a2316a76 100644 --- a/src/apps/debugger/jobs/GetStackTraceJob.cpp +++ b/src/apps/debugger/jobs/GetStackTraceJob.cpp @@ -59,7 +59,8 @@ GetStackTraceJob::Do() StackTrace* stackTrace; status_t error = fArchitecture->CreateStackTrace(fThread->GetTeam(), this, fCpuState, stackTrace, fThread->ExecutedSubroutine() - ? fThread->SubroutineAddress() : 0); + ? fThread->SubroutineAddress() : 0, fThread->ExecutedSubroutine() + ? fThread->SubroutineCpuState() : NULL); if (error != B_OK) return error; BReference stackTraceReference(stackTrace, true); diff --git a/src/apps/debugger/model/Thread.cpp b/src/apps/debugger/model/Thread.cpp index 63d21e036f..e32424c46d 100644 --- a/src/apps/debugger/model/Thread.cpp +++ b/src/apps/debugger/model/Thread.cpp @@ -19,6 +19,7 @@ Thread::Thread(Team* team, thread_id threadID) fState(THREAD_STATE_UNKNOWN), fExecutedSubroutine(false), fSubroutineAddress(0), + fSubroutineState(NULL), fStoppedReason(THREAD_STOPPED_UNKNOWN), fCpuState(NULL), fStackTrace(NULL) @@ -32,6 +33,8 @@ Thread::~Thread() fCpuState->ReleaseReference(); if (fStackTrace != NULL) fStackTrace->ReleaseReference(); + if (fSubroutineState != NULL) + fSubroutineState->ReleaseReference(); } @@ -121,3 +124,13 @@ Thread::SetExecutedSubroutine(target_addr_t address) fSubroutineAddress = address; } + +void +Thread::SetSubroutineCpuState(CpuState* state) +{ + if (fSubroutineState != NULL) + fSubroutineState->ReleaseReference(); + + fSubroutineState = state; + fSubroutineState->AcquireReference(); +} diff --git a/src/apps/debugger/model/Thread.h b/src/apps/debugger/model/Thread.h index 1cba07ff0c..17aa3307a0 100644 --- a/src/apps/debugger/model/Thread.h +++ b/src/apps/debugger/model/Thread.h @@ -74,6 +74,9 @@ public: target_addr_t SubroutineAddress() const { return fSubroutineAddress; } void SetExecutedSubroutine(target_addr_t address); + CpuState* SubroutineCpuState() const + { return fSubroutineState; } + void SetSubroutineCpuState(CpuState* state); private: Team* fTeam; @@ -82,6 +85,7 @@ private: uint32 fState; bool fExecutedSubroutine; target_addr_t fSubroutineAddress; + CpuState* fSubroutineState; uint32 fStoppedReason; BString fStoppedReasonInfo; CpuState* fCpuState;