winedbg: Fixed regression in gdb startup (especially gdb proxy).

This commit is contained in:
Eric Pouech 2006-09-25 22:45:24 +02:00 committed by Alexandre Julliard
parent e3f8799a42
commit 588a4422b0
5 changed files with 35 additions and 42 deletions

View file

@ -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); }

View file

@ -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_exception(DWORD cont, int count, int mode)
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*);

View file

@ -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",

View file

@ -70,10 +70,8 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de);
* 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 cofe, BOOL wfe)
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 cont)
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, int count, int mode)
}
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, int count, int mode)
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 cmdLine)
}
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 argc, char* argv[])
/* 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 argc, char* argv[])
else return start_error_parse;
dbg_curr_pid = pid;
dbg_wait_for_first_exception();
return start_ok;
}

View file

@ -287,6 +287,7 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid,
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 @@ int main(int argc, char** argv)
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);