4 * Parser for command lines in the Wine debugger
6 * Copyright 1993 Eric Youngdale
16 unsigned int dbg_mode
= 0;
18 static enum exec_mode dbg_exec_mode
= EXEC_CONT
;
20 void issue_prompt
(void);
21 void mode_command
(int);
22 void flush_symbols
(void);
36 %token CONT STEP NEXT QUIT HELP BACKTRACE INFO STACK SEGMENTS REGS
37 %token ENABLE DISABLE BREAK DELETE SET MODE PRINT EXAM DEFINE ABORT
41 %token
<string> IDENTIFIER
42 %token
<integer
> NUM FORMAT
46 %type
<address
> addr symbol
51 | input line
{ issue_prompt
(); }
55 |
error '\n' { yyerrok; }
56 | QUIT
'\n' { exit
(0); }
57 | HELP
'\n' { DEBUG_Help
(); }
58 | CONT
'\n' { dbg_exec_mode
= EXEC_CONT
; return
0; }
59 | STEP
'\n' { dbg_exec_mode
= EXEC_STEP_INSTR
; return
0; }
60 | NEXT
'\n' { dbg_exec_mode
= EXEC_STEP_OVER
; return
0; }
61 | ABORT
'\n' { kill
(getpid
(), SIGABRT
); }
62 | SYMBOLFILE IDENTIFIER
'\n' { DEBUG_ReadSymbolTable
( $2 ); }
63 | DEFINE IDENTIFIER addr
'\n' { DEBUG_AddSymbol
( $2, &$3 ); }
64 | MODE NUM
'\n' { mode_command
($2); }
65 | ENABLE NUM
'\n' { DEBUG_EnableBreakpoint
( $2, TRUE
); }
66 | DISABLE NUM
'\n' { DEBUG_EnableBreakpoint
( $2, FALSE
); }
67 | BREAK
'*' addr
'\n' { DEBUG_AddBreakpoint
( &$3 ); }
68 | BREAK
'\n' { DBG_ADDR addr
= { CS_reg
(DEBUG_context
),
69 EIP_reg
(DEBUG_context
) };
70 DEBUG_AddBreakpoint
( &addr
);
72 | DELETE BREAK NUM
'\n' { DEBUG_DelBreakpoint
( $3 ); }
73 | BACKTRACE
'\n' { DEBUG_BackTrace
(); }
79 SET REG
'=' expr
'\n' { DEBUG_SetRegister
( $2, $4 ); }
80 | SET
'*' addr
'=' expr
'\n' { DEBUG_WriteMemory
( &$3, $5 ); }
81 | SET IDENTIFIER
'=' addr
'\n' { if
(!DEBUG_SetSymbolValue
( $2, &$4 ))
83 fprintf
( stderr
, "Symbol %s not found\n", $2 );
90 EXAM addr
'\n' { DEBUG_ExamineMemory
( &$2, 1, 'x'); }
91 | EXAM FORMAT addr
'\n' { DEBUG_ExamineMemory
( &$3, $2>>8, $2&0xff ); }
94 PRINT addr
'\n' { DEBUG_Print
( &$2, 1, 'x' ); }
95 | PRINT FORMAT addr
'\n' { DEBUG_Print
( &$3, $2 >> 8, $2 & 0xff ); }
97 symbol
: IDENTIFIER
{ if
(!DEBUG_GetSymbolValue
( $1, &$$
))
99 fprintf
( stderr
, "Symbol %s not found\n", $1 );
104 addr
: expr
{ $$.seg
= 0xffffffff; $$.off
= $1; }
105 | expr
':' expr
{ $$.seg
= $1; $$.off
= $3; }
106 | symbol
{ $$
= $1; }
108 expr
: NUM
{ $$
= $1; }
109 | REG
{ $$
= DEBUG_GetRegister
($1); }
110 | expr
'+' NUM
{ $$
= $1 + $3; }
111 | expr
'-' NUM
{ $$
= $1 - $3; }
112 |
'(' expr
')' { $$
= $2; }
113 |
'*' addr
{ $$
= DEBUG_ReadMemory
( &$2 ); }
115 infocmd
: INFO REGS
{ DEBUG_InfoRegisters
(); }
116 | INFO STACK
{ DEBUG_InfoStack
(); }
117 | INFO BREAK
{ DEBUG_InfoBreakpoints
(); }
118 | INFO SEGMENTS
{ LDT_Print
(); }
126 fprintf
(stderr
,"Wine-dbg>");
130 void mode_command
(int newmode
)
132 if
((newmode
== 16) ||
(newmode
== 32)) dbg_mode
= newmode
;
133 else fprintf
(stderr
,"Invalid mode (use 16 or 32)\n");
137 void wine_debug
( int signal
, struct sigcontext_struct
*regs
)
139 static int loaded_symbols
= 0;
140 char SymbolTableFile
[256];
141 int instr_len
= 0, newmode
;
147 DEBUG_context
= (struct sigcontext_struct
*)regs
;
149 DEBUG_SetBreakpoints
( FALSE
);
154 GetPrivateProfileString
("wine", "SymbolTableFile", "wine.sym",
155 SymbolTableFile
, sizeof
(SymbolTableFile
), WINE_INI
);
156 DEBUG_ReadSymbolTable
( SymbolTableFile
);
157 DEBUG_LoadEntryPoints
();
160 if
((signal
!= SIGTRAP
) ||
!DEBUG_ShouldContinue
( regs
, dbg_exec_mode
))
164 addr.seg
= (CS_reg
(DEBUG_context
) == WINE_CODE_SELECTOR
) ?
165 0 : CS_reg
(DEBUG_context
);
166 addr.off
= EIP_reg
(DEBUG_context
);
168 if
(!addr.seg
) newmode
= 32;
169 else newmode
= (GET_SEL_FLAGS
(addr.seg
) & LDT_FLAGS_32BIT
) ?
32 : 16;
171 if
(newmode
!= dbg_mode
)
172 fprintf
(stderr
,"In %d bit mode.\n", dbg_mode
= newmode
);
174 /* Show where we crashed */
175 DEBUG_PrintAddress
( &addr
, dbg_mode
);
176 fprintf
(stderr
,": ");
177 DEBUG_Disasm
( &addr
);
178 fprintf
(stderr
,"\n");
179 instr_len
= addr.off
- EIP_reg
(DEBUG_context
);
186 DEBUG_RestartExecution
( regs
, dbg_exec_mode
, instr_len
);
190 int yyerror(char * s
)
192 fprintf
(stderr
,"%s\n", s
);