Release 980913
[wine/multimedia.git] / debugger / dbg.y
blob9aa95f273aaa4836408353335324ab97dd222736
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 "winbase.h"
14 #include "class.h"
15 #include "module.h"
16 #include "options.h"
17 #include "queue.h"
18 #include "win.h"
19 #include "winnt.h"
20 #include "debugger.h"
21 #include "neexe.h"
22 #include "process.h"
24 #include "expr.h"
26 extern FILE * yyin;
27 unsigned int dbg_mode = 0;
28 int curr_frame = 0;
30 static enum exec_mode dbg_exec_mode = EXEC_CONT;
31 static int dbg_exec_count = 0;
33 void issue_prompt(void);
34 void mode_command(int);
35 void flush_symbols(void);
36 int yylex(void);
37 int yyerror(char *);
39 extern void VIRTUAL_Dump(void); /* memory/virtual.c */
43 %union
45 DBG_ADDR address;
46 enum debug_regs reg;
47 char * string;
48 int integer;
49 struct list_id listing;
50 struct expr * expression;
51 struct datatype * type;
54 %token tCONT tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
55 %token tENABLE tDISABLE tBREAK tDELETE tSET tMODE tPRINT tEXAM tABORT
56 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
57 %token tEOL tSTRING
58 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
59 %token tSTEPI tNEXTI tFINISH tSHOW tDIR
60 %token <string> tPATH
61 %token <string> tIDENTIFIER tSTRING
62 %token <integer> tNUM tFORMAT
63 %token <reg> tREG
65 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
66 %token tSTRUCT tUNION tENUM
68 /* %left ',' */
69 /* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
70 OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
71 OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
72 /* %left OP_COND */ /* ... ? ... : ... */
73 %left OP_LOR
74 %left OP_LAND
75 %left '|'
76 %left '^'
77 %left '&'
78 %left OP_EQ OP_NE
79 %left '<' '>' OP_LE OP_GE
80 %left OP_SHL OP_SHR
81 %left '+' '-'
82 %left '*' '/' '%'
83 %left OP_SIGN '!' '~' OP_DEREF /* OP_INC OP_DEC OP_ADDR */
84 %left '.' '[' OP_DRF
85 %nonassoc ':'
87 %type <expression> expr lval lvalue
88 %type <type> type_cast type_expr
89 %type <address> expr_addr lval_addr
90 %type <integer> expr_value
91 %type <string> pathname
93 %type <listing> list_arg
97 input: line { issue_prompt(); }
98 | input line { issue_prompt(); }
100 line: command
101 | tEOL
102 | error tEOL { yyerrok; }
104 command:
105 tQUIT tEOL { exit(0); }
106 | tHELP tEOL { DEBUG_Help(); }
107 | tHELP tINFO tEOL { DEBUG_HelpInfo(); }
108 | tCONT tEOL { dbg_exec_count = 1;
109 dbg_exec_mode = EXEC_CONT; return 0; }
110 | tCONT tNUM tEOL { dbg_exec_count = $2;
111 dbg_exec_mode = EXEC_CONT; return 0; }
112 | tSTEP tEOL { dbg_exec_count = 1;
113 dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
114 | tNEXT tEOL { dbg_exec_count = 1;
115 dbg_exec_mode = EXEC_STEP_OVER; return 0; }
116 | tSTEP tNUM tEOL { dbg_exec_count = $2;
117 dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
118 | tNEXT tNUM tEOL { dbg_exec_count = $2;
119 dbg_exec_mode = EXEC_STEP_OVER; return 0; }
120 | tSTEPI tEOL { dbg_exec_count = 1;
121 dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
122 | tNEXTI tEOL { dbg_exec_count = 1;
123 dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
124 | tSTEPI tNUM tEOL { dbg_exec_count = $2;
125 dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
126 | tNEXTI tNUM tEOL { dbg_exec_count = $2;
127 dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
128 | tABORT tEOL { kill(getpid(), SIGABRT); }
129 | tMODE tNUM tEOL { mode_command($2); }
130 | tENABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, TRUE ); }
131 | tDISABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, FALSE ); }
132 | tDELETE tBREAK tNUM tEOL { DEBUG_DelBreakpoint( $3 ); }
133 | tBACKTRACE tEOL { DEBUG_BackTrace(); }
134 | tUP tEOL { DEBUG_SetFrame( curr_frame + 1 ); }
135 | tUP tNUM tEOL { DEBUG_SetFrame( curr_frame + $2 ); }
136 | tDOWN tEOL { DEBUG_SetFrame( curr_frame - 1 ); }
137 | tDOWN tNUM tEOL { DEBUG_SetFrame( curr_frame - $2 ); }
138 | tFRAME tNUM tEOL { DEBUG_SetFrame( $2 ); }
139 | tFINISH tEOL { dbg_exec_count = 0;
140 dbg_exec_mode = EXEC_FINISH; return 0; }
141 | tSHOW tDIR tEOL { DEBUG_ShowDir(); }
142 | tDIR pathname tEOL { DEBUG_AddPath( $2 ); }
143 | tDIR tEOL { DEBUG_NukePath(); }
144 | tDISPLAY tEOL { DEBUG_InfoDisplay(); }
145 | tDISPLAY expr tEOL { DEBUG_AddDisplay($2, 1, 0); }
146 | tDISPLAY tFORMAT expr tEOL { DEBUG_AddDisplay($3, $2 >> 8, $2 & 0xff); }
147 | tDELETE tDISPLAY tNUM tEOL { DEBUG_DelDisplay( $3 ); }
148 | tDELETE tDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
149 | tUNDISPLAY tNUM tEOL { DEBUG_DelDisplay( $2 ); }
150 | tUNDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
151 | tCOND tNUM tEOL { DEBUG_AddBPCondition($2, NULL); }
152 | tCOND tNUM expr tEOL { DEBUG_AddBPCondition($2, $3); }
153 | list_command
154 | disassemble_command
155 | set_command
156 | x_command
157 | print_command
158 | break_command
159 | info_command
160 | walk_command
162 set_command:
163 tSET tREG '=' expr_value tEOL { DEBUG_SetRegister( $2, $4 );
164 DEBUG_FreeExprMem(); }
165 | tSET lval_addr '=' expr_value tEOL { DEBUG_WriteMemory( &$2, $4 );
166 DEBUG_FreeExprMem(); }
168 pathname:
169 tIDENTIFIER { $$ = $1; }
170 | tPATH { $$ = $1; }
172 disassemble_command:
173 tDISASSEMBLE tEOL { DEBUG_Disassemble( NULL, NULL, 10 ); }
174 | tDISASSEMBLE expr_addr tEOL { DEBUG_Disassemble( & $2, NULL, 10 ); }
175 | tDISASSEMBLE expr_addr ',' expr_addr tEOL { DEBUG_Disassemble( & $2, & $4, 0 ); }
177 list_command:
178 tLIST tEOL { DEBUG_List( NULL, NULL, 10 ); }
179 | tLIST '-' tEOL { DEBUG_List( NULL, NULL, -10 ); }
180 | tLIST list_arg tEOL { DEBUG_List( & $2, NULL, 10 ); }
181 | tLIST ',' list_arg tEOL { DEBUG_List( NULL, & $3, -10 ); }
182 | tLIST list_arg ',' list_arg tEOL { DEBUG_List( & $2, & $4, 0 ); }
184 list_arg:
185 tNUM { $$.sourcefile = NULL; $$.line = $1; }
186 | pathname ':' tNUM { $$.sourcefile = $1; $$.line = $3; }
187 | tIDENTIFIER { DEBUG_GetFuncInfo( & $$, NULL, $1); }
188 | pathname ':' tIDENTIFIER { DEBUG_GetFuncInfo( & $$, $1, $3); }
189 | '*' expr_addr { DEBUG_FindNearestSymbol( & $2, FALSE, NULL,
190 0, & $$ );
191 DEBUG_FreeExprMem(); }
193 x_command:
194 tEXAM expr_addr tEOL { DEBUG_ExamineMemory( &$2, 1, 'x');
195 DEBUG_FreeExprMem(); }
196 | tEXAM tFORMAT expr_addr tEOL { DEBUG_ExamineMemory( &$3, $2>>8, $2&0xff );
197 DEBUG_FreeExprMem(); }
199 print_command:
200 tPRINT expr_addr tEOL { DEBUG_Print( &$2, 1, 0, 0 );
201 DEBUG_FreeExprMem(); }
202 | tPRINT tFORMAT expr_addr tEOL { DEBUG_Print( &$3, $2 >> 8, $2 & 0xff, 0 );
203 DEBUG_FreeExprMem(); }
205 break_command:
206 tBREAK '*' expr_addr tEOL { DEBUG_AddBreakpoint( &$3 );
207 DEBUG_FreeExprMem(); }
208 | tBREAK tIDENTIFIER tEOL { DBG_ADDR addr;
209 if( DEBUG_GetSymbolValue($2, -1, &addr, TRUE) )
211 DEBUG_AddBreakpoint( &addr );
213 else
215 fprintf(stderr,"Unable to add breakpoint\n");
218 | tBREAK tIDENTIFIER ':' tNUM tEOL { DBG_ADDR addr;
219 if( DEBUG_GetSymbolValue($2, $4, &addr, TRUE) )
221 DEBUG_AddBreakpoint( &addr );
223 else
225 fprintf(stderr,"Unable to add breakpoint\n");
228 | tBREAK tNUM tEOL { struct name_hash *nh;
229 DBG_ADDR addr = { NULL,
230 CS_reg(&DEBUG_context),
231 EIP_reg(&DEBUG_context) };
233 DBG_FIX_ADDR_SEG( &addr, CS_reg(&DEBUG_context) );
234 DEBUG_FindNearestSymbol(&addr, TRUE,
235 &nh, 0, NULL);
236 if( nh != NULL )
238 DEBUG_GetLineNumberAddr(nh,
239 $2, &addr, TRUE);
240 DEBUG_AddBreakpoint( &addr );
242 else
244 fprintf(stderr,"Unable to add breakpoint\n");
248 | tBREAK tEOL { DBG_ADDR addr = { NULL,
249 CS_reg(&DEBUG_context),
250 EIP_reg(&DEBUG_context) };
251 DEBUG_AddBreakpoint( &addr );
254 info_command:
255 tINFO tBREAK tEOL { DEBUG_InfoBreakpoints(); }
256 | tINFO tCLASS expr_value tEOL { CLASS_DumpClass( (CLASS *)$3 );
257 DEBUG_FreeExprMem(); }
258 | tINFO tSHARE tEOL { DEBUG_InfoShare(); }
259 | tINFO tMODULE expr_value tEOL { NE_DumpModule( $3 );
260 DEBUG_FreeExprMem(); }
261 | tINFO tQUEUE expr_value tEOL { QUEUE_DumpQueue( $3 );
262 DEBUG_FreeExprMem(); }
263 | tINFO tREGS tEOL { DEBUG_InfoRegisters(); }
264 | tINFO tSEGMENTS expr_value tEOL { LDT_Print( SELECTOR_TO_ENTRY($3), 1 );
265 DEBUG_FreeExprMem(); }
266 | tINFO tSEGMENTS tEOL { LDT_Print( 0, -1 ); }
267 | tINFO tSTACK tEOL { DEBUG_InfoStack(); }
268 | tINFO tMAPS tEOL { VIRTUAL_Dump(); }
269 | tINFO tWND expr_value tEOL { WIN_DumpWindow( $3 );
270 DEBUG_FreeExprMem(); }
271 | tINFO tLOCAL tEOL { DEBUG_InfoLocals(); }
272 | tINFO tDISPLAY tEOL { DEBUG_InfoDisplay(); }
274 walk_command:
275 tWALK tCLASS tEOL { CLASS_WalkClasses(); }
276 | tWALK tMODULE tEOL { NE_WalkModules(); }
277 | tWALK tQUEUE tEOL { QUEUE_WalkQueues(); }
278 | tWALK tWND tEOL { WIN_WalkWindows( 0, 0 ); }
279 | tWALK tWND tNUM tEOL { WIN_WalkWindows( $3, 0 ); }
282 type_cast:
283 '(' type_expr ')' { $$ = $2; }
285 type_expr:
286 type_expr '*' { $$ = DEBUG_FindOrMakePointerType($1); }
287 | tINT { $$ = DEBUG_TypeCast(BASIC, "int"); }
288 | tCHAR { $$ = DEBUG_TypeCast(BASIC, "char"); }
289 | tLONG tINT { $$ = DEBUG_TypeCast(BASIC, "long int"); }
290 | tUNSIGNED tINT { $$ = DEBUG_TypeCast(BASIC, "unsigned int"); }
291 | tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(BASIC, "long unsigned int"); }
292 | tLONG tLONG tINT { $$ = DEBUG_TypeCast(BASIC, "long long int"); }
293 | tLONG tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(BASIC, "long long unsigned int"); }
294 | tSHORT tINT { $$ = DEBUG_TypeCast(BASIC, "short int"); }
295 | tSHORT tUNSIGNED tINT { $$ = DEBUG_TypeCast(BASIC, "short unsigned int"); }
296 | tSIGNED tCHAR { $$ = DEBUG_TypeCast(BASIC, "signed char"); }
297 | tUNSIGNED tCHAR { $$ = DEBUG_TypeCast(BASIC, "unsigned char"); }
298 | tFLOAT { $$ = DEBUG_TypeCast(BASIC, "float"); }
299 | tDOUBLE { $$ = DEBUG_TypeCast(BASIC, "double"); }
300 | tLONG tDOUBLE { $$ = DEBUG_TypeCast(BASIC, "long double"); }
301 | tSTRUCT tIDENTIFIER { $$ = DEBUG_TypeCast(STRUCT, $2); }
302 | tUNION tIDENTIFIER { $$ = DEBUG_TypeCast(STRUCT, $2); }
303 | tENUM tIDENTIFIER { $$ = DEBUG_TypeCast(ENUM, $2); }
305 expr_addr:
306 expr { $$ = DEBUG_EvalExpr($1); }
308 expr_value:
309 expr { DBG_ADDR addr = DEBUG_EvalExpr($1);
310 $$ = addr.off ? *(unsigned int *) addr.off : 0; }
312 * The expr rule builds an expression tree. When we are done, we call
313 * EvalExpr to evaluate the value of the expression. The advantage of
314 * the two-step approach is that it is possible to save expressions for
315 * use in 'display' commands, and in conditional watchpoints.
317 expr:
318 tNUM { $$ = DEBUG_ConstExpr($1); }
319 | tSTRING { $$ = DEBUG_StringExpr($1); }
320 | tREG { $$ = DEBUG_RegisterExpr($1); }
321 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
322 | expr OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
323 | expr '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
324 | tIDENTIFIER '(' ')' { $$ = DEBUG_CallExpr($1, 0); }
325 | tIDENTIFIER '(' expr ')' { $$ = DEBUG_CallExpr($1, 1, $3); }
326 | tIDENTIFIER '(' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 2, $3,
327 $5); }
328 | tIDENTIFIER '(' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7); }
329 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9); }
330 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9, $11); }
331 | expr '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
332 | expr ':' expr { $$ = DEBUG_BinopExpr(EXP_OP_SEG, $1, $3); }
333 | expr OP_LOR expr { $$ = DEBUG_BinopExpr(EXP_OP_LOR, $1, $3); }
334 | expr OP_LAND expr { $$ = DEBUG_BinopExpr(EXP_OP_LAND, $1, $3); }
335 | expr '|' expr { $$ = DEBUG_BinopExpr(EXP_OP_OR, $1, $3); }
336 | expr '&' expr { $$ = DEBUG_BinopExpr(EXP_OP_AND, $1, $3); }
337 | expr '^' expr { $$ = DEBUG_BinopExpr(EXP_OP_XOR, $1, $3); }
338 | expr OP_EQ expr { $$ = DEBUG_BinopExpr(EXP_OP_EQ, $1, $3); }
339 | expr '>' expr { $$ = DEBUG_BinopExpr(EXP_OP_GT, $1, $3); }
340 | expr '<' expr { $$ = DEBUG_BinopExpr(EXP_OP_LT, $1, $3); }
341 | expr OP_GE expr { $$ = DEBUG_BinopExpr(EXP_OP_GE, $1, $3); }
342 | expr OP_LE expr { $$ = DEBUG_BinopExpr(EXP_OP_LE, $1, $3); }
343 | expr OP_NE expr { $$ = DEBUG_BinopExpr(EXP_OP_NE, $1, $3); }
344 | expr OP_SHL expr { $$ = DEBUG_BinopExpr(EXP_OP_SHL, $1, $3); }
345 | expr OP_SHR expr { $$ = DEBUG_BinopExpr(EXP_OP_SHR, $1, $3); }
346 | expr '+' expr { $$ = DEBUG_BinopExpr(EXP_OP_ADD, $1, $3); }
347 | expr '-' expr { $$ = DEBUG_BinopExpr(EXP_OP_SUB, $1, $3); }
348 | expr '*' expr { $$ = DEBUG_BinopExpr(EXP_OP_MUL, $1, $3); }
349 | expr '/' expr { $$ = DEBUG_BinopExpr(EXP_OP_DIV, $1, $3); }
350 | expr '%' expr { $$ = DEBUG_BinopExpr(EXP_OP_REM, $1, $3); }
351 | '-' expr %prec OP_SIGN { $$ = DEBUG_UnopExpr(EXP_OP_NEG, $2); }
352 | '+' expr %prec OP_SIGN { $$ = $2; }
353 | '!' expr { $$ = DEBUG_UnopExpr(EXP_OP_NOT, $2); }
354 | '~' expr { $$ = DEBUG_UnopExpr(EXP_OP_LNOT, $2); }
355 | '(' expr ')' { $$ = $2; }
356 | '*' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_DEREF, $2); }
357 | '&' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_ADDR, $2); }
358 | type_cast expr %prec OP_DEREF { $$ = DEBUG_TypeCastExpr($1, $2); }
361 * The lvalue rule builds an expression tree. This is a limited form
362 * of expression that is suitable to be used as an lvalue.
364 lval_addr:
365 lval { $$ = DEBUG_EvalExpr($1); }
367 lval:
368 lvalue { $$ = $1; }
369 | '*' expr { $$ = DEBUG_UnopExpr(EXP_OP_FORCE_DEREF, $2); }
371 lvalue:
372 tNUM { $$ = DEBUG_ConstExpr($1); }
373 | tREG { $$ = DEBUG_RegisterExpr($1); }
374 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
375 | lvalue OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
376 | lvalue '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
377 | lvalue '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
381 void
382 issue_prompt(){
383 #ifdef DONT_USE_READLINE
384 fprintf(stderr,"Wine-dbg>");
385 #endif
388 void mode_command(int newmode)
390 if ((newmode == 16) || (newmode == 32)) dbg_mode = newmode;
391 else fprintf(stderr,"Invalid mode (use 16 or 32)\n");
395 /***********************************************************************
396 * DEBUG_Main
398 * Debugger main loop.
400 static void DEBUG_Main( int signal )
402 static int loaded_symbols = 0;
403 static BOOL32 in_debugger = FALSE;
404 char SymbolTableFile[256];
405 int newmode;
406 BOOL32 ret_ok;
407 #ifdef YYDEBUG
408 yydebug = 0;
409 #endif
411 if (in_debugger)
413 fprintf( stderr, "Segmentation fault inside debugger, exiting.\n" );
414 exit(1);
416 in_debugger = TRUE;
417 yyin = stdin;
419 DEBUG_SetBreakpoints( FALSE );
421 if (!loaded_symbols)
423 loaded_symbols++;
426 * Initialize the type handling stuff.
428 DEBUG_InitTypes();
431 * In some cases we can read the stabs information directly
432 * from the executable. If this is the case, we don't need
433 * to bother with trying to read a symbol file, as the stabs
434 * also have line number and local variable information.
435 * As long as gcc is used for the compiler, stabs will
436 * be the default. On SVr4, DWARF could be used, but we
437 * don't grok that yet, and in this case we fall back to using
438 * the wine.sym file.
440 if( DEBUG_ReadExecutableDbgInfo() == FALSE )
442 char *symfilename = "wine.sym";
443 struct stat statbuf;
444 if (-1 == stat(symfilename, &statbuf) )
445 symfilename = LIBDIR "wine.sym";
447 PROFILE_GetWineIniString( "wine", "SymbolTableFile", symfilename,
448 SymbolTableFile, sizeof(SymbolTableFile));
449 DEBUG_ReadSymbolTable( SymbolTableFile );
452 DEBUG_LoadEntryPoints();
453 DEBUG_ProcessDeferredDebug();
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 XUngrabServer( display );
477 XFlush( display );
479 newmode = IS_SELECTOR_32BIT(addr.seg) ? 32 : 16;
480 if (newmode != dbg_mode)
481 fprintf(stderr,"In %d bit mode.\n", dbg_mode = newmode);
483 PROCESS_SuspendOtherThreads();
485 DEBUG_DoDisplay();
487 if (signal != SIGTRAP) /* This is a real crash, dump some info */
489 DEBUG_InfoRegisters();
490 DEBUG_InfoStack();
491 if (dbg_mode == 16)
493 LDT_Print( SELECTOR_TO_ENTRY(DS_reg(&DEBUG_context)), 1 );
494 if (ES_reg(&DEBUG_context) != DS_reg(&DEBUG_context))
495 LDT_Print( SELECTOR_TO_ENTRY(ES_reg(&DEBUG_context)), 1 );
497 DEBUG_BackTrace();
499 else
502 * Do a quiet backtrace so that we have an idea of what the situation
503 * is WRT the source files.
505 DEBUG_SilentBackTrace();
508 if ((signal != SIGTRAP) ||
509 (dbg_exec_mode == EXEC_STEPI_OVER) ||
510 (dbg_exec_mode == EXEC_STEPI_INSTR))
512 /* Show where we crashed */
513 curr_frame = 0;
514 DEBUG_PrintAddress( &addr, dbg_mode, TRUE );
515 fprintf(stderr,": ");
516 if (DBG_CHECK_READ_PTR( &addr, 1 ))
518 DEBUG_Disasm( &addr, TRUE );
519 fprintf(stderr,"\n");
523 ret_ok = 0;
526 issue_prompt();
527 yyparse();
528 flush_symbols();
529 addr.seg = CS_reg(&DEBUG_context);
530 addr.off = EIP_reg(&DEBUG_context);
531 DBG_FIX_ADDR_SEG( &addr, 0 );
532 ret_ok = DEBUG_ValidateRegisters();
533 if (ret_ok) ret_ok = DBG_CHECK_READ_PTR( &addr, 1 );
534 } while (!ret_ok);
537 dbg_exec_mode = DEBUG_RestartExecution( dbg_exec_mode, dbg_exec_count );
539 * This will have gotten absorbed into the breakpoint info
540 * if it was used. Otherwise it would have been ignored.
541 * In any case, we don't mess with it any more.
543 if( dbg_exec_mode == EXEC_CONT )
545 dbg_exec_count = 0;
546 PROCESS_ResumeOtherThreads();
549 in_debugger = FALSE;
554 /***********************************************************************
555 * DebugBreak (KERNEL.203) (KERNEL32.181)
557 void DebugBreak( CONTEXT *regs )
559 char module[10];
560 if (!GetModuleName( GetCurrentTask(), module, sizeof(module) ))
561 strcpy( module, "???" );
562 fprintf( stderr, "%s called DebugBreak\n", module );
563 DEBUG_context = *regs;
564 DEBUG_Main( SIGTRAP );
568 void wine_debug( int signal, SIGCONTEXT *regs )
570 #if 0
571 DWORD *stack = (DWORD *)ESP_sig(regs);
572 *(--stack) = 0;
573 *(--stack) = 0;
574 *(--stack) = EH_NONCONTINUABLE;
575 *(--stack) = EXCEPTION_ACCESS_VIOLATION;
576 *(--stack) = EIP_sig(regs);
577 ESP_sig(regs) = (DWORD)stack;
578 EIP_sig(regs) = (DWORD)RaiseException;
579 #else
580 DEBUG_SetSigContext( regs );
581 DEBUG_Main( signal );
582 DEBUG_GetSigContext( regs );
583 #endif
586 int yyerror(char * s)
588 fprintf(stderr,"%s\n", s);
589 return 0;