Added winemine app.
[wine.git] / debugger / dbg.y
blobf978d6405d758929096eae0a9c8d4f2cf1f7c85b
1 %{
2 /*
3 * Parser for command lines in the Wine debugger
5 * Copyright 1993 Eric Youngdale
6 * Copyright 1995 Morten Welinder
7 */
9 #include "config.h"
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <signal.h>
15 #include <unistd.h>
17 #include "debugger.h"
18 #include "expr.h"
19 #include "wine/exception.h"
21 extern FILE * yyin;
22 int curr_frame = 0;
24 void issue_prompt(void);
25 void mode_command(int);
26 void flush_symbols(void);
27 int yylex(void);
28 int yyerror(char *);
32 %union
34 DBG_ADDR address;
35 enum debug_regs reg;
36 char * string;
37 int integer;
38 struct list_id listing;
39 struct expr * expression;
40 struct datatype * type;
43 %token tCONT tPASS tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
44 %token tENABLE tDISABLE tBREAK tWATCH tDELETE tSET tMODE tPRINT tEXAM tABORT
45 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
46 %token tPROCESS tMODREF
47 %token tEOL tSTRING tDEBUGSTR
48 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
49 %token tSTEPI tNEXTI tFINISH tSHOW tDIR
50 %token <string> tPATH
51 %token <string> tIDENTIFIER tSTRING tDEBUGSTR
52 %token <integer> tNUM tFORMAT
53 %token <reg> tREG
54 %token tSYMBOLFILE
56 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
57 %token tSTRUCT tUNION tENUM
59 /* %left ',' */
60 /* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
61 OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
62 OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
63 /* %left OP_COND */ /* ... ? ... : ... */
64 %left OP_LOR
65 %left OP_LAND
66 %left '|'
67 %left '^'
68 %left '&'
69 %left OP_EQ OP_NE
70 %left '<' '>' OP_LE OP_GE
71 %left OP_SHL OP_SHR
72 %left '+' '-'
73 %left '*' '/' '%'
74 %left OP_SIGN '!' '~' OP_DEREF /* OP_INC OP_DEC OP_ADDR */
75 %left '.' '[' OP_DRF
76 %nonassoc ':'
78 %type <expression> expr lval lvalue
79 %type <type> type_cast type_expr
80 %type <address> expr_addr lval_addr
81 %type <integer> expr_value
82 %type <string> pathname
84 %type <listing> list_arg
88 input: line { issue_prompt(); }
89 | input line { issue_prompt(); }
91 line: command
92 | tEOL
93 | error tEOL { yyerrok; }
95 command:
96 tQUIT tEOL { DEBUG_Exit(0); }
97 | tHELP tEOL { DEBUG_Help(); }
98 | tHELP tINFO tEOL { DEBUG_HelpInfo(); }
99 | tCONT tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
100 DEBUG_CurrThread->dbg_exec_mode = EXEC_CONT; return 0; }
101 | tPASS tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
102 DEBUG_CurrThread->dbg_exec_mode = EXEC_PASS; return 0; }
103 | tCONT tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2;
104 DEBUG_CurrThread->dbg_exec_mode = EXEC_CONT; return 0; }
105 | tSTEP tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
106 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
107 | tNEXT tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
108 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEP_OVER; return 0; }
109 | tSTEP tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2;
110 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
111 | tNEXT tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2;
112 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEP_OVER; return 0; }
113 | tSTEPI tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
114 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
115 | tNEXTI tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
116 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
117 | tSTEPI tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2;
118 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
119 | tNEXTI tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2;
120 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
121 | tABORT tEOL { kill(getpid(), SIGABRT); }
122 | tMODE tNUM tEOL { mode_command($2); }
123 | tENABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, TRUE ); }
124 | tDISABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, FALSE ); }
125 | tDELETE tBREAK tNUM tEOL { DEBUG_DelBreakpoint( $3 ); }
126 | tBACKTRACE tEOL { DEBUG_BackTrace(TRUE); }
127 | tUP tEOL { DEBUG_SetFrame( curr_frame + 1 ); }
128 | tUP tNUM tEOL { DEBUG_SetFrame( curr_frame + $2 ); }
129 | tDOWN tEOL { DEBUG_SetFrame( curr_frame - 1 ); }
130 | tDOWN tNUM tEOL { DEBUG_SetFrame( curr_frame - $2 ); }
131 | tFRAME tNUM tEOL { DEBUG_SetFrame( $2 ); }
132 | tFINISH tEOL { DEBUG_CurrThread->dbg_exec_count = 0;
133 DEBUG_CurrThread->dbg_exec_mode = EXEC_FINISH; return 0; }
134 | tSHOW tDIR tEOL { DEBUG_ShowDir(); }
135 | tDIR pathname tEOL { DEBUG_AddPath( $2 ); }
136 | tDIR tEOL { DEBUG_NukePath(); }
137 | tDISPLAY tEOL { DEBUG_InfoDisplay(); }
138 | tDISPLAY expr tEOL { DEBUG_AddDisplay($2, 1, 0); }
139 | tDISPLAY tFORMAT expr tEOL { DEBUG_AddDisplay($3, $2 >> 8, $2 & 0xff); }
140 | tDELETE tDISPLAY tNUM tEOL { DEBUG_DelDisplay( $3 ); }
141 | tDELETE tDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
142 | tUNDISPLAY tNUM tEOL { DEBUG_DelDisplay( $2 ); }
143 | tUNDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
144 | tCOND tNUM tEOL { DEBUG_AddBPCondition($2, NULL); }
145 | tCOND tNUM expr tEOL { DEBUG_AddBPCondition($2, $3); }
146 | tSYMBOLFILE pathname tEOL{ DEBUG_ReadSymbolTable($2); }
147 | list_command
148 | disassemble_command
149 | set_command
150 | x_command
151 | print_command
152 | break_command
153 | info_command
154 | walk_command
156 set_command:
157 tSET tREG '=' expr_value tEOL { DEBUG_SetRegister( $2, $4 );
158 DEBUG_FreeExprMem(); }
159 | tSET lval_addr '=' expr_value tEOL { DEBUG_WriteMemory( &$2, $4 );
160 DEBUG_FreeExprMem(); }
162 pathname:
163 tIDENTIFIER { $$ = $1; }
164 | tPATH { $$ = $1; }
166 disassemble_command:
167 tDISASSEMBLE tEOL { DEBUG_Disassemble( NULL, NULL, 10 ); }
168 | tDISASSEMBLE expr_addr tEOL { DEBUG_Disassemble( & $2, NULL, 10 ); }
169 | tDISASSEMBLE expr_addr ',' expr_addr tEOL { DEBUG_Disassemble( & $2, & $4, 0 ); }
171 list_command:
172 tLIST tEOL { DEBUG_List( NULL, NULL, 10 ); }
173 | tLIST '-' tEOL { DEBUG_List( NULL, NULL, -10 ); }
174 | tLIST list_arg tEOL { DEBUG_List( & $2, NULL, 10 ); }
175 | tLIST ',' list_arg tEOL { DEBUG_List( NULL, & $3, -10 ); }
176 | tLIST list_arg ',' list_arg tEOL { DEBUG_List( & $2, & $4, 0 ); }
178 list_arg:
179 tNUM { $$.sourcefile = NULL; $$.line = $1; }
180 | pathname ':' tNUM { $$.sourcefile = $1; $$.line = $3; }
181 | tIDENTIFIER { DEBUG_GetFuncInfo( & $$, NULL, $1); }
182 | pathname ':' tIDENTIFIER { DEBUG_GetFuncInfo( & $$, $1, $3); }
183 | '*' expr_addr { DEBUG_FindNearestSymbol( & $2, FALSE, NULL,
184 0, & $$ );
185 DEBUG_FreeExprMem(); }
187 x_command:
188 tEXAM expr_addr tEOL { DEBUG_ExamineMemory( &$2, 1, 'x');
189 DEBUG_FreeExprMem(); }
190 | tEXAM tFORMAT expr_addr tEOL { DEBUG_ExamineMemory( &$3, $2>>8, $2&0xff );
191 DEBUG_FreeExprMem(); }
193 print_command:
194 tPRINT expr_addr tEOL { DEBUG_Print( &$2, 1, 0, 0 );
195 DEBUG_FreeExprMem(); }
196 | tPRINT tFORMAT expr_addr tEOL { DEBUG_Print( &$3, $2 >> 8, $2 & 0xff, 0 );
197 DEBUG_FreeExprMem(); }
199 break_command:
200 tBREAK '*' expr_addr tEOL { DEBUG_AddBreakpoint( &$3 );
201 DEBUG_FreeExprMem(); }
202 | tBREAK tIDENTIFIER tEOL { DBG_ADDR addr;
203 if( DEBUG_GetSymbolValue($2, -1, &addr, TRUE) )
205 DEBUG_AddBreakpoint( &addr );
207 else
209 fprintf(stderr,"Unable to add breakpoint\n");
212 | tBREAK tIDENTIFIER ':' tNUM tEOL { DBG_ADDR addr;
213 if( DEBUG_GetSymbolValue($2, $4, &addr, TRUE) )
215 DEBUG_AddBreakpoint( &addr );
217 else
219 fprintf(stderr,"Unable to add breakpoint\n");
222 | tBREAK tNUM tEOL { struct name_hash *nh;
223 DBG_ADDR addr;
224 DEBUG_GetCurrentAddress( &addr );
225 DEBUG_FindNearestSymbol(&addr, TRUE,
226 &nh, 0, NULL);
227 if( nh != NULL )
229 DEBUG_GetLineNumberAddr(nh,
230 $2, &addr, TRUE);
231 DEBUG_AddBreakpoint( &addr );
233 else
235 fprintf(stderr,"Unable to add breakpoint\n");
239 | tBREAK tEOL { DBG_ADDR addr;
240 DEBUG_GetCurrentAddress( &addr );
241 DEBUG_AddBreakpoint( &addr );
244 info_command:
245 tINFO tBREAK tEOL { DEBUG_InfoBreakpoints(); }
246 | tINFO tCLASS tSTRING tEOL { DEBUG_InfoClass( $3 ); DEBUG_FreeExprMem(); }
247 | tINFO tSHARE tEOL { DEBUG_InfoShare(); }
248 | tINFO tMODULE expr_value tEOL { DEBUG_DumpModule( $3 );
249 DEBUG_FreeExprMem(); }
250 | tINFO tQUEUE expr_value tEOL { DEBUG_DumpQueue( $3 );
251 DEBUG_FreeExprMem(); }
252 | tINFO tREGS tEOL { DEBUG_InfoRegisters(); }
253 | tINFO tSEGMENTS expr_value tEOL { DEBUG_InfoSegments( $3, 1 ); DEBUG_FreeExprMem(); }
254 | tINFO tSEGMENTS tEOL { DEBUG_InfoSegments( 0, -1 ); }
255 | tINFO tSTACK tEOL { DEBUG_InfoStack(); }
256 | tINFO tMAPS tEOL { DEBUG_InfoVirtual(); }
257 | tINFO tWND expr_value tEOL { DEBUG_InfoWindow( (HWND)$3 );
258 DEBUG_FreeExprMem(); }
259 | tINFO tLOCAL tEOL { DEBUG_InfoLocals(); }
260 | tINFO tDISPLAY tEOL { DEBUG_InfoDisplay(); }
262 walk_command:
263 tWALK tCLASS tEOL { DEBUG_WalkClasses(); }
264 | tWALK tMODULE tEOL { DEBUG_WalkModules(); }
265 | tWALK tQUEUE tEOL { DEBUG_WalkQueues(); }
266 | tWALK tWND tEOL { DEBUG_WalkWindows( 0, 0 ); }
267 | tWALK tWND tNUM tEOL { DEBUG_WalkWindows( $3, 0 ); }
268 | tWALK tPROCESS tEOL { DEBUG_WalkProcess(); }
269 | tWALK tMODREF expr_value tEOL { DEBUG_WalkModref( $3 ); }
272 type_cast:
273 '(' type_expr ')' { $$ = $2; }
275 type_expr:
276 type_expr '*' { $$ = DEBUG_FindOrMakePointerType($1); }
277 | tINT { $$ = DEBUG_TypeCast(DT_BASIC, "int"); }
278 | tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "char"); }
279 | tLONG tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long int"); }
280 | tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "unsigned int"); }
281 | tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long unsigned int"); }
282 | tLONG tLONG tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long long int"); }
283 | tLONG tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long long unsigned int"); }
284 | tSHORT tINT { $$ = DEBUG_TypeCast(DT_BASIC, "short int"); }
285 | tSHORT tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "short unsigned int"); }
286 | tSIGNED tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "signed char"); }
287 | tUNSIGNED tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "unsigned char"); }
288 | tFLOAT { $$ = DEBUG_TypeCast(DT_BASIC, "float"); }
289 | tDOUBLE { $$ = DEBUG_TypeCast(DT_BASIC, "double"); }
290 | tLONG tDOUBLE { $$ = DEBUG_TypeCast(DT_BASIC, "long double"); }
291 | tSTRUCT tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
292 | tUNION tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
293 | tENUM tIDENTIFIER { $$ = DEBUG_TypeCast(DT_ENUM, $2); }
295 expr_addr:
296 expr { $$ = DEBUG_EvalExpr($1); }
298 expr_value:
299 expr { DBG_ADDR addr = DEBUG_EvalExpr($1);
300 /* expr_value is typed as an integer */
301 if (!addr.off || !DEBUG_READ_MEM((void*)addr.off, &$$, sizeof($$)))
302 $$ = 0; }
304 * The expr rule builds an expression tree. When we are done, we call
305 * EvalExpr to evaluate the value of the expression. The advantage of
306 * the two-step approach is that it is possible to save expressions for
307 * use in 'display' commands, and in conditional watchpoints.
309 expr:
310 tNUM { $$ = DEBUG_ConstExpr($1); }
311 | tSTRING { $$ = DEBUG_StringExpr($1); }
312 | tREG { $$ = DEBUG_RegisterExpr($1); }
313 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
314 | expr OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
315 | expr '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
316 | tIDENTIFIER '(' ')' { $$ = DEBUG_CallExpr($1, 0); }
317 | tIDENTIFIER '(' expr ')' { $$ = DEBUG_CallExpr($1, 1, $3); }
318 | tIDENTIFIER '(' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 2, $3,
319 $5); }
320 | tIDENTIFIER '(' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7); }
321 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9); }
322 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9, $11); }
323 | expr '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
324 | expr ':' expr { $$ = DEBUG_BinopExpr(EXP_OP_SEG, $1, $3); }
325 | expr OP_LOR expr { $$ = DEBUG_BinopExpr(EXP_OP_LOR, $1, $3); }
326 | expr OP_LAND expr { $$ = DEBUG_BinopExpr(EXP_OP_LAND, $1, $3); }
327 | expr '|' expr { $$ = DEBUG_BinopExpr(EXP_OP_OR, $1, $3); }
328 | expr '&' expr { $$ = DEBUG_BinopExpr(EXP_OP_AND, $1, $3); }
329 | expr '^' expr { $$ = DEBUG_BinopExpr(EXP_OP_XOR, $1, $3); }
330 | expr OP_EQ expr { $$ = DEBUG_BinopExpr(EXP_OP_EQ, $1, $3); }
331 | expr '>' expr { $$ = DEBUG_BinopExpr(EXP_OP_GT, $1, $3); }
332 | expr '<' expr { $$ = DEBUG_BinopExpr(EXP_OP_LT, $1, $3); }
333 | expr OP_GE expr { $$ = DEBUG_BinopExpr(EXP_OP_GE, $1, $3); }
334 | expr OP_LE expr { $$ = DEBUG_BinopExpr(EXP_OP_LE, $1, $3); }
335 | expr OP_NE expr { $$ = DEBUG_BinopExpr(EXP_OP_NE, $1, $3); }
336 | expr OP_SHL expr { $$ = DEBUG_BinopExpr(EXP_OP_SHL, $1, $3); }
337 | expr OP_SHR expr { $$ = DEBUG_BinopExpr(EXP_OP_SHR, $1, $3); }
338 | expr '+' expr { $$ = DEBUG_BinopExpr(EXP_OP_ADD, $1, $3); }
339 | expr '-' expr { $$ = DEBUG_BinopExpr(EXP_OP_SUB, $1, $3); }
340 | expr '*' expr { $$ = DEBUG_BinopExpr(EXP_OP_MUL, $1, $3); }
341 | expr '/' expr { $$ = DEBUG_BinopExpr(EXP_OP_DIV, $1, $3); }
342 | expr '%' expr { $$ = DEBUG_BinopExpr(EXP_OP_REM, $1, $3); }
343 | '-' expr %prec OP_SIGN { $$ = DEBUG_UnopExpr(EXP_OP_NEG, $2); }
344 | '+' expr %prec OP_SIGN { $$ = $2; }
345 | '!' expr { $$ = DEBUG_UnopExpr(EXP_OP_NOT, $2); }
346 | '~' expr { $$ = DEBUG_UnopExpr(EXP_OP_LNOT, $2); }
347 | '(' expr ')' { $$ = $2; }
348 | '*' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_DEREF, $2); }
349 | '&' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_ADDR, $2); }
350 | type_cast expr %prec OP_DEREF { $$ = DEBUG_TypeCastExpr($1, $2); }
353 * The lvalue rule builds an expression tree. This is a limited form
354 * of expression that is suitable to be used as an lvalue.
356 lval_addr:
357 lval { $$ = DEBUG_EvalExpr($1); }
359 lval:
360 lvalue { $$ = $1; }
361 | '*' expr { $$ = DEBUG_UnopExpr(EXP_OP_FORCE_DEREF, $2); }
363 lvalue:
364 tNUM { $$ = DEBUG_ConstExpr($1); }
365 | tREG { $$ = DEBUG_RegisterExpr($1); }
366 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
367 | lvalue OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
368 | lvalue '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
369 | lvalue '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
373 void
374 issue_prompt(){
375 #ifdef DONT_USE_READLINE
376 fprintf(stderr,"Wine-dbg>");
377 #endif
380 void mode_command(int newmode)
382 if ((newmode == 16) || (newmode == 32)) DEBUG_CurrThread->dbg_mode = newmode;
383 else fprintf(stderr,"Invalid mode (use 16 or 32)\n");
386 static WINE_EXCEPTION_FILTER(no_symbol)
388 if (GetExceptionCode() == DEBUG_STATUS_NO_SYMBOL)
389 return EXCEPTION_EXECUTE_HANDLER;
390 return EXCEPTION_CONTINUE_SEARCH;
393 /***********************************************************************
394 * DEBUG_Exit
396 * Kill current process.
399 void DEBUG_Exit( DWORD exit_code )
401 TASK_KillTask( 0 ); /* FIXME: should not be necessary */
402 TerminateProcess( DEBUG_CurrProcess->handle, exit_code );
405 /***********************************************************************
406 * DEBUG_Main
408 * Debugger main loop.
410 BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code )
412 int newmode;
413 BOOL ret_ok;
414 char ch;
416 #ifdef YYDEBUG
417 yydebug = 0;
418 #endif
420 yyin = stdin;
422 DEBUG_SuspendExecution();
424 if (!is_debug)
426 #ifdef __i386__
427 if (DEBUG_IsSelectorSystem(DEBUG_context.SegCs))
428 fprintf( stderr, " in 32-bit code (0x%08lx).\n", DEBUG_context.Eip );
429 else
430 fprintf( stderr, " in 16-bit code (%04x:%04lx).\n",
431 (WORD)DEBUG_context.SegCs, DEBUG_context.Eip );
432 #else
433 fprintf( stderr, " (%p).\n", GET_IP(&DEBUG_context) );
434 #endif
437 if (DEBUG_LoadEntryPoints("Loading new modules symbols:\n"))
438 DEBUG_ProcessDeferredDebug();
440 if (force || !(is_debug && DEBUG_ShouldContinue( code,
441 DEBUG_CurrThread->dbg_exec_mode,
442 &DEBUG_CurrThread->dbg_exec_count )))
444 DBG_ADDR addr;
445 DEBUG_GetCurrentAddress( &addr );
447 /* EPP if (USER_Driver) USER_Driver->pBeginDebugging(); */
449 #ifdef __i386__
450 switch (newmode = DEBUG_GetSelectorType(addr.seg)) {
451 case 16: case 32: break;
452 default: fprintf(stderr, "Bad CS (%ld)\n", addr.seg); newmode = 32;
454 #else
455 newmode = 32;
456 #endif
457 if (newmode != DEBUG_CurrThread->dbg_mode)
458 fprintf(stderr,"In %d bit mode.\n", DEBUG_CurrThread->dbg_mode = newmode);
460 DEBUG_DoDisplay();
462 if (is_debug || force)
465 * Do a quiet backtrace so that we have an idea of what the situation
466 * is WRT the source files.
468 DEBUG_BackTrace(FALSE);
470 else
472 /* This is a real crash, dump some info */
473 DEBUG_InfoRegisters();
474 DEBUG_InfoStack();
475 #ifdef __i386__
476 if (DEBUG_CurrThread->dbg_mode == 16)
478 DEBUG_InfoSegments( DEBUG_context.SegDs >> 3, 1 );
479 if (DEBUG_context.SegEs != DEBUG_context.SegDs)
480 DEBUG_InfoSegments( DEBUG_context.SegEs >> 3, 1 );
482 DEBUG_InfoSegments( DEBUG_context.SegFs >> 3, 1 );
483 #endif
484 DEBUG_BackTrace(TRUE);
487 if (!is_debug ||
488 (DEBUG_CurrThread->dbg_exec_mode == EXEC_STEPI_OVER) ||
489 (DEBUG_CurrThread->dbg_exec_mode == EXEC_STEPI_INSTR))
491 /* Show where we crashed */
492 curr_frame = 0;
493 DEBUG_PrintAddress( &addr, DEBUG_CurrThread->dbg_mode, TRUE );
494 fprintf(stderr,": ");
495 DEBUG_Disasm( &addr, TRUE );
496 fprintf( stderr, "\n" );
499 ret_ok = 0;
502 __TRY
504 issue_prompt();
505 yyparse();
506 flush_symbols();
508 DEBUG_GetCurrentAddress( &addr );
509 if ((ret_ok = DEBUG_ValidateRegisters()))
510 ret_ok = DEBUG_READ_MEM_VERBOSE((void*)DEBUG_ToLinear( &addr ), &ch, 1 );
512 __EXCEPT(no_symbol)
514 fprintf(stderr, "Undefined symbol\n");
515 ret_ok = 0;
517 __ENDTRY;
519 } while (!ret_ok);
522 DEBUG_CurrThread->dbg_exec_mode = DEBUG_RestartExecution( DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count );
524 * This will have gotten absorbed into the breakpoint info
525 * if it was used. Otherwise it would have been ignored.
526 * In any case, we don't mess with it any more.
528 if ((DEBUG_CurrThread->dbg_exec_mode == EXEC_CONT) || (DEBUG_CurrThread->dbg_exec_mode == EXEC_PASS))
529 DEBUG_CurrThread->dbg_exec_count = 0;
530 /* EPP if (USER_Driver) USER_Driver->pEndDebugging(); */
532 return (DEBUG_CurrThread->dbg_exec_mode == EXEC_PASS) ? 0 : DBG_CONTINUE;
535 int yyerror(char* s)
537 fprintf(stderr,"%s\n", s);
538 return 0;