Commit 3acf541d authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Fixed some bugs in first chance exception handling.

parent a1e57324
...@@ -746,13 +746,14 @@ static BOOL DEBUG_ShallBreak( int bpnum ) ...@@ -746,13 +746,14 @@ static BOOL DEBUG_ShallBreak( int bpnum )
* Determine if we should continue execution after a SIGTRAP signal when * Determine if we should continue execution after a SIGTRAP signal when
* executing in the given mode. * executing in the given mode.
*/ */
BOOL DEBUG_ShouldContinue( DBG_ADDR *addr, DWORD code, enum exec_mode mode, int * count ) BOOL DEBUG_ShouldContinue( DBG_ADDR *addr, DWORD code, int * count )
{ {
int bpnum; int bpnum;
DWORD oldval; DWORD oldval;
int wpnum; int wpnum;
enum dbg_mode addr_mode; enum dbg_mode addr_mode;
struct symbol_info syminfo; struct symbol_info syminfo;
enum exec_mode mode = DEBUG_CurrThread->exec_mode;
#ifdef __i386__ #ifdef __i386__
/* If not single-stepping, back up over the int3 instruction */ /* If not single-stepping, back up over the int3 instruction */
...@@ -833,7 +834,7 @@ BOOL DEBUG_ShouldContinue( DBG_ADDR *addr, DWORD code, enum exec_mode mode, int ...@@ -833,7 +834,7 @@ BOOL DEBUG_ShouldContinue( DBG_ADDR *addr, DWORD code, enum exec_mode mode, int
* If we are about to stop, then print out the source line if we * If we are about to stop, then print out the source line if we
* have it. * have it.
*/ */
if (mode != EXEC_CONT && mode != EXEC_PASS && mode != EXEC_FINISH) if (mode != EXEC_CONT && mode != EXEC_FINISH)
{ {
DEBUG_FindNearestSymbol( addr, TRUE, NULL, 0, &syminfo.list); DEBUG_FindNearestSymbol( addr, TRUE, NULL, 0, &syminfo.list);
if( syminfo.list.sourcefile != NULL ) if( syminfo.list.sourcefile != NULL )
...@@ -853,7 +854,7 @@ BOOL DEBUG_ShouldContinue( DBG_ADDR *addr, DWORD code, enum exec_mode mode, int ...@@ -853,7 +854,7 @@ BOOL DEBUG_ShouldContinue( DBG_ADDR *addr, DWORD code, enum exec_mode mode, int
#endif #endif
/* no breakpoint, continue if in continuous mode */ /* no breakpoint, continue if in continuous mode */
return (mode == EXEC_CONT || mode == EXEC_PASS || mode == EXEC_FINISH); return (mode == EXEC_CONT || mode == EXEC_FINISH);
} }
/*********************************************************************** /***********************************************************************
...@@ -873,14 +874,14 @@ void DEBUG_SuspendExecution( void ) ...@@ -873,14 +874,14 @@ void DEBUG_SuspendExecution( void )
* Set the breakpoints to the correct state to restart execution * Set the breakpoints to the correct state to restart execution
* in the given mode. * in the given mode.
*/ */
enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count ) void DEBUG_RestartExecution( int count )
{ {
DBG_ADDR addr; DBG_ADDR addr;
DBG_ADDR addr2; DBG_ADDR addr2;
int bp; int bp;
int delta; int delta;
int status; int status;
enum exec_mode ret_mode; enum exec_mode mode, ret_mode;
DWORD instr; DWORD instr;
unsigned char ch; unsigned char ch;
...@@ -890,7 +891,7 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count ) ...@@ -890,7 +891,7 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
* This is the mode we will be running in after we finish. We would like * This is the mode we will be running in after we finish. We would like
* to be able to modify this in certain cases. * to be able to modify this in certain cases.
*/ */
ret_mode = mode; ret_mode = mode = DEBUG_CurrThread->exec_mode;
bp = DEBUG_FindBreakpoint( &addr, DBG_BREAK ); bp = DEBUG_FindBreakpoint( &addr, DBG_BREAK );
if ( bp != -1 && bp != 0) if ( bp != -1 && bp != 0)
...@@ -971,7 +972,6 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count ) ...@@ -971,7 +972,6 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
switch(mode) switch(mode)
{ {
case EXEC_CONT: /* Continuous execution */ case EXEC_CONT: /* Continuous execution */
case EXEC_PASS: /* Continue, passing exception */
#ifdef __i386__ #ifdef __i386__
DEBUG_context.EFlags &= ~STEP_FLAG; DEBUG_context.EFlags &= ~STEP_FLAG;
#endif #endif
...@@ -1030,7 +1030,7 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count ) ...@@ -1030,7 +1030,7 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL); RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
} }
DEBUG_CurrThread->stepOverBP = breakpoints[0]; DEBUG_CurrThread->stepOverBP = breakpoints[0];
return ret_mode; DEBUG_CurrThread->exec_mode = ret_mode;
} }
int int
......
...@@ -103,31 +103,30 @@ line: command ...@@ -103,31 +103,30 @@ line: command
| error tEOL { yyerrok; } | error tEOL { yyerrok; }
command: command:
tQUIT tEOL { return EXIT_QUIT; } tQUIT tEOL { DEBUG_ExitMode = EXIT_QUIT; return 1; }
| tHELP tEOL { DEBUG_Help(); } | tHELP tEOL { DEBUG_Help(); }
| tHELP tINFO tEOL { DEBUG_HelpInfo(); } | tHELP tINFO tEOL { DEBUG_HelpInfo(); }
| tCONT tEOL { DEBUG_CurrThread->dbg_exec_count = 1; | tCONT tEOL { DEBUG_CurrThread->exec_count = 1;
DEBUG_CurrThread->dbg_exec_mode = EXEC_CONT; return EXIT_CONT; } DEBUG_CurrThread->exec_mode = EXEC_CONT; return 1; }
| tPASS tEOL { DEBUG_CurrThread->dbg_exec_count = 1; | tPASS tEOL { DEBUG_ExitMode = EXIT_PASS; return 1; }
DEBUG_CurrThread->dbg_exec_mode = EXEC_PASS; return EXIT_CONT; } | tCONT tNUM tEOL { DEBUG_CurrThread->exec_count = $2;
| tCONT tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2; DEBUG_CurrThread->exec_mode = EXEC_CONT; return 1; }
DEBUG_CurrThread->dbg_exec_mode = EXEC_CONT; return EXIT_CONT; } | tSTEP tEOL { DEBUG_CurrThread->exec_count = 1;
| tSTEP tEOL { DEBUG_CurrThread->dbg_exec_count = 1; DEBUG_CurrThread->exec_mode = EXEC_STEP_INSTR; return 1; }
DEBUG_CurrThread->dbg_exec_mode = EXEC_STEP_INSTR; return EXIT_CONT; } | tNEXT tEOL { DEBUG_CurrThread->exec_count = 1;
| tNEXT tEOL { DEBUG_CurrThread->dbg_exec_count = 1; DEBUG_CurrThread->exec_mode = EXEC_STEP_OVER; return 1; }
DEBUG_CurrThread->dbg_exec_mode = EXEC_STEP_OVER; return EXIT_CONT; } | tSTEP tNUM tEOL { DEBUG_CurrThread->exec_count = $2;
| tSTEP tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2; DEBUG_CurrThread->exec_mode = EXEC_STEP_INSTR; return 1; }
DEBUG_CurrThread->dbg_exec_mode = EXEC_STEP_INSTR; return EXIT_CONT; } | tNEXT tNUM tEOL { DEBUG_CurrThread->exec_count = $2;
| tNEXT tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2; DEBUG_CurrThread->exec_mode = EXEC_STEP_OVER; return 1; }
DEBUG_CurrThread->dbg_exec_mode = EXEC_STEP_OVER; return EXIT_CONT; } | tSTEPI tEOL { DEBUG_CurrThread->exec_count = 1;
| tSTEPI tEOL { DEBUG_CurrThread->dbg_exec_count = 1; DEBUG_CurrThread->exec_mode = EXEC_STEPI_INSTR; return 1; }
DEBUG_CurrThread->dbg_exec_mode = EXEC_STEPI_INSTR; return EXIT_CONT; } | tNEXTI tEOL { DEBUG_CurrThread->exec_count = 1;
| tNEXTI tEOL { DEBUG_CurrThread->dbg_exec_count = 1; DEBUG_CurrThread->exec_mode = EXEC_STEPI_OVER; return 1; }
DEBUG_CurrThread->dbg_exec_mode = EXEC_STEPI_OVER; return EXIT_CONT; } | tSTEPI tNUM tEOL { DEBUG_CurrThread->exec_count = $2;
| tSTEPI tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2; DEBUG_CurrThread->exec_mode = EXEC_STEPI_INSTR; return 1; }
DEBUG_CurrThread->dbg_exec_mode = EXEC_STEPI_INSTR; return EXIT_CONT; } | tNEXTI tNUM tEOL { DEBUG_CurrThread->exec_count = $2;
| tNEXTI tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2; DEBUG_CurrThread->exec_mode = EXEC_STEPI_OVER; return 1; }
DEBUG_CurrThread->dbg_exec_mode = EXEC_STEPI_OVER; return EXIT_CONT; }
| tABORT tEOL { kill(getpid(), SIGABRT); } | tABORT tEOL { kill(getpid(), SIGABRT); }
| tMODE tNUM tEOL { mode_command($2); } | tMODE tNUM tEOL { mode_command($2); }
| tMODE tVM86 tEOL { DEBUG_CurrThread->dbg_mode = MODE_VM86; } | tMODE tVM86 tEOL { DEBUG_CurrThread->dbg_mode = MODE_VM86; }
...@@ -141,8 +140,8 @@ command: ...@@ -141,8 +140,8 @@ command:
| tDOWN tEOL { DEBUG_SetFrame( curr_frame - 1 ); } | tDOWN tEOL { DEBUG_SetFrame( curr_frame - 1 ); }
| tDOWN tNUM tEOL { DEBUG_SetFrame( curr_frame - $2 ); } | tDOWN tNUM tEOL { DEBUG_SetFrame( curr_frame - $2 ); }
| tFRAME tNUM tEOL { DEBUG_SetFrame( $2 ); } | tFRAME tNUM tEOL { DEBUG_SetFrame( $2 ); }
| tFINISH tEOL { DEBUG_CurrThread->dbg_exec_count = 0; | tFINISH tEOL { DEBUG_CurrThread->exec_count = 0;
DEBUG_CurrThread->dbg_exec_mode = EXEC_FINISH; return EXIT_CONT; } DEBUG_CurrThread->exec_mode = EXEC_FINISH; return 1; }
| tSHOW tDIR tEOL { DEBUG_ShowDir(); } | tSHOW tDIR tEOL { DEBUG_ShowDir(); }
| tDIR pathname tEOL { DEBUG_AddPath( $2 ); } | tDIR pathname tEOL { DEBUG_AddPath( $2 ); }
| tDIR tEOL { DEBUG_NukePath(); } | tDIR tEOL { DEBUG_NukePath(); }
...@@ -157,8 +156,8 @@ command: ...@@ -157,8 +156,8 @@ command:
| tCOND tNUM expr tEOL { DEBUG_AddBPCondition($2, $3); } | tCOND tNUM expr tEOL { DEBUG_AddBPCondition($2, $3); }
| tSYMBOLFILE pathname tEOL { DEBUG_ReadSymbolTable($2); } | tSYMBOLFILE pathname tEOL { DEBUG_ReadSymbolTable($2); }
| tWHATIS expr_addr tEOL { DEBUG_PrintType(&$2); DEBUG_FreeExprMem(); } | tWHATIS expr_addr tEOL { DEBUG_PrintType(&$2); DEBUG_FreeExprMem(); }
| tATTACH tNUM tEOL { if (DEBUG_Attach($2, FALSE)) return EXIT_CONT; } | tATTACH tNUM tEOL { if (DEBUG_Attach($2, FALSE)) return 1; }
| tDETACH tEOL { return EXIT_DETACH; } | tDETACH tEOL { DEBUG_ExitMode = EXIT_DETACH; return 1; }
| list_command | list_command
| disassemble_command | disassemble_command
| set_command | set_command
...@@ -409,29 +408,27 @@ static WINE_EXCEPTION_FILTER(wine_dbg_cmd) ...@@ -409,29 +408,27 @@ static WINE_EXCEPTION_FILTER(wine_dbg_cmd)
* *
* Debugger editline parser * Debugger editline parser
*/ */
enum exit_mode DEBUG_Parser(void) void DEBUG_Parser(void)
{ {
BOOL ret_ok; BOOL ret_ok;
enum exit_mode ret = EXIT_CONT;
#ifdef YYDEBUG #ifdef YYDEBUG
yydebug = 0; yydebug = 0;
#endif #endif
yyin = stdin; yyin = stdin;
DEBUG_ExitMode = EXIT_CONTINUE;
ret_ok = FALSE; ret_ok = FALSE;
do { do {
__TRY { __TRY {
ret_ok = TRUE; ret_ok = TRUE;
if ((ret = yyparse())) { yyparse();
DEBUG_FlushSymbols();
}
} __EXCEPT(wine_dbg_cmd) { } __EXCEPT(wine_dbg_cmd) {
ret_ok = FALSE; ret_ok = FALSE;
} }
__ENDTRY; __ENDTRY;
DEBUG_FlushSymbols();
} while (!ret_ok); } while (!ret_ok);
return ret;
} }
int yyerror(char* s) int yyerror(char* s)
......
...@@ -126,7 +126,6 @@ typedef struct wine_locals WineLocals; ...@@ -126,7 +126,6 @@ typedef struct wine_locals WineLocals;
enum exec_mode enum exec_mode
{ {
EXEC_CONT, /* Continuous execution */ EXEC_CONT, /* Continuous execution */
EXEC_PASS, /* Continue, passing exception to app */
EXEC_STEP_OVER, /* Stepping over a call to next source line */ EXEC_STEP_OVER, /* Stepping over a call to next source line */
EXEC_STEP_INSTR, /* Step to next source line, stepping in if needed */ EXEC_STEP_INSTR, /* Step to next source line, stepping in if needed */
EXEC_STEPI_OVER, /* Stepping over a call */ EXEC_STEPI_OVER, /* Stepping over a call */
...@@ -139,6 +138,19 @@ enum exec_mode ...@@ -139,6 +138,19 @@ enum exec_mode
*/ */
}; };
enum dbg_mode
{
MODE_INVALID, MODE_16, MODE_32, MODE_VM86
};
enum exit_mode /* of exception handling */
{
EXIT_CONTINUE, /* continue execution */
EXIT_PASS, /* pass exception back to app (1st chance) */
EXIT_DETACH, /* detach debugger */
EXIT_QUIT, /* exit debugger and kill debuggee */
};
#define DBG_BREAK 0 #define DBG_BREAK 0
#define DBG_WATCH 1 #define DBG_WATCH 1
...@@ -165,17 +177,6 @@ typedef struct ...@@ -165,17 +177,6 @@ typedef struct
struct expr * condition; struct expr * condition;
} DBG_BREAKPOINT; } DBG_BREAKPOINT;
enum dbg_mode
{
MODE_INVALID, MODE_16, MODE_32, MODE_VM86
};
enum exit_mode
{
EXIT_CONT, EXIT_QUIT, EXIT_DETACH
};
/* Wine extension; Windows doesn't have a name for this code. This is an /* Wine extension; Windows doesn't have a name for this code. This is an
undocumented exception understood by MS VC debugger, allowing the program undocumented exception understood by MS VC debugger, allowing the program
to name a particular thread. Search google.com or deja.com for "0x406d1388" to name a particular thread. Search google.com or deja.com for "0x406d1388"
...@@ -198,9 +199,9 @@ typedef struct tagDBG_THREAD { ...@@ -198,9 +199,9 @@ typedef struct tagDBG_THREAD {
LPVOID start; LPVOID start;
LPVOID teb; LPVOID teb;
int wait_for_first_exception; int wait_for_first_exception;
enum dbg_mode dbg_mode; enum exec_mode exec_mode; /* mode the thread is run (step/run...) */
enum exec_mode dbg_exec_mode; int exec_count; /* count of mode operations */
int dbg_exec_count; enum dbg_mode dbg_mode; /* mode (VM86, 32bit, 16bit) */
DBG_BREAKPOINT stepOverBP; DBG_BREAKPOINT stepOverBP;
char name[9]; char name[9];
struct tagDBG_THREAD* next; struct tagDBG_THREAD* next;
...@@ -241,6 +242,7 @@ extern DWORD DEBUG_CurrTid; ...@@ -241,6 +242,7 @@ extern DWORD DEBUG_CurrTid;
extern DWORD DEBUG_CurrPid; extern DWORD DEBUG_CurrPid;
extern CONTEXT DEBUG_context; extern CONTEXT DEBUG_context;
extern BOOL DEBUG_interactiveP; extern BOOL DEBUG_interactiveP;
extern enum exit_mode DEBUG_ExitMode;
#define DEBUG_READ_MEM(addr, buf, len) \ #define DEBUG_READ_MEM(addr, buf, len) \
(ReadProcessMemory(DEBUG_CurrProcess->handle, (addr), (buf), (len), NULL)) (ReadProcessMemory(DEBUG_CurrProcess->handle, (addr), (buf), (len), NULL))
...@@ -294,10 +296,9 @@ extern void DEBUG_DelBreakpoint( int num ); ...@@ -294,10 +296,9 @@ extern void DEBUG_DelBreakpoint( int num );
extern void DEBUG_EnableBreakpoint( int num, BOOL enable ); extern void DEBUG_EnableBreakpoint( int num, BOOL enable );
extern void DEBUG_InfoBreakpoints(void); extern void DEBUG_InfoBreakpoints(void);
extern BOOL DEBUG_HandleTrap(void); extern BOOL DEBUG_HandleTrap(void);
extern BOOL DEBUG_ShouldContinue( DBG_ADDR *addr, DWORD code, enum exec_mode mode, extern BOOL DEBUG_ShouldContinue( DBG_ADDR* addr, DWORD code, int* count );
int * count );
extern void DEBUG_SuspendExecution( void ); extern void DEBUG_SuspendExecution( void );
extern enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count ); extern void DEBUG_RestartExecution( int count );
extern BOOL DEBUG_IsFctReturn(void); extern BOOL DEBUG_IsFctReturn(void);
extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp); extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp);
...@@ -305,7 +306,7 @@ extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp); ...@@ -305,7 +306,7 @@ extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp);
extern void DEBUG_Disasm( DBG_ADDR *addr, int display ); extern void DEBUG_Disasm( DBG_ADDR *addr, int display );
/* debugger/dbg.y */ /* debugger/dbg.y */
extern enum exit_mode DEBUG_Parser(void); extern void DEBUG_Parser(void);
extern void DEBUG_Exit( DWORD ); extern void DEBUG_Exit( DWORD );
/* debugger/debug.l */ /* debugger/debug.l */
......
...@@ -40,6 +40,7 @@ DWORD DEBUG_CurrTid; ...@@ -40,6 +40,7 @@ DWORD DEBUG_CurrTid;
DWORD DEBUG_CurrPid; DWORD DEBUG_CurrPid;
CONTEXT DEBUG_context; CONTEXT DEBUG_context;
BOOL DEBUG_interactiveP = FALSE; BOOL DEBUG_interactiveP = FALSE;
enum exit_mode DEBUG_ExitMode = EXIT_CONTINUE;
int curr_frame = 0; int curr_frame = 0;
static char* DEBUG_LastCmdLine = NULL; static char* DEBUG_LastCmdLine = NULL;
...@@ -242,8 +243,9 @@ static DBG_THREAD* DEBUG_AddThread(DBG_PROCESS* p, DWORD tid, ...@@ -242,8 +243,9 @@ static DBG_THREAD* DEBUG_AddThread(DBG_PROCESS* p, DWORD tid,
t->teb = teb; t->teb = teb;
t->process = p; t->process = p;
t->wait_for_first_exception = 0; t->wait_for_first_exception = 0;
t->dbg_exec_mode = EXEC_CONT; t->exec_mode = EXEC_CONT;
t->dbg_exec_count = 0; t->exec_count = 0;
sprintf(t->name, "%08lx", tid); sprintf(t->name, "%08lx", tid);
p->num_threads++; p->num_threads++;
...@@ -349,10 +351,8 @@ static BOOL DEBUG_ExceptionProlog(BOOL is_debug, BOOL force, DWORD code) ...@@ -349,10 +351,8 @@ static BOOL DEBUG_ExceptionProlog(BOOL is_debug, BOOL force, DWORD code)
DEBUG_LoadEntryPoints("Loading new modules symbols:\n"); DEBUG_LoadEntryPoints("Loading new modules symbols:\n");
if (!force && is_debug && if (!force && is_debug &&
DEBUG_ShouldContinue(&addr, DEBUG_ShouldContinue(&addr, code,
code, &DEBUG_CurrThread->exec_count))
DEBUG_CurrThread->dbg_exec_mode,
&DEBUG_CurrThread->dbg_exec_count))
return FALSE; return FALSE;
if ((newmode = DEBUG_GetSelectorType(addr.seg)) == MODE_INVALID) newmode = MODE_32; if ((newmode = DEBUG_GetSelectorType(addr.seg)) == MODE_INVALID) newmode = MODE_32;
...@@ -387,8 +387,8 @@ static BOOL DEBUG_ExceptionProlog(BOOL is_debug, BOOL force, DWORD code) ...@@ -387,8 +387,8 @@ static BOOL DEBUG_ExceptionProlog(BOOL is_debug, BOOL force, DWORD code)
} }
if (!is_debug || if (!is_debug ||
(DEBUG_CurrThread->dbg_exec_mode == EXEC_STEPI_OVER) || (DEBUG_CurrThread->exec_mode == EXEC_STEPI_OVER) ||
(DEBUG_CurrThread->dbg_exec_mode == EXEC_STEPI_INSTR)) { (DEBUG_CurrThread->exec_mode == EXEC_STEPI_INSTR)) {
struct list_id list; struct list_id list;
...@@ -403,30 +403,27 @@ static BOOL DEBUG_ExceptionProlog(BOOL is_debug, BOOL force, DWORD code) ...@@ -403,30 +403,27 @@ static BOOL DEBUG_ExceptionProlog(BOOL is_debug, BOOL force, DWORD code)
return TRUE; return TRUE;
} }
static DWORD DEBUG_ExceptionEpilog(void) static void DEBUG_ExceptionEpilog(void)
{ {
DEBUG_CurrThread->dbg_exec_mode = DEBUG_RestartExecution(DEBUG_CurrThread->dbg_exec_mode, DEBUG_RestartExecution(DEBUG_CurrThread->exec_count);
DEBUG_CurrThread->dbg_exec_count);
/* /*
* This will have gotten absorbed into the breakpoint info * This will have gotten absorbed into the breakpoint info
* if it was used. Otherwise it would have been ignored. * if it was used. Otherwise it would have been ignored.
* In any case, we don't mess with it any more. * In any case, we don't mess with it any more.
*/ */
if (DEBUG_CurrThread->dbg_exec_mode == EXEC_CONT || DEBUG_CurrThread->dbg_exec_mode == EXEC_PASS) if (DEBUG_CurrThread->exec_mode == EXEC_CONT)
DEBUG_CurrThread->dbg_exec_count = 0; DEBUG_CurrThread->exec_count = 0;
return (DEBUG_CurrThread->dbg_exec_mode == EXEC_PASS) ? DBG_EXCEPTION_NOT_HANDLED : DBG_CONTINUE;
} }
static enum exit_mode DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_chance, BOOL force, LPDWORD cont) static void DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_chance, BOOL force)
{ {
BOOL is_debug = FALSE; BOOL is_debug = FALSE;
enum exit_mode ret = EXIT_CONT;
THREADNAME_INFO *pThreadName; THREADNAME_INFO *pThreadName;
DBG_THREAD *pThread; DBG_THREAD *pThread;
assert(DEBUG_CurrThread);
*cont = DBG_CONTINUE; DEBUG_ExitMode = EXIT_CONTINUE;
switch (rec->ExceptionCode) switch (rec->ExceptionCode)
{ {
...@@ -446,14 +443,14 @@ static enum exit_mode DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_ch ...@@ -446,14 +443,14 @@ static enum exit_mode DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_ch
DEBUG_Printf (DBG_CHN_MESG, DEBUG_Printf (DBG_CHN_MESG,
"Thread ID=0x%lx renamed using MS VC6 extension (name==\"%s\")\n", "Thread ID=0x%lx renamed using MS VC6 extension (name==\"%s\")\n",
pThread->tid, pThread->name); pThread->tid, pThread->name);
return EXIT_CONT; return;
} }
if (first_chance && !is_debug && !force && !DBG_IVAR(BreakOnFirstChance)) if (first_chance && !is_debug && !force && !DBG_IVAR(BreakOnFirstChance))
{ {
/* pass exception to program except for debug exceptions */ /* pass exception to program except for debug exceptions */
*cont = is_debug ? DBG_CONTINUE : DBG_EXCEPTION_NOT_HANDLED; if (!is_debug) DEBUG_ExitMode = EXIT_PASS;
return EXIT_CONT; return;
} }
if (!is_debug) if (!is_debug)
...@@ -511,7 +508,7 @@ static enum exit_mode DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_ch ...@@ -511,7 +508,7 @@ static enum exit_mode DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_ch
if (!DBG_IVAR(BreakOnCritSectTimeOut)) if (!DBG_IVAR(BreakOnCritSectTimeOut))
{ {
DEBUG_Printf(DBG_CHN_MESG, "\n"); DEBUG_Printf(DBG_CHN_MESG, "\n");
return EXIT_CONT; return;
} }
break; break;
case EXCEPTION_WINE_STUB: case EXCEPTION_WINE_STUB:
...@@ -548,27 +545,32 @@ static enum exit_mode DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_ch ...@@ -548,27 +545,32 @@ static enum exit_mode DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_ch
#else #else
0L, 0L, 0L, 0L,
#endif #endif
DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count); DEBUG_CurrThread->exec_mode, DEBUG_CurrThread->exec_count);
#endif #endif
if (automatic_mode) if (automatic_mode)
{ {
DEBUG_ExceptionProlog(is_debug, FALSE, rec->ExceptionCode); DEBUG_ExceptionProlog(is_debug, FALSE, rec->ExceptionCode);
return EXIT_QUIT; /* terminate execution */ DEBUG_ExitMode = EXIT_QUIT;
return; /* terminate execution */
} }
if (DEBUG_ExceptionProlog(is_debug, force, rec->ExceptionCode)) { if (DEBUG_ExceptionProlog(is_debug, force, rec->ExceptionCode)) {
DEBUG_interactiveP = TRUE; DEBUG_interactiveP = TRUE;
while ((ret = DEBUG_Parser()) == EXIT_CONT) { for (;;)
{
DEBUG_Parser();
if (DEBUG_ExitMode == EXIT_QUIT || DEBUG_ExitMode == EXIT_DETACH)
break;
if (DEBUG_ValidateRegisters()) { if (DEBUG_ValidateRegisters()) {
if (DEBUG_CurrThread->dbg_exec_mode != EXEC_PASS || first_chance) if (DEBUG_ExitMode == EXIT_PASS || first_chance)
break; break;
DEBUG_Printf(DBG_CHN_MESG, "Cannot pass on last chance exception. You must use cont\n"); DEBUG_Printf(DBG_CHN_MESG, "Cannot pass on last chance exception. You must use cont\n");
} }
} }
DEBUG_interactiveP = FALSE; DEBUG_interactiveP = FALSE;
} }
*cont = DEBUG_ExceptionEpilog(); DEBUG_ExceptionEpilog();
#if 0 #if 0
DEBUG_Printf(DBG_CHN_TRACE, DEBUG_Printf(DBG_CHN_TRACE,
...@@ -578,24 +580,19 @@ static enum exit_mode DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_ch ...@@ -578,24 +580,19 @@ static enum exit_mode DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_ch
#else #else
0L, 0L, 0L, 0L,
#endif #endif
DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count); DEBUG_CurrThread->exec_mode, DEBUG_CurrThread->exec_count);
#endif #endif
return ret;
} }
static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de, LPDWORD cont) static void DEBUG_HandleDebugEvent(DEBUG_EVENT* de)
{ {
char buffer[256]; char buffer[256];
enum exit_mode ret;
DEBUG_CurrPid = de->dwProcessId; DEBUG_CurrPid = de->dwProcessId;
DEBUG_CurrTid = de->dwThreadId; DEBUG_CurrTid = de->dwThreadId;
DEBUG_ExitMode = EXIT_CONTINUE;
__TRY { __TRY {
ret = EXIT_CONT;
*cont = 0L;
if ((DEBUG_CurrProcess = DEBUG_GetProcess(de->dwProcessId)) != NULL) if ((DEBUG_CurrProcess = DEBUG_GetProcess(de->dwProcessId)) != NULL)
DEBUG_CurrThread = DEBUG_GetThread(DEBUG_CurrProcess, de->dwThreadId); DEBUG_CurrThread = DEBUG_GetThread(DEBUG_CurrProcess, de->dwThreadId);
else else
...@@ -616,7 +613,6 @@ static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de, LPDWORD cont) ...@@ -616,7 +613,6 @@ static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de, LPDWORD cont)
if (DEBUG_CurrProcess->continue_on_first_exception) { if (DEBUG_CurrProcess->continue_on_first_exception) {
DEBUG_CurrProcess->continue_on_first_exception = FALSE; DEBUG_CurrProcess->continue_on_first_exception = FALSE;
if (!DBG_IVAR(BreakOnAttach)) { if (!DBG_IVAR(BreakOnAttach)) {
*cont = DBG_CONTINUE;
break; break;
} }
} }
...@@ -636,10 +632,9 @@ static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de, LPDWORD cont) ...@@ -636,10 +632,9 @@ static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de, LPDWORD cont)
break; break;
} }
ret = DEBUG_HandleException(&de->u.Exception.ExceptionRecord, DEBUG_HandleException(&de->u.Exception.ExceptionRecord,
de->u.Exception.dwFirstChance, de->u.Exception.dwFirstChance,
DEBUG_CurrThread->wait_for_first_exception, DEBUG_CurrThread->wait_for_first_exception);
cont);
if (DEBUG_CurrThread) { if (DEBUG_CurrThread) {
DEBUG_CurrThread->wait_for_first_exception = 0; DEBUG_CurrThread->wait_for_first_exception = 0;
SetThreadContext(DEBUG_CurrThread->handle, &DEBUG_context); SetThreadContext(DEBUG_CurrThread->handle, &DEBUG_context);
...@@ -793,7 +788,7 @@ static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de, LPDWORD cont) ...@@ -793,7 +788,7 @@ static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de, LPDWORD cont)
if (DBG_IVAR(BreakOnDllLoad)) { if (DBG_IVAR(BreakOnDllLoad)) {
DEBUG_Printf(DBG_CHN_MESG, "Stopping on DLL %s loading at %08lx\n", DEBUG_Printf(DBG_CHN_MESG, "Stopping on DLL %s loading at %08lx\n",
buffer, (unsigned long)de->u.LoadDll.lpBaseOfDll); buffer, (unsigned long)de->u.LoadDll.lpBaseOfDll);
ret = DEBUG_Parser(); DEBUG_Parser();
} }
break; break;
...@@ -829,38 +824,42 @@ static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de, LPDWORD cont) ...@@ -829,38 +824,42 @@ static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de, LPDWORD cont)
} }
} __EXCEPT(wine_dbg) { } __EXCEPT(wine_dbg) {
*cont = 0; DEBUG_ExitMode = EXIT_CONTINUE;
ret = EXIT_CONT;
} }
__ENDTRY; __ENDTRY;
return ret;
} }
static DWORD DEBUG_MainLoop(void) static DWORD DEBUG_MainLoop(void)
{ {
DEBUG_EVENT de; DEBUG_EVENT de;
DWORD cont;
enum exit_mode ret = EXIT_CONT;
DEBUG_Printf(DBG_CHN_MESG, " on pid %lx\n", DEBUG_CurrPid); DEBUG_Printf(DBG_CHN_MESG, " on pid %lx\n", DEBUG_CurrPid);
while (ret == EXIT_CONT) while (DEBUG_ExitMode == EXIT_CONTINUE)
{ {
/* wait until we get at least one loaded process */ /* wait until we get at least one loaded process */
while (!DEBUG_ProcessList && (ret = DEBUG_Parser()) == EXIT_CONT); while (!DEBUG_ProcessList)
if (ret != EXIT_CONT) break; {
DEBUG_Parser();
if (DEBUG_ExitMode == EXIT_CONTINUE || DEBUG_ExitMode == EXIT_QUIT) break;
}
if (DEBUG_ExitMode != EXIT_CONTINUE) break;
while (ret == EXIT_CONT && DEBUG_ProcessList && WaitForDebugEvent(&de, INFINITE)) { while ((DEBUG_ExitMode == EXIT_CONTINUE || DEBUG_ExitMode == EXIT_PASS) &&
ret = DEBUG_HandleDebugEvent(&de, &cont); DEBUG_ProcessList &&
ContinueDebugEvent(de.dwProcessId, de.dwThreadId, cont); WaitForDebugEvent(&de, INFINITE))
{
DEBUG_HandleDebugEvent(&de);
ContinueDebugEvent(de.dwProcessId, de.dwThreadId,
(DEBUG_ExitMode == EXIT_PASS) ? DBG_EXCEPTION_NOT_HANDLED : DBG_CONTINUE);
} }
if (ret == EXIT_DETACH && DEBUG_Detach()) if (DEBUG_ExitMode == EXIT_DETACH && DEBUG_Detach())
{ {
/* ret = EXIT_CONT; */ /* DEBUG_ExitMode = EXIT_CONTINUE; */
/* FIXME: as we don't have a simple way to zero out the process symbol table /* FIXME: as we don't have a simple way to zero out the process symbol table
* we simply quit the debugger on detach... * we simply quit the debugger on detach...
*/ */
ret = EXIT_QUIT; DEBUG_ExitMode = EXIT_QUIT;
} }
} }
...@@ -872,15 +871,16 @@ static DWORD DEBUG_MainLoop(void) ...@@ -872,15 +871,16 @@ static DWORD DEBUG_MainLoop(void)
static DWORD DEBUG_AutoMode(void) static DWORD DEBUG_AutoMode(void)
{ {
DEBUG_EVENT de; DEBUG_EVENT de;
DWORD cont;
enum exit_mode ret = EXIT_CONT;
DEBUG_Printf(DBG_CHN_MESG, " on pid %lx\n", DEBUG_CurrPid); DEBUG_Printf(DBG_CHN_MESG, " on pid %lx\n", DEBUG_CurrPid);
while (ret == EXIT_CONT && DEBUG_ProcessList && WaitForDebugEvent(&de, INFINITE)) while ((DEBUG_ExitMode == EXIT_CONTINUE || DEBUG_ExitMode == EXIT_PASS) &&
DEBUG_ProcessList &&
WaitForDebugEvent(&de, INFINITE))
{ {
ret = DEBUG_HandleDebugEvent(&de, &cont); DEBUG_HandleDebugEvent(&de);
ContinueDebugEvent(de.dwProcessId, de.dwThreadId, cont); ContinueDebugEvent(de.dwProcessId, de.dwThreadId,
(DEBUG_ExitMode == EXIT_PASS) ? DBG_EXCEPTION_NOT_HANDLED : DBG_CONTINUE);
} }
/* print some extra information */ /* print some extra information */
DEBUG_Printf(DBG_CHN_MESG, "Modules:\n"); DEBUG_Printf(DBG_CHN_MESG, "Modules:\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment