Introduced a debug_origin structure consisting of thread and team ID of the concerned thread, and being first member of all messages sent to the debugger. This simplifies handling of messages in the debugger a good deal.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11482 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2005-02-24 18:47:04 +00:00
parent 013765b30a
commit 433e1959ae
2 changed files with 50 additions and 51 deletions
+30 -32
View File
@@ -207,11 +207,16 @@ typedef enum {
B_DEBUGGER_MESSAGE_IMAGE_DELETED, // an image has been deleted B_DEBUGGER_MESSAGE_IMAGE_DELETED, // an image has been deleted
} debug_debugger_message; } 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 // B_DEBUGGER_MESSAGE_THREAD_STOPPED
typedef struct { typedef struct {
thread_id thread; // the stopped thread debug_origin origin;
team_id team; // the thread's team
debug_why_stopped why; // reason for contacting debugger debug_why_stopped why; // reason for contacting debugger
port_id nub_port; // port to debug nub for this team port_id nub_port; // port to debug nub for this team
debug_cpu_state cpu_state; // cpu state debug_cpu_state cpu_state; // cpu state
@@ -221,29 +226,26 @@ typedef struct {
// B_DEBUGGER_MESSAGE_PRE_SYSCALL // B_DEBUGGER_MESSAGE_PRE_SYSCALL
typedef struct { typedef struct {
thread_id thread; // thread debug_origin origin;
team_id team; // the thread's team uint32 syscall; // the syscall number
uint32 syscall; // the syscall number uint32 args[16]; // syscall arguments
uint32 args[16]; // syscall arguments
} debug_pre_syscall; } debug_pre_syscall;
// B_DEBUGGER_MESSAGE_POST_SYSCALL // B_DEBUGGER_MESSAGE_POST_SYSCALL
typedef struct { typedef struct {
thread_id thread; // thread debug_origin origin;
team_id team; // the thread's team bigtime_t start_time; // time of syscall start
bigtime_t start_time; // time of syscall start bigtime_t end_time; // time of syscall completion
bigtime_t end_time; // time of syscall completion uint64 return_value; // the syscall's return value
uint64 return_value; // the syscall's return value uint32 syscall; // the syscall number
uint32 syscall; // the syscall number uint32 args[16]; // syscall arguments
uint32 args[16]; // syscall arguments
} debug_post_syscall; } debug_post_syscall;
// B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED // B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED
typedef struct { typedef struct {
thread_id thread; // thread debug_origin origin;
team_id team; // the thread's team
int signal; // the signal int signal; // the signal
struct sigaction handler; // the signal handler struct sigaction handler; // the signal handler
bool deadly; // true, if handling the signal will kill bool deadly; // true, if handling the signal will kill
@@ -253,47 +255,42 @@ typedef struct {
// B_DEBUGGER_MESSAGE_TEAM_CREATED // B_DEBUGGER_MESSAGE_TEAM_CREATED
typedef struct { typedef struct {
thread_id thread; // the thread responsible for creating the team debug_origin origin;
team_id team; // the thread's team team_id new_team; // the newly created team
team_id new_team; // the newly created team
} debug_team_created; } debug_team_created;
// B_DEBUGGER_MESSAGE_TEAM_DELETED // B_DEBUGGER_MESSAGE_TEAM_DELETED
typedef struct { typedef struct {
team_id team; // the team debug_origin origin; // thread is < 0, team is the deleted team
// (asynchronous message)
} debug_team_deleted; } debug_team_deleted;
// B_DEBUGGER_MESSAGE_THREAD_CREATED // B_DEBUGGER_MESSAGE_THREAD_CREATED
typedef struct { typedef struct {
thread_id thread; // the thread responsible for creating the new debug_origin origin; // the thread that created the new thread
// thread team_id new_thread; // the newly created thread
team_id team; // the thread's team
team_id new_thread; // the newly created thread
} debug_thread_created; } debug_thread_created;
// B_DEBUGGER_MESSAGE_THREAD_DELETED // B_DEBUGGER_MESSAGE_THREAD_DELETED
typedef struct { typedef struct {
thread_id thread; // the thread debug_origin origin; // the deleted thread (asynchronous message)
team_id team; // the thread's team
} debug_thread_deleted; } debug_thread_deleted;
// B_DEBUGGER_MESSAGE_IMAGE_CREATED // B_DEBUGGER_MESSAGE_IMAGE_CREATED
typedef struct { typedef struct {
thread_id thread; // the thread responsible for creating the image debug_origin origin;
team_id team; // the thread's team image_info info; // info for the image
image_info info; // info for the image
} debug_image_created; } debug_image_created;
// B_DEBUGGER_MESSAGE_IMAGE_DELETED // B_DEBUGGER_MESSAGE_IMAGE_DELETED
typedef struct { typedef struct {
thread_id thread; // the thread responsible for deleting the image debug_origin origin;
team_id team; // the thread's team image_info info; // info for the image
image_info info; // info for the image
} debug_image_deleted; } debug_image_deleted;
// union of all messages structures sent to the debugger // union of all messages structures sent to the debugger
@@ -308,7 +305,8 @@ typedef union {
debug_thread_deleted thread_deleted; debug_thread_deleted thread_deleted;
debug_image_created image_created; debug_image_created image_created;
debug_image_deleted image_deleted; debug_image_deleted image_deleted;
// ...
debug_origin origin; // for convenience (no real message)
} debug_debugger_message_data; } debug_debugger_message_data;
#ifdef __cplusplus #ifdef __cplusplus
+20 -19
View File
@@ -131,8 +131,8 @@ prepare_thread_stopped_message(debug_thread_stopped &message,
{ {
struct thread *thread = thread_get_current_thread(); struct thread *thread = thread_get_current_thread();
message.thread = thread->id; message.origin.thread = thread->id;
message.team = thread->team->id; message.origin.team = thread->team->id;
message.why = whyStopped; message.why = whyStopped;
message.nub_port = nubPort; message.nub_port = nubPort;
message.data = data; message.data = data;
@@ -320,8 +320,8 @@ user_debug_pre_syscall(uint32 syscall, void *args)
// prepare the message // prepare the message
debug_pre_syscall message; debug_pre_syscall message;
message.thread = thread->id; message.origin.thread = thread->id;
message.team = thread->team->id; message.origin.team = thread->team->id;
message.syscall = syscall; message.syscall = syscall;
// copy the syscall args // copy the syscall args
@@ -354,8 +354,8 @@ user_debug_post_syscall(uint32 syscall, void *args, uint64 returnValue,
// prepare the message // prepare the message
debug_post_syscall message; debug_post_syscall message;
message.thread = thread->id; message.origin.thread = thread->id;
message.team = thread->team->id; message.origin.team = thread->team->id;
message.start_time = startTime; message.start_time = startTime;
message.end_time = system_time(); message.end_time = system_time();
message.return_value = returnValue; message.return_value = returnValue;
@@ -424,8 +424,8 @@ user_debug_handle_signal(int signal, struct sigaction *handler, bool deadly)
// prepare the message // prepare the message
debug_signal_received message; debug_signal_received message;
message.thread = thread->id; message.origin.thread = thread->id;
message.team = thread->team->id; message.origin.team = thread->team->id;
message.signal = signal; message.signal = signal;
message.handler = *handler; message.handler = *handler;
message.deadly = deadly; message.deadly = deadly;
@@ -457,8 +457,8 @@ user_debug_team_created(team_id teamID)
// prepare the message // prepare the message
debug_team_created message; debug_team_created message;
message.thread = thread->id; message.origin.thread = thread->id;
message.team = thread->team->id; message.origin.team = thread->team->id;
message.new_team = teamID; message.new_team = teamID;
thread_hit_debug_event(B_DEBUGGER_MESSAGE_TEAM_CREATED, &message, 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) { if (debuggerPort >= 0) {
debug_team_deleted message; 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, write_port_etc(debuggerPort, B_DEBUGGER_MESSAGE_TEAM_DELETED, &message,
sizeof(message), B_RELATIVE_TIMEOUT, 0); sizeof(message), B_RELATIVE_TIMEOUT, 0);
// TODO: Would it be OK to wait here? // TODO: Would it be OK to wait here?
@@ -492,8 +493,8 @@ user_debug_thread_created(thread_id threadID)
// prepare the message // prepare the message
debug_thread_created message; debug_thread_created message;
message.thread = thread->id; message.origin.thread = thread->id;
message.team = thread->team->id; message.origin.team = thread->team->id;
message.new_thread = threadID; message.new_thread = threadID;
thread_hit_debug_event(B_DEBUGGER_MESSAGE_THREAD_CREATED, &message, 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 // notify the debugger
if (debuggerPort >= 0) { if (debuggerPort >= 0) {
debug_thread_deleted message; debug_thread_deleted message;
message.thread = threadID; message.origin.thread = threadID;
message.team = teamID; message.origin.team = teamID;
write_port_etc(debuggerPort, B_DEBUGGER_MESSAGE_THREAD_DELETED, write_port_etc(debuggerPort, B_DEBUGGER_MESSAGE_THREAD_DELETED,
&message, sizeof(message), B_RELATIVE_TIMEOUT, 0); &message, sizeof(message), B_RELATIVE_TIMEOUT, 0);
// TODO: Would it be OK to wait here? // TODO: Would it be OK to wait here?
@@ -551,8 +552,8 @@ user_debug_image_created(const image_info *imageInfo)
// prepare the message // prepare the message
debug_image_created message; debug_image_created message;
message.thread = thread->id; message.origin.thread = thread->id;
message.team = thread->team->id; message.origin.team = thread->team->id;
memcpy(&message.info, imageInfo, sizeof(image_info)); memcpy(&message.info, imageInfo, sizeof(image_info));
thread_hit_debug_event(B_DEBUGGER_MESSAGE_IMAGE_CREATED, &message, 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 // prepare the message
debug_image_deleted message; debug_image_deleted message;
message.thread = thread->id; message.origin.thread = thread->id;
message.team = thread->team->id; message.origin.team = thread->team->id;
memcpy(&message.info, imageInfo, sizeof(image_info)); memcpy(&message.info, imageInfo, sizeof(image_info));
thread_hit_debug_event(B_DEBUGGER_MESSAGE_IMAGE_CREATED, &message, thread_hit_debug_event(B_DEBUGGER_MESSAGE_IMAGE_CREATED, &message,