Files
haiku-beta6/src/apps/debugger/model/StackFrame.cpp
T
Ingo Weinhold 2460bf468b * Changes that should already have been part of r31228: StackFrame and
SourceView.
* Fixed the information flow problem in Architecture::CreateStackTrace()/
  ArchitectureX86::UpdateStackCpuState() by introducing a virtual
  UpdateStackFrameCpuState() which allows the architecture to update the CPU
  state it generated before after the function the state belongs to is known.
  That's where moving the instruction pointer to the previous instruction
  happens now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31229 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-24 22:10:07 +00:00

122 lines
2.0 KiB
C++

/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "StackFrame.h"
#include "CpuState.h"
#include "FunctionDebugInfo.h"
#include "Image.h"
#include "SourceCode.h"
// #pragma mark - StackFrame
StackFrame::StackFrame(stack_frame_type type, CpuState* cpuState,
target_addr_t frameAddress, target_addr_t instructionPointer)
:
fType(type),
fCpuState(cpuState),
fFrameAddress(frameAddress),
fInstructionPointer(instructionPointer),
fReturnAddress(0),
fImage(NULL),
fFunction(NULL),
fSourceCode(NULL),
fSourceCodeState(STACK_SOURCE_NOT_LOADED)
{
fCpuState->AddReference();
}
StackFrame::~StackFrame()
{
SetSourceCode(NULL, STACK_SOURCE_NOT_LOADED);
SetImage(NULL);
SetFunction(NULL);
fCpuState->RemoveReference();
}
void
StackFrame::SetReturnAddress(target_addr_t address)
{
fReturnAddress = address;
}
void
StackFrame::SetImage(Image* image)
{
if (fImage != NULL)
fImage->RemoveReference();
fImage = image;
if (fImage != NULL)
fImage->AddReference();
}
void
StackFrame::SetFunction(FunctionDebugInfo* function)
{
if (fFunction != NULL)
fFunction->RemoveReference();
fFunction = function;
if (fFunction != NULL)
fFunction->AddReference();
}
void
StackFrame::SetSourceCode(SourceCode* source, stack_frame_source_state state)
{
if (fSourceCode != NULL)
fSourceCode->RemoveReference();
fSourceCode = source;
fSourceCodeState = state;
if (fSourceCode != NULL)
fSourceCode->AddReference();
// notify listeners
for (ListenerList::Iterator it = fListeners.GetIterator();
Listener* listener = it.Next();) {
listener->StackFrameSourceCodeChanged(this);
}
}
void
StackFrame::AddListener(Listener* listener)
{
fListeners.Add(listener);
}
void
StackFrame::RemoveListener(Listener* listener)
{
fListeners.Remove(listener);
}
// #pragma mark - Listener
StackFrame::Listener::~Listener()
{
}
void
StackFrame::Listener::StackFrameSourceCodeChanged(StackFrame* frame)
{
}