From 7f9c6739815508d8473701fc51add7550c816d1d Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 15 Jul 2005 12:18:33 +0000 Subject: [PATCH] * Introduced a new debugger message B_DEBUGGER_MESSAGE_HANDED_OVER, which is sent to a debugger when the debugged team has been successfully handed over to another debugger. * Fixed handling of B_DEBUG_MESSAGE_PREPARE_HANDOVER. We don't send a reply. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13683 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/kernel/debugger.h | 17 ++++++++++--- src/system/kernel/debug/user_debugger.cpp | 29 +++++++++++++++++------ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/headers/os/kernel/debugger.h b/headers/os/kernel/debugger.h index ab9e4a69d2..d2a96841e2 100644 --- a/headers/os/kernel/debugger.h +++ b/headers/os/kernel/debugger.h @@ -153,6 +153,9 @@ typedef enum { 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 + + B_DEBUGGER_MESSAGE_HANDED_OVER, // the debugged team has been + // handed over to another debugger } debug_debugger_message; @@ -327,9 +330,7 @@ typedef struct { // B_DEBUG_MESSAGE_PREPARE_HANDOVER -typedef struct { - status_t error; // B_OK, if the everything went fine -} debug_nub_prepare_handover_reply; +// no parameters, no reply // union of all messages structures sent to the debug nub thread typedef union { @@ -480,6 +481,15 @@ typedef struct { image_info info; // info for the image } debug_image_deleted; +// B_DEBUGGER_MESSAGE_HANDED_OVER + +typedef struct { + debug_origin origin; // thread is < 0, team is the deleted team + // (asynchronous message) + team_id debugger; // the new debugger + port_id debugger_port; // the port the new debugger uses +} debug_handed_over; + // union of all messages structures sent to the debugger typedef union { debug_thread_debugged thread_debugged; @@ -497,6 +507,7 @@ typedef union { debug_thread_deleted thread_deleted; debug_image_created image_created; debug_image_deleted image_deleted; + debug_handed_over handed_over; debug_origin origin; // for convenience (no real message) } debug_debugger_message_data; diff --git a/src/system/kernel/debug/user_debugger.cpp b/src/system/kernel/debug/user_debugger.cpp index 572e930d31..3cd24705b0 100644 --- a/src/system/kernel/debug/user_debugger.cpp +++ b/src/system/kernel/debug/user_debugger.cpp @@ -1214,7 +1214,6 @@ debug_nub_thread(void *) debug_nub_set_watchpoint_reply set_watchpoint; debug_nub_get_signal_masks_reply get_signal_masks; debug_nub_get_signal_handler_reply get_signal_handler; - debug_nub_prepare_handover_reply prepare_handover; } reply; int32 replySize = 0; port_id replyPort = -1; @@ -1731,14 +1730,9 @@ debug_nub_thread(void *) release_sem(writeLock); } else { // We probably got a SIGKILL. If so, we will terminate when - // sending the reply fails. + // reading the next message fails. } - // prepare the reply - reply.prepare_handover.error = result; - replySize = sizeof(reply.prepare_handover); - sendReply = true; - break; } @@ -1760,6 +1754,9 @@ debug_nub_thread(void *) if (error != B_OK) { // The debugger port is either not longer existing or we got // interrupted by a kill signal. In either case we terminate. + TRACE(("nub thread %ld: failed to send reply to port %ld: %s\n", + nubThread->id, replyPort, strerror(error))); + nub_thread_cleanup(nubThread); return error; } @@ -1843,6 +1840,7 @@ install_team_debugger(team_id teamID, port_id debuggerPort, bool useDefault, bool done = false; port_id result = B_ERROR; bool handOver = false; + port_id oldDebuggerPort = -1; port_id nubPort = -1; cpu_status state = disable_interrupts(); @@ -1871,6 +1869,7 @@ install_team_debugger(team_id teamID, port_id debuggerPort, bool useDefault, atomic_and(& team->debug_info.flags, ~B_TEAM_DEBUG_DEBUGGER_HANDOVER); + oldDebuggerPort = team->debug_info.debugger_port; result = nubPort = team->debug_info.nub_port; // set the new debugger @@ -1902,6 +1901,22 @@ install_team_debugger(team_id teamID, port_id debuggerPort, bool useDefault, kill_interruptable_write_port(nubPort, B_DEBUG_MESSAGE_HANDED_OVER, NULL, 0); + // notify the old debugger + debug_handed_over notification; + notification.origin.thread = -1; + notification.origin.team = teamID; + notification.origin.nub_port = nubPort; + notification.debugger = debuggerTeam; + notification.debugger_port = debuggerPort; + + error = write_port_etc(oldDebuggerPort, + B_DEBUGGER_MESSAGE_HANDED_OVER, ¬ification, + sizeof(notification), B_RELATIVE_TIMEOUT, 0); + if (error != B_OK) { + TRACE(("install_team_debugger(): Failed to send message to old " + "debugger: %s\n", strerror(error))); + } + TRACE(("install_team_debugger() done: handed over to debugger: team: " "%ld, port: %ld\n", debuggerTeam, debuggerPort));