3 * Parser for command lines in the Wine debugger
5 * Copyright 1993 Eric Youngdale
6 * Copyright 1995 Morten Welinder
27 #include "wine/winbase16.h"
40 unsigned int dbg_mode
= 0;
44 static enum exec_mode dbg_exec_mode
= EXEC_CONT
;
45 static int dbg_exec_count
= 0;
47 void issue_prompt
(void);
48 void mode_command
(int);
49 void flush_symbols
(void);
54 #define malloc(x) DBG_alloc(x)
55 #define realloc(x,y) DBG_realloc(x,y)
56 #define free(x) DBG_free(x)
59 extern
void VIRTUAL_Dump
(void); /* memory/virtual.c */
69 struct list_id listing
;
70 struct expr
* expression
;
71 struct datatype
* type
;
74 %token tCONT tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
75 %token tENABLE tDISABLE tBREAK tDELETE tSET tMODE tPRINT tEXAM tABORT tDEBUGMSG
76 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
77 %token tEOL tSTRING tDEBUGSTR
78 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
79 %token tSTEPI tNEXTI tFINISH tSHOW tDIR
81 %token
<string> tIDENTIFIER tSTRING tDEBUGSTR
82 %token
<integer
> tNUM tFORMAT
86 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
87 %token tSTRUCT tUNION tENUM
90 /* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
91 OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
92 OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
93 /* %left OP_COND */ /* ... ? ... : ... */
100 %left
'<' '>' OP_LE OP_GE
104 %left OP_SIGN
'!' '~' OP_DEREF
/* OP_INC OP_DEC OP_ADDR */
108 %type
<expression
> expr lval lvalue
109 %type
<type
> type_cast type_expr
110 %type
<address
> expr_addr lval_addr
111 %type
<integer
> expr_value
112 %type
<string> pathname
114 %type
<listing
> list_arg
118 input: line
{ issue_prompt
(); }
119 | input line
{ issue_prompt
(); }
123 |
error tEOL
{ yyerrok; }
126 tQUIT tEOL
{ exit
(0); }
127 | tHELP tEOL
{ DEBUG_Help
(); }
128 | tHELP tINFO tEOL
{ DEBUG_HelpInfo
(); }
129 | tCONT tEOL
{ dbg_exec_count
= 1;
130 dbg_exec_mode
= EXEC_CONT
; return
0; }
131 | tCONT tNUM tEOL
{ dbg_exec_count
= $2;
132 dbg_exec_mode
= EXEC_CONT
; return
0; }
133 | tSTEP tEOL
{ dbg_exec_count
= 1;
134 dbg_exec_mode
= EXEC_STEP_INSTR
; return
0; }
135 | tNEXT tEOL
{ dbg_exec_count
= 1;
136 dbg_exec_mode
= EXEC_STEP_OVER
; return
0; }
137 | tSTEP tNUM tEOL
{ dbg_exec_count
= $2;
138 dbg_exec_mode
= EXEC_STEP_INSTR
; return
0; }
139 | tNEXT tNUM tEOL
{ dbg_exec_count
= $2;
140 dbg_exec_mode
= EXEC_STEP_OVER
; return
0; }
141 | tSTEPI tEOL
{ dbg_exec_count
= 1;
142 dbg_exec_mode
= EXEC_STEPI_INSTR
; return
0; }
143 | tNEXTI tEOL
{ dbg_exec_count
= 1;
144 dbg_exec_mode
= EXEC_STEPI_OVER
; return
0; }
145 | tSTEPI tNUM tEOL
{ dbg_exec_count
= $2;
146 dbg_exec_mode
= EXEC_STEPI_INSTR
; return
0; }
147 | tNEXTI tNUM tEOL
{ dbg_exec_count
= $2;
148 dbg_exec_mode
= EXEC_STEPI_OVER
; return
0; }
149 | tABORT tEOL
{ kill
(getpid
(), SIGABRT
); }
150 | tMODE tNUM tEOL
{ mode_command
($2); }
151 | tENABLE tNUM tEOL
{ DEBUG_EnableBreakpoint
( $2, TRUE
); }
152 | tDISABLE tNUM tEOL
{ DEBUG_EnableBreakpoint
( $2, FALSE
); }
153 | tDELETE tBREAK tNUM tEOL
{ DEBUG_DelBreakpoint
( $3 ); }
154 | tBACKTRACE tEOL
{ DEBUG_BackTrace
(); }
155 | tUP tEOL
{ DEBUG_SetFrame
( curr_frame
+ 1 ); }
156 | tUP tNUM tEOL
{ DEBUG_SetFrame
( curr_frame
+ $2 ); }
157 | tDOWN tEOL
{ DEBUG_SetFrame
( curr_frame
- 1 ); }
158 | tDOWN tNUM tEOL
{ DEBUG_SetFrame
( curr_frame
- $2 ); }
159 | tFRAME tNUM tEOL
{ DEBUG_SetFrame
( $2 ); }
160 | tFINISH tEOL
{ dbg_exec_count
= 0;
161 dbg_exec_mode
= EXEC_FINISH
; return
0; }
162 | tSHOW tDIR tEOL
{ DEBUG_ShowDir
(); }
163 | tDIR pathname tEOL
{ DEBUG_AddPath
( $2 ); }
164 | tDIR tEOL
{ DEBUG_NukePath
(); }
165 | tDISPLAY tEOL
{ DEBUG_InfoDisplay
(); }
166 | tDISPLAY expr tEOL
{ DEBUG_AddDisplay
($2, 1, 0); }
167 | tDISPLAY tFORMAT expr tEOL
{ DEBUG_AddDisplay
($3, $2 >> 8, $2 & 0xff); }
168 | tDELETE tDISPLAY tNUM tEOL
{ DEBUG_DelDisplay
( $3 ); }
169 | tDELETE tDISPLAY tEOL
{ DEBUG_DelDisplay
( -1 ); }
170 | tUNDISPLAY tNUM tEOL
{ DEBUG_DelDisplay
( $2 ); }
171 | tUNDISPLAY tEOL
{ DEBUG_DelDisplay
( -1 ); }
172 | tCOND tNUM tEOL
{ DEBUG_AddBPCondition
($2, NULL
); }
173 | tCOND tNUM expr tEOL
{ DEBUG_AddBPCondition
($2, $3); }
174 | tDEBUGMSG tDEBUGSTR tEOL
{ MAIN_ParseDebugOptions
($2); }
175 | tSYMBOLFILE pathname tEOL
{ DEBUG_ReadSymbolTable
($2); }
177 | disassemble_command
186 tSET tREG
'=' expr_value tEOL
{ DEBUG_SetRegister
( $2, $4 );
187 DEBUG_FreeExprMem
(); }
188 | tSET lval_addr
'=' expr_value tEOL
{ DEBUG_WriteMemory
( &$2, $4 );
189 DEBUG_FreeExprMem
(); }
192 tIDENTIFIER
{ $$
= $1; }
196 tDISASSEMBLE tEOL
{ DEBUG_Disassemble
( NULL
, NULL
, 10 ); }
197 | tDISASSEMBLE expr_addr tEOL
{ DEBUG_Disassemble
( & $2, NULL
, 10 ); }
198 | tDISASSEMBLE expr_addr
',' expr_addr tEOL
{ DEBUG_Disassemble
( & $2, & $4, 0 ); }
201 tLIST tEOL
{ DEBUG_List
( NULL
, NULL
, 10 ); }
202 | tLIST
'-' tEOL
{ DEBUG_List
( NULL
, NULL
, -10 ); }
203 | tLIST list_arg tEOL
{ DEBUG_List
( & $2, NULL
, 10 ); }
204 | tLIST
',' list_arg tEOL
{ DEBUG_List
( NULL
, & $3, -10 ); }
205 | tLIST list_arg
',' list_arg tEOL
{ DEBUG_List
( & $2, & $4, 0 ); }
208 tNUM
{ $$.sourcefile
= NULL
; $$.line
= $1; }
209 | pathname
':' tNUM
{ $$.sourcefile
= $1; $$.line
= $3; }
210 | tIDENTIFIER
{ DEBUG_GetFuncInfo
( & $$
, NULL
, $1); }
211 | pathname
':' tIDENTIFIER
{ DEBUG_GetFuncInfo
( & $$
, $1, $3); }
212 |
'*' expr_addr
{ DEBUG_FindNearestSymbol
( & $2, FALSE
, NULL
,
214 DEBUG_FreeExprMem
(); }
217 tEXAM expr_addr tEOL
{ DEBUG_ExamineMemory
( &$2, 1, 'x');
218 DEBUG_FreeExprMem
(); }
219 | tEXAM tFORMAT expr_addr tEOL
{ DEBUG_ExamineMemory
( &$3, $2>>8, $2&0xff );
220 DEBUG_FreeExprMem
(); }
223 tPRINT expr_addr tEOL
{ DEBUG_Print
( &$2, 1, 0, 0 );
224 DEBUG_FreeExprMem
(); }
225 | tPRINT tFORMAT expr_addr tEOL
{ DEBUG_Print
( &$3, $2 >> 8, $2 & 0xff, 0 );
226 DEBUG_FreeExprMem
(); }
229 tBREAK
'*' expr_addr tEOL
{ DEBUG_AddBreakpoint
( &$3 );
230 DEBUG_FreeExprMem
(); }
231 | tBREAK tIDENTIFIER tEOL
{ DBG_ADDR addr
;
232 if
( DEBUG_GetSymbolValue
($2, -1, &addr
, TRUE
) )
234 DEBUG_AddBreakpoint
( &addr
);
238 fprintf
(stderr
,"Unable to add breakpoint\n");
241 | tBREAK tIDENTIFIER
':' tNUM tEOL
{ DBG_ADDR addr
;
242 if
( DEBUG_GetSymbolValue
($2, $4, &addr
, TRUE
) )
244 DEBUG_AddBreakpoint
( &addr
);
248 fprintf
(stderr
,"Unable to add breakpoint\n");
251 | tBREAK tNUM tEOL
{ struct name_hash
*nh
;
253 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
256 addr.seg
= CS_reg
(&DEBUG_context
);
257 addr.off
= EIP_reg
(&DEBUG_context
);
259 if
(ISV86
(&DEBUG_context
))
260 addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
261 DBG_FIX_ADDR_SEG
( &addr
, CS_reg
(&DEBUG_context
) );
262 GlobalUnlock16
( GetCurrentTask
() );
263 DEBUG_FindNearestSymbol
(&addr
, TRUE
,
267 DEBUG_GetLineNumberAddr
(nh
,
269 DEBUG_AddBreakpoint
( &addr
);
273 fprintf
(stderr
,"Unable to add breakpoint\n");
277 | tBREAK tEOL
{ DBG_ADDR addr
;
278 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
281 addr.seg
= CS_reg
(&DEBUG_context
);
282 addr.off
= EIP_reg
(&DEBUG_context
);
284 if
(ISV86
(&DEBUG_context
))
285 addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
286 GlobalUnlock16
( GetCurrentTask
() );
287 DEBUG_AddBreakpoint
( &addr
);
291 tINFO tBREAK tEOL
{ DEBUG_InfoBreakpoints
(); }
292 | tINFO tCLASS expr_value tEOL
{ CLASS_DumpClass
( (CLASS
*)$3 );
293 DEBUG_FreeExprMem
(); }
294 | tINFO tSHARE tEOL
{ DEBUG_InfoShare
(); }
295 | tINFO tMODULE expr_value tEOL
{ NE_DumpModule
( $3 );
296 DEBUG_FreeExprMem
(); }
297 | tINFO tQUEUE expr_value tEOL
{ QUEUE_DumpQueue
( $3 );
298 DEBUG_FreeExprMem
(); }
299 | tINFO tREGS tEOL
{ DEBUG_InfoRegisters
(); }
300 | tINFO tSEGMENTS expr_value tEOL
{ LDT_Print
( SELECTOR_TO_ENTRY
($3), 1 );
301 DEBUG_FreeExprMem
(); }
302 | tINFO tSEGMENTS tEOL
{ LDT_Print
( 0, -1 ); }
303 | tINFO tSTACK tEOL
{ DEBUG_InfoStack
(); }
304 | tINFO tMAPS tEOL
{ VIRTUAL_Dump
(); }
305 | tINFO tWND expr_value tEOL
{ WIN_DumpWindow
( $3 );
306 DEBUG_FreeExprMem
(); }
307 | tINFO tLOCAL tEOL
{ DEBUG_InfoLocals
(); }
308 | tINFO tDISPLAY tEOL
{ DEBUG_InfoDisplay
(); }
311 tWALK tCLASS tEOL
{ CLASS_WalkClasses
(); }
312 | tWALK tMODULE tEOL
{ NE_WalkModules
(); }
313 | tWALK tQUEUE tEOL
{ QUEUE_WalkQueues
(); }
314 | tWALK tWND tEOL
{ WIN_WalkWindows
( 0, 0 ); }
315 | tWALK tWND tNUM tEOL
{ WIN_WalkWindows
( $3, 0 ); }
319 '(' type_expr
')' { $$
= $2; }
322 type_expr
'*' { $$
= DEBUG_FindOrMakePointerType
($1); }
323 | tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "int"); }
324 | tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "char"); }
325 | tLONG tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long int"); }
326 | tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "unsigned int"); }
327 | tLONG tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long unsigned int"); }
328 | tLONG tLONG tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long long int"); }
329 | tLONG tLONG tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long long unsigned int"); }
330 | tSHORT tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "short int"); }
331 | tSHORT tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "short unsigned int"); }
332 | tSIGNED tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "signed char"); }
333 | tUNSIGNED tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "unsigned char"); }
334 | tFLOAT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "float"); }
335 | tDOUBLE
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "double"); }
336 | tLONG tDOUBLE
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long double"); }
337 | tSTRUCT tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_STRUCT
, $2); }
338 | tUNION tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_STRUCT
, $2); }
339 | tENUM tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_ENUM
, $2); }
342 expr
{ $$
= DEBUG_EvalExpr
($1); }
345 expr
{ DBG_ADDR addr
= DEBUG_EvalExpr
($1);
346 $$
= addr.off ?
*(unsigned int *) addr.off
: 0; }
348 * The expr rule builds an expression tree. When we are done, we call
349 * EvalExpr to evaluate the value of the expression. The advantage of
350 * the two-step approach is that it is possible to save expressions for
351 * use in 'display' commands, and in conditional watchpoints.
354 tNUM
{ $$
= DEBUG_ConstExpr
($1); }
355 | tSTRING
{ $$
= DEBUG_StringExpr
($1); }
356 | tREG
{ $$
= DEBUG_RegisterExpr
($1); }
357 | tIDENTIFIER
{ $$
= DEBUG_SymbolExpr
($1); }
358 | expr OP_DRF tIDENTIFIER
{ $$
= DEBUG_StructPExpr
($1, $3); }
359 | expr
'.' tIDENTIFIER
{ $$
= DEBUG_StructExpr
($1, $3); }
360 | tIDENTIFIER
'(' ')' { $$
= DEBUG_CallExpr
($1, 0); }
361 | tIDENTIFIER
'(' expr
')' { $$
= DEBUG_CallExpr
($1, 1, $3); }
362 | tIDENTIFIER
'(' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 2, $3,
364 | tIDENTIFIER
'(' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7); }
365 | tIDENTIFIER
'(' expr
',' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7, $9); }
366 | tIDENTIFIER
'(' expr
',' expr
',' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7, $9, $11); }
367 | expr
'[' expr
']' { $$
= DEBUG_BinopExpr
(EXP_OP_ARR
, $1, $3); }
368 | expr
':' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SEG
, $1, $3); }
369 | expr OP_LOR expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LOR
, $1, $3); }
370 | expr OP_LAND expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LAND
, $1, $3); }
371 | expr
'|' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_OR
, $1, $3); }
372 | expr
'&' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_AND
, $1, $3); }
373 | expr
'^' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_XOR
, $1, $3); }
374 | expr OP_EQ expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_EQ
, $1, $3); }
375 | expr
'>' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_GT
, $1, $3); }
376 | expr
'<' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LT
, $1, $3); }
377 | expr OP_GE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_GE
, $1, $3); }
378 | expr OP_LE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LE
, $1, $3); }
379 | expr OP_NE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_NE
, $1, $3); }
380 | expr OP_SHL expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SHL
, $1, $3); }
381 | expr OP_SHR expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SHR
, $1, $3); }
382 | expr
'+' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_ADD
, $1, $3); }
383 | expr
'-' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SUB
, $1, $3); }
384 | expr
'*' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_MUL
, $1, $3); }
385 | expr
'/' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_DIV
, $1, $3); }
386 | expr
'%' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_REM
, $1, $3); }
387 |
'-' expr %prec OP_SIGN
{ $$
= DEBUG_UnopExpr
(EXP_OP_NEG
, $2); }
388 |
'+' expr %prec OP_SIGN
{ $$
= $2; }
389 |
'!' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_NOT
, $2); }
390 |
'~' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_LNOT
, $2); }
391 |
'(' expr
')' { $$
= $2; }
392 |
'*' expr %prec OP_DEREF
{ $$
= DEBUG_UnopExpr
(EXP_OP_DEREF
, $2); }
393 |
'&' expr %prec OP_DEREF
{ $$
= DEBUG_UnopExpr
(EXP_OP_ADDR
, $2); }
394 | type_cast expr %prec OP_DEREF
{ $$
= DEBUG_TypeCastExpr
($1, $2); }
397 * The lvalue rule builds an expression tree. This is a limited form
398 * of expression that is suitable to be used as an lvalue.
401 lval
{ $$
= DEBUG_EvalExpr
($1); }
405 |
'*' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_FORCE_DEREF
, $2); }
408 tNUM
{ $$
= DEBUG_ConstExpr
($1); }
409 | tREG
{ $$
= DEBUG_RegisterExpr
($1); }
410 | tIDENTIFIER
{ $$
= DEBUG_SymbolExpr
($1); }
411 | lvalue OP_DRF tIDENTIFIER
{ $$
= DEBUG_StructPExpr
($1, $3); }
412 | lvalue
'.' tIDENTIFIER
{ $$
= DEBUG_StructExpr
($1, $3); }
413 | lvalue
'[' expr
']' { $$
= DEBUG_BinopExpr
(EXP_OP_ARR
, $1, $3); }
419 #ifdef DONT_USE_READLINE
420 fprintf
(stderr
,"Wine-dbg>");
424 void mode_command
(int newmode
)
426 if
((newmode
== 16) ||
(newmode
== 32)) dbg_mode
= newmode
;
427 else fprintf
(stderr
,"Invalid mode (use 16 or 32)\n");
431 /***********************************************************************
434 * Debugger main loop.
436 static void DEBUG_Main
( int signal
)
438 static int loaded_symbols
= 0;
439 static BOOL frozen
= FALSE
;
440 static BOOL in_debugger
= FALSE
;
441 char SymbolTableFile
[256];
450 fprintf
( stderr
, "Segmentation fault inside debugger, exiting.\n" );
456 DEBUG_SetBreakpoints
( FALSE
);
464 /* Don't freeze thread currently holding the X crst! */
465 EnterCriticalSection
( &X11DRV_CritSection
);
466 CLIENT_DebuggerRequest
( DEBUGGER_FREEZE_ALL
);
467 LeaveCriticalSection
( &X11DRV_CritSection
);
473 * Initialize the debugger heap.
475 dbg_heap
= HeapCreate
(HEAP_NO_SERIALIZE
, 0x1000, 0x8000000); /* 128MB */
479 * Initialize the type handling stuff.
484 * In some cases we can read the stabs information directly
485 * from the executable. If this is the case, we don't need
486 * to bother with trying to read a symbol file, as the stabs
487 * also have line number and local variable information.
488 * As long as gcc is used for the compiler, stabs will
489 * be the default. On SVr4, DWARF could be used, but we
490 * don't grok that yet, and in this case we fall back to using
493 if
( DEBUG_ReadExecutableDbgInfo
() == FALSE
)
495 char *symfilename
= "wine.sym";
497 if
(-1 == stat
(symfilename
, &statbuf
) )
498 symfilename
= LIBDIR
"wine.sym";
500 PROFILE_GetWineIniString
( "wine", "SymbolTableFile", symfilename
,
501 SymbolTableFile
, sizeof
(SymbolTableFile
));
502 DEBUG_ReadSymbolTable
( SymbolTableFile
);
505 DEBUG_LoadEntryPoints
();
506 DEBUG_ProcessDeferredDebug
();
510 fprintf
(stderr
, "Entering debugger PC=%x, mode=%d, count=%d\n",
511 EIP_reg
(&DEBUG_context
),
512 dbg_exec_mode
, dbg_exec_count
);
517 if
((signal
!= SIGTRAP
) ||
!DEBUG_ShouldContinue
( dbg_exec_mode
,
521 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
523 addr.seg
= CS_reg
(&DEBUG_context
);
524 addr.off
= EIP_reg
(&DEBUG_context
);
525 if
(ISV86
(&DEBUG_context
)) addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
527 DBG_FIX_ADDR_SEG
( &addr
, 0 );
529 GlobalUnlock16
( GetCurrentTask
() );
533 /* Don't freeze thread currently holding the X crst! */
534 EnterCriticalSection
( &X11DRV_CritSection
);
535 CLIENT_DebuggerRequest
( DEBUGGER_FREEZE_ALL
);
536 LeaveCriticalSection
( &X11DRV_CritSection
);
540 /* Put the display in a correct state */
541 USER_Driver
->pBeginDebugging
();
543 newmode
= ISV86
(&DEBUG_context
) ?
16 : IS_SELECTOR_32BIT
(addr.seg
) ?
32 : 16;
544 if
(newmode
!= dbg_mode
)
545 fprintf
(stderr
,"In %d bit mode.\n", dbg_mode
= newmode
);
549 if
(signal
!= SIGTRAP
) /* This is a real crash, dump some info */
551 DEBUG_InfoRegisters
();
555 LDT_Print
( SELECTOR_TO_ENTRY
(DS_reg
(&DEBUG_context
)), 1 );
556 if
(ES_reg
(&DEBUG_context
) != DS_reg
(&DEBUG_context
))
557 LDT_Print
( SELECTOR_TO_ENTRY
(ES_reg
(&DEBUG_context
)), 1 );
564 * Do a quiet backtrace so that we have an idea of what the situation
565 * is WRT the source files.
567 DEBUG_SilentBackTrace
();
570 if
((signal
!= SIGTRAP
) ||
571 (dbg_exec_mode
== EXEC_STEPI_OVER
) ||
572 (dbg_exec_mode
== EXEC_STEPI_INSTR
))
574 /* Show where we crashed */
576 DEBUG_PrintAddress
( &addr
, dbg_mode
, TRUE
);
577 fprintf
(stderr
,": ");
578 if
(DBG_CHECK_READ_PTR
( &addr
, 1 ))
580 DEBUG_Disasm
( &addr
, TRUE
);
581 fprintf
(stderr
,"\n");
591 addr.seg
= CS_reg
(&DEBUG_context
) |
(addr.seg
&0xffff0000);
592 addr.off
= EIP_reg
(&DEBUG_context
);
593 DBG_FIX_ADDR_SEG
( &addr
, 0 );
594 ret_ok
= DEBUG_ValidateRegisters
();
595 if
(ret_ok
) ret_ok
= DBG_CHECK_READ_PTR
( &addr
, 1 );
599 dbg_exec_mode
= DEBUG_RestartExecution
( dbg_exec_mode
, dbg_exec_count
);
601 * This will have gotten absorbed into the breakpoint info
602 * if it was used. Otherwise it would have been ignored.
603 * In any case, we don't mess with it any more.
605 if
( dbg_exec_mode
== EXEC_CONT
)
611 CLIENT_DebuggerRequest
( DEBUGGER_UNFREEZE_ALL
);
618 USER_Driver
->pEndDebugging
();
623 /***********************************************************************
624 * DebugBreak (KERNEL.203) (KERNEL32.181)
626 void DebugBreak16
( CONTEXT
*regs
)
629 if
(!GetModuleName16
( GetCurrentTask
(), module
, sizeof
(module
) ))
630 strcpy
( module
, "???" );
631 fprintf
( stderr
, "%s called DebugBreak\n", module
);
632 DEBUG_context
= *regs
;
633 DEBUG_Main
( SIGTRAP
);
637 void ctx_debug
( int signal
, CONTEXT
*regs
)
639 DEBUG_context
= *regs
;
640 DEBUG_Main
( signal
);
641 *regs
= DEBUG_context
;
644 void wine_debug
( int signal
, SIGCONTEXT
*regs
)
647 DWORD
*stack
= (DWORD
*)ESP_sig
(regs
);
650 *(--stack
) = EH_NONCONTINUABLE
;
651 *(--stack
) = EXCEPTION_ACCESS_VIOLATION
;
652 *(--stack
) = EIP_sig
(regs
);
653 ESP_sig
(regs
) = (DWORD
)stack
;
654 EIP_sig
(regs
) = (DWORD
)RaiseException
;
656 DEBUG_SetSigContext
( regs
);
657 DEBUG_Main
( signal
);
658 DEBUG_GetSigContext
( regs
);
662 int yyerror(char * s
)
664 fprintf
(stderr
,"%s\n", s
);