[haiku-commits] r39846 - in haiku/trunk: headers/os/kernel headers/private/debug headers/private/kernel src/kits/debug src/system/kernel ...

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 14 Dec 2010 06:08:49 +0100 (CET)

Author: anevilyak
Date: 2010-12-14 06:08:47 +0100 (Tue, 14 Dec 2010)
New Revision: 39846
Changeset: http://dev.haiku-os.org/changeset/39846

Modified:
   haiku/trunk/headers/os/kernel/debugger.h
   haiku/trunk/headers/private/debug/DebugMessageHandler.h
   haiku/trunk/headers/private/kernel/user_debugger.h
   haiku/trunk/src/kits/debug/DebugMessageHandler.cpp
   haiku/trunk/src/system/kernel/debug/user_debugger.cpp
   haiku/trunk/src/system/kernel/thread.cpp
Log:
Add support for thread rename and priority change notifications to the
debugger API/message set.



Modified: haiku/trunk/headers/os/kernel/debugger.h
===================================================================
--- haiku/trunk/headers/os/kernel/debugger.h    2010-12-13 23:44:02 UTC (rev 
39845)
+++ haiku/trunk/headers/os/kernel/debugger.h    2010-12-14 05:08:47 UTC (rev 
39846)
@@ -180,6 +180,8 @@
        B_DEBUGGER_MESSAGE_TEAM_DELETED,                // the debugged team is 
gone
        B_DEBUGGER_MESSAGE_TEAM_EXEC,                   // the debugged team 
executes exec()
        B_DEBUGGER_MESSAGE_THREAD_CREATED,              // a thread has been 
created
+       B_DEBUGGER_MESSAGE_THREAD_RENAMED,              // a thread has been 
renamed
+       B_DEBUGGER_MESSAGE_THREAD_PRIORITY_CHANGED,     // a thread has had its 
priority altered
        B_DEBUGGER_MESSAGE_THREAD_DELETED,              // a thread has been 
deleted
        B_DEBUGGER_MESSAGE_IMAGE_CREATED,               // an image has been 
created
        B_DEBUGGER_MESSAGE_IMAGE_DELETED,               // an image has been 
deleted
@@ -545,9 +547,25 @@
 
 typedef struct {
        debug_origin    origin;                 // the thread that created the 
new thread
-       team_id                 new_thread;             // the newly created 
thread
+       thread_id               new_thread;             // the newly created 
thread
 } debug_thread_created;
 
