3 * Parser for command lines in the Wine debugger
5 * Copyright 1993 Eric Youngdale
6 * Copyright 1995 Morten Welinder
22 #include "wine/winbase16.h"
33 unsigned int dbg_mode
= 0;
36 static enum exec_mode dbg_exec_mode
= EXEC_CONT
;
37 static int dbg_exec_count
= 0;
39 void issue_prompt
(void);
40 void mode_command
(int);
41 void flush_symbols
(void);
45 extern
void VIRTUAL_Dump
(void); /* memory/virtual.c */
55 struct list_id listing
;
56 struct expr
* expression
;
57 struct datatype
* type
;
60 %token tCONT tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
61 %token tENABLE tDISABLE tBREAK tDELETE tSET tMODE tPRINT tEXAM tABORT tDEBUGMSG
62 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
63 %token tEOL tSTRING tDEBUGSTR
64 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
65 %token tSTEPI tNEXTI tFINISH tSHOW tDIR
67 %token
<string> tIDENTIFIER tSTRING tDEBUGSTR
68 %token
<integer
> tNUM tFORMAT
72 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
73 %token tSTRUCT tUNION tENUM
76 /* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
77 OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
78 OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
79 /* %left OP_COND */ /* ... ? ... : ... */
86 %left
'<' '>' OP_LE OP_GE
90 %left OP_SIGN
'!' '~' OP_DEREF
/* OP_INC OP_DEC OP_ADDR */
94 %type
<expression
> expr lval lvalue
95 %type
<type
> type_cast type_expr
96 %type
<address
> expr_addr lval_addr
97 %type
<integer
> expr_value
98 %type
<string> pathname
100 %type
<listing
> list_arg
104 input: line
{ issue_prompt
(); }
105 | input line
{ issue_prompt
(); }
109 |
error tEOL
{ yyerrok; }
112 tQUIT tEOL
{ exit
(0); }
113 | tHELP tEOL
{ DEBUG_Help
(); }
114 | tHELP tINFO tEOL
{ DEBUG_HelpInfo
(); }
115 | tCONT tEOL
{ dbg_exec_count
= 1;
116 dbg_exec_mode
= EXEC_CONT
; return
0; }
117 | tCONT tNUM tEOL
{ dbg_exec_count
= $2;
118 dbg_exec_mode
= EXEC_CONT
; return
0; }
119 | tSTEP tEOL
{ dbg_exec_count
= 1;
120 dbg_exec_mode
= EXEC_STEP_INSTR
; return
0; }
121 | tNEXT tEOL
{ dbg_exec_count
= 1;
122 dbg_exec_mode
= EXEC_STEP_OVER
; return
0; }
123 | tSTEP tNUM tEOL
{ dbg_exec_count
= $2;
124 dbg_exec_mode
= EXEC_STEP_INSTR
; return
0; }
125 | tNEXT tNUM tEOL
{ dbg_exec_count
= $2;
126 dbg_exec_mode
= EXEC_STEP_OVER
; return
0; }
127 | tSTEPI tEOL
{ dbg_exec_count
= 1;
128 dbg_exec_mode
= EXEC_STEPI_INSTR
; return
0; }
129 | tNEXTI tEOL
{ dbg_exec_count
= 1;
130 dbg_exec_mode
= EXEC_STEPI_OVER
; return
0; }
131 | tSTEPI tNUM tEOL
{ dbg_exec_count
= $2;
132 dbg_exec_mode
= EXEC_STEPI_INSTR
; return
0; }
133 | tNEXTI tNUM tEOL
{ dbg_exec_count
= $2;
134 dbg_exec_mode
= EXEC_STEPI_OVER
; return
0; }
135 | tABORT tEOL
{ kill
(getpid
(), SIGABRT
); }
136 | tMODE tNUM tEOL
{ mode_command
($2); }
137 | tENABLE tNUM tEOL
{ DEBUG_EnableBreakpoint
( $2, TRUE
); }
138 | tDISABLE tNUM tEOL
{ DEBUG_EnableBreakpoint
( $2, FALSE
); }
139 | tDELETE tBREAK tNUM tEOL
{ DEBUG_DelBreakpoint
( $3 ); }
140 | tBACKTRACE tEOL
{ DEBUG_BackTrace
(); }
141 | tUP tEOL
{ DEBUG_SetFrame
( curr_frame
+ 1 ); }
142 | tUP tNUM tEOL
{ DEBUG_SetFrame
( curr_frame
+ $2 ); }
143 | tDOWN tEOL
{ DEBUG_SetFrame
( curr_frame
- 1 ); }
144 | tDOWN tNUM tEOL
{ DEBUG_SetFrame
( curr_frame
- $2 ); }
145 | tFRAME tNUM tEOL
{ DEBUG_SetFrame
( $2 ); }
146 | tFINISH tEOL
{ dbg_exec_count
= 0;
147 dbg_exec_mode
= EXEC_FINISH
; return
0; }
148 | tSHOW tDIR tEOL
{ DEBUG_ShowDir
(); }
149 | tDIR pathname tEOL
{ DEBUG_AddPath
( $2 ); }
150 | tDIR tEOL
{ DEBUG_NukePath
(); }
151 | tDISPLAY tEOL
{ DEBUG_InfoDisplay
(); }
152 | tDISPLAY expr tEOL
{ DEBUG_AddDisplay
($2, 1, 0); }
153 | tDISPLAY tFORMAT expr tEOL
{ DEBUG_AddDisplay
($3, $2 >> 8, $2 & 0xff); }
154 | tDELETE tDISPLAY tNUM tEOL
{ DEBUG_DelDisplay
( $3 ); }
155 | tDELETE tDISPLAY tEOL
{ DEBUG_DelDisplay
( -1 ); }
156 | tUNDISPLAY tNUM tEOL
{ DEBUG_DelDisplay
( $2 ); }
157 | tUNDISPLAY tEOL
{ DEBUG_DelDisplay
( -1 ); }
158 | tCOND tNUM tEOL
{ DEBUG_AddBPCondition
($2, NULL
); }
159 | tCOND tNUM expr tEOL
{ DEBUG_AddBPCondition
($2, $3); }
160 | tDEBUGMSG tDEBUGSTR tEOL
{ MAIN_ParseDebugOptions
($2); }
161 | tSYMBOLFILE pathname tEOL
{ DEBUG_ReadSymbolTable
($2); }
163 | disassemble_command
172 tSET tREG
'=' expr_value tEOL
{ DEBUG_SetRegister
( $2, $4 );
173 DEBUG_FreeExprMem
(); }
174 | tSET lval_addr
'=' expr_value tEOL
{ DEBUG_WriteMemory
( &$2, $4 );
175 DEBUG_FreeExprMem
(); }
178 tIDENTIFIER
{ $$
= $1; }
182 tDISASSEMBLE tEOL
{ DEBUG_Disassemble
( NULL
, NULL
, 10 ); }
183 | tDISASSEMBLE expr_addr tEOL
{ DEBUG_Disassemble
( & $2, NULL
, 10 ); }
184 | tDISASSEMBLE expr_addr
',' expr_addr tEOL
{ DEBUG_Disassemble
( & $2, & $4, 0 ); }
187 tLIST tEOL
{ DEBUG_List
( NULL
, NULL
, 10 ); }
188 | tLIST
'-' tEOL
{ DEBUG_List
( NULL
, NULL
, -10 ); }
189 | tLIST list_arg tEOL
{ DEBUG_List
( & $2, NULL
, 10 ); }
190 | tLIST
',' list_arg tEOL
{ DEBUG_List
( NULL
, & $3, -10 ); }
191 | tLIST list_arg
',' list_arg tEOL
{ DEBUG_List
( & $2, & $4, 0 ); }
194 tNUM
{ $$.sourcefile
= NULL
; $$.line
= $1; }
195 | pathname
':' tNUM
{ $$.sourcefile
= $1; $$.line
= $3; }
196 | tIDENTIFIER
{ DEBUG_GetFuncInfo
( & $$
, NULL
, $1); }
197 | pathname
':' tIDENTIFIER
{ DEBUG_GetFuncInfo
( & $$
, $1, $3); }
198 |
'*' expr_addr
{ DEBUG_FindNearestSymbol
( & $2, FALSE
, NULL
,
200 DEBUG_FreeExprMem
(); }
203 tEXAM expr_addr tEOL
{ DEBUG_ExamineMemory
( &$2, 1, 'x');
204 DEBUG_FreeExprMem
(); }
205 | tEXAM tFORMAT expr_addr tEOL
{ DEBUG_ExamineMemory
( &$3, $2>>8, $2&0xff );
206 DEBUG_FreeExprMem
(); }
209 tPRINT expr_addr tEOL
{ DEBUG_Print
( &$2, 1, 0, 0 );
210 DEBUG_FreeExprMem
(); }
211 | tPRINT tFORMAT expr_addr tEOL
{ DEBUG_Print
( &$3, $2 >> 8, $2 & 0xff, 0 );
212 DEBUG_FreeExprMem
(); }
215 tBREAK
'*' expr_addr tEOL
{ DEBUG_AddBreakpoint
( &$3 );
216 DEBUG_FreeExprMem
(); }
217 | tBREAK tIDENTIFIER tEOL
{ DBG_ADDR addr
;
218 if
( DEBUG_GetSymbolValue
($2, -1, &addr
, TRUE
) )
220 DEBUG_AddBreakpoint
( &addr
);
224 fprintf
(stderr
,"Unable to add breakpoint\n");
227 | tBREAK tIDENTIFIER
':' tNUM tEOL
{ DBG_ADDR addr
;
228 if
( DEBUG_GetSymbolValue
($2, $4, &addr
, TRUE
) )
230 DEBUG_AddBreakpoint
( &addr
);
234 fprintf
(stderr
,"Unable to add breakpoint\n");
237 | tBREAK tNUM tEOL
{ struct name_hash
*nh
;
238 DBG_ADDR addr
= { NULL
,
239 CS_reg
(&DEBUG_context
),
240 EIP_reg
(&DEBUG_context
) };
241 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
242 if
(ISV86
(&DEBUG_context
))
243 addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
244 DBG_FIX_ADDR_SEG
( &addr
, CS_reg
(&DEBUG_context
) );
245 GlobalUnlock16
( GetCurrentTask
() );
246 DEBUG_FindNearestSymbol
(&addr
, TRUE
,
250 DEBUG_GetLineNumberAddr
(nh
,
252 DEBUG_AddBreakpoint
( &addr
);
256 fprintf
(stderr
,"Unable to add breakpoint\n");
260 | tBREAK tEOL
{ DBG_ADDR addr
= { NULL
,
261 CS_reg
(&DEBUG_context
),
262 EIP_reg
(&DEBUG_context
) };
263 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
264 if
(ISV86
(&DEBUG_context
))
265 addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
266 GlobalUnlock16
( GetCurrentTask
() );
267 DEBUG_AddBreakpoint
( &addr
);
271 tINFO tBREAK tEOL
{ DEBUG_InfoBreakpoints
(); }
272 | tINFO tCLASS expr_value tEOL
{ CLASS_DumpClass
( (CLASS
*)$3 );
273 DEBUG_FreeExprMem
(); }
274 | tINFO tSHARE tEOL
{ DEBUG_InfoShare
(); }
275 | tINFO tMODULE expr_value tEOL
{ NE_DumpModule
( $3 );
276 DEBUG_FreeExprMem
(); }
277 | tINFO tQUEUE expr_value tEOL
{ QUEUE_DumpQueue
( $3 );
278 DEBUG_FreeExprMem
(); }
279 | tINFO tREGS tEOL
{ DEBUG_InfoRegisters
(); }
280 | tINFO tSEGMENTS expr_value tEOL
{ LDT_Print
( SELECTOR_TO_ENTRY
($3), 1 );
281 DEBUG_FreeExprMem
(); }
282 | tINFO tSEGMENTS tEOL
{ LDT_Print
( 0, -1 ); }
283 | tINFO tSTACK tEOL
{ DEBUG_InfoStack
(); }
284 | tINFO tMAPS tEOL
{ VIRTUAL_Dump
(); }
285 | tINFO tWND expr_value tEOL
{ WIN_DumpWindow
( $3 );
286 DEBUG_FreeExprMem
(); }
287 | tINFO tLOCAL tEOL
{ DEBUG_InfoLocals
(); }
288 | tINFO tDISPLAY tEOL
{ DEBUG_InfoDisplay
(); }
291 tWALK tCLASS tEOL
{ CLASS_WalkClasses
(); }
292 | tWALK tMODULE tEOL
{ NE_WalkModules
(); }
293 | tWALK tQUEUE tEOL
{ QUEUE_WalkQueues
(); }
294 | tWALK tWND tEOL
{ WIN_WalkWindows
( 0, 0 ); }
295 | tWALK tWND tNUM tEOL
{ WIN_WalkWindows
( $3, 0 ); }
299 '(' type_expr
')' { $$
= $2; }
302 type_expr
'*' { $$
= DEBUG_FindOrMakePointerType
($1); }
303 | tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "int"); }
304 | tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "char"); }
305 | tLONG tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long int"); }
306 | tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "unsigned int"); }
307 | tLONG tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long unsigned int"); }
308 | tLONG tLONG tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long long int"); }
309 | tLONG tLONG tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long long unsigned int"); }
310 | tSHORT tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "short int"); }
311 | tSHORT tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "short unsigned int"); }
312 | tSIGNED tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "signed char"); }
313 | tUNSIGNED tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "unsigned char"); }
314 | tFLOAT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "float"); }
315 | tDOUBLE
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "double"); }
316 | tLONG tDOUBLE
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long double"); }
317 | tSTRUCT tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_STRUCT
, $2); }
318 | tUNION tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_STRUCT
, $2); }
319 | tENUM tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_ENUM
, $2); }
322 expr
{ $$
= DEBUG_EvalExpr
($1); }
325 expr
{ DBG_ADDR addr
= DEBUG_EvalExpr
($1);
326 $$
= addr.off ?
*(unsigned int *) addr.off
: 0; }
328 * The expr rule builds an expression tree. When we are done, we call
329 * EvalExpr to evaluate the value of the expression. The advantage of
330 * the two-step approach is that it is possible to save expressions for
331 * use in 'display' commands, and in conditional watchpoints.
334 tNUM
{ $$
= DEBUG_ConstExpr
($1); }
335 | tSTRING
{ $$
= DEBUG_StringExpr
($1); }
336 | tREG
{ $$
= DEBUG_RegisterExpr
($1); }
337 | tIDENTIFIER
{ $$
= DEBUG_SymbolExpr
($1); }
338 | expr OP_DRF tIDENTIFIER
{ $$
= DEBUG_StructPExpr
($1, $3); }
339 | expr
'.' tIDENTIFIER
{ $$
= DEBUG_StructExpr
($1, $3); }
340 | tIDENTIFIER
'(' ')' { $$
= DEBUG_CallExpr
($1, 0); }
341 | tIDENTIFIER
'(' expr
')' { $$
= DEBUG_CallExpr
($1, 1, $3); }
342 | tIDENTIFIER
'(' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 2, $3,
344 | tIDENTIFIER
'(' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7); }
345 | tIDENTIFIER
'(' expr
',' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7, $9); }
346 | tIDENTIFIER
'(' expr
',' expr
',' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7, $9, $11); }
347 | expr
'[' expr
']' { $$
= DEBUG_BinopExpr
(EXP_OP_ARR
, $1, $3); }
348 | expr
':' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SEG
, $1, $3); }
349 | expr OP_LOR expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LOR
, $1, $3); }
350 | expr OP_LAND expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LAND
, $1, $3); }
351 | expr
'|' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_OR
, $1, $3); }
352 | expr
'&' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_AND
, $1, $3); }
353 | expr
'^' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_XOR
, $1, $3); }
354 | expr OP_EQ expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_EQ
, $1, $3); }
355 | expr
'>' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_GT
, $1, $3); }
356 | expr
'<' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LT
, $1, $3); }
357 | expr OP_GE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_GE
, $1, $3); }
358 | expr OP_LE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LE
, $1, $3); }
359 | expr OP_NE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_NE
, $1, $3); }
360 | expr OP_SHL expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SHL
, $1, $3); }
361 | expr OP_SHR expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SHR
, $1, $3); }
362 | expr
'+' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_ADD
, $1, $3); }
363 | expr
'-' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SUB
, $1, $3); }
364 | expr
'*' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_MUL
, $1, $3); }
365 | expr
'/' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_DIV
, $1, $3); }
366 | expr
'%' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_REM
, $1, $3); }
367 |
'-' expr %prec OP_SIGN
{ $$
= DEBUG_UnopExpr
(EXP_OP_NEG
, $2); }
368 |
'+' expr %prec OP_SIGN
{ $$
= $2; }
369 |
'!' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_NOT
, $2); }
370 |
'~' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_LNOT
, $2); }
371 |
'(' expr
')' { $$
= $2; }
372 |
'*' expr %prec OP_DEREF
{ $$
= DEBUG_UnopExpr
(EXP_OP_DEREF
, $2); }
373 |
'&' expr %prec OP_DEREF
{ $$
= DEBUG_UnopExpr
(EXP_OP_ADDR
, $2); }
374 | type_cast expr %prec OP_DEREF
{ $$
= DEBUG_TypeCastExpr
($1, $2); }
377 * The lvalue rule builds an expression tree. This is a limited form
378 * of expression that is suitable to be used as an lvalue.
381 lval
{ $$
= DEBUG_EvalExpr
($1); }
385 |
'*' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_FORCE_DEREF
, $2); }
388 tNUM
{ $$
= DEBUG_ConstExpr
($1); }
389 | tREG
{ $$
= DEBUG_RegisterExpr
($1); }
390 | tIDENTIFIER
{ $$
= DEBUG_SymbolExpr
($1); }
391 | lvalue OP_DRF tIDENTIFIER
{ $$
= DEBUG_StructPExpr
($1, $3); }
392 | lvalue
'.' tIDENTIFIER
{ $$
= DEBUG_StructExpr
($1, $3); }
393 | lvalue
'[' expr
']' { $$
= DEBUG_BinopExpr
(EXP_OP_ARR
, $1, $3); }
399 #ifdef DONT_USE_READLINE
400 fprintf
(stderr
,"Wine-dbg>");
404 void mode_command
(int newmode
)
406 if
((newmode
== 16) ||
(newmode
== 32)) dbg_mode
= newmode
;
407 else fprintf
(stderr
,"Invalid mode (use 16 or 32)\n");
411 /***********************************************************************
414 * Debugger main loop.
416 static void DEBUG_Main
( int signal
)
418 static int loaded_symbols
= 0;
419 static BOOL in_debugger
= FALSE
;
420 char SymbolTableFile
[256];
429 fprintf
( stderr
, "Segmentation fault inside debugger, exiting.\n" );
435 DEBUG_SetBreakpoints
( FALSE
);
442 * Initialize the type handling stuff.
447 * In some cases we can read the stabs information directly
448 * from the executable. If this is the case, we don't need
449 * to bother with trying to read a symbol file, as the stabs
450 * also have line number and local variable information.
451 * As long as gcc is used for the compiler, stabs will
452 * be the default. On SVr4, DWARF could be used, but we
453 * don't grok that yet, and in this case we fall back to using
456 if
( DEBUG_ReadExecutableDbgInfo
() == FALSE
)
458 char *symfilename
= "wine.sym";
460 if
(-1 == stat
(symfilename
, &statbuf
) )
461 symfilename
= LIBDIR
"wine.sym";
463 PROFILE_GetWineIniString
( "wine", "SymbolTableFile", symfilename
,
464 SymbolTableFile
, sizeof
(SymbolTableFile
));
465 DEBUG_ReadSymbolTable
( SymbolTableFile
);
468 DEBUG_LoadEntryPoints
();
469 DEBUG_ProcessDeferredDebug
();
473 fprintf
(stderr
, "Entering debugger PC=%x, mode=%d, count=%d\n",
474 EIP_reg
(&DEBUG_context
),
475 dbg_exec_mode
, dbg_exec_count
);
480 if
((signal
!= SIGTRAP
) ||
!DEBUG_ShouldContinue
( dbg_exec_mode
,
484 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
486 addr.seg
= CS_reg
(&DEBUG_context
);
487 addr.off
= EIP_reg
(&DEBUG_context
);
488 if
(ISV86
(&DEBUG_context
)) addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
490 DBG_FIX_ADDR_SEG
( &addr
, 0 );
492 GlobalUnlock16
( GetCurrentTask
() );
494 /* Put the display in a correct state */
495 USER_Driver
->pBeginDebugging
();
497 newmode
= ISV86
(&DEBUG_context
) ?
16 : IS_SELECTOR_32BIT
(addr.seg
) ?
32 : 16;
498 if
(newmode
!= dbg_mode
)
499 fprintf
(stderr
,"In %d bit mode.\n", dbg_mode
= newmode
);
501 PROCESS_SuspendOtherThreads
();
505 if
(signal
!= SIGTRAP
) /* This is a real crash, dump some info */
507 DEBUG_InfoRegisters
();
511 LDT_Print
( SELECTOR_TO_ENTRY
(DS_reg
(&DEBUG_context
)), 1 );
512 if
(ES_reg
(&DEBUG_context
) != DS_reg
(&DEBUG_context
))
513 LDT_Print
( SELECTOR_TO_ENTRY
(ES_reg
(&DEBUG_context
)), 1 );
520 * Do a quiet backtrace so that we have an idea of what the situation
521 * is WRT the source files.
523 DEBUG_SilentBackTrace
();
526 if
((signal
!= SIGTRAP
) ||
527 (dbg_exec_mode
== EXEC_STEPI_OVER
) ||
528 (dbg_exec_mode
== EXEC_STEPI_INSTR
))
530 /* Show where we crashed */
532 DEBUG_PrintAddress
( &addr
, dbg_mode
, TRUE
);
533 fprintf
(stderr
,": ");
534 if
(DBG_CHECK_READ_PTR
( &addr
, 1 ))
536 DEBUG_Disasm
( &addr
, TRUE
);
537 fprintf
(stderr
,"\n");
547 addr.seg
= CS_reg
(&DEBUG_context
) |
(addr.seg
&0xffff0000);
548 addr.off
= EIP_reg
(&DEBUG_context
);
549 DBG_FIX_ADDR_SEG
( &addr
, 0 );
550 ret_ok
= DEBUG_ValidateRegisters
();
551 if
(ret_ok
) ret_ok
= DBG_CHECK_READ_PTR
( &addr
, 1 );
555 dbg_exec_mode
= DEBUG_RestartExecution
( dbg_exec_mode
, dbg_exec_count
);
557 * This will have gotten absorbed into the breakpoint info
558 * if it was used. Otherwise it would have been ignored.
559 * In any case, we don't mess with it any more.
561 if
( dbg_exec_mode
== EXEC_CONT
)
564 PROCESS_ResumeOtherThreads
();
569 USER_Driver
->pEndDebugging
();
574 /***********************************************************************
575 * DebugBreak (KERNEL.203) (KERNEL32.181)
577 void DebugBreak16
( CONTEXT
*regs
)
580 if
(!GetModuleName16
( GetCurrentTask
(), module
, sizeof
(module
) ))
581 strcpy
( module
, "???" );
582 fprintf
( stderr
, "%s called DebugBreak\n", module
);
583 DEBUG_context
= *regs
;
584 DEBUG_Main
( SIGTRAP
);
588 void ctx_debug
( int signal
, CONTEXT
*regs
)
590 DEBUG_context
= *regs
;
591 DEBUG_Main
( signal
);
592 *regs
= DEBUG_context
;
595 void wine_debug
( int signal
, SIGCONTEXT
*regs
)
598 DWORD
*stack
= (DWORD
*)ESP_sig
(regs
);
601 *(--stack
) = EH_NONCONTINUABLE
;
602 *(--stack
) = EXCEPTION_ACCESS_VIOLATION
;
603 *(--stack
) = EIP_sig
(regs
);
604 ESP_sig
(regs
) = (DWORD
)stack
;
605 EIP_sig
(regs
) = (DWORD
)RaiseException
;
607 DEBUG_SetSigContext
( regs
);
608 DEBUG_Main
( signal
);
609 DEBUG_GetSigContext
( regs
);
613 int yyerror(char * s
)
615 fprintf
(stderr
,"%s\n", s
);