Release 980503
[wine.git] / debugger / dbg.y
blobf7963ef8968950e41ededeab6f864437f22214be
1 %{
2 /*
3 * Parser for command lines in the Wine debugger
5 * Copyright 1993 Eric Youngdale
6 * Copyright 1995 Morten Welinder
7 */
9 #include <stdio.h>
10 #include <signal.h>
11 #include <sys/stat.h>
12 #include <unistd.h>
13 #include "class.h"
14 #include "module.h"
15 #include "options.h"
16 #include "queue.h"
17 #include "win.h"
18 #include "winnt.h"
19 #include "debugger.h"
20 #include "neexe.h"
22 #include "expr.h"
24 extern FILE * yyin;
25 unsigned int dbg_mode = 0;
26 int curr_frame = 0;
28 static enum exec_mode dbg_exec_mode = EXEC_CONT;
29 static int dbg_exec_count = 0;
31 void issue_prompt(void);
32 void mode_command(int);
33 void flush_symbols(void);
34 int yylex(void);
35 int yyerror(char *);
37 extern void VIRTUAL_Dump(void); /* memory/virtual.c */
41 %union
43 DBG_ADDR address;
44 enum debug_regs reg;
45 char * string;
46 int integer;
47 struct list_id listing;
48 struct expr * expression;
49 struct datatype * type;
52 %token tCONT tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
53 %token tENABLE tDISABLE tBREAK tDELETE tSET tMODE tPRINT tEXAM tABORT
54 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
55 %token tEOL tSTRING
56 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
57 %token tSTEPI tNEXTI tFINISH tSHOW tDIR
58 %token <string> tPATH
59 %token <string> tIDENTIFIER tSTRING
60 %token <integer> tNUM tFORMAT
61 %token <reg> tREG
63 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
64 %token tSTRUCT tUNION tENUM
66 /* %left ',' */
67 /* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
68 OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
69 OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
70 /* %left OP_COND */ /* ... ? ... : ... */
71 %left OP_LOR
72 %left OP_LAND
73 %left '|'
74 %left '^'
75 %left '&'
76 %left OP_EQ OP_NE
77 %left '<' '>' OP_LE OP_GE
78 %left OP_SHL OP_SHR
79 %left '+' '-'
80 %left '*' '/' '%'
81 %left OP_SIGN '!' '~' OP_DEREF /* OP_INC OP_DEC OP_ADDR */
82 %left '.' '[' OP_DRF
83 %nonassoc ':'
85 %type <expression> expr lval lvalue
86 %type <type> type_cast type_expr
87 %type <address> expr_addr lval_addr
88 %type <integer> expr_value
89 %type <string> pathname
91 %type <listing> list_arg
95 input: line { issue_prompt(); }
96 | input line { issue_prompt(); }
98 line: command
99 | tEOL
100 | error tEOL { yyerrok; }
102 command:
103 tQUIT tEOL { exit(0); }
104 | tHELP tEOL { DEBUG_Help(); }
105 | tHELP tINFO tEOL { DEBUG_HelpInfo(); }
106 | tCONT tEOL { dbg_exec_count = 1;
107 dbg_exec_mode = EXEC_CONT; return 0; }
108 | tCONT tNUM tEOL { dbg_exec_count = $2;
109 dbg_exec_mode = EXEC_CONT; return 0; }
110 | tSTEP tEOL { dbg_exec_count = 1;
111 dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
112 | tNEXT tEOL { dbg_exec_count = 1;
113 dbg_exec_mode = EXEC_STEP_OVER; return 0; }
114 | tSTEP tNUM tEOL { dbg_exec_count = $2;
115 dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
116 | tNEXT tNUM tEOL { dbg_exec_count = $2;
117 dbg_exec_mode = EXEC_STEP_OVER; return 0; }
118 | tSTEPI tEOL { dbg_exec_count = 1;
119 dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
120 | tNEXTI tEOL { dbg_exec_count = 1;
121 dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
122 | tSTEPI tNUM tEOL { dbg_exec_count = $2;
123 dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
124 | tNEXTI tNUM tEOL { dbg_exec_count = $2;
125 dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
126 | tABORT tEOL { kill(getpid(), SIGABRT); }
127 | tMODE tNUM tEOL { mode_command($2); }
128 | tENABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, TRUE ); }
129 | tDISABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, FALSE ); }
130 | tDELETE tBREAK tNUM tEOL { DEBUG_DelBreakpoint( $3 ); }
131 | tBACKTRACE tEOL { DEBUG_BackTrace(); }
132 | tUP tEOL { DEBUG_SetFrame( curr_frame + 1 ); }
133 | tUP tNUM tEOL { DEBUG_SetFrame( curr_frame + $2 ); }
134 | tDOWN tEOL { DEBUG_SetFrame( curr_frame - 1 ); }
135 | tDOWN tNUM tEOL { DEBUG_SetFrame( curr_frame - $2 ); }
136 | tFRAME tNUM tEOL { DEBUG_SetFrame( $2 ); }
137 | tFINISH tEOL { dbg_exec_count = 0;
138 dbg_exec_mode = EXEC_FINISH; return 0; }
139 | tSHOW tDIR tEOL { DEBUG_ShowDir(); }
140 | tDIR pathname tEOL { DEBUG_AddPath( $2 ); }
141 | tDIR tEOL { DEBUG_NukePath(); }
142 | tDISPLAY tEOL { DEBUG_InfoDisplay(); }
143 | tDISPLAY expr tEOL { DEBUG_AddDisplay($2, 1, 0); }
144 | tDISPLAY tFORMAT expr tEOL { DEBUG_AddDisplay($3, $2 >> 8, $2 & 0xff); }
145 | tDELETE tDISPLAY tNUM tEOL { DEBUG_DelDisplay( $3 ); }
146 | tDELETE tDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
147 | tUNDISPLAY tNUM tEOL { DEBUG_DelDisplay( $2 ); }
148 | tUNDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
149 | tCOND tNUM tEOL { DEBUG_AddBPCondition($2, NULL); }
150 | tCOND tNUM expr tEOL { DEBUG_AddBPCondition($2, $3); }
151 | list_command
152 | disassemble_command
153 | set_command
154 | x_command
155 | print_command
156 | break_command
157 | info_command
158 | walk_command
160 set_command:
161 tSET tREG '=' expr_value tEOL { DEBUG_SetRegister( $2, $4 );
162 DEBUG_FreeExprMem(); }
163 | tSET lval_addr '=' expr_value tEOL { DEBUG_WriteMemory( &$2, $4 );
164 DEBUG_FreeExprMem(); }
166 pathname:
167 tIDENTIFIER { $$ = $1; }
168 | tPATH { $$ = $1; }
170 disassemble_command:
171 tDISASSEMBLE tEOL { DEBUG_Disassemble( NULL, NULL, 10 ); }
172 | tDISASSEMBLE expr_addr tEOL { DEBUG_Disassemble( & $2, NULL, 10 ); }
173 | tDISASSEMBLE expr_addr ',' expr_addr tEOL { DEBUG_Disassemble( & $2, & $4, 0 ); }
175 list_command:
176 tLIST tEOL { DEBUG_List( NULL, NULL, 10 ); }
177 | tLIST '-' tEOL { DEBUG_List( NULL, NULL, -10 ); }
178 | tLIST list_arg tEOL { DEBUG_List( & $2, NULL, 10 ); }
179 | tLIST ',' list_arg tEOL { DEBUG_List( NULL, & $3, -10 ); }
180 | tLIST list_arg ',' list_arg tEOL { DEBUG_List( & $2, & $4, 0 ); }
182 list_arg:
183 tNUM { $$.sourcefile = NULL; $$.line = $1; }
184 | pathname ':' tNUM { $$.sourcefile = $1; $$.line = $3; }
185 | tIDENTIFIER { DEBUG_GetFuncInfo( & $$, NULL, $1); }
186 | pathname ':' tIDENTIFIER { DEBUG_GetFuncInfo( & $$, $1, $3); }
187 | '*' expr_addr { DEBUG_FindNearestSymbol( & $2, FALSE, NULL,
188 0, & $$ );
189 DEBUG_FreeExprMem(); }
191 x_command:
192 tEXAM expr_addr tEOL { DEBUG_ExamineMemory( &$2, 1, 'x');
193 DEBUG_FreeExprMem(); }
194 | tEXAM tFORMAT expr_addr tEOL { DEBUG_ExamineMemory( &$3, $2>>8, $2&0xff );
195 DEBUG_FreeExprMem(); }
197 print_command:
198 tPRINT expr_addr tEOL { DEBUG_Print( &$2, 1, 0, 0 );
199 DEBUG_FreeExprMem(); }
200 | tPRINT tFORMAT expr_addr tEOL { DEBUG_Print( &$3, $2 >> 8, $2 & 0xff, 0 );
201 DEBUG_FreeExprMem(); }
203 break_command:
204 tBREAK '*' expr_addr tEOL { DEBUG_AddBreakpoint( &$3 );
205 DEBUG_FreeExprMem(); }
206 | tBREAK tIDENTIFIER tEOL { DBG_ADDR addr;
207 if( DEBUG_GetSymbolValue($2, -1, &addr, TRUE) )
209 DEBUG_AddBreakpoint( &addr );
211 else
213 fprintf(stderr,"Unable to add breakpoint\n");
216 | tBREAK tIDENTIFIER ':' tNUM tEOL { DBG_ADDR addr;
217 if( DEBUG_GetSymbolValue($2, $4, &addr, TRUE) )
219 DEBUG_AddBreakpoint( &addr );
221 else
223 fprintf(stderr,"Unable to add breakpoint\n");
226 | tBREAK tNUM tEOL { struct name_hash *nh;
227 DBG_ADDR addr = { NULL,
228 CS_reg(&DEBUG_context),
229 EIP_reg(&DEBUG_context) };
231 DBG_FIX_ADDR_SEG( &addr, CS_reg(&DEBUG_context) );
232 DEBUG_FindNearestSymbol(&addr, TRUE,
233 &nh, 0, NULL);
234 if( nh != NULL )
236 DEBUG_GetLineNumberAddr(nh,
237 $2, &addr, TRUE);
238 DEBUG_AddBreakpoint( &addr );
240 else
242 fprintf(stderr,"Unable to add breakpoint\n");
246 | tBREAK tEOL { DBG_ADDR addr = { NULL,
247 CS_reg(&DEBUG_context),
248 EIP_reg(&DEBUG_context) };
249 DEBUG_AddBreakpoint( &addr );
252 info_command:
253 tINFO tBREAK tEOL { DEBUG_InfoBreakpoints(); }
254 | tINFO tCLASS expr_value tEOL { CLASS_DumpClass( (CLASS *)$3 );
255 DEBUG_FreeExprMem(); }
256 | tINFO tSHARE tEOL { DEBUG_InfoShare(); }
257 | tINFO tMODULE expr_value tEOL { NE_DumpModule( $3 );
258 DEBUG_FreeExprMem(); }
259 | tINFO tQUEUE expr_value tEOL { QUEUE_DumpQueue( $3 );
260 DEBUG_FreeExprMem(); }
261 | tINFO tREGS tEOL { DEBUG_InfoRegisters(); }
262 | tINFO tSEGMENTS expr_value tEOL { LDT_Print( SELECTOR_TO_ENTRY($3), 1 );
263 DEBUG_FreeExprMem(); }
264 | tINFO tSEGMENTS tEOL { LDT_Print( 0, -1 ); }
265 | tINFO tSTACK tEOL { DEBUG_InfoStack(); }
266 | tINFO tMAPS tEOL { VIRTUAL_Dump(); }
267 | tINFO tWND expr_value tEOL { WIN_DumpWindow( $3 );
268 DEBUG_FreeExprMem(); }
269 | tINFO tLOCAL tEOL { DEBUG_InfoLocals(); }
270 | tINFO tDISPLAY tEOL { DEBUG_InfoDisplay(); }
272 walk_command:
273 tWALK tCLASS tEOL { CLASS_WalkClasses(); }
274 | tWALK tMODULE tEOL { NE_WalkModules(); }
275 | tWALK tQUEUE tEOL { QUEUE_WalkQueues(); }
276 | tWALK tWND tEOL { WIN_WalkWindows( 0, 0 ); }
277 | tWALK tWND tNUM tEOL { WIN_WalkWindows( $3, 0 ); }
280 type_cast:
281 '(' type_expr ')' { $$ = $2; }
283 type_expr:
284 type_expr '*' { $$ = DEBUG_FindOrMakePointerType($1); }
285 | tINT { $$ = DEBUG_TypeCast(BASIC, "int"); }
286 | tCHAR { $$ = DEBUG_TypeCast(BASIC, "char"); }
287 | tLONG tINT { $$ = DEBUG_TypeCast(BASIC, "long int"); }
288 | tUNSIGNED tINT { $$ = DEBUG_TypeCast(BASIC, "unsigned int"); }
289 | tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(BASIC, "long unsigned int"); }
290 | tLONG tLONG tINT { $$ = DEBUG_TypeCast(BASIC, "long long int"); }
291 | tLONG tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(BASIC, "long long unsigned int"); }
292 | tSHORT tINT { $$ = DEBUG_TypeCast(BASIC, "short int"); }
293 | tSHORT tUNSIGNED tINT { $$ = DEBUG_TypeCast(BASIC, "short unsigned int"); }
294 | tSIGNED tCHAR { $$ = DEBUG_TypeCast(BASIC, "signed char"); }
295 | tUNSIGNED tCHAR { $$ = DEBUG_TypeCast(BASIC, "unsigned char"); }
296 | tFLOAT { $$ = DEBUG_TypeCast(BASIC, "float"); }
297 | tDOUBLE { $$ = DEBUG_TypeCast(BASIC, "double"); }
298 | tLONG tDOUBLE { $$ = DEBUG_TypeCast(BASIC, "long double"); }
299 | tSTRUCT tIDENTIFIER { $$ = DEBUG_TypeCast(STRUCT, $2); }
300 | tUNION tIDENTIFIER { $$ = DEBUG_TypeCast(STRUCT, $2); }
301 | tENUM tIDENTIFIER { $$ = DEBUG_TypeCast(ENUM, $2); }
303 expr_addr:
304 expr { $$ = DEBUG_EvalExpr($1); }
306 expr_value:
307 expr { DBG_ADDR addr = DEBUG_EvalExpr($1);
308 $$ = addr.off ? *(unsigned int *) addr.off : 0; }
310 * The expr rule builds an expression tree. When we are done, we call
311 * EvalExpr to evaluate the value of the expression. The advantage of
312 * the two-step approach is that it is possible to save expressions for
313 * use in 'display' commands, and in conditional watchpoints.
315 expr:
316 tNUM { $$ = DEBUG_ConstExpr($1); }
317 | tSTRING { $$ = DEBUG_StringExpr($1); }
318 | tREG { $$ = DEBUG_RegisterExpr($1); }
319 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
320 | expr OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
321 | expr '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
322 | tIDENTIFIER '(' ')' { $$ = DEBUG_CallExpr($1, 0); }
323 | tIDENTIFIER '(' expr ')' { $$ = DEBUG_CallExpr($1, 1, $3); }
324 | tIDENTIFIER '(' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 2, $3,
325 $5); }
326 | tIDENTIFIER '(' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7); }
327 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9); }
328 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9, $11); }
329 | expr '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
330 | expr ':' expr { $$ = DEBUG_BinopExpr(EXP_OP_SEG, $1, $3); }
331 | expr OP_LOR expr { $$ = DEBUG_BinopExpr(EXP_OP_LOR, $1, $3); }
332 | expr OP_LAND expr { $$ = DEBUG_BinopExpr(EXP_OP_LAND, $1, $3); }
333 | expr '|' expr { $$ = DEBUG_BinopExpr(EXP_OP_OR, $1, $3); }
334 | expr '&' expr { $$ = DEBUG_BinopExpr(EXP_OP_AND, $1, $3); }
335 | expr '^' expr { $$ = DEBUG_BinopExpr(EXP_OP_XOR, $1, $3); }
336 | expr OP_EQ expr { $$ = DEBUG_BinopExpr(EXP_OP_EQ, $1, $3); }
337 | expr '>' expr { $$ = DEBUG_BinopExpr(EXP_OP_GT, $1, $3); }
338 | expr '<' expr { $$ = DEBUG_BinopExpr(EXP_OP_LT, $1, $3); }
339 | expr OP_GE expr { $$ = DEBUG_BinopExpr(EXP_OP_GE, $1, $3); }
340 | expr OP_LE expr { $$ = DEBUG_BinopExpr(EXP_OP_LE, $1, $3); }
341 | expr OP_NE expr { $$ = DEBUG_BinopExpr(EXP_OP_NE, $1, $3); }
342 | expr OP_SHL expr { $$ = DEBUG_BinopExpr(EXP_OP_SHL, $1, $3); }
343 | expr OP_SHR expr { $$ = DEBUG_BinopExpr(EXP_OP_SHR, $1, $3); }
344 | expr '+' expr { $$ = DEBUG_BinopExpr(EXP_OP_ADD, $1, $3); }
345 | expr '-' expr { $$ = DEBUG_BinopExpr(EXP_OP_SUB, $1, $3); }
346 | expr '*' expr { $$ = DEBUG_BinopExpr(EXP_OP_MUL, $1, $3); }
347 | expr '/' expr { $$ = DEBUG_BinopExpr(EXP_OP_DIV, $1, $3); }
348 | expr '%' expr { $$ = DEBUG_BinopExpr(EXP_OP_REM, $1, $3); }
349 | '-' expr %prec OP_SIGN { $$ = DEBUG_UnopExpr(EXP_OP_NEG, $2); }
350 | '+' expr %prec OP_SIGN { $$ = $2; }
351 | '!' expr { $$ = DEBUG_UnopExpr(EXP_OP_NOT, $2); }
352 | '~' expr { $$ = DEBUG_UnopExpr(EXP_OP_LNOT, $2); }
353 | '(' expr ')' { $$ = $2; }
354 | '*' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_DEREF, $2); }
355 | '&' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_ADDR, $2); }
356 | type_cast expr %prec OP_DEREF { $$ = DEBUG_TypeCastExpr($1, $2); }
359 * The lvalue rule builds an expression tree. This is a limited form
360 * of expression that is suitable to be used as an lvalue.
362 lval_addr:
363 lval { $$ = DEBUG_EvalExpr($1); }
365 lval:
366 lvalue { $$ = $1; }
367 | '*' expr { $$ = DEBUG_UnopExpr(EXP_OP_FORCE_DEREF, $2); }
369 lvalue:
370 tNUM { $$ = DEBUG_ConstExpr($1); }
371 | tREG { $$ = DEBUG_RegisterExpr($1); }
372 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
373 | lvalue OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
374 | lvalue '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
375 | lvalue '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
379 void
380 issue_prompt(){
381 #ifdef DONT_USE_READLINE
382 fprintf(stderr,"Wine-dbg>");
383 #endif
386 void mode_command(int newmode)
388 if ((newmode == 16) || (newmode == 32)) dbg_mode = newmode;
389 else fprintf(stderr,"Invalid mode (use 16 or 32)\n");
393 /***********************************************************************
394 * DEBUG_Main
396 * Debugger main loop.
398 static void DEBUG_Main( int signal )
400 static int loaded_symbols = 0;
401 static BOOL32 in_debugger = FALSE;
402 char SymbolTableFile[256];
403 int newmode;
404 BOOL32 ret_ok;
405 #ifdef YYDEBUG
406 yydebug = 0;
407 #endif
409 if (in_debugger)
411 fprintf( stderr, "Segmentation fault inside debugger, exiting.\n" );
412 exit(1);
414 in_debugger = TRUE;
415 yyin = stdin;
417 DEBUG_SetBreakpoints( FALSE );
419 if (!loaded_symbols)
421 loaded_symbols++;
424 * Initialize the type handling stuff.
426 DEBUG_InitTypes();
429 * In some cases we can read the stabs information directly
430 * from the executable. If this is the case, we don't need
431 * to bother with trying to read a symbol file, as the stabs
432 * also have line number and local variable information.
433 * As long as gcc is used for the compiler, stabs will
434 * be the default. On SVr4, DWARF could be used, but we
435 * don't grok that yet, and in this case we fall back to using
436 * the wine.sym file.
438 fprintf(stderr,"Loading symbols: ");
439 if( DEBUG_ReadExecutableDbgInfo() == FALSE )
441 char *symfilename = "wine.sym";
442 struct stat statbuf;
443 if (-1 == stat(symfilename, &statbuf) )
444 symfilename = LIBDIR "wine.sym";
446 PROFILE_GetWineIniString( "wine", "SymbolTableFile", symfilename,
447 SymbolTableFile, sizeof(SymbolTableFile));
448 DEBUG_ReadSymbolTable( SymbolTableFile );
451 DEBUG_LoadEntryPoints();
452 DEBUG_ProcessDeferredDebug();
453 fprintf(stderr,"\n");
456 #if 0
457 fprintf(stderr, "Entering debugger PC=%x, mode=%d, count=%d\n",
458 EIP_reg(&DEBUG_context),
459 dbg_exec_mode, dbg_exec_count);
461 sleep(1);
462 #endif
464 if ((signal != SIGTRAP) || !DEBUG_ShouldContinue( dbg_exec_mode,
465 &dbg_exec_count ))
467 DBG_ADDR addr;
469 addr.seg = CS_reg(&DEBUG_context);
470 addr.off = EIP_reg(&DEBUG_context);
471 addr.type = NULL;
472 DBG_FIX_ADDR_SEG( &addr, 0 );
474 /* Put the display in a correct state */
476 XUngrabPointer( display, CurrentTime );
477 XUngrabServer( display );
478 XFlush( display );
480 newmode = IS_SELECTOR_32BIT(addr.seg) ? 32 : 16;
481 if (newmode != dbg_mode)
482 fprintf(stderr,"In %d bit mode.\n", dbg_mode = newmode);
484 DEBUG_DoDisplay();
486 if (signal != SIGTRAP) /* This is a real crash, dump some info */
488 DEBUG_InfoRegisters();
489 DEBUG_InfoStack();
490 if (dbg_mode == 16)
492 LDT_Print( SELECTOR_TO_ENTRY(DS_reg(&DEBUG_context)), 1 );
493 if (ES_reg(&DEBUG_context) != DS_reg(&DEBUG_context))
494 LDT_Print( SELECTOR_TO_ENTRY(ES_reg(&DEBUG_context)), 1 );
496 DEBUG_BackTrace();
498 else
501 * Do a quiet backtrace so that we have an idea of what the situation
502 * is WRT the source files.
504 DEBUG_SilentBackTrace();
507 if ((signal != SIGTRAP) ||
508 (dbg_exec_mode == EXEC_STEPI_OVER) ||
509 (dbg_exec_mode == EXEC_STEPI_INSTR))
511 /* Show where we crashed */
512 curr_frame = 0;
513 DEBUG_PrintAddress( &addr, dbg_mode, TRUE );
514 fprintf(stderr,": ");
515 if (DBG_CHECK_READ_PTR( &addr, 1 ))
517 DEBUG_Disasm( &addr, TRUE );
518 fprintf(stderr,"\n");
522 ret_ok = 0;
525 issue_prompt();
526 yyparse();
527 flush_symbols();
528 addr.seg = CS_reg(&DEBUG_context);
529 addr.off = EIP_reg(&DEBUG_context);
530 DBG_FIX_ADDR_SEG( &addr, 0 );
531 ret_ok = DEBUG_ValidateRegisters();
532 if (ret_ok) ret_ok = DBG_CHECK_READ_PTR( &addr, 1 );
533 } while (!ret_ok);
536 dbg_exec_mode = DEBUG_RestartExecution( dbg_exec_mode, dbg_exec_count );
538 * This will have gotten absorbed into the breakpoint info
539 * if it was used. Otherwise it would have been ignored.
540 * In any case, we don't mess with it any more.
542 if( dbg_exec_mode == EXEC_CONT )
544 dbg_exec_count = 0;
547 in_debugger = FALSE;
551 /***********************************************************************
552 * DebugBreak32 (KERNEL32)
554 void DebugBreak32( CONTEXT *regs )
556 const char *module = MODULE_GetModuleName( GetCurrentTask() );
557 fprintf( stderr, "%s called DebugBreak\n", module ? module : "???" );
558 DEBUG_context = *regs;
559 DEBUG_Main( SIGTRAP );
562 /***********************************************************************
563 * DebugBreak16 (KERNEL.203)
565 void DebugBreak16( CONTEXT *regs )
567 const char *module = MODULE_GetModuleName( GetCurrentTask() );
568 fprintf( stderr, "%s called DebugBreak\n", module ? module : "???" );
569 DEBUG_context = *regs;
570 DEBUG_Main( SIGTRAP );
574 void wine_debug( int signal, SIGCONTEXT *regs )
576 DEBUG_SetSigContext( regs );
577 #if 0
578 DWORD *stack = (DWORD *)ESP_reg(&DEBUG_context);
579 *(--stack) = 0;
580 *(--stack) = 0;
581 *(--stack) = EH_NONCONTINUABLE;
582 *(--stack) = EXCEPTION_ACCESS_VIOLATION;
583 *(--stack) = EIP_reg(&DEBUG_context);
584 ESP_reg(&DEBUG_context) = (DWORD)stack;
585 EIP_reg(&DEBUG_context) = GetProcAddress32( GetModuleHandle("KERNEL32"),
586 "RaiseException" );
587 #endif
588 DEBUG_Main( signal );
589 DEBUG_GetSigContext( regs );
592 int yyerror(char * s)
594 fprintf(stderr,"%s\n", s);
595 return 0;