Skip to content

Commit

Permalink
Some optimizations for ThreadHandler.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
anevilyak committed Dec 26, 2012
1 parent 50bd564 commit 1167ae5
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 9 deletions.
10 changes: 6 additions & 4 deletions src/apps/debugger/arch/Architecture.cpp
Expand Up @@ -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<CpuState> cpuStateReference(cpuState);

Expand Down Expand Up @@ -161,16 +162,17 @@ 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;
}

// 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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/apps/debugger/arch/Architecture.h
Expand Up @@ -109,7 +109,8 @@ class Architecture : public BReferenceable {
CpuState* cpuState,
StackTrace*& _stackTrace,
int32 maxStackDepth = -1,
bool useExistingTrace = false);
bool useExistingTrace = false,
bool getFullFrameInfo = true);
// team is not locked

virtual status_t GetWatchpointDebugCapabilities(
Expand Down
3 changes: 2 additions & 1 deletion src/apps/debugger/controllers/ThreadHandler.cpp
Expand Up @@ -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);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/apps/debugger/debug_info/DebuggerImageDebugInfo.h
Expand Up @@ -35,6 +35,7 @@ class DebuggerImageDebugInfo : public SpecificImageDebugInfo {
virtual status_t CreateFrame(Image* image,
FunctionInstance* functionInstance,
CpuState* cpuState,
bool getFullFrameInfo,
StackFrame*& _previousFrame,
CpuState*& _previousCpuState);
virtual status_t GetStatement(FunctionDebugInfo* function,
Expand Down
4 changes: 2 additions & 2 deletions src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp
Expand Up @@ -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<DwarfFunctionDebugInfo*>(
functionInstance->GetFunctionDebugInfo());
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/apps/debugger/debug_info/DwarfImageDebugInfo.h
Expand Up @@ -61,6 +61,7 @@ class DwarfImageDebugInfo : public SpecificImageDebugInfo {
virtual status_t CreateFrame(Image* image,
FunctionInstance* functionInstance,
CpuState* cpuState,
bool getFullFrameInfo,
StackFrame*& _frame,
CpuState*& _previousCpuState);
virtual status_t GetStatement(FunctionDebugInfo* function,
Expand Down
4 changes: 4 additions & 0 deletions src/apps/debugger/debug_info/SpecificImageDebugInfo.h
Expand Up @@ -55,11 +55,15 @@ class SpecificImageDebugInfo : public BReferenceable {
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;
Expand Down

0 comments on commit 1167ae5

Please sign in to comment.