Skip to content

Commit

Permalink
Debugger: Add rename event for Team.
Browse files Browse the repository at this point in the history
Team:
- Add listener hook and event type for rename events. These occur on exec()
  since at this point we're running a different executable.

TeamWindow:
- Factor out code for generating window title into a helper, and use from both
  window initialization and newly implemented rename listener hook.
  • Loading branch information
anevilyak committed Jul 26, 2015
1 parent 25c638c commit 754b42a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/apps/debugger/MessageCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum {
MSG_SET_CUSTOM_SIGNAL_DISPOSITION = 'scsd',
MSG_REMOVE_CUSTOM_SIGNAL_DISPOSITION = 'rcsd',

MSG_TEAM_RENAMED = 'tera',
MSG_THREAD_STATE_CHANGED = 'tsch',
MSG_THREAD_CPU_STATE_CHANGED = 'tcsc',
MSG_THREAD_STACK_TRACE_CHANGED = 'tstc',
Expand Down
17 changes: 17 additions & 0 deletions src/apps/debugger/model/Team.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void
Team::SetName(const BString& name)
{
fName = name;
_NotifyTeamRenamed();
}


Expand Down Expand Up @@ -862,6 +863,16 @@ Team::NotifyMemoryChanged(target_addr_t address, target_size_t size)
}


void
Team::_NotifyTeamRenamed()
{
for (ListenerList::Iterator it = fListeners.GetIterator();
Listener* listener = it.Next();) {
listener->TeamRenamed(Event(TEAM_EVENT_TEAM_RENAMED, this));
}
}


void
Team::_NotifyThreadAdded(Thread* thread)
{
Expand Down Expand Up @@ -1067,6 +1078,12 @@ Team::Listener::~Listener()
}


void
Team::Listener::TeamRenamed(const Team::Event& event)
{
}


void
Team::Listener::ThreadAdded(const Team::ThreadEvent& event)
{
Expand Down
6 changes: 6 additions & 0 deletions src/apps/debugger/model/Team.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

// team event types
enum {
TEAM_EVENT_TEAM_RENAMED,

TEAM_EVENT_THREAD_ADDED,
TEAM_EVENT_THREAD_REMOVED,
TEAM_EVENT_IMAGE_ADDED,
Expand Down Expand Up @@ -273,6 +275,7 @@ class Team {
typedef DoublyLinkedList<Listener> ListenerList;

private:
void _NotifyTeamRenamed();
void _NotifyThreadAdded(Thread* thread);
void _NotifyThreadRemoved(Thread* thread);
void _NotifyImageAdded(Image* image);
Expand Down Expand Up @@ -474,6 +477,9 @@ class Team::Listener : public DoublyLinkedListLinkImpl<Team::Listener> {
public:
virtual ~Listener();

virtual void TeamRenamed(
const Team::Event& event);

virtual void ThreadAdded(const Team::ThreadEvent& event);
virtual void ThreadRemoved(const Team::ThreadEvent& event);

Expand Down
31 changes: 25 additions & 6 deletions src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,7 @@ TeamWindow::TeamWindow(::Team* team, UserInterfaceListener* listener)
fFilePanel(NULL),
fActiveSourceWorker(-1)
{
fTeam->Lock();
BString name = fTeam->Name();
fTeam->Unlock();
if (fTeam->ID() >= 0)
name << " (" << fTeam->ID() << ")";
SetTitle(name.String());
_UpdateTitle();

fTeam->AddListener(this);
}
Expand Down Expand Up @@ -518,6 +513,11 @@ TeamWindow::MessageReceived(BMessage* message)
}
break;
}
case MSG_TEAM_RENAMED:
{
_UpdateTitle();
break;
}
case MSG_THREAD_STATE_CHANGED:
{
int32 threadID;
Expand Down Expand Up @@ -905,6 +905,13 @@ TeamWindow::ValueNodeWriteRequested(ValueNode* node, CpuState* state,
}


void
TeamWindow::TeamRenamed(const Team::Event& event)
{
PostMessage(MSG_TEAM_RENAMED);
}


void
TeamWindow::ThreadStateChanged(const Team::ThreadEvent& event)
{
Expand Down Expand Up @@ -1141,6 +1148,18 @@ TeamWindow::_Init()
}


void
TeamWindow::_UpdateTitle()
{
AutoLocker< ::Team> lock(fTeam);

BString name = fTeam->Name();
if (fTeam->ID() >= 0)
name << " (" << fTeam->ID() << ")";
SetTitle(name.String());
}


void
TeamWindow::_SetActiveThread(::Thread* thread)
{
Expand Down
2 changes: 2 additions & 0 deletions src/apps/debugger/user_interface/gui/team_window/TeamWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class TeamWindow : public BWindow, ThreadListView::Listener,
CpuState* state, Value* value);

// Team::Listener
virtual void TeamRenamed(const Team::Event& event);
virtual void ThreadStateChanged(
const Team::ThreadEvent& event);
virtual void ThreadCpuStateChanged(
Expand All @@ -157,6 +158,7 @@ class TeamWindow : public BWindow, ThreadListView::Listener,

void _Init();

void _UpdateTitle();
void _SetActiveThread(::Thread* thread);
void _SetActiveImage(Image* image);
void _SetActiveStackTrace(StackTrace* stackTrace);
Expand Down

0 comments on commit 754b42a

Please sign in to comment.