diff --git a/headers/os/kernel/debugger.h b/headers/os/kernel/debugger.h index c18429189e..5613a22db3 100644 --- a/headers/os/kernel/debugger.h +++ b/headers/os/kernel/debugger.h @@ -207,11 +207,16 @@ typedef enum { B_DEBUGGER_MESSAGE_IMAGE_DELETED, // an image has been deleted } debug_debugger_message; +// first member of all debugger messages -- not a message by itself +typedef struct { + thread_id thread; // the thread being the event origin + team_id team; // the thread's team +} debug_origin; + // B_DEBUGGER_MESSAGE_THREAD_STOPPED typedef struct { - thread_id thread; // the stopped thread - team_id team; // the thread's team + debug_origin origin; debug_why_stopped why; // reason for contacting debugger port_id nub_port; // port to debug nub for this team debug_cpu_state cpu_state; // cpu state @@ -221,29 +226,26 @@ typedef struct { // B_DEBUGGER_MESSAGE_PRE_SYSCALL typedef struct { - thread_id thread; // thread - team_id team; // the thread's team - uint32 syscall; // the syscall number - uint32 args[16]; // syscall arguments + debug_origin origin; + uint32 syscall; // the syscall number + uint32 args[16]; // syscall arguments } debug_pre_syscall; // B_DEBUGGER_MESSAGE_POST_SYSCALL typedef struct { - thread_id thread; // thread - team_id team; // the thread's team - bigtime_t start_time; // time of syscall start - bigtime_t end_time; // time of syscall completion - uint64 return_value; // the syscall's return value - uint32 syscall; // the syscall number - uint32 args[16]; // syscall arguments + debug_origin origin; + bigtime_t start_time; // time of syscall start + bigtime_t end_time; // time of syscall completion + uint64 return_value; // the syscall's return value + uint32 syscall; // the syscall number + uint32 args[16]; // syscall arguments } debug_post_syscall; // B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED typedef struct { - thread_id thread; // thread - team_id team; // the thread's team + debug_origin origin; int signal; // the signal struct sigaction handler; // the signal handler bool deadly; // true, if handling the signal will kill @@ -253,47 +255,42 @@ typedef struct { // B_DEBUGGER_MESSAGE_TEAM_CREATED typedef struct { - thread_id thread; // the thread responsible for creating the team - team_id team; // the thread's team - team_id new_team; // the newly created team + debug_origin origin; + team_id new_team; // the newly created team } debug_team_created; // B_DEBUGGER_MESSAGE_TEAM_DELETED typedef struct { - team_id team; // the team + debug_origin origin; // thread is < 0, team is the deleted team + // (asynchronous message) } debug_team_deleted; // B_DEBUGGER_MESSAGE_THREAD_CREATED typedef struct { - thread_id thread; // the thread responsible for creating the new - // thread - team_id team; // the thread's team - team_id new_thread; // the newly created thread + debug_origin origin; // the thread that created the new thread + team_id new_thread; // the newly created thread } debug_thread_created; // B_DEBUGGER_MESSAGE_THREAD_DELETED typedef struct { - thread_id thread; // the thread - team_id team; // the thread's team + debug_origin origin; // the deleted thread (asynchronous message) } debug_thread_deleted; // B_DEBUGGER_MESSAGE_IMAGE_CREATED typedef struct { - thread_id thread; // the thread responsible for creating the image - team_id team; // the thread's team - image_info info; // info for the image + debug_origin origin; + image_info info; // info for the image } debug_image_created; // B_DEBUGGER_MESSAGE_IMAGE_DELETED typedef struct { - thread_id thread; // the thread responsible for deleting the image - team_id team; // the thread's team - image_info info; // info for the image + debug_origin origin; + image_info info; // info for the image } debug_image_deleted; // union of all messages structures sent to the debugger @@ -308,7 +305,8 @@ typedef union { debug_thread_deleted thread_deleted; debug_image_created image_created; debug_image_deleted image_deleted; - // ... + + debug_origin origin; // for convenience (no real message) } debug_debugger_message_data; #ifdef __cplusplus diff --git a/src/kernel/core/user_debugger.cpp b/src/kernel/core/user_debugger.cpp index ee030b2ff5..facf958696 100644 --- a/src/kernel/core/user_debugger.cpp +++ b/src/kernel/core/user_debugger.cpp @@ -131,8 +131,8 @@ prepare_thread_stopped_message(debug_thread_stopped &message, { struct thread *thread = thread_get_current_thread(); - message.thread = thread->id; - message.team = thread->team->id; + message.origin.thread = thread->id; + message.origin.team = thread->team->id; message.why = whyStopped; message.nub_port = nubPort; message.data = data; @@ -320,8 +320,8 @@ user_debug_pre_syscall(uint32 syscall, void *args) // prepare the message debug_pre_syscall message; - message.thread = thread->id; - message.team = thread->team->id; + message.origin.thread = thread->id; + message.origin.team = thread->team->id; message.syscall = syscall; // copy the syscall args @@ -354,8 +354,8 @@ user_debug_post_syscall(uint32 syscall, void *args, uint64 returnValue, // prepare the message debug_post_syscall message; - message.thread = thread->id; - message.team = thread->team->id; + message.origin.thread = thread->id; + message.origin.team = thread->team->id; message.start_time = startTime; message.end_time = system_time(); message.return_value = returnValue; @@ -424,8 +424,8 @@ user_debug_handle_signal(int signal, struct sigaction *handler, bool deadly) // prepare the message debug_signal_received message; - message.thread = thread->id; - message.team = thread->team->id; + message.origin.thread = thread->id; + message.origin.team = thread->team->id; message.signal = signal; message.handler = *handler; message.deadly = deadly; @@ -457,8 +457,8 @@ user_debug_team_created(team_id teamID) // prepare the message debug_team_created message; - message.thread = thread->id; - message.team = thread->team->id; + message.origin.thread = thread->id; + message.origin.team = thread->team->id; message.new_team = teamID; thread_hit_debug_event(B_DEBUGGER_MESSAGE_TEAM_CREATED, &message, @@ -471,7 +471,8 @@ user_debug_team_deleted(team_id teamID, port_id debuggerPort) { if (debuggerPort >= 0) { debug_team_deleted message; - message.team = teamID; + message.origin.thread = -1; + message.origin.team = teamID; write_port_etc(debuggerPort, B_DEBUGGER_MESSAGE_TEAM_DELETED, &message, sizeof(message), B_RELATIVE_TIMEOUT, 0); // TODO: Would it be OK to wait here? @@ -492,8 +493,8 @@ user_debug_thread_created(thread_id threadID) // prepare the message debug_thread_created message; - message.thread = thread->id; - message.team = thread->team->id; + message.origin.thread = thread->id; + message.origin.team = thread->team->id; message.new_thread = threadID; thread_hit_debug_event(B_DEBUGGER_MESSAGE_THREAD_CREATED, &message, @@ -529,8 +530,8 @@ user_debug_thread_deleted(team_id teamID, thread_id threadID) // notify the debugger if (debuggerPort >= 0) { debug_thread_deleted message; - message.thread = threadID; - message.team = teamID; + message.origin.thread = threadID; + message.origin.team = teamID; write_port_etc(debuggerPort, B_DEBUGGER_MESSAGE_THREAD_DELETED, &message, sizeof(message), B_RELATIVE_TIMEOUT, 0); // TODO: Would it be OK to wait here? @@ -551,8 +552,8 @@ user_debug_image_created(const image_info *imageInfo) // prepare the message debug_image_created message; - message.thread = thread->id; - message.team = thread->team->id; + message.origin.thread = thread->id; + message.origin.team = thread->team->id; memcpy(&message.info, imageInfo, sizeof(image_info)); thread_hit_debug_event(B_DEBUGGER_MESSAGE_IMAGE_CREATED, &message, @@ -573,8 +574,8 @@ user_debug_image_deleted(const image_info *imageInfo) // prepare the message debug_image_deleted message; - message.thread = thread->id; - message.team = thread->team->id; + message.origin.thread = thread->id; + message.origin.team = thread->team->id; memcpy(&message.info, imageInfo, sizeof(image_info)); thread_hit_debug_event(B_DEBUGGER_MESSAGE_IMAGE_CREATED, &message,