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
25 #include "wine/port.h"
33 #include "wine/exception.h"
38 int yyerror(const char*);
44 struct dbg_lvalue lvalue
;
47 IMAGEHLP_LINE listing
;
48 struct expr
* expression
;
49 struct type_expr_t type
;
52 %token tCONT tPASS tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tALL tINFO tUP tDOWN
53 %token tENABLE tDISABLE tBREAK tWATCH tDELETE tSET tMODE tPRINT tEXAM tABORT tVM86
54 %token tCLASS tMAPS tSTACK tSEGMENTS tSYMBOL tREGS tWND tQUEUE tLOCAL tEXCEPTION
55 %token tPROCESS tTHREAD tMODREF tEOL tEOF
56 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
57 %token tSTEPI tNEXTI tFINISH tSHOW tDIR tWHATIS tSOURCE
58 %token
<string> tPATH tIDENTIFIER tSTRING tDEBUGSTR tINTVAR
59 %token
<integer
> tNUM tFORMAT
60 %token tSYMBOLFILE tRUN tATTACH tDETACH tMAINTENANCE tTYPE tMINIDUMP
63 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
64 %token tSTRUCT tUNION tENUM
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 */ /* ... ? ... : ... */
77 %left
'<' '>' OP_LE OP_GE
81 %left OP_SIGN
'!' '~' OP_DEREF
/* OP_INC OP_DEC OP_ADDR */
85 %type
<expression
> expr lvalue
86 %type
<lvalue
> expr_lvalue lvalue_addr
87 %type
<integer
> expr_rvalue
88 %type
<string> pathname identifier
89 %type
<listing
> list_arg
90 %type
<type
> type_expr
100 command tEOL
{ expr_free_all
(); }
103 |
error tEOL
{ yyerrok; expr_free_all
(); }
108 | tHELP
{ print_help
(); }
109 | tHELP tINFO
{ info_help
(); }
110 | tPASS
{ dbg_wait_next_exception
(DBG_EXCEPTION_NOT_HANDLED
, 0, 0); }
111 | tCONT
{ dbg_wait_next_exception
(DBG_CONTINUE
, 1, dbg_exec_cont
); }
112 | tCONT tNUM
{ dbg_wait_next_exception
(DBG_CONTINUE
, $2, dbg_exec_cont
); }
113 | tSTEP
{ dbg_wait_next_exception
(DBG_CONTINUE
, 1, dbg_exec_step_into_line
); }
114 | tSTEP tNUM
{ dbg_wait_next_exception
(DBG_CONTINUE
, $2, dbg_exec_step_into_line
); }
115 | tNEXT
{ dbg_wait_next_exception
(DBG_CONTINUE
, 1, dbg_exec_step_over_line
); }
116 | tNEXT tNUM
{ dbg_wait_next_exception
(DBG_CONTINUE
, $2, dbg_exec_step_over_line
); }
117 | tSTEPI
{ dbg_wait_next_exception
(DBG_CONTINUE
, 1, dbg_exec_step_into_insn
); }
118 | tSTEPI tNUM
{ dbg_wait_next_exception
(DBG_CONTINUE
, $2, dbg_exec_step_into_insn
); }
119 | tNEXTI
{ dbg_wait_next_exception
(DBG_CONTINUE
, 1, dbg_exec_step_over_insn
); }
120 | tNEXTI tNUM
{ dbg_wait_next_exception
(DBG_CONTINUE
, $2, dbg_exec_step_over_insn
); }
121 | tFINISH
{ dbg_wait_next_exception
(DBG_CONTINUE
, 0, dbg_exec_finish
); }
122 | tABORT
{ abort
(); }
123 | tBACKTRACE
{ stack_backtrace
(dbg_curr_tid
, TRUE
); }
124 | tBACKTRACE tNUM
{ stack_backtrace
($2, TRUE
); }
125 | tBACKTRACE tALL
{ stack_backtrace
(-1, TRUE
); }
126 | tUP
{ stack_set_frame
(dbg_curr_frame
+ 1); }
127 | tUP tNUM
{ stack_set_frame
(dbg_curr_frame
+ $2); }
128 | tDOWN
{ stack_set_frame
(dbg_curr_frame
- 1); }
129 | tDOWN tNUM
{ stack_set_frame
(dbg_curr_frame
- $2); }
130 | tFRAME tNUM
{ stack_set_frame
($2); }
131 | tSHOW tDIR
{ source_show_path
(); }
132 | tDIR pathname
{ source_add_path
($2); }
133 | tDIR
{ source_nuke_path
(); }
134 | tCOND tNUM
{ break_add_condition
($2, NULL
); }
135 | tCOND tNUM expr
{ break_add_condition
($2, $3); }
136 | tSOURCE pathname
{ parser
($2); }
137 | tSYMBOLFILE pathname
{ symbol_read_symtable
($2, 0); }
138 | tSYMBOLFILE pathname expr_rvalue
{ symbol_read_symtable
($2, $3); }
139 | tWHATIS expr_lvalue
{ types_print_type
(&$2.type
, FALSE
); dbg_printf
("\n"); }
140 | tATTACH tNUM
{ dbg_attach_debuggee
($2, FALSE
, TRUE
); }
141 | tDETACH
{ dbg_detach_debuggee
(); }
142 | tMINIDUMP pathname
{ minidump_write
($2, (dbg_curr_thread
&& dbg_curr_thread
->in_exception
) ?
&dbg_curr_thread
->excpt_record
: NULL
);}
145 | disassemble_command
153 | maintenance_command
158 identifier
{ $$
= $1; }
159 | tSTRING
{ $$
= $1; }
164 tIDENTIFIER
{ $$
= $1; }
165 | tPATH
'!' tIDENTIFIER
{ $$
= lexeme_alloc_size
(strlen
($1) + 1 + strlen
($3) + 1);
166 sprintf
($$
, "%s!%s", $1, $3); }
167 | identifier
':' ':' tIDENTIFIER
{ $$
= lexeme_alloc_size
(strlen
($1) + 2 + strlen
($4) + 1);
168 sprintf
($$
, "%s::%s", $1, $4); }
172 tNUM
{ $$.FileName
= NULL
; $$.LineNumber
= $1; }
173 | pathname
':' tNUM
{ $$.FileName
= $1; $$.LineNumber
= $3; }
174 | identifier
{ symbol_get_line
(NULL
, $1, &$$
); }
175 | pathname
':' identifier
{ symbol_get_line
($3, $1, &$$
); }
176 |
'*' expr_lvalue
{ DWORD disp
; $$.SizeOfStruct
= sizeof
($$
);
177 SymGetLineFromAddr
(dbg_curr_process
->handle
, (unsigned long)memory_to_linear_addr
(& $2.addr
), &disp
, & $$
); }
181 tRUN
{ dbg_run_debuggee
(NULL
); }
182 | tRUN tSTRING
{ dbg_run_debuggee
($2); }
186 tLIST
{ source_list
(NULL
, NULL
, 10); }
187 | tLIST
'-' { source_list
(NULL
, NULL
, -10); }
188 | tLIST list_arg
{ source_list
(& $2, NULL
, 10); }
189 | tLIST
',' list_arg
{ source_list
(NULL
, & $3, -10); }
190 | tLIST list_arg
',' list_arg
{ source_list
(& $2, & $4, 0); }
194 tDISASSEMBLE
{ memory_disassemble
(NULL
, NULL
, 10); }
195 | tDISASSEMBLE expr_lvalue
{ memory_disassemble
(&$2, NULL
, 10); }
196 | tDISASSEMBLE expr_lvalue
',' expr_lvalue
{ memory_disassemble
(&$2, &$4, 0); }
200 tSET lvalue_addr
'=' expr_rvalue
{ memory_write_value
(&$2, sizeof
(int), &$4); }
201 | tSET
'+' tIDENTIFIER
{ info_wine_dbg_channel
(TRUE
, NULL
, $3); }
202 | tSET
'-' tIDENTIFIER
{ info_wine_dbg_channel
(FALSE
, NULL
, $3); }
203 | tSET tIDENTIFIER
'+' tIDENTIFIER
{ info_wine_dbg_channel
(TRUE
, $2, $4); }
204 | tSET tIDENTIFIER
'-' tIDENTIFIER
{ info_wine_dbg_channel
(FALSE
, $2, $4); }
208 tEXAM expr_lvalue
{ memory_examine
(&$2, 1, 'x'); }
209 | tEXAM tFORMAT expr_lvalue
{ memory_examine
(&$3, $2 >> 8, $2 & 0xff); }
213 tPRINT expr_lvalue
{ print_value
(&$2, 0, 0); }
214 | tPRINT tFORMAT expr_lvalue
{ if
(($2 >> 8) == 1) print_value
(&$3, $2 & 0xff, 0); else dbg_printf
("Count is meaningless in print command\n"); }
218 tBREAK
'*' expr_lvalue
{ break_add_break_from_lvalue
(&$3); }
219 | tBREAK identifier
{ break_add_break_from_id
($2, -1); }
220 | tBREAK identifier
':' tNUM
{ break_add_break_from_id
($2, $4); }
221 | tBREAK tNUM
{ break_add_break_from_lineno
($2); }
222 | tBREAK
{ break_add_break_from_lineno
(-1); }
223 | tENABLE tNUM
{ break_enable_xpoint
($2, TRUE
); }
224 | tENABLE tBREAK tNUM
{ break_enable_xpoint
($3, TRUE
); }
225 | tDISABLE tNUM
{ break_enable_xpoint
($2, FALSE
); }
226 | tDISABLE tBREAK tNUM
{ break_enable_xpoint
($3, FALSE
); }
227 | tDELETE tNUM
{ break_delete_xpoint
($2); }
228 | tDELETE tBREAK tNUM
{ break_delete_xpoint
($3); }
232 tWATCH
'*' expr_lvalue
{ break_add_watch_from_lvalue
(&$3); }
233 | tWATCH identifier
{ break_add_watch_from_id
($2); }
237 tDISPLAY
{ display_print
(); }
238 | tDISPLAY expr
{ display_add
($2, 1, 0); }
239 | tDISPLAY tFORMAT expr
{ display_add
($3, $2 >> 8, $2 & 0xff); }
240 | tENABLE tDISPLAY tNUM
{ display_enable
($3, TRUE
); }
241 | tDISABLE tDISPLAY tNUM
{ display_enable
($3, FALSE
); }
242 | tDELETE tDISPLAY tNUM
{ display_delete
($3); }
243 | tDELETE tDISPLAY
{ display_delete
(-1); }
244 | tUNDISPLAY tNUM
{ display_delete
($2); }
245 | tUNDISPLAY
{ display_delete
(-1); }
249 tINFO tBREAK
{ break_info
(); }
250 | tINFO tSHARE
{ info_win32_module
(0); }
251 | tINFO tSHARE expr_rvalue
{ info_win32_module
($3); }
252 | tINFO tREGS
{ be_cpu
->print_context
(dbg_curr_thread
->handle
, &dbg_context
); }
253 | tINFO tSEGMENTS expr_rvalue
{ info_win32_segments
($3 >> 3, 1); }
254 | tINFO tSEGMENTS
{ info_win32_segments
(0, -1); }
255 | tINFO tSTACK
{ stack_info
(); }
256 | tINFO tSYMBOL tSTRING
{ symbol_info
($3); }
257 | tINFO tLOCAL
{ symbol_info_locals
(); }
258 | tINFO tDISPLAY
{ display_info
(); }
259 | tINFO tCLASS
{ info_win32_class
(NULL
, NULL
); }
260 | tINFO tCLASS tSTRING
{ info_win32_class
(NULL
, $3); }
261 | tINFO tWND
{ info_win32_window
(NULL
, FALSE
); }
262 | tINFO tWND expr_rvalue
{ info_win32_window
((HWND
)$3, FALSE
); }
263 | tINFO
'*' tWND
{ info_win32_window
(NULL
, TRUE
); }
264 | tINFO
'*' tWND expr_rvalue
{ info_win32_window
((HWND
)$4, TRUE
); }
265 | tINFO tPROCESS
{ info_win32_processes
(); }
266 | tINFO tTHREAD
{ info_win32_threads
(); }
267 | tINFO tEXCEPTION
{ info_win32_exceptions
(dbg_curr_tid
); }
268 | tINFO tEXCEPTION expr_rvalue
{ info_win32_exceptions
($3); }
269 | tINFO tMAPS
{ info_win32_virtual
(dbg_curr_pid
); }
270 | tINFO tMAPS expr_rvalue
{ info_win32_virtual
($3); }
274 tMAINTENANCE tTYPE
{ print_types
(); }
278 tNOPROCESS
{} /* <CR> shall not barf anything */
279 | tNOPROCESS tBACKTRACE tALL
{ stack_backtrace
(-1, TRUE
); } /* can backtrace all threads with no attached process */
280 | tNOPROCESS tSTRING
{ dbg_printf
("No process loaded, cannot execute '%s'\n", $2); }
284 tCHAR
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_char
; }
285 | tINT
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_signed_int
; }
286 | tLONG tINT
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_signed_long_int
; }
287 | tLONG
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_signed_long_int
; }
288 | tUNSIGNED tINT
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_unsigned_int
; }
289 | tUNSIGNED
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_unsigned_int
; }
290 | tLONG tUNSIGNED tINT
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_unsigned_long_int
; }
291 | tLONG tUNSIGNED
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_unsigned_long_int
; }
292 | tSHORT tINT
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_signed_short_int
; }
293 | tSHORT
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_signed_short_int
; }
294 | tSHORT tUNSIGNED tINT
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_unsigned_short_int
; }
295 | tSHORT tUNSIGNED
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_unsigned_short_int
; }
296 | tSIGNED tCHAR
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_signed_char_int
; }
297 | tUNSIGNED tCHAR
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_unsigned_char_int
; }
298 | tLONG tLONG tUNSIGNED tINT
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_unsigned_longlong_int
; }
299 | tLONG tLONG tUNSIGNED
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_unsigned_longlong_int
; }
300 | tLONG tLONG tINT
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_signed_longlong_int
; }
301 | tLONG tLONG
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_signed_longlong_int
; }
302 | tFLOAT
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_short_real
; }
303 | tDOUBLE
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_real
; }
304 | tLONG tDOUBLE
{ $$.type
= type_expr_type_id
; $$.deref_count
= 0; $$.u.type.module
= 0; $$.u.type.id
= dbg_itype_long_real
; }
305 | type_expr
'*' { $$
= $1; $$.deref_count
++; }
306 | tCLASS identifier
{ $$.type
= type_expr_udt_class
; $$.deref_count
= 0; $$.u.name
= $2; }
307 | tSTRUCT identifier
{ $$.type
= type_expr_udt_struct
; $$.deref_count
= 0; $$.u.name
= $2; }
308 | tUNION identifier
{ $$.type
= type_expr_udt_union
; $$.deref_count
= 0; $$.u.name
= $2; }
309 | tENUM identifier
{ $$.type
= type_expr_enumeration
; $$.deref_count
= 0; $$.u.name
= $2; }
313 expr
{ $$
= expr_eval
($1); }
317 expr_lvalue
{ $$
= types_extract_as_integer
(&$1); }
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.
327 tNUM
{ $$
= expr_alloc_sconstant
($1); }
328 | tSTRING
{ $$
= expr_alloc_string
($1); }
329 | tINTVAR
{ $$
= expr_alloc_internal_var
($1); }
330 | identifier
{ $$
= expr_alloc_symbol
($1); }
331 | expr OP_DRF tIDENTIFIER
{ $$
= expr_alloc_pstruct
($1, $3); }
332 | expr
'.' tIDENTIFIER
{ $$
= expr_alloc_struct
($1, $3); }
333 | identifier
'(' ')' { $$
= expr_alloc_func_call
($1, 0); }
334 | identifier
'(' expr
')' { $$
= expr_alloc_func_call
($1, 1, $3); }
335 | identifier
'(' expr
',' expr
')' { $$
= expr_alloc_func_call
($1, 2, $3, $5); }
336 | identifier
'(' expr
',' expr
',' expr
')' { $$
= expr_alloc_func_call
($1, 3, $3, $5, $7); }
337 | identifier
'(' expr
',' expr
',' expr
',' expr
')' { $$
= expr_alloc_func_call
($1, 4, $3, $5, $7, $9); }
338 | identifier
'(' expr
',' expr
',' expr
',' expr
',' expr
')' { $$
= expr_alloc_func_call
($1, 5, $3, $5, $7, $9, $11); }
339 | expr
'[' expr
']' { $$
= expr_alloc_binary_op
(EXP_OP_ARR
, $1, $3); }
340 | expr
':' expr
{ $$
= expr_alloc_binary_op
(EXP_OP_SEG
, $1, $3); }
341 | expr OP_LOR expr
{ $$
= expr_alloc_binary_op
(EXP_OP_LOR
, $1, $3); }
342 | expr OP_LAND expr
{ $$
= expr_alloc_binary_op
(EXP_OP_LAND
, $1, $3); }
343 | expr
'|' expr
{ $$
= expr_alloc_binary_op
(EXP_OP_OR
, $1, $3); }
344 | expr
'&' expr
{ $$
= expr_alloc_binary_op
(EXP_OP_AND
, $1, $3); }
345 | expr
'^' expr
{ $$
= expr_alloc_binary_op
(EXP_OP_XOR
, $1, $3); }
346 | expr OP_EQ expr
{ $$
= expr_alloc_binary_op
(EXP_OP_EQ
, $1, $3); }
347 | expr
'>' expr
{ $$
= expr_alloc_binary_op
(EXP_OP_GT
, $1, $3); }
348 | expr
'<' expr
{ $$
= expr_alloc_binary_op
(EXP_OP_LT
, $1, $3); }
349 | expr OP_GE expr
{ $$
= expr_alloc_binary_op
(EXP_OP_GE
, $1, $3); }
350 | expr OP_LE expr
{ $$
= expr_alloc_binary_op
(EXP_OP_LE
, $1, $3); }
351 | expr OP_NE expr
{ $$
= expr_alloc_binary_op
(EXP_OP_NE
, $1, $3); }
352 | expr OP_SHL expr
{ $$
= expr_alloc_binary_op
(EXP_OP_SHL
, $1, $3); }
353 | expr OP_SHR expr
{ $$
= expr_alloc_binary_op
(EXP_OP_SHR
, $1, $3); }
354 | expr
'+' expr
{ $$
= expr_alloc_binary_op
(EXP_OP_ADD
, $1, $3); }
355 | expr
'-' expr
{ $$
= expr_alloc_binary_op
(EXP_OP_SUB
, $1, $3); }
356 | expr
'*' expr
{ $$
= expr_alloc_binary_op
(EXP_OP_MUL
, $1, $3); }
357 | expr
'/' expr
{ $$
= expr_alloc_binary_op
(EXP_OP_DIV
, $1, $3); }
358 | expr
'%' expr
{ $$
= expr_alloc_binary_op
(EXP_OP_REM
, $1, $3); }
359 |
'-' expr %prec OP_SIGN
{ $$
= expr_alloc_unary_op
(EXP_OP_NEG
, $2); }
360 |
'+' expr %prec OP_SIGN
{ $$
= $2; }
361 |
'!' expr
{ $$
= expr_alloc_unary_op
(EXP_OP_NOT
, $2); }
362 |
'~' expr
{ $$
= expr_alloc_unary_op
(EXP_OP_LNOT
, $2); }
363 |
'(' expr
')' { $$
= $2; }
364 |
'*' expr %prec OP_DEREF
{ $$
= expr_alloc_unary_op
(EXP_OP_DEREF
, $2); }
365 |
'&' expr %prec OP_DEREF
{ $$
= expr_alloc_unary_op
(EXP_OP_ADDR
, $2); }
366 |
'(' type_expr
')' expr %prec OP_DEREF
{ $$
= expr_alloc_typecast
(&$2, $4); }
370 * The lvalue rule builds an expression tree. This is a limited form
371 * of expression that is suitable to be used as an lvalue.
374 lvalue
{ $$
= expr_eval
($1); }
377 lvalue: tNUM
{ $$
= expr_alloc_sconstant
($1); }
378 | tINTVAR
{ $$
= expr_alloc_internal_var
($1); }
379 | identifier
{ $$
= expr_alloc_symbol
($1); }
380 | lvalue OP_DRF tIDENTIFIER
{ $$
= expr_alloc_pstruct
($1, $3); }
381 | lvalue
'.' tIDENTIFIER
{ $$
= expr_alloc_struct
($1, $3); }
382 | lvalue
'[' expr
']' { $$
= expr_alloc_binary_op
(EXP_OP_ARR
, $1, $3); }
383 |
'*' expr
{ $$
= expr_alloc_unary_op
(EXP_OP_FORCE_DEREF
, $2); }
388 static WINE_EXCEPTION_FILTER
(wine_dbg_cmd
)
390 switch
(GetExceptionCode
())
392 case DEBUG_STATUS_INTERNAL_ERROR
:
393 dbg_printf
("\nWineDbg internal error\n");
395 case DEBUG_STATUS_NO_SYMBOL
:
396 dbg_printf
("\nUndefined symbol\n");
398 case DEBUG_STATUS_DIV_BY_ZERO
:
399 dbg_printf
("\nDivision by zero\n");
401 case DEBUG_STATUS_BAD_TYPE
:
402 dbg_printf
("\nNo type or type mismatch\n");
404 case DEBUG_STATUS_NO_FIELD
:
405 dbg_printf
("\nNo such field in structure or union\n");
407 case DEBUG_STATUS_CANT_DEREF
:
408 dbg_printf
("\nDereference failed (not a pointer, or out of array bounds)\n");
410 case DEBUG_STATUS_ABORT
:
412 case DEBUG_STATUS_NOT_AN_INTEGER
:
413 dbg_printf
("\nNeeding an integral value\n");
416 /* this is generally sent by a ctrl-c when we run winedbg outside of wineconsole */
417 /* stop the debuggee, and continue debugger execution, we will be reentered by the
418 * debug events generated by stopping
420 dbg_interrupt_debuggee
();
421 return EXCEPTION_CONTINUE_EXECUTION
;
423 dbg_printf
("\nException %lx\n", GetExceptionCode
());
427 return EXCEPTION_EXECUTE_HANDLER
;
431 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
434 /* Strip whitespace from the start and end of STRING. */
435 static void stripwhite
(char *string)
439 for
(i
= 0; whitespace
(string[i
]); i
++);
440 if
(i
) strcpy
(string, string + i
);
442 last
= i
= strlen
(string) - 1;
443 if
(string[last
] == '\n') i
--;
445 while
(i
> 0 && whitespace
(string[i
])) i
--;
446 if
(string[last
] == '\n')
451 static HANDLE dbg_parser_input
;
452 static HANDLE dbg_parser_output
;
454 /* command passed in the command line arguments */
455 char *arg_command
= NULL
;
457 int input_fetch_entire_line
(const char* pfx
, char** line
, size_t* alloc
, BOOL check_nl
)
460 DWORD nread
, nwritten
;
464 /* we only run one command before exiting */
465 const char q
[] = "quit\n";
467 arg_command
= HeapAlloc
(GetProcessHeap
(), 0, sizeof q
);
468 lstrcpyA
(arg_command
, q
);
472 /* as of today, console handles can be file handles... so better use file APIs rather than
475 WriteFile
(dbg_parser_output
, pfx
, strlen
(pfx
), &nwritten
, NULL
);
480 if
(!ReadFile
(dbg_parser_input
, buf_line
, sizeof
(buf_line
) - 1, &nread
, NULL
) || nread
== 0)
482 buf_line
[nread
] = '\0';
484 if
(check_nl
&& len
== 0 && nread
== 1 && buf_line
[0] == '\n')
487 /* store stuff at the end of last_line */
488 if
(len
+ nread
+ 1 > *alloc
)
490 while
(len
+ nread
+ 1 > *alloc
) *alloc
*= 2;
491 *line
= dbg_heap_realloc
(*line
, *alloc
);
493 strcpy
(*line
+ len
, buf_line
);
495 } while
(nread
== 0 || buf_line
[nread
- 1] != '\n');
499 *line
= HeapReAlloc
(GetProcessHeap
(), 0, *line
, *alloc
= 1);
503 /* Remove leading and trailing whitespace from the line */
508 int input_read_line
(const char* pfx
, char* buf
, int size
)
513 /* first alloc of our current buffer */
514 line
= HeapAlloc
(GetProcessHeap
(), 0, len
= 2);
519 input_fetch_entire_line
(pfx
, &line
, &len
, FALSE
);
521 /* remove trailing \n */
522 if
(len
> 0 && line
[len
- 1] == '\n') len
--;
523 len
= min
(size
- 1, len
);
524 memcpy
(buf
, line
, len
);
526 HeapFree
(GetProcessHeap
(), 0, line
);
530 /***********************************************************************
533 * Debugger command line parser
535 void parser
(const char* filename
)
538 HANDLE in_copy
= dbg_parser_input
;
539 HANDLE out_copy
= dbg_parser_output
;
549 HANDLE h
= CreateFile
(filename
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0L, 0);
550 if
(h
== INVALID_HANDLE_VALUE
) return
;
551 dbg_parser_output
= 0;
552 dbg_parser_input
= h
;
556 dbg_parser_output
= GetStdHandle
(STD_OUTPUT_HANDLE
);
557 dbg_parser_input
= GetStdHandle
(STD_INPUT_HANDLE
);
567 __EXCEPT
(wine_dbg_cmd
)
575 if
(filename
) CloseHandle
(dbg_parser_input
);
576 dbg_parser_input
= in_copy
;
577 dbg_parser_output
= out_copy
;
580 int yyerror(const char* s
)
582 dbg_printf
("%s\n", s
);