4 /* Parser for command lines in the Wine debugger
21 unsigned int * regval = NULL;
22 unsigned int dbg_mask = 0;
23 unsigned int dbg_mode = 0;
25 void issue_prompt(void);
26 void mode_command(int);
46 %token FILE_IDENTIFIER
56 | input line { issue_prompt(); }
60 | error '\n' { yyerrok; }
61 | QUIT '\n' { exit(0); }
62 | 'q' '\n' { exit(0); }
63 | HELP '\n' { dbg_help(); }
64 | CONT '\n' { return 0; }
65 | 'c' '\n' { return 0; }
66 | ABORT '\n' { kill(getpid(), SIGABRT); }
67 | SYMBOLFILE FILE_IDENTIFIER '\n' { read_symboltable($2); }
68 | DEFINE IDENTIFIER expr '\n' { add_hash($2, 0, $3); }
69 | MODE NUM { mode_command($2); }
70 | ENABLE NUM { enable_break($2); }
71 | DISABLE NUM { disable_break($2); }
72 | BREAK '*' expr { add_break($3); }
74 | BACKTRACE '\n' { dbg_bt(); }
79 SET REG '=' expr '\n' { if(regval) regval[$2] = $4; else application_not_running();}
80 | SET '*' expr '=' expr '\n' { *((unsigned int *) $3) = $5; }
81 | SET symbol '=' expr '\n' { *((unsigned int *) $2) = $4; }
85 'x' expr '\n' { examine_memory($2, 1, 'x'); }
86 | 'x' '/' fmt expr '\n' { examine_memory($4, 1, $3); }
87 | 'x' '/' NUM fmt expr '\n' { examine_memory($5, $3, $4); }
94 print expr '\n' { examine_memory(((unsigned int) &$2 ), 1, 'x'); }
95 | print '/' fmt expr '\n' { examine_memory((unsigned int) &$4, 1, $3); }
96 | print '/' NUM fmt expr '\n' { examine_memory((unsigned int) &$5, $3, $4); }
98 fmt: 'x' { $$ = 'x'; }
106 symbol: IDENTIFIER { $$ = find_hash($1);
107 if($$ == 0xffffffff) {
108 fprintf(stderr,"Symbol %s not found\n", $1);
113 expr: NUM { $$ = $1; }
114 | REG { if(regval) $$ = regval[$1]; else application_not_running();}
115 | symbol { $$ = $1; }
116 | expr '+' NUM { $$ = $1 + $3; }
117 | expr '-' NUM { $$ = $1 - $3; }
118 | '(' expr ')' { $$ = $2; }
119 | '*' expr { $$ = *((unsigned int *) $2); }
121 infocmd: INFO REGS { info_reg(); }
122 | INFO STACK { info_stack(); }
123 | INFO SEGMENTS { LDT_Print(); }
124 | INFO BREAK { info_break(); }
132 fprintf(stderr,"Wine-dbg>");
136 void mode_command(int newmode)
144 dbg_mask = 0xffffffff;
148 fprintf(stderr,"Invalid mode (use 16 or 32)\n");
151 static int loaded_symbols = 0;
154 wine_debug(int signal, int * regs)
156 static int dummy_regs[32];
157 char SymbolTableFile[256];
163 regval = regs ? regs : dummy_regs;
165 if (SC_CS == WINE_CODE_SELECTOR)
167 dbg_mask = 0xffffffff;
174 fprintf(stderr,"In %d bit mode.\n", dbg_mode);
176 if(dbg_mode == 32 && !loaded_symbols)
179 GetPrivateProfileString("wine", "SymbolTableFile", "wine.sym",
180 SymbolTableFile, sizeof(SymbolTableFile), WINE_INI);
181 read_symboltable(SymbolTableFile);
184 /* Remove the breakpoints from memory... */
187 /* If we stopped on a breakpoint, report this fact */
188 if(signal == SIGTRAP)
192 addr = SC_EIP(dbg_mask);
193 if((addr & 0xffff0000) == 0 && dbg_mode == 16)
194 addr = PTR_SEG_OFF_TO_LIN( SC_CS, addr );
195 if(should_continue(bpnum=get_bpnum(addr))){
199 fprintf(stderr,"Stopped on breakpoint %d\n", bpnum);
202 /* Show where we crashed */
204 examine_memory(SC_EIP(dbg_mask), 1, 'i');
211 /* Re-insert the breakpoints from memory... */
214 fprintf(stderr,"Returning to Wine...\n");
219 int yyerror(char * s)
221 fprintf(stderr,"%s\n", s);