Eric Pouech : winedbg: Fixed regression in gdb startup (
especially gdb proxy).
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Sep 26 05:30:18 CDT 2006
Module: wine
Branch: master
Commit: 588a4422b01b146ce17f875b61bb8d76107869e2
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=588a4422b01b146ce17f875b61bb8d76107869e2
Author: Eric Pouech <eric.pouech at wanadoo.fr>
Date: Mon Sep 25 22:45:24 2006 +0200
winedbg: Fixed regression in gdb startup (especially gdb proxy).
---
programs/winedbg/dbg.y | 2 +
programs/winedbg/debugger.h | 6 +++-
programs/winedbg/stack.c | 3 +-
programs/winedbg/tgt_active.c | 59 +++++++++++++++--------------------------
programs/winedbg/winedbg.c | 7 +++++
5 files changed, 35 insertions(+), 42 deletions(-)
diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y
index ea28b54..0c225e1 100644
--- a/programs/winedbg/dbg.y
+++ b/programs/winedbg/dbg.y
@@ -139,7 +139,7 @@ command:
| tSYMBOLFILE pathname { symbol_read_symtable($2, 0); }
| tSYMBOLFILE pathname expr_rvalue { symbol_read_symtable($2, $3); }
| tWHATIS expr_lvalue { dbg_printf("type = "); types_print_type(&$2.type, FALSE); dbg_printf("\n"); }
- | tATTACH tNUM { dbg_attach_debuggee($2, FALSE, TRUE); }
+ | tATTACH tNUM { dbg_attach_debuggee($2, FALSE); dbg_active_wait_for_first_exception(); }
| tDETACH { dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE); }
| tMINIDUMP pathname { minidump_write($2, (dbg_curr_thread && dbg_curr_thread->in_exception) ? &dbg_curr_thread->excpt_record : NULL);}
| tECHO tSTRING { dbg_printf("%s\n", $2); }
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h
index ac9d4de..fad77f3 100644
--- a/programs/winedbg/debugger.h
+++ b/programs/winedbg/debugger.h
@@ -205,7 +205,8 @@ struct dbg_process
void* pio_data;
const char* imageName;
struct dbg_thread* threads;
- unsigned continue_on_first_exception;
+ unsigned continue_on_first_exception : 1,
+ active_debuggee : 1;
struct dbg_breakpoint bp[MAX_BREAKPOINTS];
unsigned next_bp;
struct dbg_delayed_bp* delayed_bp;
@@ -378,7 +379,8 @@ extern void dbg_wait_next_ex
extern enum dbg_start dbg_active_attach(int argc, char* argv[]);
extern enum dbg_start dbg_active_launch(int argc, char* argv[]);
extern enum dbg_start dbg_active_auto(int argc, char* argv[]);
-extern BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe, BOOL wfe);
+extern void dbg_active_wait_for_first_exception(void);
+extern BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe);
/* tgt_minidump.c */
extern void minidump_write(const char*, const EXCEPTION_RECORD*);
diff --git a/programs/winedbg/stack.c b/programs/winedbg/stack.c
index 14d4df5..8a6bbd6 100644
--- a/programs/winedbg/stack.c
+++ b/programs/winedbg/stack.c
@@ -364,13 +364,14 @@ static void backtrace_all(void)
if (entry.th32OwnerProcessID != dbg_curr_pid)
{
- if (!dbg_attach_debuggee(entry.th32OwnerProcessID, FALSE, TRUE))
+ if (!dbg_attach_debuggee(entry.th32OwnerProcessID, FALSE))
{
dbg_printf("\nwarning: could not attach to 0x%lx\n",
entry.th32OwnerProcessID);
continue;
}
dbg_curr_pid = dbg_curr_process->pid;
+ dbg_active_wait_for_first_exception();
}
dbg_printf("\nBacktracing for thread 0x%lx in process 0x%lx (%s):\n",
diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c
index 7636b16..af619a0 100644
--- a/programs/winedbg/tgt_active.c
+++ b/programs/winedbg/tgt_active.c
@@ -70,10 +70,8 @@ static unsigned dbg_handle_debug_event(D
* wfe is set to TRUE if dbg_attach_debuggee should also proceed with all debug events
* until the first exception is received (aka: attach to an already running process)
*/
-BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe, BOOL wfe)
+BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe)
{
- DEBUG_EVENT de;
-
if (!(dbg_curr_process = dbg_add_process(&be_process_active_io, pid, 0))) return FALSE;
if (!DebugActiveProcess(pid))
@@ -86,15 +84,7 @@ BOOL dbg_attach_debuggee(DWORD pid, BOOL
SetEnvironmentVariableA("DBGHELP_NOLIVE", NULL);
- if (wfe) /* shall we proceed all debug events until we get an exception ? */
- {
- dbg_interactiveP = FALSE;
- while (dbg_curr_process && WaitForDebugEvent(&de, INFINITE))
- {
- if (dbg_handle_debug_event(&de)) break;
- }
- if (dbg_curr_process) dbg_interactiveP = TRUE;
- }
+ dbg_curr_process->active_debuggee = TRUE;
return TRUE;
}
@@ -667,9 +657,19 @@ static void dbg_resume_debuggee(DWORD co
dbg_printf("Cannot continue on %lu (%lu)\n", dbg_curr_tid, cont);
}
+static void wait_exception(void)
+{
+ DEBUG_EVENT de;
+
+ while (dbg_curr_process && WaitForDebugEvent(&de, INFINITE))
+ {
+ if (dbg_handle_debug_event(&de)) break;
+ }
+ dbg_interactiveP = TRUE;
+}
+
void dbg_wait_next_exception(DWORD cont, int count, int mode)
{
- DEBUG_EVENT de;
ADDRESS64 addr;
char hexbuf[MAX_OFFSET_TO_STR_LEN];
@@ -680,12 +680,8 @@ void dbg_wait_next_exception(DWORD cont,
}
dbg_resume_debuggee(cont);
- while (dbg_curr_process && WaitForDebugEvent(&de, INFINITE))
- {
- if (dbg_handle_debug_event(&de)) break;
- }
+ wait_exception();
if (!dbg_curr_process) return;
- dbg_interactiveP = TRUE;
memory_get_current_pc(&addr);
WINE_TRACE("Entering debugger PC=%s mode=%d count=%d\n",
@@ -694,18 +690,11 @@ void dbg_wait_next_exception(DWORD cont,
dbg_curr_thread->exec_count);
}
-static void dbg_wait_for_first_exception(void)
+void dbg_active_wait_for_first_exception(void)
{
- DEBUG_EVENT de;
-
- if (dbg_curr_process)
- dbg_printf("WineDbg starting on pid 0x%lx\n", dbg_curr_pid);
-
+ dbg_interactiveP = FALSE;
/* wait for first exception */
- while (WaitForDebugEvent(&de, INFINITE))
- {
- if (dbg_handle_debug_event(&de)) break;
- }
+ wait_exception();
}
static unsigned dbg_start_debuggee(LPSTR cmdLine)
@@ -749,7 +738,7 @@ static unsigned dbg_start_debuggee(LPSTR
}
dbg_curr_pid = info.dwProcessId;
if (!(dbg_curr_process = dbg_add_process(&be_process_active_io, dbg_curr_pid, 0))) return FALSE;
- dbg_wait_for_first_exception();
+ dbg_curr_process->active_debuggee = TRUE;
return TRUE;
}
@@ -763,18 +752,13 @@ void dbg_run_debuggee(const char* args)
}
else
{
- DEBUG_EVENT de;
-
if (!dbg_last_cmd_line)
{
dbg_printf("Cannot find previously used command line.\n");
return;
}
dbg_start_debuggee(dbg_last_cmd_line);
- while (dbg_curr_process && WaitForDebugEvent(&de, INFINITE))
- {
- if (dbg_handle_debug_event(&de)) break;
- }
+ dbg_active_wait_for_first_exception();
source_list_from_addr(NULL, 0);
}
}
@@ -801,14 +785,14 @@ enum dbg_start dbg_active_attach(int ar
/* try the form <myself> pid */
if (argc == 1 && str2int(argv[0], &pid) && pid != 0)
{
- if (!dbg_attach_debuggee(pid, FALSE, FALSE))
+ if (!dbg_attach_debuggee(pid, FALSE))
return start_error_init;
}
/* try the form <myself> pid evt (Win32 JIT debugger) */
else if (argc == 2 && str2int(argv[0], &pid) && pid != 0 &&
str2int(argv[1], &evt) && evt != 0)
{
- if (!dbg_attach_debuggee(pid, TRUE, FALSE))
+ if (!dbg_attach_debuggee(pid, TRUE))
{
/* don't care about result */
SetEvent((HANDLE)evt);
@@ -824,7 +808,6 @@ enum dbg_start dbg_active_attach(int ar
else return start_error_parse;
dbg_curr_pid = pid;
- dbg_wait_for_first_exception();
return start_ok;
}
diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c
index 5810c78..d206d3b 100644
--- a/programs/winedbg/winedbg.c
+++ b/programs/winedbg/winedbg.c
@@ -287,6 +287,7 @@ struct dbg_process* dbg_add_process(cons
p->imageName = NULL;
p->threads = NULL;
p->continue_on_first_exception = FALSE;
+ p->active_debuggee = FALSE;
p->next_bp = 1; /* breakpoint 0 is reserved for step-over */
memset(p->bp, 0, sizeof(p->bp));
p->delayed_bp = NULL;
@@ -583,6 +584,12 @@ #endif
case start_error_init: return -1;
}
+ if (dbg_curr_process)
+ {
+ dbg_printf("WineDbg starting on pid 0x%lx\n", dbg_curr_pid);
+ if (dbg_curr_process->active_debuggee) dbg_active_wait_for_first_exception();
+ }
+
dbg_interactiveP = TRUE;
parser_handle(hFile);
More information about the wine-cvs
mailing list