Made the winedbg an external and WineLib program.
[wine.git] / debugger / dbg.y
blob913e1d4f7975287c525a16852023ebff33b426c8
1 %{
2 /*
3 * Parser for command lines in the Wine debugger
5 * Copyright 1993 Eric Youngdale
6 * Copyright 1995 Morten Welinder
7 * Copyright 2000 Eric Pouech
8 */
10 #include "config.h"
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <signal.h>
16 #include <unistd.h>
18 #include "wine/exception.h"
19 #include "debugger.h"
20 #include "expr.h"
21 #include "task.h"
23 extern FILE * yyin;
24 int curr_frame = 0;
26 static void issue_prompt(void);
27 static void mode_command(int);
28 void flush_symbols(void);
29 int yylex(void);
30 int yyerror(char *);
34 %union
36 DBG_VALUE value;
37 enum debug_regs reg;
38 char * string;
39 int integer;
40 struct list_id listing;
41 struct expr * expression;
42 struct datatype * type;
45 %token tCONT tPASS tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
46 %token tENABLE tDISABLE tBREAK tWATCH tDELETE tSET tMODE tPRINT tEXAM tABORT
47 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
48 %token tPROCESS tMODREF
49 %token tEOL tSTRING tDEBUGSTR
50 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
51 %token tSTEPI tNEXTI tFINISH tSHOW tDIR tWHATIS
52 %token <string> tPATH
53 %token <string> tIDENTIFIER tSTRING tDEBUGSTR
54 %token <integer> tNUM tFORMAT
55 %token <reg> tREG
56 %token tSYMBOLFILE
58 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
59 %token tSTRUCT tUNION tENUM
61 /* %left ',' */
62 /* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
63 OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
64 OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
65 /* %left OP_COND */ /* ... ? ... : ... */
66 %left OP_LOR
67 %left OP_LAND
68 %left '|'
69 %left '^'
70 %left '&'
71 %left OP_EQ OP_NE
72 %left '<' '>' OP_LE OP_GE
73 %left OP_SHL OP_SHR
74 %left '+' '-'
75 %left '*' '/' '%'
76 %left OP_SIGN '!' '~' OP_DEREF /* OP_INC OP_DEC OP_ADDR */
77 %left '.' '[' OP_DRF
78 %nonassoc ':'
80 %type <expression> expr lval lvalue
81 %type <type> type_cast type_expr
82 %type <value> expr_addr lval_addr
83 %type <integer> expr_value
84 %type <string> pathname
86 %type <listing> list_arg
90 input: line { issue_prompt(); }
91 | input line { issue_prompt(); }
93 line: command
94 | tEOL
95 | error tEOL { yyerrok; }
97 command:
98 tQUIT tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
99 DEBUG_CurrThread->dbg_exec_mode = EXEC_KILL; return 1; }
100 | tHELP tEOL { DEBUG_Help(); }
101 | tHELP tINFO tEOL { DEBUG_HelpInfo(); }
102 | tCONT tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
103 DEBUG_CurrThread->dbg_exec_mode = EXEC_CONT; return 0; }
104 | tPASS tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
105 DEBUG_CurrThread->dbg_exec_mode = EXEC_PASS; return 0; }
106 | tCONT tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2;
107 DEBUG_CurrThread->dbg_exec_mode = EXEC_CONT; return 0; }
108 | tSTEP tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
109 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
110 | tNEXT tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
111 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEP_OVER; return 0; }
112 | tSTEP tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2;
113 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
114 | tNEXT tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2;
115 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEP_OVER; return 0; }
116 | tSTEPI tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
117 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
118 | tNEXTI tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
119 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
120 | tSTEPI tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2;
121 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
122 | tNEXTI tNUM tEOL { DEBUG_CurrThread->dbg_exec_count = $2;
123 DEBUG_CurrThread->dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
124 | tABORT tEOL { kill(getpid(), SIGABRT); }
125 | tMODE tNUM tEOL { mode_command($2); }
126 | tENABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, TRUE ); }
127 | tDISABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, FALSE ); }
128 | tDELETE tBREAK tNUM tEOL { DEBUG_DelBreakpoint( $3 ); }
129 | tBACKTRACE tEOL { DEBUG_BackTrace(TRUE); }
130 | tUP tEOL { DEBUG_SetFrame( curr_frame + 1 ); }
131 | tUP tNUM tEOL { DEBUG_SetFrame( curr_frame + $2 ); }
132 | tDOWN tEOL { DEBUG_SetFrame( curr_frame - 1 ); }
133 | tDOWN tNUM tEOL { DEBUG_SetFrame( curr_frame - $2 ); }
134 | tFRAME tNUM tEOL { DEBUG_SetFrame( $2 ); }
135 | tFINISH tEOL { DEBUG_CurrThread->dbg_exec_count = 0;
136 DEBUG_CurrThread->dbg_exec_mode = EXEC_FINISH; return 0; }
137 | tSHOW tDIR tEOL { DEBUG_ShowDir(); }
138 | tDIR pathname tEOL { DEBUG_AddPath( $2 ); }
139 | tDIR tEOL { DEBUG_NukePath(); }
140 | tDISPLAY tEOL { DEBUG_InfoDisplay(); }
141 | tDISPLAY expr tEOL { DEBUG_AddDisplay($2, 1, 0); }
142 | tDISPLAY tFORMAT expr tEOL { DEBUG_AddDisplay($3, $2 >> 8, $2 & 0xff); }
143 | tDELETE tDISPLAY tNUM tEOL { DEBUG_DelDisplay( $3 ); }
144 | tDELETE tDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
145 | tUNDISPLAY tNUM tEOL { DEBUG_DelDisplay( $2 ); }
146 | tUNDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
147 | tCOND tNUM tEOL { DEBUG_AddBPCondition($2, NULL); }
148 | tCOND tNUM expr tEOL { DEBUG_AddBPCondition($2, $3); }
149 | tSYMBOLFILE pathname tEOL{ DEBUG_ReadSymbolTable($2); }
150 | tWHATIS expr_addr tEOL { DEBUG_PrintType(&$2); DEBUG_FreeExprMem(); }
151 | list_command
152 | disassemble_command
153 | set_command
154 | x_command
155 | print_command
156 | break_command
157 | watch_command
158 | info_command
159 | walk_command
161 set_command:
162 tSET tREG '=' expr_value tEOL { DEBUG_SetRegister( $2, $4 );
163 DEBUG_FreeExprMem(); }
164 | tSET lval_addr '=' expr_value tEOL { DEBUG_WriteMemory( &$2.addr, $4 );
165 DEBUG_FreeExprMem(); }
167 pathname:
168 tIDENTIFIER { $$ = $1; }
169 | tPATH { $$ = $1; }
171 disassemble_command:
172 tDISASSEMBLE tEOL { DEBUG_Disassemble( NULL, NULL, 10 ); }
173 | tDISASSEMBLE expr_addr tEOL { DEBUG_Disassemble( & $2, NULL, 10 ); }
174 | tDISASSEMBLE expr_addr ',' expr_addr tEOL { DEBUG_Disassemble( & $2, & $4, 0 ); }
176 list_command:
177 tLIST tEOL { DEBUG_List( NULL, NULL, 10 ); }
178 | tLIST '-' tEOL { DEBUG_List( NULL, NULL, -10 ); }
179 | tLIST list_arg tEOL { DEBUG_List( & $2, NULL, 10 ); }
180 | tLIST ',' list_arg tEOL { DEBUG_List( NULL, & $3, -10 ); }
181 | tLIST list_arg ',' list_arg tEOL { DEBUG_List( & $2, & $4, 0 ); }
183 list_arg:
184 tNUM { $$.sourcefile = NULL; $$.line = $1; }
185 | pathname ':' tNUM { $$.sourcefile = $1; $$.line = $3; }
186 | tIDENTIFIER { DEBUG_GetFuncInfo( & $$, NULL, $1); }
187 | pathname ':' tIDENTIFIER { DEBUG_GetFuncInfo( & $$, $1, $3); }
188 | '*' expr_addr { DEBUG_FindNearestSymbol( & $2.addr, FALSE, NULL,
189 0, & $$ );
190 DEBUG_FreeExprMem(); }
192 x_command:
193 tEXAM expr_addr tEOL { DEBUG_ExamineMemory( &$2, 1, 'x');
194 DEBUG_FreeExprMem(); }
195 | tEXAM tFORMAT expr_addr tEOL { DEBUG_ExamineMemory( &$3, $2>>8, $2&0xff );
196 DEBUG_FreeExprMem(); }
198 print_command:
199 tPRINT expr_addr tEOL { DEBUG_Print( &$2, 1, 0, 0 );
200 DEBUG_FreeExprMem(); }
201 | tPRINT tFORMAT expr_addr tEOL { DEBUG_Print( &$3, $2 >> 8, $2 & 0xff, 0 );
202 DEBUG_FreeExprMem(); }
204 break_command:
205 tBREAK '*' expr_addr tEOL { DEBUG_AddBreakpoint( &$3 );
206 DEBUG_FreeExprMem(); }
207 | tBREAK tIDENTIFIER tEOL { DBG_VALUE value;
208 if( DEBUG_GetSymbolValue($2, -1, &value, TRUE) )
210 DEBUG_AddBreakpoint( &value );
212 else
214 DEBUG_Printf(DBG_CHN_MESG,"Unable to add breakpoint\n");
217 | tBREAK tIDENTIFIER ':' tNUM tEOL { DBG_VALUE value;
218 if( DEBUG_GetSymbolValue($2, $4, &value, TRUE) )
220 DEBUG_AddBreakpoint( &value );
222 else
224 DEBUG_Printf(DBG_CHN_MESG,"Unable to add breakpoint\n");
227 | tBREAK tNUM tEOL { struct name_hash *nh;
228 DBG_VALUE value;
229 DEBUG_GetCurrentAddress( &value.addr );
230 DEBUG_FindNearestSymbol(&value.addr, TRUE,
231 &nh, 0, NULL);
232 if( nh != NULL )
234 DEBUG_GetLineNumberAddr(nh, $2, &value.addr, TRUE);
235 value.type = NULL;
236 value.cookie = DV_TARGET;
237 DEBUG_AddBreakpoint( &value );
239 else
241 DEBUG_Printf(DBG_CHN_MESG,"Unable to add breakpoint\n");
245 | tBREAK tEOL { DBG_VALUE value;
246 DEBUG_GetCurrentAddress( &value.addr );
247 value.type = NULL;
248 value.cookie = DV_TARGET;
249 DEBUG_AddBreakpoint( &value );
252 watch_command:
253 tWATCH '*' expr_addr tEOL { DEBUG_AddWatchpoint( &$3, 1 );
254 DEBUG_FreeExprMem(); }
255 | tWATCH tIDENTIFIER tEOL { DBG_VALUE value;
256 if( DEBUG_GetSymbolValue($2, -1, &value, TRUE) )
257 DEBUG_AddWatchpoint( &value, 1 );
258 else
259 DEBUG_Printf(DBG_CHN_MESG,"Unable to add breakpoint\n");
262 info_command:
263 tINFO tBREAK tEOL { DEBUG_InfoBreakpoints(); }
264 | tINFO tCLASS tSTRING tEOL { DEBUG_InfoClass( $3 ); DEBUG_FreeExprMem(); }
265 | tINFO tSHARE tEOL { DEBUG_InfoShare(); }
266 | tINFO tMODULE expr_value tEOL { DEBUG_DumpModule( $3 ); DEBUG_FreeExprMem(); }
267 | tINFO tQUEUE expr_value tEOL { DEBUG_DumpQueue( $3 ); DEBUG_FreeExprMem(); }
268 | tINFO tREGS tEOL { DEBUG_InfoRegisters(); }
269 | tINFO tSEGMENTS expr_value tEOL { DEBUG_InfoSegments( $3, 1 ); DEBUG_FreeExprMem(); }
270 | tINFO tSEGMENTS tEOL { DEBUG_InfoSegments( 0, -1 ); }
271 | tINFO tSTACK tEOL { DEBUG_InfoStack(); }
272 | tINFO tMAPS tEOL { DEBUG_InfoVirtual(); }
273 | tINFO tWND expr_value tEOL { DEBUG_InfoWindow( (HWND)$3 );
274 DEBUG_FreeExprMem(); }
275 | tINFO tLOCAL tEOL { DEBUG_InfoLocals(); }
276 | tINFO tDISPLAY tEOL { DEBUG_InfoDisplay(); }
278 walk_command:
279 tWALK tCLASS tEOL { DEBUG_WalkClasses(); }
280 | tWALK tMODULE tEOL { DEBUG_WalkModules(); }
281 | tWALK tQUEUE tEOL { DEBUG_WalkQueues(); }
282 | tWALK tWND tEOL { DEBUG_WalkWindows( 0, 0 ); }
283 | tWALK tWND tNUM tEOL { DEBUG_WalkWindows( $3, 0 ); }
284 | tWALK tPROCESS tEOL { DEBUG_WalkProcess(); }
285 | tWALK tMODREF expr_value tEOL { DEBUG_WalkModref( $3 ); }
288 type_cast:
289 '(' type_expr ')' { $$ = $2; }
291 type_expr:
292 type_expr '*' { $$ = DEBUG_FindOrMakePointerType($1); }
293 | tINT { $$ = DEBUG_TypeCast(DT_BASIC, "int"); }
294 | tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "char"); }
295 | tLONG tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long int"); }
296 | tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "unsigned int"); }
297 | tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long unsigned int"); }
298 | tLONG tLONG tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long long int"); }
299 | tLONG tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long long unsigned int"); }
300 | tSHORT tINT { $$ = DEBUG_TypeCast(DT_BASIC, "short int"); }
301 | tSHORT tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "short unsigned int"); }
302 | tSIGNED tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "signed char"); }
303 | tUNSIGNED tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "unsigned char"); }
304 | tFLOAT { $$ = DEBUG_TypeCast(DT_BASIC, "float"); }
305 | tDOUBLE { $$ = DEBUG_TypeCast(DT_BASIC, "double"); }
306 | tLONG tDOUBLE { $$ = DEBUG_TypeCast(DT_BASIC, "long double"); }
307 | tSTRUCT tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
308 | tUNION tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
309 | tENUM tIDENTIFIER { $$ = DEBUG_TypeCast(DT_ENUM, $2); }
311 expr_addr:
312 expr { $$ = DEBUG_EvalExpr($1); }
314 expr_value:
315 expr { DBG_VALUE value = DEBUG_EvalExpr($1);
316 /* expr_value is typed as an integer */
317 if (!value.addr.off ||
318 !DEBUG_READ_MEM((void*)value.addr.off, &$$, sizeof($$)))
319 $$ = 0; }
321 * The expr rule builds an expression tree. When we are done, we call
322 * EvalExpr to evaluate the value of the expression. The advantage of
323 * the two-step approach is that it is possible to save expressions for
324 * use in 'display' commands, and in conditional watchpoints.
326 expr:
327 tNUM { $$ = DEBUG_ConstExpr($1); }
328 | tSTRING { $$ = DEBUG_StringExpr($1); }
329 | tREG { $$ = DEBUG_RegisterExpr($1); }
330 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
331 | expr OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
332 | expr '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
333 | tIDENTIFIER '(' ')' { $$ = DEBUG_CallExpr($1, 0); }
334 | tIDENTIFIER '(' expr ')' { $$ = DEBUG_CallExpr($1, 1, $3); }
335 | tIDENTIFIER '(' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 2, $3, $5); }
336 | tIDENTIFIER '(' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7); }
337 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9); }
338 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9, $11); }
339 | expr '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
340 | expr ':' expr { $$ = DEBUG_BinopExpr(EXP_OP_SEG, $1, $3); }
341 | expr OP_LOR expr { $$ = DEBUG_BinopExpr(EXP_OP_LOR, $1, $3); }
342 | expr OP_LAND expr { $$ = DEBUG_BinopExpr(EXP_OP_LAND, $1, $3); }
343 | expr '|' expr { $$ = DEBUG_BinopExpr(EXP_OP_OR, $1, $3); }
344 | expr '&' expr { $$ = DEBUG_BinopExpr(EXP_OP_AND, $1, $3); }
345 | expr '^' expr { $$ = DEBUG_BinopExpr(EXP_OP_XOR, $1, $3); }
346 | expr OP_EQ expr { $$ = DEBUG_BinopExpr(EXP_OP_EQ, $1, $3); }
347 | expr '>' expr { $$ = DEBUG_BinopExpr(EXP_OP_GT, $1, $3); }
348 | expr '<' expr { $$ = DEBUG_BinopExpr(EXP_OP_LT, $1, $3); }
349 | expr OP_GE expr { $$ = DEBUG_BinopExpr(EXP_OP_GE, $1, $3); }
350 | expr OP_LE expr { $$ = DEBUG_BinopExpr(EXP_OP_LE, $1, $3); }
351 | expr OP_NE expr { $$ = DEBUG_BinopExpr(EXP_OP_NE, $1, $3); }
352 | expr OP_SHL expr { $$ = DEBUG_BinopExpr(EXP_OP_SHL, $1, $3); }
353 | expr OP_SHR expr { $$ = DEBUG_BinopExpr(EXP_OP_SHR, $1, $3); }
354 | expr '+' expr { $$ = DEBUG_BinopExpr(EXP_OP_ADD, $1, $3); }
355 | expr '-' expr { $$ = DEBUG_BinopExpr(EXP_OP_SUB, $1, $3); }
356 | expr '*' expr { $$ = DEBUG_BinopExpr(EXP_OP_MUL, $1, $3); }
357 | expr '/' expr { $$ = DEBUG_BinopExpr(EXP_OP_DIV, $1, $3); }
358 | expr '%' expr { $$ = DEBUG_BinopExpr(EXP_OP_REM, $1, $3); }
359 | '-' expr %prec OP_SIGN { $$ = DEBUG_UnopExpr(EXP_OP_NEG, $2); }
360 | '+' expr %prec OP_SIGN { $$ = $2; }
361 | '!' expr { $$ = DEBUG_UnopExpr(EXP_OP_NOT, $2); }
362 | '~' expr { $$ = DEBUG_UnopExpr(EXP_OP_LNOT, $2); }
363 | '(' expr ')' { $$ = $2; }
364 | '*' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_DEREF, $2); }
365 | '&' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_ADDR, $2); }
366 | type_cast expr %prec OP_DEREF { $$ = DEBUG_TypeCastExpr($1, $2); }
369 * The lvalue rule builds an expression tree. This is a limited form
370 * of expression that is suitable to be used as an lvalue.
372 lval_addr:
373 lval { $$ = DEBUG_EvalExpr($1); }
375 lval:
376 lvalue { $$ = $1; }
377 | '*' expr { $$ = DEBUG_UnopExpr(EXP_OP_FORCE_DEREF, $2); }
379 lvalue:
380 tNUM { $$ = DEBUG_ConstExpr($1); }
381 | tREG { $$ = DEBUG_RegisterExpr($1); }
382 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
383 | lvalue OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
384 | lvalue '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
385 | lvalue '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
389 static void issue_prompt(void)
391 #ifdef DONT_USE_READLINE
392 DEBUG_Printf(DBG_CHN_MESG, "Wine-dbg>");
393 #endif
396 static void mode_command(int newmode)
398 if ((newmode == 16) || (newmode == 32)) DEBUG_CurrThread->dbg_mode = newmode;
399 else DEBUG_Printf(DBG_CHN_MESG,"Invalid mode (use 16 or 32)\n");
402 void DEBUG_Exit(DWORD ec)
404 ExitProcess(ec);
407 static WINE_EXCEPTION_FILTER(wine_dbg_cmd)
409 DEBUG_Printf(DBG_CHN_MESG, "\nwine_dbg_cmd: ");
410 switch (GetExceptionCode()) {
411 case DEBUG_STATUS_INTERNAL_ERROR:
412 DEBUG_Printf(DBG_CHN_MESG, "WineDbg internal error\n");
413 break;
414 case DEBUG_STATUS_NO_SYMBOL:
415 DEBUG_Printf(DBG_CHN_MESG, "Undefined symbol\n");
416 break;
417 case DEBUG_STATUS_DIV_BY_ZERO:
418 DEBUG_Printf(DBG_CHN_MESG, "Division by zero\n");
419 break;
420 case DEBUG_STATUS_BAD_TYPE:
421 DEBUG_Printf(DBG_CHN_MESG, "No type or type mismatch\n");
422 break;
423 default:
424 DEBUG_Printf(DBG_CHN_MESG, "Exception %lx\n", GetExceptionCode());
425 break;
428 return EXCEPTION_EXECUTE_HANDLER;
431 /***********************************************************************
432 * DEBUG_Main
434 * Debugger main loop.
436 BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code )
438 int newmode;
439 BOOL ret_ok;
440 char ch;
442 #ifdef YYDEBUG
443 yydebug = 0;
444 #endif
446 yyin = stdin;
448 DEBUG_SuspendExecution();
450 if (!is_debug)
452 #ifdef __i386__
453 if (DEBUG_IsSelectorSystem(DEBUG_context.SegCs))
454 DEBUG_Printf( DBG_CHN_MESG, " in 32-bit code (0x%08lx).\n", DEBUG_context.Eip );
455 else
456 DEBUG_Printf( DBG_CHN_MESG, " in 16-bit code (%04x:%04lx).\n",
457 (WORD)DEBUG_context.SegCs, DEBUG_context.Eip );
458 #else
459 DEBUG_Printf( DBG_CHN_MESG, " (%p).\n", GET_IP(&DEBUG_context) );
460 #endif
463 DEBUG_LoadEntryPoints("Loading new modules symbols:\n");
465 if (force || !(is_debug && DEBUG_ShouldContinue( code,
466 DEBUG_CurrThread->dbg_exec_mode,
467 &DEBUG_CurrThread->dbg_exec_count )))
469 DBG_ADDR addr;
470 DEBUG_GetCurrentAddress( &addr );
472 #ifdef __i386__
473 switch (newmode = DEBUG_GetSelectorType(addr.seg)) {
474 case 16: case 32: break;
475 default: DEBUG_Printf(DBG_CHN_MESG, "Bad CS (%ld)\n", addr.seg); newmode = 32;
477 #else
478 newmode = 32;
479 #endif
480 if (newmode != DEBUG_CurrThread->dbg_mode)
481 DEBUG_Printf(DBG_CHN_MESG,"In %d bit mode.\n", DEBUG_CurrThread->dbg_mode = newmode);
483 DEBUG_DoDisplay();
485 if (is_debug || force)
488 * Do a quiet backtrace so that we have an idea of what the situation
489 * is WRT the source files.
491 DEBUG_BackTrace(FALSE);
493 else
495 /* This is a real crash, dump some info */
496 DEBUG_InfoRegisters();
497 DEBUG_InfoStack();
498 #ifdef __i386__
499 if (DEBUG_CurrThread->dbg_mode == 16)
501 DEBUG_InfoSegments( DEBUG_context.SegDs >> 3, 1 );
502 if (DEBUG_context.SegEs != DEBUG_context.SegDs)
503 DEBUG_InfoSegments( DEBUG_context.SegEs >> 3, 1 );
505 DEBUG_InfoSegments( DEBUG_context.SegFs >> 3, 1 );
506 #endif
507 DEBUG_BackTrace(TRUE);
510 if (!is_debug ||
511 (DEBUG_CurrThread->dbg_exec_mode == EXEC_STEPI_OVER) ||
512 (DEBUG_CurrThread->dbg_exec_mode == EXEC_STEPI_INSTR))
514 /* Show where we crashed */
515 curr_frame = 0;
516 DEBUG_PrintAddress( &addr, DEBUG_CurrThread->dbg_mode, TRUE );
517 DEBUG_Printf(DBG_CHN_MESG,": ");
518 DEBUG_Disasm( &addr, TRUE );
519 DEBUG_Printf( DBG_CHN_MESG, "\n" );
522 ret_ok = 0;
525 __TRY
527 issue_prompt();
528 if (yyparse()) {
529 DEBUG_CurrThread->dbg_exec_mode = EXEC_KILL;
530 ret_ok = TRUE;
531 } else {
532 flush_symbols();
534 DEBUG_GetCurrentAddress( &addr );
535 ret_ok = DEBUG_ValidateRegisters() &&
536 DEBUG_READ_MEM_VERBOSE((void*)DEBUG_ToLinear(&addr), &ch, 1);
539 __EXCEPT(wine_dbg_cmd)
541 ret_ok = FALSE;
543 __ENDTRY;
545 } while (!ret_ok);
548 DEBUG_CurrThread->dbg_exec_mode = DEBUG_RestartExecution( DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count );
550 * This will have gotten absorbed into the breakpoint info
551 * if it was used. Otherwise it would have been ignored.
552 * In any case, we don't mess with it any more.
554 if (DEBUG_CurrThread->dbg_exec_mode == EXEC_CONT || DEBUG_CurrThread->dbg_exec_mode == EXEC_PASS)
555 DEBUG_CurrThread->dbg_exec_count = 0;
557 return (DEBUG_CurrThread->dbg_exec_mode == EXEC_PASS) ? DBG_EXCEPTION_NOT_HANDLED : DBG_CONTINUE;
560 int yyerror(char* s)
562 DEBUG_Printf(DBG_CHN_MESG,"%s\n", s);
563 return 0;