Release 940201
[wine/gsoc-2012-control.git] / debugger / dbg.y
bloba6279626248c3d9ff8f9d18d43b59744f734ef1a
2 %{
4 /* Parser for command lines in the Wine debugger
6 * Version 1.0
7 * Eric Youngdale
8 * 9/93
9 */
11 #include <stdio.h>
12 #define YYSTYPE int
14 #include "regpos.h"
15 extern FILE * yyin;
16 unsigned int * regval = NULL;
17 unsigned int dbg_mask = 0;
18 unsigned int dbg_mode = 0;
20 void issue_prompt();
24 %token CONT
25 %token QUIT
26 %token HELP
27 %token INFO
28 %token STACK
29 %token REG
30 %token REGS
31 %token NUM
32 %token SET
33 %token PRINT
34 %token IDENTIFIER
35 %token NO_SYMBOL
36 %token SYMBOLFILE
37 %token DEFINE
41 input: /* empty */
42 | input line { issue_prompt(); }
44 line: '\n'
45 | infocmd '\n'
46 | error '\n' {yyerrok; }
47 | QUIT '\n' { exit(0); };
48 | HELP '\n' { dbg_help(); };
49 | CONT '\n' { return; };
50 | SYMBOLFILE IDENTIFIER '\n' { read_symboltable($2); };
51 | DEFINE IDENTIFIER expr '\n' { add_hash($2, $3); };
52 | x_command
53 | print_command
54 | deposit_command
56 deposit_command:
57 SET REG '=' expr '\n' { regval[$2] = $4; }
58 | SET '*' expr '=' expr '\n' { *((unsigned int *) $3) = $5; }
59 | SET symbol '=' expr '\n' { *((unsigned int *) $2) = $4; }
62 x_command:
63 'x' expr '\n' { examine_memory($2, 1, 'x'); };
64 | 'x' '/' fmt expr '\n' { examine_memory($4, 1, $3); };
65 | 'x' '/' NUM fmt expr '\n' { examine_memory($5, $3, $4); };
67 print_command:
68 PRINT expr '\n' { examine_memory(((unsigned int) &$2 ), 1, 'x'); };
70 fmt: 'x' { $$ = 'x'; }
71 | 'd' { $$ = 'd'; }
72 | 'i' { $$ = 'i'; }
73 | 'w' { $$ = 'w'; }
74 | 's' { $$ = 's'; }
75 | 'c' { $$ = 'c'; }
76 | 'b' { $$ = 'b'; }
78 symbol: IDENTIFIER { $$ = find_hash($1);
79 if($$ == 0xffffffff) {
80 fprintf(stderr,"Symbol %s not found\n", $1);
81 YYERROR;
83 };
85 expr: NUM { $$ = $1; }
86 | REG { $$ = regval[$1]; }
87 | symbol { $$ = *((unsigned int *) $1); }
88 | expr '+' NUM { $$ = $1 + $3; }
89 | expr '-' NUM { $$ = $1 - $3; };
90 | '(' expr ')' { $$ = $2; };
91 | '*' expr { $$ = *((unsigned int *) $2); };
93 infocmd: INFO REGS { info_reg(); }
94 | INFO STACK { info_stack(); };
99 void
100 issue_prompt(){
101 #ifndef USE_READLINE
102 fprintf(stderr,"Wine-dbg>");
103 #endif
106 static int loaded_symbols = 0;
108 void
109 wine_debug(int * regs)
111 int i;
112 #ifdef YYDEBUG
113 yydebug = 0;
114 #endif
115 yyin = stdin;
116 regval = regs;
118 #ifdef linux
119 if((SC_CS & 7) != 7) {
120 dbg_mask = 0xffffffff;
121 dbg_mode = 32;
122 } else {
123 dbg_mask = 0xffff;
124 dbg_mode = 16;
126 #endif
127 #ifdef __NetBSD__
128 if(SC_CS == 0x1f) {
129 dbg_mask = 0xffffffff;
130 dbg_mode = 32;
131 } else {
132 dbg_mask = 0xffff;
133 dbg_mode = 16;
135 #endif
137 /* This is intended to read the entry points from the Windows image, and
138 insert them in the hash table. It does not work yet, so it is commented out. */
139 #if 0
140 if(!loaded_symbols){
141 loaded_symbols++;
142 load_entrypoints();
144 #endif
146 /* Show where we crashed */
147 examine_memory(SC_EIP(dbg_mask), 1, 'i');
149 issue_prompt();
151 yyparse();
152 flush_symbols();
153 fprintf(stderr,"Returning to Wine...\n");
158 yyerror(char * s){
159 fprintf(stderr,"%s\n", s);