Merge branch 'master' of ssh://git.haiku-os.org/haiku
This commit is contained in:
@@ -100,7 +100,7 @@ Architecture::CreateStackTrace(Team* team,
|
|||||||
|
|
||||||
StackTrace* stackTrace = NULL;
|
StackTrace* stackTrace = NULL;
|
||||||
ObjectDeleter<StackTrace> stackTraceDeleter;
|
ObjectDeleter<StackTrace> stackTraceDeleter;
|
||||||
StackFrame* frame = NULL;
|
StackFrame* nextFrame = NULL;
|
||||||
|
|
||||||
if (useExistingTrace)
|
if (useExistingTrace)
|
||||||
stackTrace = _stackTrace;
|
stackTrace = _stackTrace;
|
||||||
@@ -115,8 +115,8 @@ Architecture::CreateStackTrace(Team* team,
|
|||||||
// if we're passed an already existing partial stack trace,
|
// if we're passed an already existing partial stack trace,
|
||||||
// attempt to continue building it from where it left off.
|
// attempt to continue building it from where it left off.
|
||||||
if (stackTrace->CountFrames() > 0) {
|
if (stackTrace->CountFrames() > 0) {
|
||||||
frame = stackTrace->FrameAt(stackTrace->CountFrames() - 1);
|
nextFrame = stackTrace->FrameAt(stackTrace->CountFrames() - 1);
|
||||||
cpuState = frame->GetCpuState();
|
cpuState = nextFrame->GetPreviousCpuState();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (cpuState != NULL) {
|
while (cpuState != NULL) {
|
||||||
@@ -152,42 +152,42 @@ Architecture::CreateStackTrace(Team* team,
|
|||||||
|
|
||||||
// If the CPU state's instruction pointer is actually the return address
|
// If the CPU state's instruction pointer is actually the return address
|
||||||
// of the next frame, we let the architecture fix that.
|
// of the next frame, we let the architecture fix that.
|
||||||
if (frame != NULL
|
if (nextFrame != NULL
|
||||||
&& frame->ReturnAddress() == cpuState->InstructionPointer()) {
|
&& nextFrame->ReturnAddress() == cpuState->InstructionPointer()) {
|
||||||
UpdateStackFrameCpuState(frame, image,
|
UpdateStackFrameCpuState(nextFrame, image,
|
||||||
functionDebugInfo, cpuState);
|
functionDebugInfo, cpuState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the frame using the debug info
|
// create the frame using the debug info
|
||||||
StackFrame* previousFrame = NULL;
|
StackFrame* frame = NULL;
|
||||||
CpuState* previousCpuState = NULL;
|
CpuState* previousCpuState = NULL;
|
||||||
if (function != NULL) {
|
if (function != NULL) {
|
||||||
status_t error = functionDebugInfo->GetSpecificImageDebugInfo()
|
status_t error = functionDebugInfo->GetSpecificImageDebugInfo()
|
||||||
->CreateFrame(image, function, cpuState, previousFrame,
|
->CreateFrame(image, function, cpuState, frame,
|
||||||
previousCpuState);
|
previousCpuState);
|
||||||
if (error != B_OK && error != B_UNSUPPORTED)
|
if (error != B_OK && error != B_UNSUPPORTED)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have no frame yet, let the architecture create it.
|
// If we have no frame yet, let the architecture create it.
|
||||||
if (previousFrame == NULL) {
|
if (frame == NULL) {
|
||||||
status_t error = CreateStackFrame(image, functionDebugInfo,
|
status_t error = CreateStackFrame(image, functionDebugInfo,
|
||||||
cpuState, frame == NULL, previousFrame, previousCpuState);
|
cpuState, nextFrame == NULL, frame, previousCpuState);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpuStateReference.SetTo(previousCpuState, true);
|
cpuStateReference.SetTo(previousCpuState, true);
|
||||||
|
|
||||||
previousFrame->SetImage(image);
|
frame->SetImage(image);
|
||||||
previousFrame->SetFunction(function);
|
frame->SetFunction(function);
|
||||||
|
|
||||||
if (!stackTrace->AddFrame(previousFrame)) {
|
if (!stackTrace->AddFrame(frame)) {
|
||||||
delete previousFrame;
|
delete frame;
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame = previousFrame;
|
frame = nextFrame;
|
||||||
cpuState = previousCpuState;
|
cpuState = previousCpuState;
|
||||||
if (--maxStackDepth == 0)
|
if (--maxStackDepth == 0)
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public:
|
|||||||
virtual status_t CreateStackFrame(Image* image,
|
virtual status_t CreateStackFrame(Image* image,
|
||||||
FunctionDebugInfo* function,
|
FunctionDebugInfo* function,
|
||||||
CpuState* cpuState, bool isTopFrame,
|
CpuState* cpuState, bool isTopFrame,
|
||||||
StackFrame*& _previousFrame,
|
StackFrame*& _frame,
|
||||||
CpuState*& _previousCpuState) = 0;
|
CpuState*& _previousCpuState) = 0;
|
||||||
// returns reference to previous frame
|
// returns reference to previous frame
|
||||||
// and CPU state; returned CPU state
|
// and CPU state; returned CPU state
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ ArchitectureX86::CreateCpuState(const void* cpuStateData, size_t size,
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
ArchitectureX86::CreateStackFrame(Image* image, FunctionDebugInfo* function,
|
ArchitectureX86::CreateStackFrame(Image* image, FunctionDebugInfo* function,
|
||||||
CpuState* _cpuState, bool isTopFrame, StackFrame*& _previousFrame,
|
CpuState* _cpuState, bool isTopFrame, StackFrame*& _frame,
|
||||||
CpuState*& _previousCpuState)
|
CpuState*& _previousCpuState)
|
||||||
{
|
{
|
||||||
CpuStateX86* cpuState = dynamic_cast<CpuStateX86*>(_cpuState);
|
CpuStateX86* cpuState = dynamic_cast<CpuStateX86*>(_cpuState);
|
||||||
@@ -382,11 +382,12 @@ ArchitectureX86::CreateStackFrame(Image* image, FunctionDebugInfo* function,
|
|||||||
previousCpuState->SetIntRegister(X86_REGISTER_EBP,
|
previousCpuState->SetIntRegister(X86_REGISTER_EBP,
|
||||||
previousFramePointer);
|
previousFramePointer);
|
||||||
previousCpuState->SetIntRegister(X86_REGISTER_EIP, returnAddress);
|
previousCpuState->SetIntRegister(X86_REGISTER_EIP, returnAddress);
|
||||||
|
frame->SetPreviousCpuState(previousCpuState);
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->SetReturnAddress(returnAddress);
|
frame->SetReturnAddress(returnAddress);
|
||||||
|
|
||||||
_previousFrame = frameReference.Detach();
|
_frame = frameReference.Detach();
|
||||||
_previousCpuState = previousCpuState;
|
_previousCpuState = previousCpuState;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ DwarfImageDebugInfo::GetAddressSectionType(target_addr_t address)
|
|||||||
status_t
|
status_t
|
||||||
DwarfImageDebugInfo::CreateFrame(Image* image,
|
DwarfImageDebugInfo::CreateFrame(Image* image,
|
||||||
FunctionInstance* functionInstance, CpuState* cpuState,
|
FunctionInstance* functionInstance, CpuState* cpuState,
|
||||||
StackFrame*& _previousFrame, CpuState*& _previousCpuState)
|
StackFrame*& _frame, CpuState*& _previousCpuState)
|
||||||
{
|
{
|
||||||
DwarfFunctionDebugInfo* function = dynamic_cast<DwarfFunctionDebugInfo*>(
|
DwarfFunctionDebugInfo* function = dynamic_cast<DwarfFunctionDebugInfo*>(
|
||||||
functionInstance->GetFunctionDebugInfo());
|
functionInstance->GetFunctionDebugInfo());
|
||||||
@@ -634,9 +634,11 @@ DwarfImageDebugInfo::CreateFrame(Image* image,
|
|||||||
instructionPointer, functionInstance->Address() - fRelocationDelta,
|
instructionPointer, functionInstance->Address() - fRelocationDelta,
|
||||||
subprogramEntry->Variables(), subprogramEntry->Blocks());
|
subprogramEntry->Variables(), subprogramEntry->Blocks());
|
||||||
|
|
||||||
_previousFrame = frameReference.Detach();
|
_frame = frameReference.Detach();
|
||||||
_previousCpuState = previousCpuStateReference.Detach();
|
_previousCpuState = previousCpuStateReference.Detach();
|
||||||
|
|
||||||
|
frame->SetPreviousCpuState(_previousCpuState);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
virtual status_t CreateFrame(Image* image,
|
virtual status_t CreateFrame(Image* image,
|
||||||
FunctionInstance* functionInstance,
|
FunctionInstance* functionInstance,
|
||||||
CpuState* cpuState,
|
CpuState* cpuState,
|
||||||
StackFrame*& _previousFrame,
|
StackFrame*& _frame,
|
||||||
CpuState*& _previousCpuState);
|
CpuState*& _previousCpuState);
|
||||||
virtual status_t GetStatement(FunctionDebugInfo* function,
|
virtual status_t GetStatement(FunctionDebugInfo* function,
|
||||||
target_addr_t address,
|
target_addr_t address,
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public:
|
|||||||
virtual status_t CreateFrame(Image* image,
|
virtual status_t CreateFrame(Image* image,
|
||||||
FunctionInstance* functionInstance,
|
FunctionInstance* functionInstance,
|
||||||
CpuState* cpuState,
|
CpuState* cpuState,
|
||||||
StackFrame*& _previousFrame,
|
StackFrame*& _Frame,
|
||||||
CpuState*& _previousCpuState) = 0;
|
CpuState*& _previousCpuState) = 0;
|
||||||
// returns reference to previous frame
|
// returns reference to previous frame
|
||||||
// and CPU state; returned CPU state
|
// and CPU state; returned CPU state
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ StackFrame::StackFrame(stack_frame_type type, CpuState* cpuState,
|
|||||||
:
|
:
|
||||||
fType(type),
|
fType(type),
|
||||||
fCpuState(cpuState),
|
fCpuState(cpuState),
|
||||||
|
fPreviousCpuState(NULL),
|
||||||
fFrameAddress(frameAddress),
|
fFrameAddress(frameAddress),
|
||||||
fInstructionPointer(instructionPointer),
|
fInstructionPointer(instructionPointer),
|
||||||
fReturnAddress(0),
|
fReturnAddress(0),
|
||||||
@@ -49,6 +50,7 @@ StackFrame::~StackFrame()
|
|||||||
|
|
||||||
SetImage(NULL);
|
SetImage(NULL);
|
||||||
SetFunction(NULL);
|
SetFunction(NULL);
|
||||||
|
SetPreviousCpuState(NULL);
|
||||||
|
|
||||||
fDebugInfo->ReleaseReference();
|
fDebugInfo->ReleaseReference();
|
||||||
fCpuState->ReleaseReference();
|
fCpuState->ReleaseReference();
|
||||||
@@ -80,6 +82,18 @@ StackFrame::Init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
StackFrame::SetPreviousCpuState(CpuState* state)
|
||||||
|
{
|
||||||
|
if (fPreviousCpuState != NULL)
|
||||||
|
fPreviousCpuState->ReleaseReference();
|
||||||
|
|
||||||
|
fPreviousCpuState = state;
|
||||||
|
|
||||||
|
if (fPreviousCpuState != NULL)
|
||||||
|
fPreviousCpuState->AcquireReference();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StackFrame::SetReturnAddress(target_addr_t address)
|
StackFrame::SetReturnAddress(target_addr_t address)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ public:
|
|||||||
target_addr_t InstructionPointer() const
|
target_addr_t InstructionPointer() const
|
||||||
{ return fInstructionPointer; }
|
{ return fInstructionPointer; }
|
||||||
|
|
||||||
|
CpuState* GetPreviousCpuState() const
|
||||||
|
{ return fPreviousCpuState; }
|
||||||
|
void SetPreviousCpuState(CpuState* state);
|
||||||
|
|
||||||
target_addr_t ReturnAddress() const { return fReturnAddress; }
|
target_addr_t ReturnAddress() const { return fReturnAddress; }
|
||||||
void SetReturnAddress(target_addr_t address);
|
void SetReturnAddress(target_addr_t address);
|
||||||
|
|
||||||
@@ -89,6 +93,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
stack_frame_type fType;
|
stack_frame_type fType;
|
||||||
CpuState* fCpuState;
|
CpuState* fCpuState;
|
||||||
|
CpuState* fPreviousCpuState;
|
||||||
target_addr_t fFrameAddress;
|
target_addr_t fFrameAddress;
|
||||||
target_addr_t fInstructionPointer;
|
target_addr_t fInstructionPointer;
|
||||||
target_addr_t fReturnAddress;
|
target_addr_t fReturnAddress;
|
||||||
|
|||||||
Reference in New Issue
Block a user