Get rid of the X11DRV_DC_Funcs hack.
[wine.git] / programs / winedbg / dbg.y
blob781740c7421bfea71f1067d016a05b3d11ae7ac1
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
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "config.h"
25 #include "wine/port.h"
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <signal.h>
31 #include <unistd.h>
33 #include "wine/exception.h"
34 #include "debugger.h"
35 #include "expr.h"
36 #include "excpt.h"
38 static void mode_command(int);
39 int yylex(void);
40 int yyerror(const char *);
44 %union
46 DBG_VALUE value;
47 char * string;
48 int integer;
49 struct list_id listing;
50 struct expr * expression;
51 struct datatype* type;
54 %token tCONT tPASS tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
55 %token tENABLE tDISABLE tBREAK tWATCH tDELETE tSET tMODE tPRINT tEXAM tABORT tVM86
56 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tSYMBOL tREGS tWND tQUEUE tLOCAL tEXCEPTION
57 %token tPROCESS tTHREAD tMODREF tEOL tEOF
58 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
59 %token tSTEPI tNEXTI tFINISH tSHOW tDIR tWHATIS tSOURCE
60 %token <string> tPATH
61 %token <string> tIDENTIFIER tSTRING tDEBUGSTR tINTVAR
62 %token <integer> tNUM tFORMAT
63 %token tSYMBOLFILE tRUN tATTACH tDETACH tNOPROCESS tMAINTENANCE tTYPE
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_expr
89 %type <value> expr_addr lval_addr
90 %type <integer> expr_value
91 %type <string> pathname identifier
93 %type <listing> list_arg
97 input: line
98 | input line
101 line: command { DEBUG_FreeExprMem(); }
102 | tEOL
103 | tEOF { return 1; }
104 | error tEOL { yyerrok; DEBUG_FreeExprMem(); }
107 command:
108 tQUIT tEOL { /*DEBUG_Quit();*/ return 1; }
109 | tHELP tEOL { DEBUG_Help(); }
110 | tHELP tINFO tEOL { DEBUG_HelpInfo(); }
111 | tPASS tEOL { DEBUG_WaitNextException(DBG_EXCEPTION_NOT_HANDLED, 0, 0); }
112 | tCONT tEOL { DEBUG_WaitNextException(DBG_CONTINUE, 1, EXEC_CONT); }
113 | tCONT tNUM tEOL { DEBUG_WaitNextException(DBG_CONTINUE, $2, EXEC_CONT); }
114 | tSTEP tEOL { DEBUG_WaitNextException(DBG_CONTINUE, 1, EXEC_STEP_INSTR); }
115 | tSTEP tNUM tEOL { DEBUG_WaitNextException(DBG_CONTINUE, $2, EXEC_STEP_INSTR); }
116 | tNEXT tEOL { DEBUG_WaitNextException(DBG_CONTINUE, 1, EXEC_STEP_OVER); }
117 | tNEXT tNUM tEOL { DEBUG_WaitNextException(DBG_CONTINUE, $2, EXEC_STEP_OVER); }
118 | tSTEPI tEOL { DEBUG_WaitNextException(DBG_CONTINUE, 1, EXEC_STEPI_INSTR); }
119 | tSTEPI tNUM tEOL { DEBUG_WaitNextException(DBG_CONTINUE, $2, EXEC_STEPI_INSTR); }
120 | tNEXTI tEOL { DEBUG_WaitNextException(DBG_CONTINUE, 1, EXEC_STEPI_OVER); }
121 | tNEXTI tNUM tEOL { DEBUG_WaitNextException(DBG_CONTINUE, $2, EXEC_STEPI_OVER); }
122 | tFINISH tEOL { DEBUG_WaitNextException(DBG_CONTINUE, 0, EXEC_FINISH); }
123 | tABORT tEOL { abort(); }
124 | tMODE tNUM tEOL { mode_command($2); }
125 | tMODE tVM86 tEOL { DEBUG_CurrThread->dbg_mode = MODE_VM86; }
126 | tBACKTRACE tEOL { DEBUG_BackTrace(DEBUG_CurrTid, TRUE); }
127 | tBACKTRACE tNUM tEOL { DEBUG_BackTrace($2, TRUE); }
128 | tUP tEOL { DEBUG_SetFrame( curr_frame + 1 ); }
129 | tUP tNUM tEOL { DEBUG_SetFrame( curr_frame + $2 ); }
130 | tDOWN tEOL { DEBUG_SetFrame( curr_frame - 1 ); }
131 | tDOWN tNUM tEOL { DEBUG_SetFrame( curr_frame - $2 ); }
132 | tFRAME tNUM tEOL { DEBUG_SetFrame( $2 ); }
133 | tSHOW tDIR tEOL { DEBUG_ShowDir(); }
134 | tDIR pathname tEOL { DEBUG_AddPath( $2 ); }
135 | tDIR tEOL { DEBUG_NukePath(); }
136 | tCOND tNUM tEOL { DEBUG_AddBPCondition($2, NULL); }
137 | tCOND tNUM expr tEOL { DEBUG_AddBPCondition($2, $3); }
138 | tSOURCE pathname tEOL { DEBUG_Parser($2); }
139 | tSYMBOLFILE pathname tEOL { DEBUG_ReadSymbolTable($2, 0); }
140 | tSYMBOLFILE pathname expr_value tEOL { DEBUG_ReadSymbolTable($2, $3); }
141 | tWHATIS expr_addr tEOL { DEBUG_PrintType(&$2); }
142 | tATTACH tNUM tEOL { DEBUG_Attach($2, FALSE, TRUE); }
143 | tDETACH tEOL { return DEBUG_Detach(); /* FIXME: we shouldn't return, but since we cannot simply clean the symbol table, exit debugger for now */ }
144 | list_command
145 | disassemble_command
146 | set_command
147 | x_command
148 | print_command
149 | break_commands
150 | display_commands
151 | watch_command
152 | info_command
153 | walk_command
154 | run_command
155 | maintenance_command
156 | noprocess_state
159 display_commands:
160 | tDISPLAY tEOL { DEBUG_InfoDisplay(); }
161 | tDISPLAY expr tEOL { DEBUG_AddDisplay($2, 1, 0, FALSE); }
162 | tDISPLAY tFORMAT expr tEOL{ DEBUG_AddDisplay($3, $2 >> 8, $2 & 0xff, FALSE); }
163 | tLOCAL tDISPLAY expr tEOL { DEBUG_AddDisplay($3, 1, 0, TRUE); }
164 | tLOCAL tDISPLAY tFORMAT expr tEOL { DEBUG_AddDisplay($4, $3 >> 8, $3 & 0xff, TRUE); }
165 | tENABLE tDISPLAY tNUM tEOL{ DEBUG_EnableDisplay( $3, TRUE ); }
166 | tDISABLE tDISPLAY tNUM tEOL { DEBUG_EnableDisplay( $3, FALSE ); }
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 ); }
173 set_command:
174 tSET lval_addr '=' expr_value tEOL { DEBUG_WriteMemory(&$2, $4); }
175 | tSET '+' tIDENTIFIER tEOL { DEBUG_DbgChannel(TRUE, NULL, $3); }
176 | tSET '-' tIDENTIFIER tEOL { DEBUG_DbgChannel(FALSE, NULL, $3); }
177 | tSET tIDENTIFIER '+' tIDENTIFIER tEOL { DEBUG_DbgChannel(TRUE, $2, $4); }
178 | tSET tIDENTIFIER '-' tIDENTIFIER tEOL { DEBUG_DbgChannel(FALSE, $2, $4); }
181 pathname:
182 tIDENTIFIER { $$ = $1; }
183 | tPATH { $$ = $1; }
186 disassemble_command:
187 tDISASSEMBLE tEOL { DEBUG_Disassemble( NULL, NULL, 10 ); }
188 | tDISASSEMBLE expr_addr tEOL { DEBUG_Disassemble( & $2, NULL, 10 ); }
189 | tDISASSEMBLE expr_addr ',' expr_addr tEOL { DEBUG_Disassemble( & $2, & $4, 0 ); }
192 list_command:
193 tLIST tEOL { DEBUG_List( NULL, NULL, 10 ); }
194 | tLIST '-' tEOL { DEBUG_List( NULL, NULL, -10 ); }
195 | tLIST list_arg tEOL { DEBUG_List( & $2, NULL, 10 ); }
196 | tLIST ',' list_arg tEOL { DEBUG_List( NULL, & $3, -10 ); }
197 | tLIST list_arg ',' list_arg tEOL { DEBUG_List( & $2, & $4, 0 ); }
200 list_arg:
201 tNUM { $$.sourcefile = NULL; $$.line = $1; }
202 | pathname ':' tNUM { $$.sourcefile = $1; $$.line = $3; }
203 | tIDENTIFIER { DEBUG_GetFuncInfo( & $$, NULL, $1); }
204 | pathname ':' tIDENTIFIER { DEBUG_GetFuncInfo( & $$, $1, $3); }
205 | '*' expr_addr { DEBUG_FindNearestSymbol( & $2.addr, FALSE, NULL, 0, & $$ ); }
208 x_command:
209 tEXAM expr_addr tEOL { DEBUG_ExamineMemory( &$2, 1, 'x'); }
210 | tEXAM tFORMAT expr_addr tEOL { DEBUG_ExamineMemory( &$3, $2>>8, $2&0xff ); }
213 print_command:
214 tPRINT expr_addr tEOL { DEBUG_Print( &$2, 1, 0, 0 ); }
215 | tPRINT tFORMAT expr_addr tEOL { DEBUG_Print( &$3, $2 >> 8, $2 & 0xff, 0 ); }
218 break_commands:
219 tBREAK '*' expr_addr tEOL{ DEBUG_AddBreakpointFromValue( &$3 ); }
220 | tBREAK identifier tEOL { DEBUG_AddBreakpointFromId($2, -1); }
221 | tBREAK identifier ':' tNUM tEOL { DEBUG_AddBreakpointFromId($2, $4); }
222 | tBREAK tNUM tEOL { DEBUG_AddBreakpointFromLineno($2); }
223 | tBREAK tEOL { DEBUG_AddBreakpointFromLineno(-1); }
224 | tENABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, TRUE ); }
225 | tENABLE tBREAK tNUM tEOL { DEBUG_EnableBreakpoint( $3, TRUE ); }
226 | tDISABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, FALSE ); }
227 | tDISABLE tBREAK tNUM tEOL { DEBUG_EnableBreakpoint( $3, FALSE ); }
228 | tDELETE tNUM tEOL { DEBUG_DelBreakpoint( $2 ); }
229 | tDELETE tBREAK tNUM tEOL { DEBUG_DelBreakpoint( $3 ); }
232 watch_command:
233 tWATCH '*' expr_addr tEOL { DEBUG_AddWatchpoint( &$3, 1 ); }
234 | tWATCH identifier tEOL { DEBUG_AddWatchpointFromId($2); }
237 info_command:
238 tINFO tBREAK tEOL { DEBUG_InfoBreakpoints(); }
239 | tINFO tCLASS tSTRING tEOL { DEBUG_InfoClass( $3 ); }
240 | tINFO tSHARE tEOL { DEBUG_InfoShare(); }
241 | tINFO tMODULE expr_value tEOL { DEBUG_DumpModule( $3 ); }
242 | tINFO tREGS tEOL { DEBUG_InfoRegisters(&DEBUG_context); }
243 | tINFO tSEGMENTS expr_value tEOL { DEBUG_InfoSegments( $3, 1 ); }
244 | tINFO tSEGMENTS tEOL { DEBUG_InfoSegments( 0, -1 ); }
245 | tINFO tSTACK tEOL { DEBUG_InfoStack(); }
246 | tINFO tSYMBOL tSTRING tEOL{ DEBUG_InfoSymbols($3); }
247 | tINFO tWND expr_value tEOL{ DEBUG_InfoWindow( (HWND)$3 ); }
248 | tINFO tLOCAL tEOL { DEBUG_InfoLocals(); }
249 | tINFO tDISPLAY tEOL { DEBUG_InfoDisplay(); }
252 walk_command:
253 tWALK tCLASS tEOL { DEBUG_WalkClasses(); }
254 | tWALK tMODULE tEOL { DEBUG_WalkModules(); }
255 | tWALK tWND tEOL { DEBUG_WalkWindows( 0, 0 ); }
256 | tWALK tWND expr_value tEOL{ DEBUG_WalkWindows( (HWND)$3, 0 ); }
257 | tWALK tMAPS tEOL { DEBUG_InfoVirtual(0); }
258 | tWALK tMAPS expr_value tEOL { DEBUG_InfoVirtual($3); }
259 | tWALK tPROCESS tEOL { DEBUG_WalkProcess(); }
260 | tWALK tTHREAD tEOL { DEBUG_WalkThreads(); }
261 | tWALK tEXCEPTION tEOL { DEBUG_WalkExceptions(DEBUG_CurrTid); }
262 | tWALK tEXCEPTION expr_value tEOL{ DEBUG_WalkExceptions($3); }
265 run_command:
266 tRUN tEOL { DEBUG_Run(NULL); }
267 | tRUN tSTRING tEOL { DEBUG_Run($2); }
270 maintenance_command:
271 tMAINTENANCE tTYPE { DEBUG_DumpTypes(); }
274 noprocess_state:
275 tNOPROCESS tEOL {} /* <CR> shall not barf anything */
276 | tNOPROCESS tSTRING tEOL { DEBUG_Printf("No process loaded, cannot execute '%s'\n", $2); }
279 type_expr:
280 type_expr '*' { $$ = $1 ? DEBUG_FindOrMakePointerType($1) : NULL; }
281 | tINT { $$ = DEBUG_GetBasicType(DT_BASIC_INT); }
282 | tCHAR { $$ = DEBUG_GetBasicType(DT_BASIC_CHAR); }
283 | tLONG tINT { $$ = DEBUG_GetBasicType(DT_BASIC_LONGINT); }
284 | tUNSIGNED tINT { $$ = DEBUG_GetBasicType(DT_BASIC_UINT); }
285 | tLONG tUNSIGNED tINT { $$ = DEBUG_GetBasicType(DT_BASIC_ULONGINT); }
286 | tLONG tLONG tINT { $$ = DEBUG_GetBasicType(DT_BASIC_LONGLONGINT); }
287 | tLONG tLONG tUNSIGNED tINT{ $$ = DEBUG_GetBasicType(DT_BASIC_ULONGLONGINT); }
288 | tSHORT tINT { $$ = DEBUG_GetBasicType(DT_BASIC_SHORTINT); }
289 | tSHORT tUNSIGNED tINT { $$ = DEBUG_GetBasicType(DT_BASIC_USHORTINT); }
290 | tSIGNED tCHAR { $$ = DEBUG_GetBasicType(DT_BASIC_SCHAR); }
291 | tUNSIGNED tCHAR { $$ = DEBUG_GetBasicType(DT_BASIC_UCHAR); }
292 | tFLOAT { $$ = DEBUG_GetBasicType(DT_BASIC_FLOAT); }
293 | tDOUBLE { $$ = DEBUG_GetBasicType(DT_BASIC_DOUBLE); }
294 | tLONG tDOUBLE { $$ = DEBUG_GetBasicType(DT_BASIC_LONGDOUBLE); }
295 | tSTRUCT tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
296 | tUNION tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
297 | tENUM tIDENTIFIER { $$ = DEBUG_TypeCast(DT_ENUM, $2); }
300 expr_addr: expr { $$ = DEBUG_EvalExpr($1); }
303 expr_value: expr { DBG_VALUE value = DEBUG_EvalExpr($1);
304 /* expr_value is typed as an integer */
305 $$ = DEBUG_ReadMemory(&value); }
309 * The expr rule builds an expression tree. When we are done, we call
310 * EvalExpr to evaluate the value of the expression. The advantage of
311 * the two-step approach is that it is possible to save expressions for
312 * use in 'display' commands, and in conditional watchpoints.
314 expr:
315 tNUM { $$ = DEBUG_ConstExpr($1); }
316 | tSTRING { $$ = DEBUG_StringExpr($1); }
317 | tINTVAR { $$ = DEBUG_IntVarExpr($1); }
318 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
319 | expr OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
320 | expr '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
321 | tIDENTIFIER '(' ')' { $$ = DEBUG_CallExpr($1, 0); }
322 | tIDENTIFIER '(' expr ')' { $$ = DEBUG_CallExpr($1, 1, $3); }
323 | tIDENTIFIER '(' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 2, $3, $5); }
324 | tIDENTIFIER '(' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7); }
325 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 4, $3, $5, $7, $9); }
326 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 5, $3, $5, $7, $9, $11); }
327 | expr '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
328 | expr ':' expr { $$ = DEBUG_BinopExpr(EXP_OP_SEG, $1, $3); }
329 | expr OP_LOR expr { $$ = DEBUG_BinopExpr(EXP_OP_LOR, $1, $3); }
330 | expr OP_LAND expr { $$ = DEBUG_BinopExpr(EXP_OP_LAND, $1, $3); }
331 | expr '|' expr { $$ = DEBUG_BinopExpr(EXP_OP_OR, $1, $3); }
332 | expr '&' expr { $$ = DEBUG_BinopExpr(EXP_OP_AND, $1, $3); }
333 | expr '^' expr { $$ = DEBUG_BinopExpr(EXP_OP_XOR, $1, $3); }
334 | expr OP_EQ expr { $$ = DEBUG_BinopExpr(EXP_OP_EQ, $1, $3); }
335 | expr '>' expr { $$ = DEBUG_BinopExpr(EXP_OP_GT, $1, $3); }
336 | expr '<' expr { $$ = DEBUG_BinopExpr(EXP_OP_LT, $1, $3); }
337 | expr OP_GE expr { $$ = DEBUG_BinopExpr(EXP_OP_GE, $1, $3); }
338 | expr OP_LE expr { $$ = DEBUG_BinopExpr(EXP_OP_LE, $1, $3); }
339 | expr OP_NE expr { $$ = DEBUG_BinopExpr(EXP_OP_NE, $1, $3); }
340 | expr OP_SHL expr { $$ = DEBUG_BinopExpr(EXP_OP_SHL, $1, $3); }
341 | expr OP_SHR expr { $$ = DEBUG_BinopExpr(EXP_OP_SHR, $1, $3); }
342 | expr '+' expr { $$ = DEBUG_BinopExpr(EXP_OP_ADD, $1, $3); }
343 | expr '-' expr { $$ = DEBUG_BinopExpr(EXP_OP_SUB, $1, $3); }
344 | expr '*' expr { $$ = DEBUG_BinopExpr(EXP_OP_MUL, $1, $3); }
345 | expr '/' expr { $$ = DEBUG_BinopExpr(EXP_OP_DIV, $1, $3); }
346 | expr '%' expr { $$ = DEBUG_BinopExpr(EXP_OP_REM, $1, $3); }
347 | '-' expr %prec OP_SIGN { $$ = DEBUG_UnopExpr(EXP_OP_NEG, $2); }
348 | '+' expr %prec OP_SIGN { $$ = $2; }
349 | '!' expr { $$ = DEBUG_UnopExpr(EXP_OP_NOT, $2); }
350 | '~' expr { $$ = DEBUG_UnopExpr(EXP_OP_LNOT, $2); }
351 | '(' expr ')' { $$ = $2; }
352 | '*' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_DEREF, $2); }
353 | '&' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_ADDR, $2); }
354 | '(' type_expr ')' expr %prec OP_DEREF { $$ = DEBUG_TypeCastExpr($2, $4); }
358 * The lvalue rule builds an expression tree. This is a limited form
359 * of expression that is suitable to be used as an lvalue.
361 lval_addr: lval { $$ = DEBUG_EvalExpr($1); }
364 lval: lvalue { $$ = $1; }
365 | '*' expr { $$ = DEBUG_UnopExpr(EXP_OP_FORCE_DEREF, $2); }
368 lvalue: tNUM { $$ = DEBUG_ConstExpr($1); }
369 | tINTVAR { $$ = DEBUG_IntVarExpr($1); }
370 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
371 | lvalue OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
372 | lvalue '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
373 | lvalue '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
376 identifier: tIDENTIFIER { $$ = $1; }
377 | identifier '.' tIDENTIFIER { char* ptr = DBG_alloc(strlen($1) + 1 + strlen($3)+ 1);
378 sprintf(ptr, "%s.%s", $1, $3); $$ = DEBUG_MakeSymbol(ptr);
379 DBG_free(ptr); }
380 | identifier ':' ':' tIDENTIFIER { char* ptr = DBG_alloc(strlen($1) + 2 + strlen($4) + 1);
381 sprintf(ptr, "%s::%s", $1, $4); $$ = DEBUG_MakeSymbol(ptr);
382 DBG_free(ptr); }
387 static void mode_command(int newmode)
389 switch(newmode)
391 case 16: DEBUG_CurrThread->dbg_mode = MODE_16; break;
392 case 32: DEBUG_CurrThread->dbg_mode = MODE_32; break;
393 default: DEBUG_Printf("Invalid mode (use 16, 32 or vm86)\n");
397 void DEBUG_Exit(DWORD ec)
399 ExitProcess(ec);
402 static WINE_EXCEPTION_FILTER(wine_dbg_cmd)
404 if (DBG_IVAR(ExtDbgOnInternalException))
405 DEBUG_ExternalDebugger();
406 DEBUG_Printf("\nwine_dbg_cmd: ");
407 switch (GetExceptionCode()) {
408 case DEBUG_STATUS_INTERNAL_ERROR:
409 DEBUG_Printf("WineDbg internal error\n");
410 if (DBG_IVAR(ExtDbgOnInternalException))
411 DEBUG_ExternalDebugger();
412 break;
413 case DEBUG_STATUS_NO_SYMBOL:
414 DEBUG_Printf("Undefined symbol\n");
415 break;
416 case DEBUG_STATUS_DIV_BY_ZERO:
417 DEBUG_Printf("Division by zero\n");
418 break;
419 case DEBUG_STATUS_BAD_TYPE:
420 DEBUG_Printf("No type or type mismatch\n");
421 break;
422 case DEBUG_STATUS_NO_FIELD:
423 DEBUG_Printf("No such field in structure or union\n");
424 break;
425 case DEBUG_STATUS_ABORT:
426 break;
427 case CONTROL_C_EXIT:
428 /* this is generally sent by a ctrl-c when we run winedbg outside of wineconsole */
429 DEBUG_Printf("Ctrl-C\n");
430 /* stop the debuggee, and continue debugger execution, we will be reintered by the
431 * debug events generated by stopping
433 DEBUG_InterruptDebuggee();
434 return EXCEPTION_CONTINUE_EXECUTION;
435 default:
436 DEBUG_Printf("Exception %lx\n", GetExceptionCode());
437 DEBUG_ExternalDebugger();
438 break;
441 return EXCEPTION_EXECUTE_HANDLER;
444 static void set_default_channels(void)
446 DEBUG_hParserOutput = GetStdHandle(STD_OUTPUT_HANDLE);
447 DEBUG_hParserInput = GetStdHandle(STD_INPUT_HANDLE);
450 /***********************************************************************
451 * DEBUG_Parser
453 * Debugger command line parser
455 void DEBUG_Parser(LPCSTR filename)
457 BOOL ret_ok;
458 #ifdef YYDEBUG
459 yydebug = 0;
460 #endif
462 ret_ok = FALSE;
464 if (filename)
466 DEBUG_hParserOutput = 0;
467 DEBUG_hParserInput = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0L, 0);
468 if (DEBUG_hParserInput == INVALID_HANDLE_VALUE)
470 set_default_channels();
471 return;
474 else
475 set_default_channels();
479 __TRY
481 ret_ok = TRUE;
482 yyparse();
484 __EXCEPT(wine_dbg_cmd)
486 ret_ok = FALSE;
488 __ENDTRY;
489 DEBUG_FlushSymbols();
490 } while (!ret_ok);
492 if (filename)
493 CloseHandle(DEBUG_hParserInput);
494 set_default_channels();
497 int yyerror(const char* s)
499 DEBUG_Printf("%s\n", s);
500 return 0;