3 * Parser for command lines in the Wine debugger
5 * Copyright 1993 Eric Youngdale
6 * Copyright 1995 Morten Welinder
22 #include "wine/winbase16.h"
34 unsigned int dbg_mode
= 0;
37 static enum exec_mode dbg_exec_mode
= EXEC_CONT
;
38 static int dbg_exec_count
= 0;
40 void issue_prompt
(void);
41 void mode_command
(int);
42 void flush_symbols
(void);
46 extern
void VIRTUAL_Dump
(void); /* memory/virtual.c */
56 struct list_id listing
;
57 struct expr
* expression
;
58 struct datatype
* type
;
61 %token tCONT tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
62 %token tENABLE tDISABLE tBREAK tDELETE tSET tMODE tPRINT tEXAM tABORT tDEBUGMSG
63 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
64 %token tEOL tSTRING tDEBUGSTR
65 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
66 %token tSTEPI tNEXTI tFINISH tSHOW tDIR
68 %token
<string> tIDENTIFIER tSTRING tDEBUGSTR
69 %token
<integer
> tNUM tFORMAT
73 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
74 %token tSTRUCT tUNION tENUM
77 /* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
78 OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
79 OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
80 /* %left OP_COND */ /* ... ? ... : ... */
87 %left
'<' '>' OP_LE OP_GE
91 %left OP_SIGN
'!' '~' OP_DEREF
/* OP_INC OP_DEC OP_ADDR */
95 %type
<expression
> expr lval lvalue
96 %type
<type
> type_cast type_expr
97 %type
<address
> expr_addr lval_addr
98 %type
<integer
> expr_value
99 %type
<string> pathname
101 %type
<listing
> list_arg
105 input: line
{ issue_prompt
(); }
106 | input line
{ issue_prompt
(); }
110 |
error tEOL
{ yyerrok; }
113 tQUIT tEOL
{ exit
(0); }
114 | tHELP tEOL
{ DEBUG_Help
(); }
115 | tHELP tINFO tEOL
{ DEBUG_HelpInfo
(); }
116 | tCONT tEOL
{ dbg_exec_count
= 1;
117 dbg_exec_mode
= EXEC_CONT
; return
0; }
118 | tCONT tNUM tEOL
{ dbg_exec_count
= $2;
119 dbg_exec_mode
= EXEC_CONT
; return
0; }
120 | tSTEP tEOL
{ dbg_exec_count
= 1;
121 dbg_exec_mode
= EXEC_STEP_INSTR
; return
0; }
122 | tNEXT tEOL
{ dbg_exec_count
= 1;
123 dbg_exec_mode
= EXEC_STEP_OVER
; return
0; }
124 | tSTEP tNUM tEOL
{ dbg_exec_count
= $2;
125 dbg_exec_mode
= EXEC_STEP_INSTR
; return
0; }
126 | tNEXT tNUM tEOL
{ dbg_exec_count
= $2;
127 dbg_exec_mode
= EXEC_STEP_OVER
; return
0; }
128 | tSTEPI tEOL
{ dbg_exec_count
= 1;
129 dbg_exec_mode
= EXEC_STEPI_INSTR
; return
0; }
130 | tNEXTI tEOL
{ dbg_exec_count
= 1;
131 dbg_exec_mode
= EXEC_STEPI_OVER
; return
0; }
132 | tSTEPI tNUM tEOL
{ dbg_exec_count
= $2;
133 dbg_exec_mode
= EXEC_STEPI_INSTR
; return
0; }
134 | tNEXTI tNUM tEOL
{ dbg_exec_count
= $2;
135 dbg_exec_mode
= EXEC_STEPI_OVER
; return
0; }
136 | tABORT tEOL
{ kill
(getpid
(), SIGABRT
); }
137 | tMODE tNUM tEOL
{ mode_command
($2); }
138 | tENABLE tNUM tEOL
{ DEBUG_EnableBreakpoint
( $2, TRUE
); }
139 | tDISABLE tNUM tEOL
{ DEBUG_EnableBreakpoint
( $2, FALSE
); }
140 | tDELETE tBREAK tNUM tEOL
{ DEBUG_DelBreakpoint
( $3 ); }
141 | tBACKTRACE tEOL
{ DEBUG_BackTrace
(); }
142 | tUP tEOL
{ DEBUG_SetFrame
( curr_frame
+ 1 ); }
143 | tUP tNUM tEOL
{ DEBUG_SetFrame
( curr_frame
+ $2 ); }
144 | tDOWN tEOL
{ DEBUG_SetFrame
( curr_frame
- 1 ); }
145 | tDOWN tNUM tEOL
{ DEBUG_SetFrame
( curr_frame
- $2 ); }
146 | tFRAME tNUM tEOL
{ DEBUG_SetFrame
( $2 ); }
147 | tFINISH tEOL
{ dbg_exec_count
= 0;
148 dbg_exec_mode
= EXEC_FINISH
; return
0; }
149 | tSHOW tDIR tEOL
{ DEBUG_ShowDir
(); }
150 | tDIR pathname tEOL
{ DEBUG_AddPath
( $2 ); }
151 | tDIR tEOL
{ DEBUG_NukePath
(); }
152 | tDISPLAY tEOL
{ DEBUG_InfoDisplay
(); }
153 | tDISPLAY expr tEOL
{ DEBUG_AddDisplay
($2, 1, 0); }
154 | tDISPLAY tFORMAT expr tEOL
{ DEBUG_AddDisplay
($3, $2 >> 8, $2 & 0xff); }
155 | tDELETE tDISPLAY tNUM tEOL
{ DEBUG_DelDisplay
( $3 ); }
156 | tDELETE tDISPLAY tEOL
{ DEBUG_DelDisplay
( -1 ); }
157 | tUNDISPLAY tNUM tEOL
{ DEBUG_DelDisplay
( $2 ); }
158 | tUNDISPLAY tEOL
{ DEBUG_DelDisplay
( -1 ); }
159 | tCOND tNUM tEOL
{ DEBUG_AddBPCondition
($2, NULL
); }
160 | tCOND tNUM expr tEOL
{ DEBUG_AddBPCondition
($2, $3); }
161 | tDEBUGMSG tDEBUGSTR tEOL
{ MAIN_ParseDebugOptions
($2); }
162 | tSYMBOLFILE pathname tEOL
{ DEBUG_ReadSymbolTable
($2); }
164 | disassemble_command
173 tSET tREG
'=' expr_value tEOL
{ DEBUG_SetRegister
( $2, $4 );
174 DEBUG_FreeExprMem
(); }
175 | tSET lval_addr
'=' expr_value tEOL
{ DEBUG_WriteMemory
( &$2, $4 );
176 DEBUG_FreeExprMem
(); }
179 tIDENTIFIER
{ $$
= $1; }
183 tDISASSEMBLE tEOL
{ DEBUG_Disassemble
( NULL
, NULL
, 10 ); }
184 | tDISASSEMBLE expr_addr tEOL
{ DEBUG_Disassemble
( & $2, NULL
, 10 ); }
185 | tDISASSEMBLE expr_addr
',' expr_addr tEOL
{ DEBUG_Disassemble
( & $2, & $4, 0 ); }
188 tLIST tEOL
{ DEBUG_List
( NULL
, NULL
, 10 ); }
189 | tLIST
'-' tEOL
{ DEBUG_List
( NULL
, NULL
, -10 ); }
190 | tLIST list_arg tEOL
{ DEBUG_List
( & $2, NULL
, 10 ); }
191 | tLIST
',' list_arg tEOL
{ DEBUG_List
( NULL
, & $3, -10 ); }
192 | tLIST list_arg
',' list_arg tEOL
{ DEBUG_List
( & $2, & $4, 0 ); }
195 tNUM
{ $$.sourcefile
= NULL
; $$.line
= $1; }
196 | pathname
':' tNUM
{ $$.sourcefile
= $1; $$.line
= $3; }
197 | tIDENTIFIER
{ DEBUG_GetFuncInfo
( & $$
, NULL
, $1); }
198 | pathname
':' tIDENTIFIER
{ DEBUG_GetFuncInfo
( & $$
, $1, $3); }
199 |
'*' expr_addr
{ DEBUG_FindNearestSymbol
( & $2, FALSE
, NULL
,
201 DEBUG_FreeExprMem
(); }
204 tEXAM expr_addr tEOL
{ DEBUG_ExamineMemory
( &$2, 1, 'x');
205 DEBUG_FreeExprMem
(); }
206 | tEXAM tFORMAT expr_addr tEOL
{ DEBUG_ExamineMemory
( &$3, $2>>8, $2&0xff );
207 DEBUG_FreeExprMem
(); }
210 tPRINT expr_addr tEOL
{ DEBUG_Print
( &$2, 1, 0, 0 );
211 DEBUG_FreeExprMem
(); }
212 | tPRINT tFORMAT expr_addr tEOL
{ DEBUG_Print
( &$3, $2 >> 8, $2 & 0xff, 0 );
213 DEBUG_FreeExprMem
(); }
216 tBREAK
'*' expr_addr tEOL
{ DEBUG_AddBreakpoint
( &$3 );
217 DEBUG_FreeExprMem
(); }
218 | tBREAK tIDENTIFIER tEOL
{ DBG_ADDR addr
;
219 if
( DEBUG_GetSymbolValue
($2, -1, &addr
, TRUE
) )
221 DEBUG_AddBreakpoint
( &addr
);
225 fprintf
(stderr
,"Unable to add breakpoint\n");
228 | tBREAK tIDENTIFIER
':' tNUM tEOL
{ DBG_ADDR addr
;
229 if
( DEBUG_GetSymbolValue
($2, $4, &addr
, TRUE
) )
231 DEBUG_AddBreakpoint
( &addr
);
235 fprintf
(stderr
,"Unable to add breakpoint\n");
238 | tBREAK tNUM tEOL
{ struct name_hash
*nh
;
240 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
243 addr.seg
= CS_reg
(&DEBUG_context
);
244 addr.off
= EIP_reg
(&DEBUG_context
);
246 if
(ISV86
(&DEBUG_context
))
247 addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
248 DBG_FIX_ADDR_SEG
( &addr
, CS_reg
(&DEBUG_context
) );
249 GlobalUnlock16
( GetCurrentTask
() );
250 DEBUG_FindNearestSymbol
(&addr
, TRUE
,
254 DEBUG_GetLineNumberAddr
(nh
,
256 DEBUG_AddBreakpoint
( &addr
);
260 fprintf
(stderr
,"Unable to add breakpoint\n");
264 | tBREAK tEOL
{ DBG_ADDR addr
;
265 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
268 addr.seg
= CS_reg
(&DEBUG_context
);
269 addr.off
= EIP_reg
(&DEBUG_context
);
271 if
(ISV86
(&DEBUG_context
))
272 addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
273 GlobalUnlock16
( GetCurrentTask
() );
274 DEBUG_AddBreakpoint
( &addr
);
278 tINFO tBREAK tEOL
{ DEBUG_InfoBreakpoints
(); }
279 | tINFO tCLASS expr_value tEOL
{ CLASS_DumpClass
( (CLASS
*)$3 );
280 DEBUG_FreeExprMem
(); }
281 | tINFO tSHARE tEOL
{ DEBUG_InfoShare
(); }
282 | tINFO tMODULE expr_value tEOL
{ NE_DumpModule
( $3 );
283 DEBUG_FreeExprMem
(); }
284 | tINFO tQUEUE expr_value tEOL
{ QUEUE_DumpQueue
( $3 );
285 DEBUG_FreeExprMem
(); }
286 | tINFO tREGS tEOL
{ DEBUG_InfoRegisters
(); }
287 | tINFO tSEGMENTS expr_value tEOL
{ LDT_Print
( SELECTOR_TO_ENTRY
($3), 1 );
288 DEBUG_FreeExprMem
(); }
289 | tINFO tSEGMENTS tEOL
{ LDT_Print
( 0, -1 ); }
290 | tINFO tSTACK tEOL
{ DEBUG_InfoStack
(); }
291 | tINFO tMAPS tEOL
{ VIRTUAL_Dump
(); }
292 | tINFO tWND expr_value tEOL
{ WIN_DumpWindow
( $3 );
293 DEBUG_FreeExprMem
(); }
294 | tINFO tLOCAL tEOL
{ DEBUG_InfoLocals
(); }
295 | tINFO tDISPLAY tEOL
{ DEBUG_InfoDisplay
(); }
298 tWALK tCLASS tEOL
{ CLASS_WalkClasses
(); }
299 | tWALK tMODULE tEOL
{ NE_WalkModules
(); }
300 | tWALK tQUEUE tEOL
{ QUEUE_WalkQueues
(); }
301 | tWALK tWND tEOL
{ WIN_WalkWindows
( 0, 0 ); }
302 | tWALK tWND tNUM tEOL
{ WIN_WalkWindows
( $3, 0 ); }
306 '(' type_expr
')' { $$
= $2; }
309 type_expr
'*' { $$
= DEBUG_FindOrMakePointerType
($1); }
310 | tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "int"); }
311 | tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "char"); }
312 | tLONG tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long int"); }
313 | tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "unsigned int"); }
314 | tLONG tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long unsigned int"); }
315 | tLONG tLONG tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long long int"); }
316 | tLONG tLONG tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long long unsigned int"); }
317 | tSHORT tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "short int"); }
318 | tSHORT tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "short unsigned int"); }
319 | tSIGNED tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "signed char"); }
320 | tUNSIGNED tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "unsigned char"); }
321 | tFLOAT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "float"); }
322 | tDOUBLE
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "double"); }
323 | tLONG tDOUBLE
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long double"); }
324 | tSTRUCT tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_STRUCT
, $2); }
325 | tUNION tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_STRUCT
, $2); }
326 | tENUM tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_ENUM
, $2); }
329 expr
{ $$
= DEBUG_EvalExpr
($1); }
332 expr
{ DBG_ADDR addr
= DEBUG_EvalExpr
($1);
333 $$
= addr.off ?
*(unsigned int *) addr.off
: 0; }
335 * The expr rule builds an expression tree. When we are done, we call
336 * EvalExpr to evaluate the value of the expression. The advantage of
337 * the two-step approach is that it is possible to save expressions for
338 * use in 'display' commands, and in conditional watchpoints.
341 tNUM
{ $$
= DEBUG_ConstExpr
($1); }
342 | tSTRING
{ $$
= DEBUG_StringExpr
($1); }
343 | tREG
{ $$
= DEBUG_RegisterExpr
($1); }
344 | tIDENTIFIER
{ $$
= DEBUG_SymbolExpr
($1); }
345 | expr OP_DRF tIDENTIFIER
{ $$
= DEBUG_StructPExpr
($1, $3); }
346 | expr
'.' tIDENTIFIER
{ $$
= DEBUG_StructExpr
($1, $3); }
347 | tIDENTIFIER
'(' ')' { $$
= DEBUG_CallExpr
($1, 0); }
348 | tIDENTIFIER
'(' expr
')' { $$
= DEBUG_CallExpr
($1, 1, $3); }
349 | tIDENTIFIER
'(' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 2, $3,
351 | tIDENTIFIER
'(' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7); }
352 | tIDENTIFIER
'(' expr
',' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7, $9); }
353 | tIDENTIFIER
'(' expr
',' expr
',' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7, $9, $11); }
354 | expr
'[' expr
']' { $$
= DEBUG_BinopExpr
(EXP_OP_ARR
, $1, $3); }
355 | expr
':' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SEG
, $1, $3); }
356 | expr OP_LOR expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LOR
, $1, $3); }
357 | expr OP_LAND expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LAND
, $1, $3); }
358 | expr
'|' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_OR
, $1, $3); }
359 | expr
'&' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_AND
, $1, $3); }
360 | expr
'^' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_XOR
, $1, $3); }
361 | expr OP_EQ expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_EQ
, $1, $3); }
362 | expr
'>' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_GT
, $1, $3); }
363 | expr
'<' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LT
, $1, $3); }
364 | expr OP_GE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_GE
, $1, $3); }
365 | expr OP_LE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LE
, $1, $3); }
366 | expr OP_NE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_NE
, $1, $3); }
367 | expr OP_SHL expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SHL
, $1, $3); }
368 | expr OP_SHR expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SHR
, $1, $3); }
369 | expr
'+' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_ADD
, $1, $3); }
370 | expr
'-' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SUB
, $1, $3); }
371 | expr
'*' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_MUL
, $1, $3); }
372 | expr
'/' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_DIV
, $1, $3); }
373 | expr
'%' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_REM
, $1, $3); }
374 |
'-' expr %prec OP_SIGN
{ $$
= DEBUG_UnopExpr
(EXP_OP_NEG
, $2); }
375 |
'+' expr %prec OP_SIGN
{ $$
= $2; }
376 |
'!' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_NOT
, $2); }
377 |
'~' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_LNOT
, $2); }
378 |
'(' expr
')' { $$
= $2; }
379 |
'*' expr %prec OP_DEREF
{ $$
= DEBUG_UnopExpr
(EXP_OP_DEREF
, $2); }
380 |
'&' expr %prec OP_DEREF
{ $$
= DEBUG_UnopExpr
(EXP_OP_ADDR
, $2); }
381 | type_cast expr %prec OP_DEREF
{ $$
= DEBUG_TypeCastExpr
($1, $2); }
384 * The lvalue rule builds an expression tree. This is a limited form
385 * of expression that is suitable to be used as an lvalue.
388 lval
{ $$
= DEBUG_EvalExpr
($1); }
392 |
'*' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_FORCE_DEREF
, $2); }
395 tNUM
{ $$
= DEBUG_ConstExpr
($1); }
396 | tREG
{ $$
= DEBUG_RegisterExpr
($1); }
397 | tIDENTIFIER
{ $$
= DEBUG_SymbolExpr
($1); }
398 | lvalue OP_DRF tIDENTIFIER
{ $$
= DEBUG_StructPExpr
($1, $3); }
399 | lvalue
'.' tIDENTIFIER
{ $$
= DEBUG_StructExpr
($1, $3); }
400 | lvalue
'[' expr
']' { $$
= DEBUG_BinopExpr
(EXP_OP_ARR
, $1, $3); }
406 #ifdef DONT_USE_READLINE
407 fprintf
(stderr
,"Wine-dbg>");
411 void mode_command
(int newmode
)
413 if
((newmode
== 16) ||
(newmode
== 32)) dbg_mode
= newmode
;
414 else fprintf
(stderr
,"Invalid mode (use 16 or 32)\n");
418 /***********************************************************************
421 * Debugger main loop.
423 static void DEBUG_Main
( int signal
)
425 static int loaded_symbols
= 0;
426 static BOOL frozen
= FALSE
;
427 static BOOL in_debugger
= FALSE
;
428 char SymbolTableFile
[256];
437 fprintf
( stderr
, "Segmentation fault inside debugger, exiting.\n" );
443 DEBUG_SetBreakpoints
( FALSE
);
451 CLIENT_DebuggerRequest
( DEBUGGER_FREEZE_ALL
);
456 * Initialize the type handling stuff.
461 * In some cases we can read the stabs information directly
462 * from the executable. If this is the case, we don't need
463 * to bother with trying to read a symbol file, as the stabs
464 * also have line number and local variable information.
465 * As long as gcc is used for the compiler, stabs will
466 * be the default. On SVr4, DWARF could be used, but we
467 * don't grok that yet, and in this case we fall back to using
470 if
( DEBUG_ReadExecutableDbgInfo
() == FALSE
)
472 char *symfilename
= "wine.sym";
474 if
(-1 == stat
(symfilename
, &statbuf
) )
475 symfilename
= LIBDIR
"wine.sym";
477 PROFILE_GetWineIniString
( "wine", "SymbolTableFile", symfilename
,
478 SymbolTableFile
, sizeof
(SymbolTableFile
));
479 DEBUG_ReadSymbolTable
( SymbolTableFile
);
482 DEBUG_LoadEntryPoints
();
483 DEBUG_ProcessDeferredDebug
();
487 fprintf
(stderr
, "Entering debugger PC=%x, mode=%d, count=%d\n",
488 EIP_reg
(&DEBUG_context
),
489 dbg_exec_mode
, dbg_exec_count
);
494 if
((signal
!= SIGTRAP
) ||
!DEBUG_ShouldContinue
( dbg_exec_mode
,
498 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
500 addr.seg
= CS_reg
(&DEBUG_context
);
501 addr.off
= EIP_reg
(&DEBUG_context
);
502 if
(ISV86
(&DEBUG_context
)) addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
504 DBG_FIX_ADDR_SEG
( &addr
, 0 );
506 GlobalUnlock16
( GetCurrentTask
() );
510 CLIENT_DebuggerRequest
( DEBUGGER_FREEZE_ALL
);
514 /* Put the display in a correct state */
515 USER_Driver
->pBeginDebugging
();
517 newmode
= ISV86
(&DEBUG_context
) ?
16 : IS_SELECTOR_32BIT
(addr.seg
) ?
32 : 16;
518 if
(newmode
!= dbg_mode
)
519 fprintf
(stderr
,"In %d bit mode.\n", dbg_mode
= newmode
);
523 if
(signal
!= SIGTRAP
) /* This is a real crash, dump some info */
525 DEBUG_InfoRegisters
();
529 LDT_Print
( SELECTOR_TO_ENTRY
(DS_reg
(&DEBUG_context
)), 1 );
530 if
(ES_reg
(&DEBUG_context
) != DS_reg
(&DEBUG_context
))
531 LDT_Print
( SELECTOR_TO_ENTRY
(ES_reg
(&DEBUG_context
)), 1 );
538 * Do a quiet backtrace so that we have an idea of what the situation
539 * is WRT the source files.
541 DEBUG_SilentBackTrace
();
544 if
((signal
!= SIGTRAP
) ||
545 (dbg_exec_mode
== EXEC_STEPI_OVER
) ||
546 (dbg_exec_mode
== EXEC_STEPI_INSTR
))
548 /* Show where we crashed */
550 DEBUG_PrintAddress
( &addr
, dbg_mode
, TRUE
);
551 fprintf
(stderr
,": ");
552 if
(DBG_CHECK_READ_PTR
( &addr
, 1 ))
554 DEBUG_Disasm
( &addr
, TRUE
);
555 fprintf
(stderr
,"\n");
565 addr.seg
= CS_reg
(&DEBUG_context
) |
(addr.seg
&0xffff0000);
566 addr.off
= EIP_reg
(&DEBUG_context
);
567 DBG_FIX_ADDR_SEG
( &addr
, 0 );
568 ret_ok
= DEBUG_ValidateRegisters
();
569 if
(ret_ok
) ret_ok
= DBG_CHECK_READ_PTR
( &addr
, 1 );
573 dbg_exec_mode
= DEBUG_RestartExecution
( dbg_exec_mode
, dbg_exec_count
);
575 * This will have gotten absorbed into the breakpoint info
576 * if it was used. Otherwise it would have been ignored.
577 * In any case, we don't mess with it any more.
579 if
( dbg_exec_mode
== EXEC_CONT
)
585 CLIENT_DebuggerRequest
( DEBUGGER_UNFREEZE_ALL
);
592 USER_Driver
->pEndDebugging
();
597 /***********************************************************************
598 * DebugBreak (KERNEL.203) (KERNEL32.181)
600 void DebugBreak16
( CONTEXT
*regs
)
603 if
(!GetModuleName16
( GetCurrentTask
(), module
, sizeof
(module
) ))
604 strcpy
( module
, "???" );
605 fprintf
( stderr
, "%s called DebugBreak\n", module
);
606 DEBUG_context
= *regs
;
607 DEBUG_Main
( SIGTRAP
);
611 void ctx_debug
( int signal
, CONTEXT
*regs
)
613 DEBUG_context
= *regs
;
614 DEBUG_Main
( signal
);
615 *regs
= DEBUG_context
;
618 void wine_debug
( int signal
, SIGCONTEXT
*regs
)
621 DWORD
*stack
= (DWORD
*)ESP_sig
(regs
);
624 *(--stack
) = EH_NONCONTINUABLE
;
625 *(--stack
) = EXCEPTION_ACCESS_VIOLATION
;
626 *(--stack
) = EIP_sig
(regs
);
627 ESP_sig
(regs
) = (DWORD
)stack
;
628 EIP_sig
(regs
) = (DWORD
)RaiseException
;
630 DEBUG_SetSigContext
( regs
);
631 DEBUG_Main
( signal
);
632 DEBUG_GetSigContext
( regs
);
636 int yyerror(char * s
)
638 fprintf
(stderr
,"%s\n", s
);