From 1167ae5274affc91edf51577ea0d881f38599393 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 26 Dec 2012 00:17:09 -0500 Subject: [PATCH] Some optimizations for ThreadHandler. - CreateStackTrace() now takes a parameter indicating whether or not to try and retrieve full frame information. This in turn is passed on to SpecificImageDebugInfo, where e.g. DwarfImageDebugInfo can use it to avoid constructing variables and parameters. This is used by ThreadHandler since, when it requests the top frame for its stepping calculations, this additional data/work is completely unnecessary. --- src/apps/debugger/arch/Architecture.cpp | 10 ++++++---- src/apps/debugger/arch/Architecture.h | 3 ++- src/apps/debugger/controllers/ThreadHandler.cpp | 3 ++- .../debugger/debug_info/DebuggerImageDebugInfo.cpp | 3 ++- src/apps/debugger/debug_info/DebuggerImageDebugInfo.h | 1 + src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp | 4 ++-- src/apps/debugger/debug_info/DwarfImageDebugInfo.h | 1 + src/apps/debugger/debug_info/SpecificImageDebugInfo.h | 4 ++++ 8 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/apps/debugger/arch/Architecture.cpp b/src/apps/debugger/arch/Architecture.cpp index 62aee4cfa1..01b39992e5 100644 --- a/src/apps/debugger/arch/Architecture.cpp +++ b/src/apps/debugger/arch/Architecture.cpp @@ -94,7 +94,8 @@ Architecture::InitRegisterRules(CfaContext& context) const status_t Architecture::CreateStackTrace(Team* team, ImageDebugInfoProvider* imageInfoProvider, CpuState* cpuState, - StackTrace*& _stackTrace, int32 maxStackDepth, bool useExistingTrace) + StackTrace*& _stackTrace, int32 maxStackDepth, bool useExistingTrace, + bool getFullFrameInfo) { BReference cpuStateReference(cpuState); @@ -161,8 +162,8 @@ Architecture::CreateStackTrace(Team* team, CpuState* previousCpuState = NULL; if (function != NULL) { status_t error = functionDebugInfo->GetSpecificImageDebugInfo() - ->CreateFrame(image, function, cpuState, frame, - previousCpuState); + ->CreateFrame(image, function, cpuState, getFullFrameInfo, + frame, previousCpuState); if (error != B_OK && error != B_UNSUPPORTED) break; } @@ -170,7 +171,8 @@ Architecture::CreateStackTrace(Team* team, // If we have no frame yet, let the architecture create it. if (frame == NULL) { status_t error = CreateStackFrame(image, functionDebugInfo, - cpuState, nextFrame == NULL, frame, previousCpuState); + cpuState, nextFrame == NULL, frame, + previousCpuState); if (error != B_OK) break; } diff --git a/src/apps/debugger/arch/Architecture.h b/src/apps/debugger/arch/Architecture.h index 998d3be7f4..38409d0a3a 100644 --- a/src/apps/debugger/arch/Architecture.h +++ b/src/apps/debugger/arch/Architecture.h @@ -109,7 +109,8 @@ public: CpuState* cpuState, StackTrace*& _stackTrace, int32 maxStackDepth = -1, - bool useExistingTrace = false); + bool useExistingTrace = false, + bool getFullFrameInfo = true); // team is not locked virtual status_t GetWatchpointDebugCapabilities( diff --git a/src/apps/debugger/controllers/ThreadHandler.cpp b/src/apps/debugger/controllers/ThreadHandler.cpp index 366c3923b9..40539460a0 100644 --- a/src/apps/debugger/controllers/ThreadHandler.cpp +++ b/src/apps/debugger/controllers/ThreadHandler.cpp @@ -253,7 +253,8 @@ ThreadHandler::HandleThreadAction(uint32 action) if (stackTrace == NULL && cpuState != NULL) { if (fDebuggerInterface->GetArchitecture()->CreateStackTrace( - fThread->GetTeam(), this, cpuState, stackTrace, 1) == B_OK) { + fThread->GetTeam(), this, cpuState, stackTrace, 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 01467c789d..da467da3b0 100644 --- a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp @@ -68,7 +68,8 @@ DebuggerImageDebugInfo::GetAddressSectionType(target_addr_t address) status_t DebuggerImageDebugInfo::CreateFrame(Image* image, FunctionInstance* functionInstance, CpuState* cpuState, - StackFrame*& _previousFrame, CpuState*& _previousCpuState) + bool getFullFrameInfo, 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 043b4eae52..8c0c520160 100644 --- a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h +++ b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h @@ -35,6 +35,7 @@ public: virtual status_t CreateFrame(Image* image, FunctionInstance* functionInstance, CpuState* cpuState, + bool getFullFrameInfo, 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 2781768c3b..d64f823034 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp @@ -516,7 +516,7 @@ DwarfImageDebugInfo::GetAddressSectionType(target_addr_t address) status_t DwarfImageDebugInfo::CreateFrame(Image* image, FunctionInstance* functionInstance, CpuState* cpuState, - StackFrame*& _frame, CpuState*& _previousCpuState) + bool getFullFrameInfo, StackFrame*& _frame, CpuState*& _previousCpuState) { DwarfFunctionDebugInfo* function = dynamic_cast( functionInstance->GetFunctionDebugInfo()); @@ -635,7 +635,7 @@ DwarfImageDebugInfo::CreateFrame(Image* image, // The subprogram entry may not be available since this may be a case // where .eh_frame was used to unwind the stack without other DWARF // info being available. - if (subprogramEntry != NULL) { + if (subprogramEntry != NULL && getFullFrameInfo) { // create function parameter objects for (DebugInfoEntryList::ConstIterator it = subprogramEntry->Parameters().GetIterator(); diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.h b/src/apps/debugger/debug_info/DwarfImageDebugInfo.h index 67b1cf1e1f..a79a58bb51 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.h +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.h @@ -61,6 +61,7 @@ public: virtual status_t CreateFrame(Image* image, FunctionInstance* functionInstance, CpuState* cpuState, + bool getFullFrameInfo, StackFrame*& _frame, CpuState*& _previousCpuState); virtual status_t GetStatement(FunctionDebugInfo* function, diff --git a/src/apps/debugger/debug_info/SpecificImageDebugInfo.h b/src/apps/debugger/debug_info/SpecificImageDebugInfo.h index 0f9f74ad68..7287964ce5 100644 --- a/src/apps/debugger/debug_info/SpecificImageDebugInfo.h +++ b/src/apps/debugger/debug_info/SpecificImageDebugInfo.h @@ -55,11 +55,15 @@ public: virtual status_t CreateFrame(Image* image, FunctionInstance* functionInstance, CpuState* cpuState, + bool getFullFrameInfo, StackFrame*& _Frame, CpuState*& _previousCpuState) = 0; // returns reference to previous frame // and CPU state; returned CPU state // can be NULL; can return B_UNSUPPORTED + // getFullFrameInfo: try to retrieve + // variables/parameters if true + // (and supported) virtual status_t GetStatement(FunctionDebugInfo* function, target_addr_t address, Statement*& _statement) = 0;