3 * Parser for command lines in the Wine debugger
5 * Copyright 1993 Eric Youngdale
6 * Copyright 1995 Morten Welinder
26 #include "wine/winbase16.h"
39 unsigned int dbg_mode
= 0;
43 static enum exec_mode dbg_exec_mode
= EXEC_CONT
;
44 static int dbg_exec_count
= 0;
46 void issue_prompt
(void);
47 void mode_command
(int);
48 void flush_symbols
(void);
53 #define malloc(x) DBG_alloc(x)
54 #define realloc(x,y) DBG_realloc(x,y)
55 #define free(x) DBG_free(x)
58 extern
void VIRTUAL_Dump
(void); /* memory/virtual.c */
68 struct list_id listing
;
69 struct expr
* expression
;
70 struct datatype
* type
;
73 %token tCONT tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
74 %token tENABLE tDISABLE tBREAK tDELETE tSET tMODE tPRINT tEXAM tABORT tDEBUGMSG
75 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
76 %token tPROCESS tMODREF
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
( (struct tagCLASS
*)$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 ); }
316 | tWALK tPROCESS tEOL
{ PROCESS_WalkProcess
(); }
317 | tWALK tMODREF expr_value tEOL
{ MODULE_WalkModref
( $3 ); }
321 '(' type_expr
')' { $$
= $2; }
324 type_expr
'*' { $$
= DEBUG_FindOrMakePointerType
($1); }
325 | tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "int"); }
326 | tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "char"); }
327 | tLONG tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long int"); }
328 | tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "unsigned int"); }
329 | tLONG tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long unsigned int"); }
330 | tLONG tLONG tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long long int"); }
331 | tLONG tLONG tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long long unsigned int"); }
332 | tSHORT tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "short int"); }
333 | tSHORT tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "short unsigned int"); }
334 | tSIGNED tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "signed char"); }
335 | tUNSIGNED tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "unsigned char"); }
336 | tFLOAT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "float"); }
337 | tDOUBLE
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "double"); }
338 | tLONG tDOUBLE
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long double"); }
339 | tSTRUCT tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_STRUCT
, $2); }
340 | tUNION tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_STRUCT
, $2); }
341 | tENUM tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_ENUM
, $2); }
344 expr
{ $$
= DEBUG_EvalExpr
($1); }
347 expr
{ DBG_ADDR addr
= DEBUG_EvalExpr
($1);
348 $$
= addr.off ?
*(unsigned int *) addr.off
: 0; }
350 * The expr rule builds an expression tree. When we are done, we call
351 * EvalExpr to evaluate the value of the expression. The advantage of
352 * the two-step approach is that it is possible to save expressions for
353 * use in 'display' commands, and in conditional watchpoints.
356 tNUM
{ $$
= DEBUG_ConstExpr
($1); }
357 | tSTRING
{ $$
= DEBUG_StringExpr
($1); }
358 | tREG
{ $$
= DEBUG_RegisterExpr
($1); }
359 | tIDENTIFIER
{ $$
= DEBUG_SymbolExpr
($1); }
360 | expr OP_DRF tIDENTIFIER
{ $$
= DEBUG_StructPExpr
($1, $3); }
361 | expr
'.' tIDENTIFIER
{ $$
= DEBUG_StructExpr
($1, $3); }
362 | tIDENTIFIER
'(' ')' { $$
= DEBUG_CallExpr
($1, 0); }
363 | tIDENTIFIER
'(' expr
')' { $$
= DEBUG_CallExpr
($1, 1, $3); }
364 | tIDENTIFIER
'(' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 2, $3,
366 | tIDENTIFIER
'(' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7); }
367 | tIDENTIFIER
'(' expr
',' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7, $9); }
368 | tIDENTIFIER
'(' expr
',' expr
',' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7, $9, $11); }
369 | expr
'[' expr
']' { $$
= DEBUG_BinopExpr
(EXP_OP_ARR
, $1, $3); }
370 | expr
':' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SEG
, $1, $3); }
371 | expr OP_LOR expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LOR
, $1, $3); }
372 | expr OP_LAND expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LAND
, $1, $3); }
373 | expr
'|' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_OR
, $1, $3); }
374 | expr
'&' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_AND
, $1, $3); }
375 | expr
'^' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_XOR
, $1, $3); }
376 | expr OP_EQ expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_EQ
, $1, $3); }
377 | expr
'>' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_GT
, $1, $3); }
378 | expr
'<' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LT
, $1, $3); }
379 | expr OP_GE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_GE
, $1, $3); }
380 | expr OP_LE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LE
, $1, $3); }
381 | expr OP_NE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_NE
, $1, $3); }
382 | expr OP_SHL expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SHL
, $1, $3); }
383 | expr OP_SHR expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SHR
, $1, $3); }
384 | expr
'+' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_ADD
, $1, $3); }
385 | expr
'-' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SUB
, $1, $3); }
386 | expr
'*' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_MUL
, $1, $3); }
387 | expr
'/' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_DIV
, $1, $3); }
388 | expr
'%' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_REM
, $1, $3); }
389 |
'-' expr %prec OP_SIGN
{ $$
= DEBUG_UnopExpr
(EXP_OP_NEG
, $2); }
390 |
'+' expr %prec OP_SIGN
{ $$
= $2; }
391 |
'!' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_NOT
, $2); }
392 |
'~' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_LNOT
, $2); }
393 |
'(' expr
')' { $$
= $2; }
394 |
'*' expr %prec OP_DEREF
{ $$
= DEBUG_UnopExpr
(EXP_OP_DEREF
, $2); }
395 |
'&' expr %prec OP_DEREF
{ $$
= DEBUG_UnopExpr
(EXP_OP_ADDR
, $2); }
396 | type_cast expr %prec OP_DEREF
{ $$
= DEBUG_TypeCastExpr
($1, $2); }
399 * The lvalue rule builds an expression tree. This is a limited form
400 * of expression that is suitable to be used as an lvalue.
403 lval
{ $$
= DEBUG_EvalExpr
($1); }
407 |
'*' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_FORCE_DEREF
, $2); }
410 tNUM
{ $$
= DEBUG_ConstExpr
($1); }
411 | tREG
{ $$
= DEBUG_RegisterExpr
($1); }
412 | tIDENTIFIER
{ $$
= DEBUG_SymbolExpr
($1); }
413 | lvalue OP_DRF tIDENTIFIER
{ $$
= DEBUG_StructPExpr
($1, $3); }
414 | lvalue
'.' tIDENTIFIER
{ $$
= DEBUG_StructExpr
($1, $3); }
415 | lvalue
'[' expr
']' { $$
= DEBUG_BinopExpr
(EXP_OP_ARR
, $1, $3); }
421 #ifdef DONT_USE_READLINE
422 fprintf
(stderr
,"Wine-dbg>");
426 void mode_command
(int newmode
)
428 if
((newmode
== 16) ||
(newmode
== 32)) dbg_mode
= newmode
;
429 else fprintf
(stderr
,"Invalid mode (use 16 or 32)\n");
433 /***********************************************************************
436 * Debugger main loop.
438 static void DEBUG_Main
( int signal
)
440 static int loaded_symbols
= 0;
441 static BOOL frozen
= FALSE
;
442 static BOOL in_debugger
= FALSE
;
443 char SymbolTableFile
[256];
452 fprintf
( stderr
, "Segmentation fault inside debugger, exiting.\n" );
458 DEBUG_SetBreakpoints
( FALSE
);
466 /* Don't freeze thread currently holding the X crst! */
467 EnterCriticalSection
( &X11DRV_CritSection
);
468 CLIENT_DebuggerRequest
( DEBUGGER_FREEZE_ALL
);
469 LeaveCriticalSection
( &X11DRV_CritSection
);
475 * Initialize the debugger heap.
477 dbg_heap
= HeapCreate
(HEAP_NO_SERIALIZE
, 0x1000, 0x8000000); /* 128MB */
481 * Initialize the type handling stuff.
486 * In some cases we can read the stabs information directly
487 * from the executable. If this is the case, we don't need
488 * to bother with trying to read a symbol file, as the stabs
489 * also have line number and local variable information.
490 * As long as gcc is used for the compiler, stabs will
491 * be the default. On SVr4, DWARF could be used, but we
492 * don't grok that yet, and in this case we fall back to using
495 if
( DEBUG_ReadExecutableDbgInfo
() == FALSE
)
497 char *symfilename
= "wine.sym";
499 if
(-1 == stat
(symfilename
, &statbuf
) )
500 symfilename
= LIBDIR
"wine.sym";
502 PROFILE_GetWineIniString
( "wine", "SymbolTableFile", symfilename
,
503 SymbolTableFile
, sizeof
(SymbolTableFile
));
504 DEBUG_ReadSymbolTable
( SymbolTableFile
);
507 DEBUG_LoadEntryPoints
();
508 DEBUG_ProcessDeferredDebug
();
512 fprintf
(stderr
, "Entering debugger PC=%x, mode=%d, count=%d\n",
513 EIP_reg
(&DEBUG_context
),
514 dbg_exec_mode
, dbg_exec_count
);
519 if
((signal
!= SIGTRAP
) ||
!DEBUG_ShouldContinue
( dbg_exec_mode
,
523 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
525 addr.seg
= CS_reg
(&DEBUG_context
);
526 addr.off
= EIP_reg
(&DEBUG_context
);
527 if
(ISV86
(&DEBUG_context
)) addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
529 DBG_FIX_ADDR_SEG
( &addr
, 0 );
531 GlobalUnlock16
( GetCurrentTask
() );
535 /* Don't freeze thread currently holding the X crst! */
536 EnterCriticalSection
( &X11DRV_CritSection
);
537 CLIENT_DebuggerRequest
( DEBUGGER_FREEZE_ALL
);
538 LeaveCriticalSection
( &X11DRV_CritSection
);
542 /* Put the display in a correct state */
543 USER_Driver
->pBeginDebugging
();
545 newmode
= ISV86
(&DEBUG_context
) ?
16 : IS_SELECTOR_32BIT
(addr.seg
) ?
32 : 16;
546 if
(newmode
!= dbg_mode
)
547 fprintf
(stderr
,"In %d bit mode.\n", dbg_mode
= newmode
);
551 if
(signal
!= SIGTRAP
) /* This is a real crash, dump some info */
553 DEBUG_InfoRegisters
();
557 LDT_Print
( SELECTOR_TO_ENTRY
(DS_reg
(&DEBUG_context
)), 1 );
558 if
(ES_reg
(&DEBUG_context
) != DS_reg
(&DEBUG_context
))
559 LDT_Print
( SELECTOR_TO_ENTRY
(ES_reg
(&DEBUG_context
)), 1 );
566 * Do a quiet backtrace so that we have an idea of what the situation
567 * is WRT the source files.
569 DEBUG_SilentBackTrace
();
572 if
((signal
!= SIGTRAP
) ||
573 (dbg_exec_mode
== EXEC_STEPI_OVER
) ||
574 (dbg_exec_mode
== EXEC_STEPI_INSTR
))
576 /* Show where we crashed */
578 DEBUG_PrintAddress
( &addr
, dbg_mode
, TRUE
);
579 fprintf
(stderr
,": ");
580 if
(DBG_CHECK_READ_PTR
( &addr
, 1 ))
582 DEBUG_Disasm
( &addr
, TRUE
);
583 fprintf
(stderr
,"\n");
593 addr.seg
= CS_reg
(&DEBUG_context
) |
(addr.seg
&0xffff0000);
594 addr.off
= EIP_reg
(&DEBUG_context
);
595 DBG_FIX_ADDR_SEG
( &addr
, 0 );
596 ret_ok
= DEBUG_ValidateRegisters
();
597 if
(ret_ok
) ret_ok
= DBG_CHECK_READ_PTR
( &addr
, 1 );
601 dbg_exec_mode
= DEBUG_RestartExecution
( dbg_exec_mode
, dbg_exec_count
);
603 * This will have gotten absorbed into the breakpoint info
604 * if it was used. Otherwise it would have been ignored.
605 * In any case, we don't mess with it any more.
607 if
( dbg_exec_mode
== EXEC_CONT
)
613 CLIENT_DebuggerRequest
( DEBUGGER_UNFREEZE_ALL
);
620 USER_Driver
->pEndDebugging
();
625 /***********************************************************************
626 * DebugBreak (KERNEL.203) (KERNEL32.181)
628 void DebugBreak16
( CONTEXT
*regs
)
631 if
(!GetModuleName16
( GetCurrentTask
(), module
, sizeof
(module
) ))
632 strcpy
( module
, "???" );
633 fprintf
( stderr
, "%s called DebugBreak\n", module
);
634 DEBUG_context
= *regs
;
635 DEBUG_Main
( SIGTRAP
);
639 void ctx_debug
( int signal
, CONTEXT
*regs
)
641 DEBUG_context
= *regs
;
642 DEBUG_Main
( signal
);
643 *regs
= DEBUG_context
;
646 void wine_debug
( int signal
, SIGCONTEXT
*regs
)
649 DWORD
*stack
= (DWORD
*)ESP_sig
(regs
);
652 *(--stack
) = EH_NONCONTINUABLE
;
653 *(--stack
) = EXCEPTION_ACCESS_VIOLATION
;
654 *(--stack
) = EIP_sig
(regs
);
655 ESP_sig
(regs
) = (DWORD
)stack
;
656 EIP_sig
(regs
) = (DWORD
)RaiseException
;
658 DEBUG_SetSigContext
( regs
);
659 DEBUG_Main
( signal
);
660 DEBUG_GetSigContext
( regs
);
664 int yyerror(char * s
)
666 fprintf
(stderr
,"%s\n", s
);