3 * Parser for command lines in the Wine debugger
5 * Copyright 1993 Eric Youngdale
6 * Copyright 1995 Morten Welinder
27 #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 tEOL tSTRING tDEBUGSTR
77 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
78 %token tSTEPI tNEXTI tFINISH tSHOW tDIR
80 %token
<string> tIDENTIFIER tSTRING tDEBUGSTR
81 %token
<integer
> tNUM tFORMAT
85 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
86 %token tSTRUCT tUNION tENUM
89 /* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
90 OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
91 OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
92 /* %left OP_COND */ /* ... ? ... : ... */
99 %left
'<' '>' OP_LE OP_GE
103 %left OP_SIGN
'!' '~' OP_DEREF
/* OP_INC OP_DEC OP_ADDR */
107 %type
<expression
> expr lval lvalue
108 %type
<type
> type_cast type_expr
109 %type
<address
> expr_addr lval_addr
110 %type
<integer
> expr_value
111 %type
<string> pathname
113 %type
<listing
> list_arg
117 input: line
{ issue_prompt
(); }
118 | input line
{ issue_prompt
(); }
122 |
error tEOL
{ yyerrok; }
125 tQUIT tEOL
{ exit
(0); }
126 | tHELP tEOL
{ DEBUG_Help
(); }
127 | tHELP tINFO tEOL
{ DEBUG_HelpInfo
(); }
128 | tCONT tEOL
{ dbg_exec_count
= 1;
129 dbg_exec_mode
= EXEC_CONT
; return
0; }
130 | tCONT tNUM tEOL
{ dbg_exec_count
= $2;
131 dbg_exec_mode
= EXEC_CONT
; return
0; }
132 | tSTEP tEOL
{ dbg_exec_count
= 1;
133 dbg_exec_mode
= EXEC_STEP_INSTR
; return
0; }
134 | tNEXT tEOL
{ dbg_exec_count
= 1;
135 dbg_exec_mode
= EXEC_STEP_OVER
; return
0; }
136 | tSTEP tNUM tEOL
{ dbg_exec_count
= $2;
137 dbg_exec_mode
= EXEC_STEP_INSTR
; return
0; }
138 | tNEXT tNUM tEOL
{ dbg_exec_count
= $2;
139 dbg_exec_mode
= EXEC_STEP_OVER
; return
0; }
140 | tSTEPI tEOL
{ dbg_exec_count
= 1;
141 dbg_exec_mode
= EXEC_STEPI_INSTR
; return
0; }
142 | tNEXTI tEOL
{ dbg_exec_count
= 1;
143 dbg_exec_mode
= EXEC_STEPI_OVER
; return
0; }
144 | tSTEPI tNUM tEOL
{ dbg_exec_count
= $2;
145 dbg_exec_mode
= EXEC_STEPI_INSTR
; return
0; }
146 | tNEXTI tNUM tEOL
{ dbg_exec_count
= $2;
147 dbg_exec_mode
= EXEC_STEPI_OVER
; return
0; }
148 | tABORT tEOL
{ kill
(getpid
(), SIGABRT
); }
149 | tMODE tNUM tEOL
{ mode_command
($2); }
150 | tENABLE tNUM tEOL
{ DEBUG_EnableBreakpoint
( $2, TRUE
); }
151 | tDISABLE tNUM tEOL
{ DEBUG_EnableBreakpoint
( $2, FALSE
); }
152 | tDELETE tBREAK tNUM tEOL
{ DEBUG_DelBreakpoint
( $3 ); }
153 | tBACKTRACE tEOL
{ DEBUG_BackTrace
(); }
154 | tUP tEOL
{ DEBUG_SetFrame
( curr_frame
+ 1 ); }
155 | tUP tNUM tEOL
{ DEBUG_SetFrame
( curr_frame
+ $2 ); }
156 | tDOWN tEOL
{ DEBUG_SetFrame
( curr_frame
- 1 ); }
157 | tDOWN tNUM tEOL
{ DEBUG_SetFrame
( curr_frame
- $2 ); }
158 | tFRAME tNUM tEOL
{ DEBUG_SetFrame
( $2 ); }
159 | tFINISH tEOL
{ dbg_exec_count
= 0;
160 dbg_exec_mode
= EXEC_FINISH
; return
0; }
161 | tSHOW tDIR tEOL
{ DEBUG_ShowDir
(); }
162 | tDIR pathname tEOL
{ DEBUG_AddPath
( $2 ); }
163 | tDIR tEOL
{ DEBUG_NukePath
(); }
164 | tDISPLAY tEOL
{ DEBUG_InfoDisplay
(); }
165 | tDISPLAY expr tEOL
{ DEBUG_AddDisplay
($2, 1, 0); }
166 | tDISPLAY tFORMAT expr tEOL
{ DEBUG_AddDisplay
($3, $2 >> 8, $2 & 0xff); }
167 | tDELETE tDISPLAY tNUM tEOL
{ DEBUG_DelDisplay
( $3 ); }
168 | tDELETE tDISPLAY tEOL
{ DEBUG_DelDisplay
( -1 ); }
169 | tUNDISPLAY tNUM tEOL
{ DEBUG_DelDisplay
( $2 ); }
170 | tUNDISPLAY tEOL
{ DEBUG_DelDisplay
( -1 ); }
171 | tCOND tNUM tEOL
{ DEBUG_AddBPCondition
($2, NULL
); }
172 | tCOND tNUM expr tEOL
{ DEBUG_AddBPCondition
($2, $3); }
173 | tDEBUGMSG tDEBUGSTR tEOL
{ MAIN_ParseDebugOptions
($2); }
174 | tSYMBOLFILE pathname tEOL
{ DEBUG_ReadSymbolTable
($2); }
176 | disassemble_command
185 tSET tREG
'=' expr_value tEOL
{ DEBUG_SetRegister
( $2, $4 );
186 DEBUG_FreeExprMem
(); }
187 | tSET lval_addr
'=' expr_value tEOL
{ DEBUG_WriteMemory
( &$2, $4 );
188 DEBUG_FreeExprMem
(); }
191 tIDENTIFIER
{ $$
= $1; }
195 tDISASSEMBLE tEOL
{ DEBUG_Disassemble
( NULL
, NULL
, 10 ); }
196 | tDISASSEMBLE expr_addr tEOL
{ DEBUG_Disassemble
( & $2, NULL
, 10 ); }
197 | tDISASSEMBLE expr_addr
',' expr_addr tEOL
{ DEBUG_Disassemble
( & $2, & $4, 0 ); }
200 tLIST tEOL
{ DEBUG_List
( NULL
, NULL
, 10 ); }
201 | tLIST
'-' tEOL
{ DEBUG_List
( NULL
, NULL
, -10 ); }
202 | tLIST list_arg tEOL
{ DEBUG_List
( & $2, NULL
, 10 ); }
203 | tLIST
',' list_arg tEOL
{ DEBUG_List
( NULL
, & $3, -10 ); }
204 | tLIST list_arg
',' list_arg tEOL
{ DEBUG_List
( & $2, & $4, 0 ); }
207 tNUM
{ $$.sourcefile
= NULL
; $$.line
= $1; }
208 | pathname
':' tNUM
{ $$.sourcefile
= $1; $$.line
= $3; }
209 | tIDENTIFIER
{ DEBUG_GetFuncInfo
( & $$
, NULL
, $1); }
210 | pathname
':' tIDENTIFIER
{ DEBUG_GetFuncInfo
( & $$
, $1, $3); }
211 |
'*' expr_addr
{ DEBUG_FindNearestSymbol
( & $2, FALSE
, NULL
,
213 DEBUG_FreeExprMem
(); }
216 tEXAM expr_addr tEOL
{ DEBUG_ExamineMemory
( &$2, 1, 'x');
217 DEBUG_FreeExprMem
(); }
218 | tEXAM tFORMAT expr_addr tEOL
{ DEBUG_ExamineMemory
( &$3, $2>>8, $2&0xff );
219 DEBUG_FreeExprMem
(); }
222 tPRINT expr_addr tEOL
{ DEBUG_Print
( &$2, 1, 0, 0 );
223 DEBUG_FreeExprMem
(); }
224 | tPRINT tFORMAT expr_addr tEOL
{ DEBUG_Print
( &$3, $2 >> 8, $2 & 0xff, 0 );
225 DEBUG_FreeExprMem
(); }
228 tBREAK
'*' expr_addr tEOL
{ DEBUG_AddBreakpoint
( &$3 );
229 DEBUG_FreeExprMem
(); }
230 | tBREAK tIDENTIFIER tEOL
{ DBG_ADDR addr
;
231 if
( DEBUG_GetSymbolValue
($2, -1, &addr
, TRUE
) )
233 DEBUG_AddBreakpoint
( &addr
);
237 fprintf
(stderr
,"Unable to add breakpoint\n");
240 | tBREAK tIDENTIFIER
':' tNUM tEOL
{ DBG_ADDR addr
;
241 if
( DEBUG_GetSymbolValue
($2, $4, &addr
, TRUE
) )
243 DEBUG_AddBreakpoint
( &addr
);
247 fprintf
(stderr
,"Unable to add breakpoint\n");
250 | tBREAK tNUM tEOL
{ struct name_hash
*nh
;
252 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
255 addr.seg
= CS_reg
(&DEBUG_context
);
256 addr.off
= EIP_reg
(&DEBUG_context
);
258 if
(ISV86
(&DEBUG_context
))
259 addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
260 DBG_FIX_ADDR_SEG
( &addr
, CS_reg
(&DEBUG_context
) );
261 GlobalUnlock16
( GetCurrentTask
() );
262 DEBUG_FindNearestSymbol
(&addr
, TRUE
,
266 DEBUG_GetLineNumberAddr
(nh
,
268 DEBUG_AddBreakpoint
( &addr
);
272 fprintf
(stderr
,"Unable to add breakpoint\n");
276 | tBREAK tEOL
{ DBG_ADDR addr
;
277 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
280 addr.seg
= CS_reg
(&DEBUG_context
);
281 addr.off
= EIP_reg
(&DEBUG_context
);
283 if
(ISV86
(&DEBUG_context
))
284 addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
285 GlobalUnlock16
( GetCurrentTask
() );
286 DEBUG_AddBreakpoint
( &addr
);
290 tINFO tBREAK tEOL
{ DEBUG_InfoBreakpoints
(); }
291 | tINFO tCLASS expr_value tEOL
{ CLASS_DumpClass
( (CLASS
*)$3 );
292 DEBUG_FreeExprMem
(); }
293 | tINFO tSHARE tEOL
{ DEBUG_InfoShare
(); }
294 | tINFO tMODULE expr_value tEOL
{ NE_DumpModule
( $3 );
295 DEBUG_FreeExprMem
(); }
296 | tINFO tQUEUE expr_value tEOL
{ QUEUE_DumpQueue
( $3 );
297 DEBUG_FreeExprMem
(); }
298 | tINFO tREGS tEOL
{ DEBUG_InfoRegisters
(); }
299 | tINFO tSEGMENTS expr_value tEOL
{ LDT_Print
( SELECTOR_TO_ENTRY
($3), 1 );
300 DEBUG_FreeExprMem
(); }
301 | tINFO tSEGMENTS tEOL
{ LDT_Print
( 0, -1 ); }
302 | tINFO tSTACK tEOL
{ DEBUG_InfoStack
(); }
303 | tINFO tMAPS tEOL
{ VIRTUAL_Dump
(); }
304 | tINFO tWND expr_value tEOL
{ WIN_DumpWindow
( $3 );
305 DEBUG_FreeExprMem
(); }
306 | tINFO tLOCAL tEOL
{ DEBUG_InfoLocals
(); }
307 | tINFO tDISPLAY tEOL
{ DEBUG_InfoDisplay
(); }
310 tWALK tCLASS tEOL
{ CLASS_WalkClasses
(); }
311 | tWALK tMODULE tEOL
{ NE_WalkModules
(); }
312 | tWALK tQUEUE tEOL
{ QUEUE_WalkQueues
(); }
313 | tWALK tWND tEOL
{ WIN_WalkWindows
( 0, 0 ); }
314 | tWALK tWND tNUM tEOL
{ WIN_WalkWindows
( $3, 0 ); }
318 '(' type_expr
')' { $$
= $2; }
321 type_expr
'*' { $$
= DEBUG_FindOrMakePointerType
($1); }
322 | tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "int"); }
323 | tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "char"); }
324 | tLONG tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long int"); }
325 | tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "unsigned int"); }
326 | tLONG tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long unsigned int"); }
327 | tLONG tLONG tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long long int"); }
328 | tLONG tLONG tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long long unsigned int"); }
329 | tSHORT tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "short int"); }
330 | tSHORT tUNSIGNED tINT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "short unsigned int"); }
331 | tSIGNED tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "signed char"); }
332 | tUNSIGNED tCHAR
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "unsigned char"); }
333 | tFLOAT
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "float"); }
334 | tDOUBLE
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "double"); }
335 | tLONG tDOUBLE
{ $$
= DEBUG_TypeCast
(DT_BASIC
, "long double"); }
336 | tSTRUCT tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_STRUCT
, $2); }
337 | tUNION tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_STRUCT
, $2); }
338 | tENUM tIDENTIFIER
{ $$
= DEBUG_TypeCast
(DT_ENUM
, $2); }
341 expr
{ $$
= DEBUG_EvalExpr
($1); }
344 expr
{ DBG_ADDR addr
= DEBUG_EvalExpr
($1);
345 $$
= addr.off ?
*(unsigned int *) addr.off
: 0; }
347 * The expr rule builds an expression tree. When we are done, we call
348 * EvalExpr to evaluate the value of the expression. The advantage of
349 * the two-step approach is that it is possible to save expressions for
350 * use in 'display' commands, and in conditional watchpoints.
353 tNUM
{ $$
= DEBUG_ConstExpr
($1); }
354 | tSTRING
{ $$
= DEBUG_StringExpr
($1); }
355 | tREG
{ $$
= DEBUG_RegisterExpr
($1); }
356 | tIDENTIFIER
{ $$
= DEBUG_SymbolExpr
($1); }
357 | expr OP_DRF tIDENTIFIER
{ $$
= DEBUG_StructPExpr
($1, $3); }
358 | expr
'.' tIDENTIFIER
{ $$
= DEBUG_StructExpr
($1, $3); }
359 | tIDENTIFIER
'(' ')' { $$
= DEBUG_CallExpr
($1, 0); }
360 | tIDENTIFIER
'(' expr
')' { $$
= DEBUG_CallExpr
($1, 1, $3); }
361 | tIDENTIFIER
'(' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 2, $3,
363 | tIDENTIFIER
'(' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7); }
364 | tIDENTIFIER
'(' expr
',' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7, $9); }
365 | tIDENTIFIER
'(' expr
',' expr
',' expr
',' expr
',' expr
')' { $$
= DEBUG_CallExpr
($1, 3, $3, $5, $7, $9, $11); }
366 | expr
'[' expr
']' { $$
= DEBUG_BinopExpr
(EXP_OP_ARR
, $1, $3); }
367 | expr
':' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SEG
, $1, $3); }
368 | expr OP_LOR expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LOR
, $1, $3); }
369 | expr OP_LAND expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LAND
, $1, $3); }
370 | expr
'|' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_OR
, $1, $3); }
371 | expr
'&' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_AND
, $1, $3); }
372 | expr
'^' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_XOR
, $1, $3); }
373 | expr OP_EQ expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_EQ
, $1, $3); }
374 | expr
'>' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_GT
, $1, $3); }
375 | expr
'<' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LT
, $1, $3); }
376 | expr OP_GE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_GE
, $1, $3); }
377 | expr OP_LE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_LE
, $1, $3); }
378 | expr OP_NE expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_NE
, $1, $3); }
379 | expr OP_SHL expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SHL
, $1, $3); }
380 | expr OP_SHR expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SHR
, $1, $3); }
381 | expr
'+' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_ADD
, $1, $3); }
382 | expr
'-' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_SUB
, $1, $3); }
383 | expr
'*' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_MUL
, $1, $3); }
384 | expr
'/' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_DIV
, $1, $3); }
385 | expr
'%' expr
{ $$
= DEBUG_BinopExpr
(EXP_OP_REM
, $1, $3); }
386 |
'-' expr %prec OP_SIGN
{ $$
= DEBUG_UnopExpr
(EXP_OP_NEG
, $2); }
387 |
'+' expr %prec OP_SIGN
{ $$
= $2; }
388 |
'!' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_NOT
, $2); }
389 |
'~' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_LNOT
, $2); }
390 |
'(' expr
')' { $$
= $2; }
391 |
'*' expr %prec OP_DEREF
{ $$
= DEBUG_UnopExpr
(EXP_OP_DEREF
, $2); }
392 |
'&' expr %prec OP_DEREF
{ $$
= DEBUG_UnopExpr
(EXP_OP_ADDR
, $2); }
393 | type_cast expr %prec OP_DEREF
{ $$
= DEBUG_TypeCastExpr
($1, $2); }
396 * The lvalue rule builds an expression tree. This is a limited form
397 * of expression that is suitable to be used as an lvalue.
400 lval
{ $$
= DEBUG_EvalExpr
($1); }
404 |
'*' expr
{ $$
= DEBUG_UnopExpr
(EXP_OP_FORCE_DEREF
, $2); }
407 tNUM
{ $$
= DEBUG_ConstExpr
($1); }
408 | tREG
{ $$
= DEBUG_RegisterExpr
($1); }
409 | tIDENTIFIER
{ $$
= DEBUG_SymbolExpr
($1); }
410 | lvalue OP_DRF tIDENTIFIER
{ $$
= DEBUG_StructPExpr
($1, $3); }
411 | lvalue
'.' tIDENTIFIER
{ $$
= DEBUG_StructExpr
($1, $3); }
412 | lvalue
'[' expr
']' { $$
= DEBUG_BinopExpr
(EXP_OP_ARR
, $1, $3); }
418 #ifdef DONT_USE_READLINE
419 fprintf
(stderr
,"Wine-dbg>");
423 void mode_command
(int newmode
)
425 if
((newmode
== 16) ||
(newmode
== 32)) dbg_mode
= newmode
;
426 else fprintf
(stderr
,"Invalid mode (use 16 or 32)\n");
430 /***********************************************************************
433 * Debugger main loop.
435 static void DEBUG_Main
( int signal
)
437 static int loaded_symbols
= 0;
438 static BOOL frozen
= FALSE
;
439 static BOOL in_debugger
= FALSE
;
440 char SymbolTableFile
[256];
449 fprintf
( stderr
, "Segmentation fault inside debugger, exiting.\n" );
455 DEBUG_SetBreakpoints
( FALSE
);
463 CLIENT_DebuggerRequest
( DEBUGGER_FREEZE_ALL
);
469 * Initialize the debugger heap.
471 dbg_heap
= HeapCreate
(HEAP_NO_SERIALIZE
, 0x1000, 0x8000000); /* 128MB */
475 * Initialize the type handling stuff.
480 * In some cases we can read the stabs information directly
481 * from the executable. If this is the case, we don't need
482 * to bother with trying to read a symbol file, as the stabs
483 * also have line number and local variable information.
484 * As long as gcc is used for the compiler, stabs will
485 * be the default. On SVr4, DWARF could be used, but we
486 * don't grok that yet, and in this case we fall back to using
489 if
( DEBUG_ReadExecutableDbgInfo
() == FALSE
)
491 char *symfilename
= "wine.sym";
493 if
(-1 == stat
(symfilename
, &statbuf
) )
494 symfilename
= LIBDIR
"wine.sym";
496 PROFILE_GetWineIniString
( "wine", "SymbolTableFile", symfilename
,
497 SymbolTableFile
, sizeof
(SymbolTableFile
));
498 DEBUG_ReadSymbolTable
( SymbolTableFile
);
501 DEBUG_LoadEntryPoints
();
502 DEBUG_ProcessDeferredDebug
();
506 fprintf
(stderr
, "Entering debugger PC=%x, mode=%d, count=%d\n",
507 EIP_reg
(&DEBUG_context
),
508 dbg_exec_mode
, dbg_exec_count
);
513 if
((signal
!= SIGTRAP
) ||
!DEBUG_ShouldContinue
( dbg_exec_mode
,
517 TDB
*pTask
= (TDB
*)GlobalLock16
( GetCurrentTask
() );
519 addr.seg
= CS_reg
(&DEBUG_context
);
520 addr.off
= EIP_reg
(&DEBUG_context
);
521 if
(ISV86
(&DEBUG_context
)) addr.seg |
= (DWORD
)(pTask?
(pTask
->hModule
):0)<<16;
523 DBG_FIX_ADDR_SEG
( &addr
, 0 );
525 GlobalUnlock16
( GetCurrentTask
() );
529 CLIENT_DebuggerRequest
( DEBUGGER_FREEZE_ALL
);
533 /* Put the display in a correct state */
534 USER_Driver
->pBeginDebugging
();
536 newmode
= ISV86
(&DEBUG_context
) ?
16 : IS_SELECTOR_32BIT
(addr.seg
) ?
32 : 16;
537 if
(newmode
!= dbg_mode
)
538 fprintf
(stderr
,"In %d bit mode.\n", dbg_mode
= newmode
);
542 if
(signal
!= SIGTRAP
) /* This is a real crash, dump some info */
544 DEBUG_InfoRegisters
();
548 LDT_Print
( SELECTOR_TO_ENTRY
(DS_reg
(&DEBUG_context
)), 1 );
549 if
(ES_reg
(&DEBUG_context
) != DS_reg
(&DEBUG_context
))
550 LDT_Print
( SELECTOR_TO_ENTRY
(ES_reg
(&DEBUG_context
)), 1 );
557 * Do a quiet backtrace so that we have an idea of what the situation
558 * is WRT the source files.
560 DEBUG_SilentBackTrace
();
563 if
((signal
!= SIGTRAP
) ||
564 (dbg_exec_mode
== EXEC_STEPI_OVER
) ||
565 (dbg_exec_mode
== EXEC_STEPI_INSTR
))
567 /* Show where we crashed */
569 DEBUG_PrintAddress
( &addr
, dbg_mode
, TRUE
);
570 fprintf
(stderr
,": ");
571 if
(DBG_CHECK_READ_PTR
( &addr
, 1 ))
573 DEBUG_Disasm
( &addr
, TRUE
);
574 fprintf
(stderr
,"\n");
584 addr.seg
= CS_reg
(&DEBUG_context
) |
(addr.seg
&0xffff0000);
585 addr.off
= EIP_reg
(&DEBUG_context
);
586 DBG_FIX_ADDR_SEG
( &addr
, 0 );
587 ret_ok
= DEBUG_ValidateRegisters
();
588 if
(ret_ok
) ret_ok
= DBG_CHECK_READ_PTR
( &addr
, 1 );
592 dbg_exec_mode
= DEBUG_RestartExecution
( dbg_exec_mode
, dbg_exec_count
);
594 * This will have gotten absorbed into the breakpoint info
595 * if it was used. Otherwise it would have been ignored.
596 * In any case, we don't mess with it any more.
598 if
( dbg_exec_mode
== EXEC_CONT
)
604 CLIENT_DebuggerRequest
( DEBUGGER_UNFREEZE_ALL
);
611 USER_Driver
->pEndDebugging
();
616 /***********************************************************************
617 * DebugBreak (KERNEL.203) (KERNEL32.181)
619 void DebugBreak16
( CONTEXT
*regs
)
622 if
(!GetModuleName16
( GetCurrentTask
(), module
, sizeof
(module
) ))
623 strcpy
( module
, "???" );
624 fprintf
( stderr
, "%s called DebugBreak\n", module
);
625 DEBUG_context
= *regs
;
626 DEBUG_Main
( SIGTRAP
);
630 void ctx_debug
( int signal
, CONTEXT
*regs
)
632 DEBUG_context
= *regs
;
633 DEBUG_Main
( signal
);
634 *regs
= DEBUG_context
;
637 void wine_debug
( int signal
, SIGCONTEXT
*regs
)
640 DWORD
*stack
= (DWORD
*)ESP_sig
(regs
);
643 *(--stack
) = EH_NONCONTINUABLE
;
644 *(--stack
) = EXCEPTION_ACCESS_VIOLATION
;
645 *(--stack
) = EIP_sig
(regs
);
646 ESP_sig
(regs
) = (DWORD
)stack
;
647 EIP_sig
(regs
) = (DWORD
)RaiseException
;
649 DEBUG_SetSigContext
( regs
);
650 DEBUG_Main
( signal
);
651 DEBUG_GetSigContext
( regs
);
655 int yyerror(char * s
)
657 fprintf
(stderr
,"%s\n", s
);