Module: wine Branch: master Commit: c1a32a080f982d972247db3b8d42a37bea2385dd URL: https://source.winehq.org/git/wine.git/?a=commit;h=c1a32a080f982d972247db3b8...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Aug 6 15:05:36 2019 +0200
server: Report only one debug event per process at the time.
Instead of one per thread.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/kernel32/tests/debugger.c | 7 +++++++ server/debugger.c | 10 +++++----- server/process.c | 1 + server/process.h | 1 + server/thread.c | 1 - server/thread.h | 1 - 6 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/dlls/kernel32/tests/debugger.c b/dlls/kernel32/tests/debugger.c index 7594b25..106c1c4 100644 --- a/dlls/kernel32/tests/debugger.c +++ b/dlls/kernel32/tests/debugger.c @@ -287,6 +287,9 @@ static void next_event_(unsigned line, struct debugger_context *ctx, unsigned ti
static void process_attach_events(struct debugger_context *ctx) { + DEBUG_EVENT ev; + BOOL ret; + ctx->ev.dwDebugEventCode = -1; next_event(ctx, 0); ok(ctx->ev.dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx->ev.dwDebugEventCode); @@ -304,6 +307,10 @@ static void process_attach_events(struct debugger_context *ctx)
do { + /* even when there are more pending events, they are not reported until current event is continued */ + ret = WaitForDebugEvent(&ev, 10); + ok(GetLastError() == ERROR_SEM_TIMEOUT, "WaitForDebugEvent returned %x(%u)\n", ret, GetLastError()); + next_event(ctx, WAIT_EVENT_TIMEOUT); if (ctx->ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT) ok(ctx->ev.u.LoadDll.lpBaseOfDll != ntdll, "ntdll.dll reported out of order\n"); diff --git a/server/debugger.c b/server/debugger.c index 99e50aa..a5c39aa 100644 --- a/server/debugger.c +++ b/server/debugger.c @@ -244,7 +244,7 @@ static const fill_event_func fill_debug_event[NB_DEBUG_EVENTS] = static void unlink_event( struct debug_ctx *debug_ctx, struct debug_event *event ) { list_remove( &event->entry ); - if (event->sender->debug_event == event) event->sender->debug_event = NULL; + if (event->sender->process->debug_event == event) event->sender->process->debug_event = NULL; release_object( event ); }
@@ -256,7 +256,7 @@ static void link_event( struct debug_event *event ) assert( debug_ctx ); grab_object( event ); list_add_tail( &debug_ctx->event_queue, &event->entry ); - if (!event->sender->debug_event) + if (!event->sender->process->debug_event) { /* grab reference since debugger could be killed while trying to wake up */ grab_object( debug_ctx ); @@ -273,7 +273,7 @@ static struct debug_event *find_event_to_send( struct debug_ctx *debug_ctx ) LIST_FOR_EACH_ENTRY( event, &debug_ctx->event_queue, struct debug_event, entry ) { if (event->state == EVENT_SENT) continue; /* already sent */ - if (event->sender->debug_event) continue; /* thread busy with another one */ + if (event->sender->process->debug_event) continue; /* process busy with another one */ return event; } return NULL; @@ -371,7 +371,7 @@ static int continue_debug_event( struct process *process, struct thread *thread, if (event->state != EVENT_SENT) continue; if (event->sender == thread) { - assert( event->sender->debug_event == event ); + assert( event->sender->process->debug_event == event );
event->status = status; event->state = EVENT_CONTINUED; @@ -594,7 +594,7 @@ DECL_HANDLER(wait_debug_event) { data_size_t size = get_reply_max_size(); event->state = EVENT_SENT; - event->sender->debug_event = event; + event->sender->process->debug_event = event; reply->pid = get_process_id( event->sender->process ); reply->tid = get_thread_id( event->sender ); if (size > sizeof(debug_event_t)) size = sizeof(debug_event_t); diff --git a/server/process.c b/server/process.c index b67bd88..16bb5d5 100644 --- a/server/process.c +++ b/server/process.c @@ -502,6 +502,7 @@ struct process *create_process( int fd, struct process *parent, int inherit_all, } process->parent_id = 0; process->debugger = NULL; + process->debug_event = NULL; process->handles = NULL; process->msg_fd = NULL; process->sigkill_timeout = NULL; diff --git a/server/process.h b/server/process.h index 20503a2..20ff6be 100644 --- a/server/process.h +++ b/server/process.h @@ -57,6 +57,7 @@ struct process process_id_t parent_id; /* parent process id (at the time of creation) */ struct list thread_list; /* thread list */ struct thread *debugger; /* thread debugging this process */ + struct debug_event *debug_event; /* debug event being sent to debugger */ struct handle_table *handles; /* handle entries */ struct fd *msg_fd; /* fd for sendmsg/recvmsg */ process_id_t id; /* id of the process */ diff --git a/server/thread.c b/server/thread.c index d5742a1..e753c8d 100644 --- a/server/thread.c +++ b/server/thread.c @@ -184,7 +184,6 @@ static inline void init_thread_structure( struct thread *thread ) thread->teb = 0; thread->entry_point = 0; thread->debug_ctx = NULL; - thread->debug_event = NULL; thread->system_regs = 0; thread->queue = NULL; thread->wait = NULL; diff --git a/server/thread.h b/server/thread.h index 40f0eec..e10120d 100644 --- a/server/thread.h +++ b/server/thread.h @@ -55,7 +55,6 @@ struct thread thread_id_t id; /* thread id */ struct list mutex_list; /* list of currently owned mutexes */ struct debug_ctx *debug_ctx; /* debugger context if this thread is a debugger */ - struct debug_event *debug_event; /* debug event being sent to debugger */ unsigned int system_regs; /* which system regs have been set */ struct msg_queue *queue; /* message queue */ struct thread_wait *wait; /* current wait condition if sleeping */