3 * Parser for command lines in the Wine debugger
5 * Copyright 1993 Eric Youngdale
6 * Copyright 1995 Morten Welinder
7 * Copyright 2000 Eric Pouech
20 #include "wine/exception.h"
25 static void issue_prompt
(void);
26 static void mode_command
(int);
27 void flush_symbols
(void);
39 struct list_id listing
;
40 struct expr
* expression
;
41 struct datatype
* type
;
44 %token tCONT tPASS tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
45 %token tENABLE tDISABLE tBREAK tWATCH tDELETE tSET tMODE tPRINT tEXAM tABORT
46 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
47 %token tPROCESS tMODREF
48 %token tEOL tSTRING tDEBUGSTR
49 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
50 %token tSTEPI tNEXTI tFINISH tSHOW tDIR tWHATIS
52 %token
<string> tIDENTIFIER tSTRING tDEBUGSTR
53 %token
<integer
> tNUM tFORMAT
57 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
58 %token tSTRUCT tUNION tENUM
61 /* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
62 OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
63 OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
64 /* %left OP_COND */ /* ... ? ... : ... */
71 %left
'<' '>' OP_LE OP_GE
75 %left OP_SIGN
'!' '~' OP_DEREF
/* OP_INC OP_DEC OP_ADDR */
79 %type
<expression
> expr lval lvalue
80 %type
<type
> type_cast type_expr
81 %type
<value
> expr_addr lval_addr
82 %type
<integer
> expr_value
83 %type
<string> pathname
85 %type
<listing
> list_arg
89 input: line
{ issue_prompt
(); }
90 | input line
{ issue_prompt
(); }
94 |
error tEOL
{ yyerrok; }
97 tQUIT tEOL
{ DEBUG_Exit
(0); }
98 | tHELP tEOL
{ DEBUG_Help
(); }
99 | tHELP tINFO tEOL
{ DEBUG_HelpInfo
(); }
100 | tCONT tEOL
{ DEBUG_CurrThread
->dbg_exec_count
= 1;
101 DEBUG_CurrThread
->dbg_exec_mode
= EXEC_CONT
; return
0; }
102 | tPASS tEOL
{ DEBUG_CurrThread
->dbg_exec_count
= 1;
103 DEBUG_CurrThread
->dbg_exec_mode
= EXEC_PASS
; return
0; }
104 | tCONT tNUM tEOL
{ DEBUG_CurrThread
->dbg_exec_count
= $2;
105 DEBUG_CurrThread
->dbg_exec_mode
= EXEC_CONT
; return
0; }
106 | tSTEP tEOL
{ DEBUG_CurrThread
->dbg_exec_count
= 1;
107 DEBUG_CurrThread
->dbg_exec_mode
= EXEC_STEP_INSTR
; return
0; }
108 | tNEXT tEOL
{ DEBUG_CurrThread
->dbg_exec_count
= 1;
109 DEBUG_CurrThread
->dbg_exec_mode
= EXEC_STEP_OVER
; return
0; }
110 | tSTEP tNUM tEOL
{ DEBUG_CurrThread
->dbg_exec_count
= $2;
111 DEBUG_CurrThread
->dbg_exec_mode
= EXEC_STEP_INSTR
; return
0; }
112 | tNEXT tNUM tEOL
{ DEBUG_CurrThread
->dbg_exec_count
= $2;
113 DEBUG_CurrThread
->dbg_exec_mode
= EXEC_STEP_OVER
; return
0; }
114 | tSTEPI tEOL
{ DEBUG_CurrThread
->dbg_exec_count
= 1;
115 DEBUG_CurrThread
->dbg_exec_mode
= EXEC_STEPI_INSTR
; return
0; }
116 | tNEXTI tEOL
{ DEBUG_CurrThread
->dbg_exec_count
= 1;
117 DEBUG_CurrThread
->dbg_exec_mode
= EXEC_STEPI_OVER
; return
0; }
118 | tSTEPI tNUM tEOL
{ DEBUG_CurrThread
->dbg_exec_count
= $2;
119 DEBUG_CurrThread
->dbg_exec_mode
= EXEC_STEPI_INSTR
; return
0; }
120 | tNEXTI tNUM tEOL
{ DEBUG_CurrThread
->dbg_exec_count
= $2;
121 DEBUG_CurrThread
->dbg_exec_mode
= EXEC_STEPI_OVER
; return
0; }
122 | tABORT tEOL
{ kill
(getpid
(), SIGABRT
); }
123 | tMODE tNUM tEOL
{ mode_command
($2); }
124 | tENABLE tNUM tEOL
{ DEBUG_EnableBreakpoint
( $2, TRUE
); }
125 | tDISABLE tNUM tEOL
{ DEBUG_EnableBreakpoint
( $2, FALSE
); }
126 | tDELETE tBREAK tNUM tEOL
{ DEBUG_DelBreakpoint
( $3 ); }
127 | tBACKTRACE tEOL
{ DEBUG_BackTrace
(TRUE
); }
128 | tUP tEOL
{ DEBUG_SetFrame
( curr_frame
+ 1 ); }
129 | tUP tNUM tEOL
{ DEBUG_SetFrame
( curr_frame
+ $2 ); }
130 | tDOWN tEOL
{ DEBUG_SetFrame
( curr_frame
- 1 ); }
131 | tDOWN tNUM tEOL
{ DEBUG_SetFrame
( curr_frame
- $2 ); }
132 | tFRAME tNUM tEOL
{ DEBUG_SetFrame
( $2 ); }
133 | tFINISH tEOL
{ DEBUG_CurrThread
->dbg_exec_count
= 0;
134 DEBUG_CurrThread
->dbg_exec_mode
= EXEC_FINISH
; return
0; }
135 | tSHOW tDIR tEOL
{ DEBUG_ShowDir
(); }
136 | tDIR pathname tEOL
{ DEBUG_AddPath
( $2 ); }
137 | tDIR tEOL
{ DEBUG_NukePath
(); }
138 | tDISPLAY tEOL
{ DEBUG_InfoDisplay
(); }
139 | tDISPLAY expr tEOL
{ DEBUG_AddDisplay
($2, 1, 0); }
140 | tDISPLAY tFORMAT expr tEOL
{ DEBUG_AddDisplay
($3, $2 >> 8, $2 & 0xff); }
141 | tDELETE tDISPLAY tNUM tEOL
{ DEBUG_DelDisplay
( $3 ); }
142 | tDELETE tDISPLAY tEOL
{ DEBUG_DelDisplay
( -1 ); }
143 | tUNDISPLAY tNUM tEOL
{ DEBUG_DelDisplay
( $2 ); }
144 | tUNDISPLAY tEOL
{ DEBUG_DelDisplay
( -1 ); }
145 | tCOND tNUM tEOL
{ DEBUG_AddBPCondition
($2, NULL
); }
146 | tCOND tNUM expr tEOL
{ DEBUG_AddBPCondition
($2, $3); }
147 | tSYMBOLFILE pathname tEOL
{ DEBUG_ReadSymbolTable
($2); }
148 | tWHATIS expr_addr tEOL
{ DEBUG_PrintType
(&$2); DEBUG_FreeExprMem
(); }
150 | disassemble_command
160 tSET tREG
'=' expr_value tEOL
{ DEBUG_SetRegister
( $2, $4 );
161 DEBUG_FreeExprMem
(); }
162 | tSET lval_addr
'=' expr_value tEOL
{ DEBUG_WriteMemory
( &$2.addr
, $4 );
163 DEBUG_FreeExprMem
(); }
166 tIDENTIFIER
{ $$
= $1; }
170 tDISASSEMBLE tEOL
{ DEBUG_Disassemble
( NULL
, NULL
, 10 ); }
171 | tDISASSEMBLE expr_addr tEOL
{ DEBUG_Disassemble
( & $2, NULL
, 10 ); }
172 | tDISASSEMBLE expr_addr
',' expr_addr tEOL
{ DEBUG_Disassemble
( & $2, & $4, 0 ); }
175 tLIST tEOL
{ DEBUG_List
( NULL
, NULL
, 10 ); }
176 | tLIST
'-' tEOL
{ DEBUG_List
( NULL
, NULL
, -10 ); }
177 | tLIST list_arg tEOL
{ DEBUG_List
( & $2, NULL
, 10 ); }
178 | tLIST
',' list_arg tEOL
{ DEBUG_List
( NULL
, & $3, -10 ); }
179 | tLIST list_arg
',' list_arg tEOL
{ DEBUG_List
( & $2, & $4, 0 ); }
182 tNUM
{ $$.sourcefile
= NULL
; $$.line
= $1; }
183 | pathname
':' tNUM
{ $$.sourcefile
= $1; $$.line
= $3; }
184 | tIDENTIFIER
{ DEBUG_GetFuncInfo
( & $$
, NULL
, $1); }
185 | pathname
':' tIDENTIFIER
{ DEBUG_GetFuncInfo
( & $$
, $1, $3); }
186 |
'*' expr_addr
{ DEBUG_FindNearestSymbol
( & $2.addr
, FALSE
, NULL
,
188 DEBUG_FreeExprMem
(); }
191 tEXAM expr_addr tEOL
{ DEBUG_ExamineMemory
( &$2, 1, 'x');
192 DEBUG_FreeExprMem
(); }
193 | tEXAM tFORMAT expr_addr tEOL
{ DEBUG_ExamineMemory
( &$3, $2>>8, $2&0xff );
194 DEBUG_FreeExprMem
(); }
197 tPRINT expr_addr tEOL
{ DEBUG_Print
( &$2, 1, 0, 0 );
198 DEBUG_FreeExprMem
(); }
199 | tPRINT tFORMAT expr_addr tEOL
{ DEBUG_Print
( &$3, $2 >> 8, $2 & 0xff, 0 );
200 DEBUG_FreeExprMem
(); }
203 tBREAK
'*' expr_addr tEOL
{ DEBUG_AddBreakpoint
( &$3 );
204 DEBUG_FreeExprMem
(); }
205 | tBREAK tIDENTIFIER tEOL
{ DBG_VALUE value
;
206 if
( DEBUG_GetSymbolValue
($2, -1, &value
, TRUE
) )
208 DEBUG_AddBreakpoint
( &value
);
212 fprintf
(stderr
,"Unable to add breakpoint\n");
215 | tBREAK tIDENTIFIER
':' tNUM tEOL
{ DBG_VALUE value
;
216 if
( DEBUG_GetSymbolValue
($2, $4, &value
, TRUE
) )
218 DEBUG_AddBreakpoint
( &value
);
222 fprintf
(stderr
,"Unable to add breakpoint\n");
225 | tBREAK tNUM tEOL
{ struct name_hash
*nh
;
227 DEBUG_GetCurrentAddress
( &value.addr
);
228 DEBUG_FindNearestSymbol
(&value.addr
, TRUE
,
232 DEBUG_GetLineNumberAddr
(nh
, $2, &value.addr
, TRUE
);
234 value.cookie
= DV_TARGET
;
235 DEBUG_AddBreakpoint
( &value
);
239 fprintf
(stderr
,"Unable to add breakpoint\n");
243 | tBREAK tEOL
{ DBG_VALUE value
;
244 DEBUG_GetCurrentAddress
( &value.addr
);
246 value.cookie
= DV_TARGET
;
247 DEBUG_AddBreakpoint
( &value
);
251 tWATCH
'*' expr_addr tEOL
{ DEBUG_AddWatchpoint
( &$3, 1 );
252 DEBUG_FreeExprMem
(); }
253 | tWATCH tIDENTIFIER tEOL
{ DBG_VALUE value
;
254 if
( DEBUG_GetSymbolValue
($2, -1, &value
, TRUE
) )
255 DEBUG_AddWatchpoint
( &value
, 1 );
257 fprintf
(stderr
,"Unable to add breakpoint\n");
261 tINFO tBREAK tEOL
{ DEBUG_InfoBreakpoints
(); }
262 | tINFO tCLASS tSTRING tEOL
{ DEBUG_InfoClass
( $3 ); DEBUG_FreeExprMem
(); }
263 | tINFO tSHARE tEOL
{ DEBUG_InfoShare
(); }
264 | tINFO tMODULE expr_value tEOL
{ DEBUG_DumpModule
( $3 ); DEBUG_FreeExprMem
(); }
265 | tINFO tQUEUE expr_value tEOL
{ DEBUG_DumpQueue
( $3 ); DEBUG_FreeExprMem
(); }
266 | tINFO tREGS tEOL
{ DEBUG_InfoRegisters
(); }
267 | tINFO tSEGMENTS expr_value tEOL
{ DEBUG_InfoSegments
( $3, 1 ); DEBUG_FreeExprMem
(); }
268 | tINFO tSEGMENTS tEOL
{ DEBUG_InfoSegments
( 0, -1 ); }
269 | tINFO tSTACK tEOL
{ DEBUG_InfoStack
(); }
270 | tINFO tMAPS tEOL
{ DEBUG_InfoVirtual
(); }
271 | tINFO tWND expr_value tEOL
{ DEBUG_InfoWindow
( (HWND
)$3 );
272 DEBUG_FreeExprMem
(); }
273 | tINFO tLOCAL tEOL
{ DEBUG_InfoLocals
(); }
274 | tINFO tDISPLAY tEOL
{ DEBUG_InfoDisplay
(); }
277 tWALK tCLASS tEOL
{ DEBUG_WalkClasses
(); }
278 | tWALK tMODULE tEOL
{ DEBUG_WalkModules
(); }
279 | tWALK tQUEUE tEOL
{ DEBUG_WalkQueues
(); }
280 | tWALK tWND tEOL
{ DEBUG_WalkWindows
( 0, 0 ); }
281 | tWALK tWND tNUM tEOL
{ DEBUG_WalkWindows
( $3, 0 ); }
282 | tWALK tPROCESS tEOL
{ DEBUG_WalkProcess
(); }
283 | tWALK tMODREF expr_value tEOL
{ DEBUG_WalkModref
( $3 ); }
287 '(' type_expr
')' { $$
= $2; }
290 type_expr
'*' { $$
= DEBUG_FindOrMakePointerType
($1); }
291 | tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "int"); }
292 | tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "char"); }
293 | tLONG tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long int"); }
294 | tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "unsigned int"); }
295 | tLONG tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long unsigned int"); }
296 | tLONG tLONG tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long long int"); }
297 | tLONG tLONG tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long long unsigned int"); }
298 | tSHORT tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "short int"); }
299 | tSHORT tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "short unsigned int"); }
300 | tSIGNED tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "signed char"); }
301 | tUNSIGNED tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "unsigned char"); }
302 | tFLOAT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "float"); }
303 | tDOUBLE
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "double"); }
304 | tLONG tDOUBLE
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long double"); }
305 | tSTRUCT tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_STRUCT
, $2); }
306 | tUNION tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_STRUCT
, $2); }
307 | tENUM tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_ENUM
, $2); }
310 expr
{ $$
= DEBUG_EvalExpr
($1); }
313 expr
{ DBG_VALUE value
= DEBUG_EvalExpr
($1);
314 /* expr_value is typed as an integer */
315 if
(!value.addr.off ||
316 !DEBUG_READ_MEM
((void*)value.addr.off
, &$$
, sizeof
($$
)))
319 * The expr rule builds an expression tree. When we are done, we call
320 * EvalExpr to evaluate the value of the expression. The advantage of
321 * the two-step approach is that it is possible to save expressions for
322 * use in 'display' commands, and in conditional watchpoints.
325 tNUM
{ $$
= DEBUG_ConstExpr
($1); }
326 | tSTRING
{ $$
= DEBUG_StringExpr
($1); }
327 | tREG
{ $$
= DEBUG_RegisterExpr
($1); }
328 | tIDENTIFIER
{ $$
= DEBUG_SymbolExpr
($1); }
329 | expr OP_DRF tIDENTIFIER
{ $$
= DEBUG_StructPExpr
($1, $3); }
330 | expr
'.' tIDENTIFIER
{ $$
= DEBUG_StructExpr
($1, $3); }
331 | tIDENTIFIER
'(' ')' { $$
= DEBUG_CallExpr
($1, 0); }
332 | tIDENTIFIER
'(' expr
')' { $$
= DEBUG_CallExpr
($1, 1, $3); }
333 | tIDENTIFIER
'(' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 2, $3, $5); }
334 | tIDENTIFIER
'(' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7); }
335 | tIDENTIFIER
'(' expr
',' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7, $9); }
336 | tIDENTIFIER
'(' expr
',' expr
',' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7, $9, $11); }
337 | expr
'[' expr
']' { $$
= DEBUG_BinopExpr
(EXP_OP_ARR
, $1, $3); }
338 | expr
':' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SEG
, $1, $3); }
339 | expr OP_LOR expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LOR
, $1, $3); }
340 | expr OP_LAND expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LAND
, $1, $3); }
341 | expr
'|' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_OR
, $1, $3); }
342 | expr
'&' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_AND
, $1, $3); }
343 | expr
'^' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_XOR
, $1, $3); }
344 | expr OP_EQ expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_EQ
, $1, $3); }
345 | expr
'>' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_GT
, $1, $3); }
346 | expr
'<' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LT
, $1, $3); }
347 | expr OP_GE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_GE
, $1, $3); }
348 | expr OP_LE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LE
, $1, $3); }
349 | expr OP_NE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_NE
, $1, $3); }
350 | expr OP_SHL expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SHL
, $1, $3); }
351 | expr OP_SHR expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SHR
, $1, $3); }
352 | expr
'+' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_ADD
, $1, $3); }
353 | expr
'-' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SUB
, $1, $3); }
354 | expr
'*' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_MUL
, $1, $3); }
355 | expr
'/' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_DIV
, $1, $3); }
356 | expr
'%' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_REM
, $1, $3); }
357 |
'-' expr %prec OP_SIGN
{ $$
= DEBUG_UnopExpr
(EXP_OP_NEG
, $2); }
358 |
'+' expr %prec OP_SIGN
{ $$
= $2; }
359 |
'!' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_NOT
, $2); }
360 |
'~' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_LNOT
, $2); }
361 |
'(' expr
')' { $$
= $2; }
362 |
'*' expr %prec OP_DEREF
{ $$
= DEBUG_UnopExpr
(EXP_OP_DEREF
, $2); }
363 |
'&' expr %prec OP_DEREF
{ $$
= DEBUG_UnopExpr
(EXP_OP_ADDR
, $2); }
364 | type_cast expr %prec OP_DEREF
{ $$
= DEBUG_TypeCastExpr
($1, $2); }
367 * The lvalue rule builds an expression tree. This is a limited form
368 * of expression that is suitable to be used as an lvalue.
371 lval
{ $$
= DEBUG_EvalExpr
($1); }
375 |
'*' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_FORCE_DEREF
, $2); }
378 tNUM
{ $$
= DEBUG_ConstExpr
($1); }
379 | tREG
{ $$
= DEBUG_RegisterExpr
($1); }
380 | tIDENTIFIER
{ $$
= DEBUG_SymbolExpr
($1); }
381 | lvalue OP_DRF tIDENTIFIER
{ $$
= DEBUG_StructPExpr
($1, $3); }
382 | lvalue
'.' tIDENTIFIER
{ $$
= DEBUG_StructExpr
($1, $3); }
383 | lvalue
'[' expr
']' { $$
= DEBUG_BinopExpr
(EXP_OP_ARR
, $1, $3); }
387 static void issue_prompt
(void)
389 #ifdef DONT_USE_READLINE
390 fprintf
(stderr
, "Wine-dbg>");
394 static void mode_command
(int newmode
)
396 if
((newmode
== 16) ||
(newmode
== 32)) DEBUG_CurrThread
->dbg_mode
= newmode
;
397 else fprintf
(stderr
,"Invalid mode (use 16 or 32)\n");
400 static WINE_EXCEPTION_FILTER
(wine_dbg
)
402 switch
(GetExceptionCode
()) {
403 case DEBUG_STATUS_INTERNAL_ERROR
:
404 fprintf
(stderr
, "WineDbg internal error\n");
406 case DEBUG_STATUS_NO_SYMBOL
:
407 fprintf
(stderr
, "Undefined symbol\n");
409 case DEBUG_STATUS_DIV_BY_ZERO
:
410 fprintf
(stderr
, "Division by zero\n");
412 case DEBUG_STATUS_BAD_TYPE
:
413 fprintf
(stderr
, "No type or type mismatch\n");
416 fprintf
(stderr
, "Exception %lx\n", GetExceptionCode
());
419 return EXCEPTION_EXECUTE_HANDLER
;
422 /***********************************************************************
425 * Kill current process.
428 void DEBUG_Exit
( DWORD exit_code
)
430 TASK_KillTask
( 0 ); /* FIXME: should not be necessary */
431 TerminateProcess
( DEBUG_CurrProcess
->handle
, exit_code
);
434 /***********************************************************************
437 * Debugger main loop.
439 BOOL DEBUG_Main
( BOOL is_debug
, BOOL force
, DWORD code
)
451 DEBUG_SuspendExecution
();
456 if
(DEBUG_IsSelectorSystem
(DEBUG_context.SegCs
))
457 fprintf
( stderr
, " in 32-bit code (0x%08lx).\n", DEBUG_context.Eip
);
459 fprintf
( stderr
, " in 16-bit code (%04x:%04lx).\n",
460 (WORD
)DEBUG_context.SegCs
, DEBUG_context.Eip
);
462 fprintf
( stderr
, " (%p).\n", GET_IP
(&DEBUG_context
) );
466 if
(DEBUG_LoadEntryPoints
("Loading new modules symbols:\n"))
467 DEBUG_ProcessDeferredDebug
();
469 if
(force ||
!(is_debug
&& DEBUG_ShouldContinue
( code
,
470 DEBUG_CurrThread
->dbg_exec_mode
,
471 &DEBUG_CurrThread
->dbg_exec_count
)))
474 DEBUG_GetCurrentAddress
( &addr
);
477 switch
(newmode
= DEBUG_GetSelectorType
(addr.seg
)) {
478 case
16: case
32: break
;
479 default
: fprintf
(stderr
, "Bad CS (%ld)\n", addr.seg
); newmode
= 32;
484 if
(newmode
!= DEBUG_CurrThread
->dbg_mode
)
485 fprintf
(stderr
,"In %d bit mode.\n", DEBUG_CurrThread
->dbg_mode
= newmode
);
489 if
(is_debug || force
)
492 * Do a quiet backtrace so that we have an idea of what the situation
493 * is WRT the source files.
495 DEBUG_BackTrace
(FALSE
);
499 /* This is a real crash, dump some info */
500 DEBUG_InfoRegisters
();
503 if
(DEBUG_CurrThread
->dbg_mode
== 16)
505 DEBUG_InfoSegments
( DEBUG_context.SegDs
>> 3, 1 );
506 if
(DEBUG_context.SegEs
!= DEBUG_context.SegDs
)
507 DEBUG_InfoSegments
( DEBUG_context.SegEs
>> 3, 1 );
509 DEBUG_InfoSegments
( DEBUG_context.SegFs
>> 3, 1 );
511 DEBUG_BackTrace
(TRUE
);
515 (DEBUG_CurrThread
->dbg_exec_mode
== EXEC_STEPI_OVER
) ||
516 (DEBUG_CurrThread
->dbg_exec_mode
== EXEC_STEPI_INSTR
))
518 /* Show where we crashed */
520 DEBUG_PrintAddress
( &addr
, DEBUG_CurrThread
->dbg_mode
, TRUE
);
521 fprintf
(stderr
,": ");
522 DEBUG_Disasm
( &addr
, TRUE
);
523 fprintf
( stderr
, "\n" );
535 DEBUG_GetCurrentAddress
( &addr
);
536 if
((ret_ok
= DEBUG_ValidateRegisters
()))
537 ret_ok
= DEBUG_READ_MEM_VERBOSE
((void*)DEBUG_ToLinear
( &addr
), &ch
, 1 );
548 DEBUG_CurrThread
->dbg_exec_mode
= DEBUG_RestartExecution
( DEBUG_CurrThread
->dbg_exec_mode
, DEBUG_CurrThread
->dbg_exec_count
);
550 * This will have gotten absorbed into the breakpoint info
551 * if it was used. Otherwise it would have been ignored.
552 * In any case, we don't mess with it any more.
554 if
((DEBUG_CurrThread
->dbg_exec_mode
== EXEC_CONT
) ||
(DEBUG_CurrThread
->dbg_exec_mode
== EXEC_PASS
))
555 DEBUG_CurrThread
->dbg_exec_count
= 0;
557 return
(DEBUG_CurrThread
->dbg_exec_mode
== EXEC_PASS
) ?
0 : DBG_CONTINUE
;
562 fprintf
(stderr
,"%s\n", s
);