+// B_DEBUGGER_MESSAGE_THREAD_RENAMED
+
+typedef struct {
+       debug_origin    origin;
+       thread_id               renamed_thread; // the thread whose name has 
changed
+       char                    name[B_OS_NAME_LENGTH];
+} debug_thread_renamed;
+
+// B_DEBUGGER_MESSAGE_THREAD_PRIORITY_CHANGED
+
+typedef struct {
+       debug_origin    origin;
+       thread_id               changed_thread; // the thread whose priority 
has changed
+       int32                   new_priority;   // the new priority
+} debug_thread_priority_changed;
+
 // B_DEBUGGER_MESSAGE_THREAD_DELETED
 
 typedef struct {
@@ -619,6 +637,8 @@
        debug_team_deleted                              team_deleted;
        debug_team_exec                                 team_exec;
        debug_thread_created                    thread_created;
+       debug_thread_renamed                    thread_renamed;
+       debug_thread_priority_changed   thread_priority_changed;
        debug_thread_deleted                    thread_deleted;
        debug_image_created                             image_created;
        debug_image_deleted                             image_deleted;

Modified: haiku/trunk/headers/private/debug/DebugMessageHandler.h
===================================================================
--- haiku/trunk/headers/private/debug/DebugMessageHandler.h     2010-12-13 
23:44:02 UTC (rev 39845)
+++ haiku/trunk/headers/private/debug/DebugMessageHandler.h     2010-12-14 
05:08:47 UTC (rev 39846)
@@ -42,6 +42,11 @@
                                                                        const 
debug_team_exec& message);
        virtual bool                            HandleThreadCreated(
                                                                        const 
debug_thread_created& message);
+       virtual bool                            HandleThreadRenamed(
+                                                                       const 
debug_thread_renamed& message);
+       virtual bool                            HandleThreadPriorityChanged(
+                                                                       const 
debug_thread_priority_changed&
+                                                                               
message);
        virtual bool                            HandleThreadDeleted(
                                                                        const 
debug_thread_deleted& message);
        virtual bool                            HandleImageCreated(

Modified: haiku/trunk/headers/private/kernel/user_debugger.h
===================================================================
--- haiku/trunk/headers/private/kernel/user_debugger.h  2010-12-13 23:44:02 UTC 
(rev 39845)
+++ haiku/trunk/headers/private/kernel/user_debugger.h  2010-12-14 05:08:47 UTC 
(rev 39846)
@@ -234,6 +234,8 @@
 void user_debug_team_exec();
 void user_debug_update_new_thread_flags(thread_id threadID);
 void user_debug_thread_created(thread_id threadID);
+void user_debug_thread_renamed(thread_id threadID, const char* name);
+void user_debug_thread_priority_changed(thread_id threadID, int32 priority);
 void user_debug_thread_deleted(team_id teamID, thread_id threadID);
 void user_debug_thread_exiting(struct thread* thread);
 void user_debug_image_created(const image_info *imageInfo);

Modified: haiku/trunk/src/kits/debug/DebugMessageHandler.cpp
===================================================================
--- haiku/trunk/src/kits/debug/DebugMessageHandler.cpp  2010-12-13 23:44:02 UTC 
(rev 39845)
+++ haiku/trunk/src/kits/debug/DebugMessageHandler.cpp  2010-12-14 05:08:47 UTC 
(rev 39846)
@@ -54,6 +54,8 @@
                        return HandleThreadCreated(message.thread_created);
                case B_DEBUGGER_MESSAGE_THREAD_DELETED:
                        return HandleThreadDeleted(message.thread_deleted);
+               case B_DEBUGGER_MESSAGE_THREAD_RENAMED:
+                       return HandleThreadRenamed(message.thread_renamed);
                case B_DEBUGGER_MESSAGE_IMAGE_CREATED:
                        return HandleImageCreated(message.image_created);
                case B_DEBUGGER_MESSAGE_IMAGE_DELETED:
@@ -174,6 +176,23 @@
 
 
 bool
+BDebugMessageHandler::HandleThreadRenamed(const debug_thread_renamed& message)
+{
+       return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_THREAD_RENAMED,
+               (const debug_debugger_message_data&)message);
+}
+
+
+bool
+BDebugMessageHandler::HandleThreadPriorityChanged(
+       const debug_thread_priority_changed& message)
+{
+       return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_THREAD_PRIORITY_CHANGED,
+               (const debug_debugger_message_data&)message);
+}
+
+
+bool
 BDebugMessageHandler::HandleThreadDeleted(const debug_thread_deleted& message)
 {
        return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_THREAD_DELETED,

Modified: haiku/trunk/src/system/kernel/debug/user_debugger.cpp
===================================================================
--- haiku/trunk/src/system/kernel/debug/user_debugger.cpp       2010-12-13 
23:44:02 UTC (rev 39845)
+++ haiku/trunk/src/system/kernel/debug/user_debugger.cpp       2010-12-14 
05:08:47 UTC (rev 39846)
@@ -1078,6 +1078,48 @@
 
 
 void
+user_debug_thread_renamed(thread_id threadID, const char *name)
+{
+       // check, if a debugger is installed and is interested in thread events
+       struct thread *thread = thread_get_current_thread();
+       int32 teamDebugFlags = atomic_get(&thread->team->debug_info.flags);
+       if (~teamDebugFlags
+               & (B_TEAM_DEBUG_DEBUGGER_INSTALLED | B_TEAM_DEBUG_THREADS)) {
+               return;
+       }
+
+       // prepare the message
+       debug_thread_renamed message;
+       message.renamed_thread = threadID;
+       strlcpy(message.name, name, sizeof(message.name));
+
+       thread_hit_debug_event(B_DEBUGGER_MESSAGE_THREAD_RENAMED, &message,
+               sizeof(message), true);
+}
+
+
+void
+user_debug_thread_priority_changed(thread_id threadID, int32 priority)
+{
+       // check, if a debugger is installed and is interested in thread events
+       struct thread *thread = thread_get_current_thread();
+       int32 teamDebugFlags = atomic_get(&thread->team->debug_info.flags);
+       if (~teamDebugFlags
+               & (B_TEAM_DEBUG_DEBUGGER_INSTALLED | B_TEAM_DEBUG_THREADS)) {
+               return;
+       }
+
+       // prepare the message
+       debug_thread_priority_changed message;
+       message.changed_thread = threadID;
+       message.new_priority = priority;
+
+       thread_hit_debug_event(B_DEBUGGER_MESSAGE_THREAD_PRIORITY_CHANGED, 
&message,
+               sizeof(message), true);
+}
+
+
+void
 user_debug_thread_deleted(team_id teamID, thread_id threadID)
 {
        // Things are a bit complicated here, since this thread no longer 
belongs to

Modified: haiku/trunk/src/system/kernel/thread.cpp
===================================================================
--- haiku/trunk/src/system/kernel/thread.cpp    2010-12-13 23:44:02 UTC (rev 
39845)
+++ haiku/trunk/src/system/kernel/thread.cpp    2010-12-14 05:08:47 UTC (rev 
39846)
@@ -2559,6 +2559,9 @@
        RELEASE_THREAD_LOCK();
        restore_interrupts(state);
 
+       if (status == B_OK)
+               user_debug_thread_renamed(id, name);
+
        return status;
 }
 
@@ -2601,6 +2604,8 @@
                scheduler_set_thread_priority(thread, priority);
        }
 
+       user_debug_thread_priority_changed(id, priority);
+
        return oldPriority;
 }
 


Other related posts: