* If a stack frame is selected show its registers instead those of the top
frame. * Some cleanup in ThreadListView. * Unregister view listeners in the window destructor. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31147 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -135,6 +135,11 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StackFrame* FrameAt(int32 index) const
|
||||||
|
{
|
||||||
|
return fStackTrace != NULL ? fStackTrace->FrameAt(index) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StackTrace* fStackTrace;
|
StackTrace* fStackTrace;
|
||||||
};
|
};
|
||||||
@@ -143,11 +148,12 @@ private:
|
|||||||
// #pragma mark - StackTraceView
|
// #pragma mark - StackTraceView
|
||||||
|
|
||||||
|
|
||||||
StackTraceView::StackTraceView()
|
StackTraceView::StackTraceView(Listener* listener)
|
||||||
:
|
:
|
||||||
BGroupView(B_VERTICAL),
|
BGroupView(B_VERTICAL),
|
||||||
fFramesTable(NULL),
|
fFramesTable(NULL),
|
||||||
fFramesTableModel(NULL)
|
fFramesTableModel(NULL),
|
||||||
|
fListener(listener)
|
||||||
{
|
{
|
||||||
SetName("Stack Trace");
|
SetName("Stack Trace");
|
||||||
}
|
}
|
||||||
@@ -162,9 +168,9 @@ StackTraceView::~StackTraceView()
|
|||||||
|
|
||||||
|
|
||||||
/*static*/ StackTraceView*
|
/*static*/ StackTraceView*
|
||||||
StackTraceView::Create()
|
StackTraceView::Create(Listener* listener)
|
||||||
{
|
{
|
||||||
StackTraceView* self = new StackTraceView();
|
StackTraceView* self = new StackTraceView(listener);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
self->_Init();
|
self->_Init();
|
||||||
@@ -177,6 +183,13 @@ StackTraceView::Create()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
StackTraceView::UnsetListener()
|
||||||
|
{
|
||||||
|
fListener = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StackTraceView::SetStackTrace(StackTrace* stackTrace)
|
StackTraceView::SetStackTrace(StackTrace* stackTrace)
|
||||||
{
|
{
|
||||||
@@ -195,6 +208,19 @@ StackTraceView::SetStackTrace(StackTrace* stackTrace)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
StackTraceView::TableSelectionChanged(Table* table)
|
||||||
|
{
|
||||||
|
if (fListener == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
StackFrame* frame
|
||||||
|
= fFramesTableModel->FrameAt(table->SelectionModel()->RowAt(0));
|
||||||
|
|
||||||
|
fListener->StackFrameSelectionChanged(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StackTraceView::TableRowInvoked(Table* table, int32 rowIndex)
|
StackTraceView::TableRowInvoked(Table* table, int32 rowIndex)
|
||||||
{
|
{
|
||||||
@@ -213,11 +239,20 @@ StackTraceView::_Init()
|
|||||||
1000, B_TRUNCATE_END, B_ALIGN_RIGHT));
|
1000, B_TRUNCATE_END, B_ALIGN_RIGHT));
|
||||||
fFramesTable->AddColumn(new TargetAddressValueColumn(1, "IP", 80, 40, 1000,
|
fFramesTable->AddColumn(new TargetAddressValueColumn(1, "IP", 80, 40, 1000,
|
||||||
B_TRUNCATE_END, B_ALIGN_RIGHT));
|
B_TRUNCATE_END, B_ALIGN_RIGHT));
|
||||||
fFramesTable->AddColumn(new StringTableColumn(2, "Function", 80, 40, 1000,
|
fFramesTable->AddColumn(new StringTableColumn(2, "Function", 300, 100, 1000,
|
||||||
B_TRUNCATE_END, B_ALIGN_LEFT));
|
B_TRUNCATE_END, B_ALIGN_LEFT));
|
||||||
|
|
||||||
fFramesTableModel = new FramesTableModel();
|
fFramesTableModel = new FramesTableModel();
|
||||||
fFramesTable->SetTableModel(fFramesTableModel);
|
fFramesTable->SetTableModel(fFramesTableModel);
|
||||||
|
|
||||||
|
fFramesTable->SetSelectionMode(B_SINGLE_SELECTION_LIST);
|
||||||
fFramesTable->AddTableListener(this);
|
fFramesTable->AddTableListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - Listener
|
||||||
|
|
||||||
|
|
||||||
|
StackTraceView::Listener::~Listener()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,14 +11,22 @@
|
|||||||
#include "Team.h"
|
#include "Team.h"
|
||||||
|
|
||||||
|
|
||||||
|
class StackFrame;
|
||||||
|
|
||||||
|
|
||||||
class StackTraceView : public BGroupView, private TableListener {
|
class StackTraceView : public BGroupView, private TableListener {
|
||||||
public:
|
public:
|
||||||
StackTraceView();
|
class Listener;
|
||||||
|
|
||||||
|
public:
|
||||||
|
StackTraceView(Listener* listener);
|
||||||
~StackTraceView();
|
~StackTraceView();
|
||||||
|
|
||||||
static StackTraceView* Create();
|
static StackTraceView* Create(Listener* listener);
|
||||||
// throws
|
// throws
|
||||||
|
|
||||||
|
void UnsetListener();
|
||||||
|
|
||||||
void SetStackTrace(StackTrace* stackTrace);
|
void SetStackTrace(StackTrace* stackTrace);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -26,6 +34,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// TableListener
|
// TableListener
|
||||||
|
virtual void TableSelectionChanged(Table* table);
|
||||||
virtual void TableRowInvoked(Table* table, int32 rowIndex);
|
virtual void TableRowInvoked(Table* table, int32 rowIndex);
|
||||||
|
|
||||||
void _Init();
|
void _Init();
|
||||||
@@ -34,6 +43,16 @@ private:
|
|||||||
StackTrace* fStackTrace;
|
StackTrace* fStackTrace;
|
||||||
Table* fFramesTable;
|
Table* fFramesTable;
|
||||||
FramesTableModel* fFramesTableModel;
|
FramesTableModel* fFramesTableModel;
|
||||||
|
Listener* fListener;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class StackTraceView::Listener {
|
||||||
|
public:
|
||||||
|
virtual ~Listener();
|
||||||
|
|
||||||
|
virtual void StackFrameSelectionChanged(
|
||||||
|
StackFrame* frame) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ TeamWindow::TeamWindow(TeamDebugModel* debugModel, Listener* listener)
|
|||||||
B_ASYNCHRONOUS_CONTROLS),
|
B_ASYNCHRONOUS_CONTROLS),
|
||||||
fDebugModel(debugModel),
|
fDebugModel(debugModel),
|
||||||
fActiveThread(NULL),
|
fActiveThread(NULL),
|
||||||
|
fActiveStackFrame(NULL),
|
||||||
fListener(listener),
|
fListener(listener),
|
||||||
fTabView(NULL),
|
fTabView(NULL),
|
||||||
fLocalsTabView(NULL),
|
fLocalsTabView(NULL),
|
||||||
@@ -58,6 +59,11 @@ TeamWindow::TeamWindow(TeamDebugModel* debugModel, Listener* listener)
|
|||||||
|
|
||||||
TeamWindow::~TeamWindow()
|
TeamWindow::~TeamWindow()
|
||||||
{
|
{
|
||||||
|
if (fThreadListView != NULL)
|
||||||
|
fThreadListView->UnsetListener();
|
||||||
|
if (fStackTraceView != NULL)
|
||||||
|
fStackTraceView->UnsetListener();
|
||||||
|
|
||||||
fDebugModel->GetTeam()->RemoveListener(this);
|
fDebugModel->GetTeam()->RemoveListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +149,13 @@ TeamWindow::ThreadSelectionChanged(::Thread* thread)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TeamWindow::StackFrameSelectionChanged(StackFrame* frame)
|
||||||
|
{
|
||||||
|
_SetActiveStackFrame(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TeamWindow::ThreadStateChanged(const Team::ThreadEvent& event)
|
TeamWindow::ThreadStateChanged(const Team::ThreadEvent& event)
|
||||||
{
|
{
|
||||||
@@ -197,7 +210,7 @@ TeamWindow::_Init()
|
|||||||
fTabView->AddTab(threadGroup);
|
fTabView->AddTab(threadGroup);
|
||||||
BLayoutBuilder::Split<>(threadGroup)
|
BLayoutBuilder::Split<>(threadGroup)
|
||||||
.Add(fThreadListView = ThreadListView::Create(this))
|
.Add(fThreadListView = ThreadListView::Create(this))
|
||||||
.Add(fStackTraceView = StackTraceView::Create());
|
.Add(fStackTraceView = StackTraceView::Create(this));
|
||||||
|
|
||||||
// add images tab
|
// add images tab
|
||||||
BSplitView* imagesGroup = new BSplitView(B_HORIZONTAL);
|
BSplitView* imagesGroup = new BSplitView(B_HORIZONTAL);
|
||||||
@@ -243,11 +256,6 @@ TeamWindow::_SetActiveThread(::Thread* thread)
|
|||||||
AutoLocker<TeamDebugModel> locker(fDebugModel);
|
AutoLocker<TeamDebugModel> locker(fDebugModel);
|
||||||
_UpdateRunButtons();
|
_UpdateRunButtons();
|
||||||
|
|
||||||
CpuState* cpuState = fActiveThread != NULL
|
|
||||||
? fActiveThread->GetCpuState() : NULL;
|
|
||||||
Reference<CpuState> cpuStateReference(cpuState);
|
|
||||||
// hold a reference until the register view has one
|
|
||||||
|
|
||||||
StackTrace* stackTrace = fActiveThread != NULL
|
StackTrace* stackTrace = fActiveThread != NULL
|
||||||
? fActiveThread->GetStackTrace() : NULL;
|
? fActiveThread->GetStackTrace() : NULL;
|
||||||
Reference<StackTrace> stackTraceReference(stackTrace);
|
Reference<StackTrace> stackTraceReference(stackTrace);
|
||||||
@@ -255,8 +263,49 @@ TeamWindow::_SetActiveThread(::Thread* thread)
|
|||||||
|
|
||||||
locker.Unlock();
|
locker.Unlock();
|
||||||
|
|
||||||
fRegisterView->SetCpuState(cpuState);
|
|
||||||
fStackTraceView->SetStackTrace(stackTrace);
|
fStackTraceView->SetStackTrace(stackTrace);
|
||||||
|
_UpdateCpuState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TeamWindow::_SetActiveStackFrame(StackFrame* frame)
|
||||||
|
{
|
||||||
|
if (frame == fActiveStackFrame)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fActiveStackFrame != NULL)
|
||||||
|
fActiveStackFrame->RemoveReference();
|
||||||
|
|
||||||
|
fActiveStackFrame = frame;
|
||||||
|
|
||||||
|
if (fActiveStackFrame != NULL)
|
||||||
|
fActiveStackFrame->AddReference();
|
||||||
|
|
||||||
|
_UpdateCpuState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TeamWindow::_UpdateCpuState()
|
||||||
|
{
|
||||||
|
// get the CPU state
|
||||||
|
CpuState* cpuState = NULL;
|
||||||
|
Reference<CpuState> cpuStateReference;
|
||||||
|
// hold a reference until the register view has one
|
||||||
|
|
||||||
|
if (fActiveThread != NULL) {
|
||||||
|
// Get the CPU state from the active stack frame or the thread directly.
|
||||||
|
if (fActiveStackFrame == NULL) {
|
||||||
|
AutoLocker<TeamDebugModel> locker(fDebugModel);
|
||||||
|
cpuState = fActiveThread->GetCpuState();
|
||||||
|
cpuStateReference.SetTo(cpuState);
|
||||||
|
locker.Unlock();
|
||||||
|
} else
|
||||||
|
cpuState = fActiveStackFrame->GetCpuState();
|
||||||
|
}
|
||||||
|
|
||||||
|
fRegisterView->SetCpuState(cpuState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -312,16 +361,7 @@ TeamWindow::_HandleCpuStateChanged(thread_id threadID)
|
|||||||
if (fActiveThread == NULL || threadID != fActiveThread->ID())
|
if (fActiveThread == NULL || threadID != fActiveThread->ID())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AutoLocker<TeamDebugModel> locker(fDebugModel);
|
_UpdateCpuState();
|
||||||
|
|
||||||
CpuState* cpuState = fActiveThread != NULL
|
|
||||||
? fActiveThread->GetCpuState() : NULL;
|
|
||||||
Reference<CpuState> reference(cpuState);
|
|
||||||
// hold a reference until the register view has one
|
|
||||||
|
|
||||||
locker.Unlock();
|
|
||||||
|
|
||||||
fRegisterView->SetCpuState(cpuState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
#include "StackTraceView.h"
|
||||||
#include "Team.h"
|
#include "Team.h"
|
||||||
#include "ThreadListView.h"
|
#include "ThreadListView.h"
|
||||||
|
|
||||||
@@ -16,12 +17,11 @@ class BButton;
|
|||||||
class BTabView;
|
class BTabView;
|
||||||
class ImageListView;
|
class ImageListView;
|
||||||
class RegisterView;
|
class RegisterView;
|
||||||
class StackTraceView;
|
|
||||||
class TeamDebugModel;
|
class TeamDebugModel;
|
||||||
|
|
||||||
|
|
||||||
class TeamWindow : public BWindow, private ThreadListView::Listener,
|
class TeamWindow : public BWindow, private ThreadListView::Listener,
|
||||||
Team::Listener {
|
StackTraceView::Listener, Team::Listener {
|
||||||
public:
|
public:
|
||||||
class Listener;
|
class Listener;
|
||||||
|
|
||||||
@@ -41,6 +41,9 @@ private:
|
|||||||
// ThreadListView::Listener
|
// ThreadListView::Listener
|
||||||
virtual void ThreadSelectionChanged(::Thread* thread);
|
virtual void ThreadSelectionChanged(::Thread* thread);
|
||||||
|
|
||||||
|
// StackTraceView::Listener
|
||||||
|
virtual void StackFrameSelectionChanged(StackFrame* frame);
|
||||||
|
|
||||||
// Team::Listener
|
// Team::Listener
|
||||||
virtual void ThreadStateChanged(
|
virtual void ThreadStateChanged(
|
||||||
const Team::ThreadEvent& event);
|
const Team::ThreadEvent& event);
|
||||||
@@ -52,6 +55,8 @@ private:
|
|||||||
void _Init();
|
void _Init();
|
||||||
|
|
||||||
void _SetActiveThread(::Thread* thread);
|
void _SetActiveThread(::Thread* thread);
|
||||||
|
void _SetActiveStackFrame(StackFrame* frame);
|
||||||
|
void _UpdateCpuState();
|
||||||
void _UpdateRunButtons();
|
void _UpdateRunButtons();
|
||||||
|
|
||||||
void _HandleThreadStateChanged(thread_id threadID);
|
void _HandleThreadStateChanged(thread_id threadID);
|
||||||
@@ -61,6 +66,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
TeamDebugModel* fDebugModel;
|
TeamDebugModel* fDebugModel;
|
||||||
::Thread* fActiveThread;
|
::Thread* fActiveThread;
|
||||||
|
StackFrame* fActiveStackFrame;
|
||||||
Listener* fListener;
|
Listener* fListener;
|
||||||
BTabView* fTabView;
|
BTabView* fTabView;
|
||||||
BTabView* fLocalsTabView;
|
BTabView* fLocalsTabView;
|
||||||
|
|||||||
@@ -165,6 +165,13 @@ ThreadListView::Create(Listener* listener)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ThreadListView::UnsetListener()
|
||||||
|
{
|
||||||
|
fListener = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ThreadListView::SetTeam(Team* team)
|
ThreadListView::SetTeam(Team* team)
|
||||||
{
|
{
|
||||||
@@ -222,6 +229,9 @@ ThreadListView::ThreadRemoved(const Team::ThreadEvent& event)
|
|||||||
void
|
void
|
||||||
ThreadListView::TableSelectionChanged(Table* table)
|
ThreadListView::TableSelectionChanged(Table* table)
|
||||||
{
|
{
|
||||||
|
if (fListener == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
Thread* thread = NULL;
|
Thread* thread = NULL;
|
||||||
if (fThreadsTableModel != NULL) {
|
if (fThreadsTableModel != NULL) {
|
||||||
TableSelectionModel* selectionModel = table->SelectionModel();
|
TableSelectionModel* selectionModel = table->SelectionModel();
|
||||||
@@ -232,17 +242,6 @@ ThreadListView::TableSelectionChanged(Table* table)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ThreadListView::TableRowInvoked(Table* table, int32 rowIndex)
|
|
||||||
{
|
|
||||||
// if (fThreadsTableModel != NULL) {
|
|
||||||
// Thread* thread = fThreadsTableModel->ThreadAt(rowIndex);
|
|
||||||
// if (thread != NULL)
|
|
||||||
// fParent->OpenThreadWindow(thread);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ThreadListView::_Init()
|
ThreadListView::_Init()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ public:
|
|||||||
static ThreadListView* Create(Listener* listener);
|
static ThreadListView* Create(Listener* listener);
|
||||||
// throws
|
// throws
|
||||||
|
|
||||||
|
void UnsetListener();
|
||||||
|
|
||||||
void SetTeam(Team* team);
|
void SetTeam(Team* team);
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
@@ -40,7 +42,6 @@ private:
|
|||||||
|
|
||||||
// TableListener
|
// TableListener
|
||||||
virtual void TableSelectionChanged(Table* table);
|
virtual void TableSelectionChanged(Table* table);
|
||||||
virtual void TableRowInvoked(Table* table, int32 rowIndex);
|
|
||||||
|
|
||||||
void _Init();
|
void _Init();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user