Implement support for catching rename and thread priority change events.

This lets us keep up to date with thread names, which makes, for example
Tracker a bit more tolerable to debug since it employs thread renaming
to set the names of its windows.

Implements #4430.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39847 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2010-12-14 05:11:21 +00:00
parent 7040b50df5
commit 8fb7eb8b17
5 changed files with 113 additions and 0 deletions

View File

@ -884,6 +884,25 @@ TeamDebugger::_HandleDebuggerMessage(DebugEvent* event)
handled = _HandleThreadCreated(threadEvent);
break;
}
case B_DEBUGGER_MESSAGE_THREAD_RENAMED:
{
ThreadRenamedEvent* threadEvent
= dynamic_cast<ThreadRenamedEvent*>(event);
TRACE_EVENTS("B_DEBUGGER_MESSAGE_THREAD_RENAMED: thread: %ld "
"(\"%s\")\n",
threadEvent->RenamedThread(), threadEvent->NewName());
handled = _HandleThreadRenamed(threadEvent);
break;
}
case B_DEBUGGER_MESSAGE_THREAD_PRIORITY_CHANGED:
{
ThreadPriorityChangedEvent* threadEvent
= dynamic_cast<ThreadPriorityChangedEvent*>(event);
TRACE_EVENTS("B_DEBUGGER_MESSAGE_THREAD_PRIORITY_CHANGED: thread:"
" %ld\n", threadEvent->ChangedThread());
handled = _HandleThreadPriorityChanged(threadEvent);
break;
}
case B_DEBUGGER_MESSAGE_THREAD_DELETED:
TRACE_EVENTS("B_DEBUGGER_MESSAGE_THREAD_DELETED: thread: %ld\n",
event->Thread());
@ -953,6 +972,29 @@ TeamDebugger::_HandleThreadCreated(ThreadCreatedEvent* event)
}
bool
TeamDebugger::_HandleThreadRenamed(ThreadRenamedEvent* event)
{
AutoLocker< ::Team> locker(fTeam);
::Thread* thread = fTeam->ThreadByID(event->RenamedThread());
if (thread != NULL)
thread->SetName(event->NewName());
return false;
}
bool
TeamDebugger::_HandleThreadPriorityChanged(ThreadPriorityChangedEvent*)
{
// TODO: implement once we actually track thread priorities
return false;
}
bool
TeamDebugger::_HandleThreadDeleted(ThreadDeletedEvent* event)
{

View File

@ -95,6 +95,10 @@ private:
bool _HandleThreadCreated(
ThreadCreatedEvent* event);
bool _HandleThreadRenamed(
ThreadRenamedEvent* event);
bool _HandleThreadPriorityChanged(
ThreadPriorityChangedEvent* event);
bool _HandleThreadDeleted(
ThreadDeletedEvent* event);
bool _HandleImageCreated(

View File

@ -155,6 +155,32 @@ ThreadCreatedEvent::ThreadCreatedEvent(team_id team, thread_id thread,
}
// #pragma mark - ThreadRenamedEvent
ThreadRenamedEvent::ThreadRenamedEvent(team_id team, thread_id thread,
thread_id renamedThread, const char* newName)
:
DebugEvent(B_DEBUGGER_MESSAGE_THREAD_RENAMED, team, thread),
fRenamedThread(renamedThread)
{
strlcpy(fName, newName, sizeof(fName));
}
// #pragma mark - ThreadPriorityChangedEvent
ThreadPriorityChangedEvent::ThreadPriorityChangedEvent(team_id team,
thread_id thread, thread_id changedThread, int32 newPriority)
:
DebugEvent(B_DEBUGGER_MESSAGE_THREAD_PRIORITY_CHANGED, team, thread),
fChangedThread(changedThread),
fNewPriority(newPriority)
{
}
// #pragma mark - ThreadDeletedEvent

View File

@ -127,6 +127,36 @@ private:
};
class ThreadRenamedEvent : public DebugEvent {
public:
ThreadRenamedEvent(team_id team,
thread_id thread, thread_id renamedThread,
const char* name);
thread_id RenamedThread() const { return fRenamedThread; }
const char* NewName() const { return fName; }
private:
thread_id fRenamedThread;
char fName[B_OS_NAME_LENGTH];
};
class ThreadPriorityChangedEvent : public DebugEvent {
public:
ThreadPriorityChangedEvent(team_id team,
thread_id thread, thread_id changedThread,
int32 newPriority);
thread_id ChangedThread() const { return fChangedThread; }
int32 NewPriority() const { return fNewPriority; }
private:
thread_id fChangedThread;
int32 fNewPriority;
};
class ThreadDeletedEvent : public DebugEvent {
public:
ThreadDeletedEvent(team_id team,

View File

@ -670,6 +670,17 @@ DebuggerInterface::_CreateDebugEvent(int32 messageCode,
event = new(std::nothrow) ThreadCreatedEvent(message.origin.team,
message.origin.thread, message.thread_created.new_thread);
break;
case B_DEBUGGER_MESSAGE_THREAD_RENAMED:
event = new(std::nothrow) ThreadRenamedEvent(message.origin.team,
message.origin.thread, message.thread_renamed.renamed_thread,
message.thread_renamed.name);
break;
case B_DEBUGGER_MESSAGE_THREAD_PRIORITY_CHANGED:
event = new(std::nothrow) ThreadPriorityChangedEvent(
message.origin.team, message.origin.thread,
message.thread_priority_changed.changed_thread,
message.thread_priority_changed.new_priority);
break;
case B_DEBUGGER_MESSAGE_THREAD_DELETED:
event = new(std::nothrow) ThreadDeletedEvent(message.origin.team,
message.origin.thread);