Authors: Chris Morgan <cmorgan@wpi.edu>, James Abbatiello <abbejy@wpi.edu>
[wine/multimedia.git] / debugger / dbg.y
blob5c15c1ef1fc1aeaffc19e67c02c7734535fb3e70
1 %{
2 /*
3 * Parser for command lines in the Wine debugger
5 * Copyright 1993 Eric Youngdale
6 * Copyright 1995 Morten Welinder
7 */
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <signal.h>
13 #include <sys/stat.h>
14 #include <unistd.h>
16 #include "winbase.h"
17 #include "class.h"
18 #include "module.h"
19 #include "task.h"
20 #include "options.h"
21 #include "queue.h"
22 #include "wine/winbase16.h"
23 #include "winnt.h"
24 #include "win.h"
25 #include "debugger.h"
26 #include "neexe.h"
27 #include "process.h"
28 #include "server.h"
29 #include "main.h"
30 #include "expr.h"
31 #include "user.h"
33 extern FILE * yyin;
34 unsigned int dbg_mode = 0;
35 int curr_frame = 0;
37 static enum exec_mode dbg_exec_mode = EXEC_CONT;
38 static int dbg_exec_count = 0;
40 void issue_prompt(void);
41 void mode_command(int);
42 void flush_symbols(void);
43 int yylex(void);
44 int yyerror(char *);
46 extern void VIRTUAL_Dump(void); /* memory/virtual.c */
50 %union
52 DBG_ADDR address;
53 enum debug_regs reg;
54 char * string;
55 int integer;
56 struct list_id listing;
57 struct expr * expression;
58 struct datatype * type;
61 %token tCONT tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
62 %token tENABLE tDISABLE tBREAK tDELETE tSET tMODE tPRINT tEXAM tABORT tDEBUGMSG
63 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
64 %token tEOL tSTRING tDEBUGSTR
65 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
66 %token tSTEPI tNEXTI tFINISH tSHOW tDIR
67 %token <string> tPATH
68 %token <string> tIDENTIFIER tSTRING tDEBUGSTR
69 %token <integer> tNUM tFORMAT
70 %token <reg> tREG
71 %token tSYMBOLFILE
73 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
74 %token tSTRUCT tUNION tENUM
76 /* %left ',' */
77 /* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
78 OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
79 OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
80 /* %left OP_COND */ /* ... ? ... : ... */
81 %left OP_LOR
82 %left OP_LAND
83 %left '|'
84 %left '^'
85 %left '&'
86 %left OP_EQ OP_NE
87 %left '<' '>' OP_LE OP_GE
88 %left OP_SHL OP_SHR
89 %left '+' '-'
90 %left '*' '/' '%'
91 %left OP_SIGN '!' '~' OP_DEREF /* OP_INC OP_DEC OP_ADDR */
92 %left '.' '[' OP_DRF
93 %nonassoc ':'
95 %type <expression> expr lval lvalue
96 %type <type> type_cast type_expr
97 %type <address> expr_addr lval_addr
98 %type <integer> expr_value
99 %type <string> pathname
101 %type <listing> list_arg
105 input: line { issue_prompt(); }
106 | input line { issue_prompt(); }
108 line: command
109 | tEOL
110 | error tEOL { yyerrok; }
112 command:
113 tQUIT tEOL { exit(0); }
114 | tHELP tEOL { DEBUG_Help(); }
115 | tHELP tINFO tEOL { DEBUG_HelpInfo(); }
116 | tCONT tEOL { dbg_exec_count = 1;
117 dbg_exec_mode = EXEC_CONT; return 0; }
118 | tCONT tNUM tEOL { dbg_exec_count = $2;
119 dbg_exec_mode = EXEC_CONT; return 0; }
120 | tSTEP tEOL { dbg_exec_count = 1;
121 dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
122 | tNEXT tEOL { dbg_exec_count = 1;
123 dbg_exec_mode = EXEC_STEP_OVER; return 0; }
124 | tSTEP tNUM tEOL { dbg_exec_count = $2;
125 dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
126 | tNEXT tNUM tEOL { dbg_exec_count = $2;
127 dbg_exec_mode = EXEC_STEP_OVER; return 0; }
128 | tSTEPI tEOL { dbg_exec_count = 1;
129 dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
130 | tNEXTI tEOL { dbg_exec_count = 1;
131 dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
132 | tSTEPI tNUM tEOL { dbg_exec_count = $2;
133 dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
134 | tNEXTI tNUM tEOL { dbg_exec_count = $2;
135 dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
136 | tABORT tEOL { kill(getpid(), SIGABRT); }
137 | tMODE tNUM tEOL { mode_command($2); }
138 | tENABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, TRUE ); }
139 | tDISABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, FALSE ); }
140 | tDELETE tBREAK tNUM tEOL { DEBUG_DelBreakpoint( $3 ); }
141 | tBACKTRACE tEOL { DEBUG_BackTrace(); }
142 | tUP tEOL { DEBUG_SetFrame( curr_frame + 1 ); }
143 | tUP tNUM tEOL { DEBUG_SetFrame( curr_frame + $2 ); }
144 | tDOWN tEOL { DEBUG_SetFrame( curr_frame - 1 ); }
145 | tDOWN tNUM tEOL { DEBUG_SetFrame( curr_frame - $2 ); }
146 | tFRAME tNUM tEOL { DEBUG_SetFrame( $2 ); }
147 | tFINISH tEOL { dbg_exec_count = 0;
148 dbg_exec_mode = EXEC_FINISH; return 0; }
149 | tSHOW tDIR tEOL { DEBUG_ShowDir(); }
150 | tDIR pathname tEOL { DEBUG_AddPath( $2 ); }
151 | tDIR tEOL { DEBUG_NukePath(); }
152 | tDISPLAY tEOL { DEBUG_InfoDisplay(); }
153 | tDISPLAY expr tEOL { DEBUG_AddDisplay($2, 1, 0); }
154 | tDISPLAY tFORMAT expr tEOL { DEBUG_AddDisplay($3, $2 >> 8, $2 & 0xff); }
155 | tDELETE tDISPLAY tNUM tEOL { DEBUG_DelDisplay( $3 ); }
156 | tDELETE tDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
157 | tUNDISPLAY tNUM tEOL { DEBUG_DelDisplay( $2 ); }
158 | tUNDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
159 | tCOND tNUM tEOL { DEBUG_AddBPCondition($2, NULL); }
160 | tCOND tNUM expr tEOL { DEBUG_AddBPCondition($2, $3); }
161 | tDEBUGMSG tDEBUGSTR tEOL { MAIN_ParseDebugOptions($2); }
162 | tSYMBOLFILE pathname tEOL{ DEBUG_ReadSymbolTable($2); }
163 | list_command
164 | disassemble_command
165 | set_command
166 | x_command
167 | print_command
168 | break_command
169 | info_command
170 | walk_command
172 set_command:
173 tSET tREG '=' expr_value tEOL { DEBUG_SetRegister( $2, $4 );
174 DEBUG_FreeExprMem(); }
175 | tSET lval_addr '=' expr_value tEOL { DEBUG_WriteMemory( &$2, $4 );
176 DEBUG_FreeExprMem(); }
178 pathname:
179 tIDENTIFIER { $$ = $1; }
180 | tPATH { $$ = $1; }
182 disassemble_command:
183 tDISASSEMBLE tEOL { DEBUG_Disassemble( NULL, NULL, 10 ); }
184 | tDISASSEMBLE expr_addr tEOL { DEBUG_Disassemble( & $2, NULL, 10 ); }
185 | tDISASSEMBLE expr_addr ',' expr_addr tEOL { DEBUG_Disassemble( & $2, & $4, 0 ); }
187 list_command:
188 tLIST tEOL { DEBUG_List( NULL, NULL, 10 ); }
189 | tLIST '-' tEOL { DEBUG_List( NULL, NULL, -10 ); }
190 | tLIST list_arg tEOL { DEBUG_List( & $2, NULL, 10 ); }
191 | tLIST ',' list_arg tEOL { DEBUG_List( NULL, & $3, -10 ); }
192 | tLIST list_arg ',' list_arg tEOL { DEBUG_List( & $2, & $4, 0 ); }
194 list_arg:
195 tNUM { $$.sourcefile = NULL; $$.line = $1; }
196 | pathname ':' tNUM { $$.sourcefile = $1; $$.line = $3; }
197 | tIDENTIFIER { DEBUG_GetFuncInfo( & $$, NULL, $1); }
198 | pathname ':' tIDENTIFIER { DEBUG_GetFuncInfo( & $$, $1, $3); }
199 | '*' expr_addr { DEBUG_FindNearestSymbol( & $2, FALSE, NULL,
200 0, & $$ );
201 DEBUG_FreeExprMem(); }
203 x_command:
204 tEXAM expr_addr tEOL { DEBUG_ExamineMemory( &$2, 1, 'x');
205 DEBUG_FreeExprMem(); }
206 | tEXAM tFORMAT expr_addr tEOL { DEBUG_ExamineMemory( &$3, $2>>8, $2&0xff );
207 DEBUG_FreeExprMem(); }
209 print_command:
210 tPRINT expr_addr tEOL { DEBUG_Print( &$2, 1, 0, 0 );
211 DEBUG_FreeExprMem(); }
212 | tPRINT tFORMAT expr_addr tEOL { DEBUG_Print( &$3, $2 >> 8, $2 & 0xff, 0 );
213 DEBUG_FreeExprMem(); }
215 break_command:
216 tBREAK '*' expr_addr tEOL { DEBUG_AddBreakpoint( &$3 );
217 DEBUG_FreeExprMem(); }
218 | tBREAK tIDENTIFIER tEOL { DBG_ADDR addr;
219 if( DEBUG_GetSymbolValue($2, -1, &addr, TRUE) )
221 DEBUG_AddBreakpoint( &addr );
223 else
225 fprintf(stderr,"Unable to add breakpoint\n");
228 | tBREAK tIDENTIFIER ':' tNUM tEOL { DBG_ADDR addr;
229 if( DEBUG_GetSymbolValue($2, $4, &addr, TRUE) )
231 DEBUG_AddBreakpoint( &addr );
233 else
235 fprintf(stderr,"Unable to add breakpoint\n");
238 | tBREAK tNUM tEOL { struct name_hash *nh;
239 DBG_ADDR addr;
240 TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
242 addr.type = NULL;
243 addr.seg = CS_reg(&DEBUG_context);
244 addr.off = EIP_reg(&DEBUG_context);
246 if (ISV86(&DEBUG_context))
247 addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
248 DBG_FIX_ADDR_SEG( &addr, CS_reg(&DEBUG_context) );
249 GlobalUnlock16( GetCurrentTask() );
250 DEBUG_FindNearestSymbol(&addr, TRUE,
251 &nh, 0, NULL);
252 if( nh != NULL )
254 DEBUG_GetLineNumberAddr(nh,
255 $2, &addr, TRUE);
256 DEBUG_AddBreakpoint( &addr );
258 else
260 fprintf(stderr,"Unable to add breakpoint\n");
264 | tBREAK tEOL { DBG_ADDR addr;
265 TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
267 addr.type = NULL;
268 addr.seg = CS_reg(&DEBUG_context);
269 addr.off = EIP_reg(&DEBUG_context);
271 if (ISV86(&DEBUG_context))
272 addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
273 GlobalUnlock16( GetCurrentTask() );
274 DEBUG_AddBreakpoint( &addr );
277 info_command:
278 tINFO tBREAK tEOL { DEBUG_InfoBreakpoints(); }
279 | tINFO tCLASS expr_value tEOL { CLASS_DumpClass( (CLASS *)$3 );
280 DEBUG_FreeExprMem(); }
281 | tINFO tSHARE tEOL { DEBUG_InfoShare(); }
282 | tINFO tMODULE expr_value tEOL { NE_DumpModule( $3 );
283 DEBUG_FreeExprMem(); }
284 | tINFO tQUEUE expr_value tEOL { QUEUE_DumpQueue( $3 );
285 DEBUG_FreeExprMem(); }
286 | tINFO tREGS tEOL { DEBUG_InfoRegisters(); }
287 | tINFO tSEGMENTS expr_value tEOL { LDT_Print( SELECTOR_TO_ENTRY($3), 1 );
288 DEBUG_FreeExprMem(); }
289 | tINFO tSEGMENTS tEOL { LDT_Print( 0, -1 ); }
290 | tINFO tSTACK tEOL { DEBUG_InfoStack(); }
291 | tINFO tMAPS tEOL { VIRTUAL_Dump(); }
292 | tINFO tWND expr_value tEOL { WIN_DumpWindow( $3 );
293 DEBUG_FreeExprMem(); }
294 | tINFO tLOCAL tEOL { DEBUG_InfoLocals(); }
295 | tINFO tDISPLAY tEOL { DEBUG_InfoDisplay(); }
297 walk_command:
298 tWALK tCLASS tEOL { CLASS_WalkClasses(); }
299 | tWALK tMODULE tEOL { NE_WalkModules(); }
300 | tWALK tQUEUE tEOL { QUEUE_WalkQueues(); }
301 | tWALK tWND tEOL { WIN_WalkWindows( 0, 0 ); }
302 | tWALK tWND tNUM tEOL { WIN_WalkWindows( $3, 0 ); }
305 type_cast:
306 '(' type_expr ')' { $$ = $2; }
308 type_expr:
309 type_expr '*' { $$ = DEBUG_FindOrMakePointerType($1); }
310 | tINT { $$ = DEBUG_TypeCast(DT_BASIC, "int"); }
311 | tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "char"); }
312 | tLONG tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long int"); }
313 | tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "unsigned int"); }
314 | tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long unsigned int"); }
315 | tLONG tLONG tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long long int"); }
316 | tLONG tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long long unsigned int"); }
317 | tSHORT tINT { $$ = DEBUG_TypeCast(DT_BASIC, "short int"); }
318 | tSHORT tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "short unsigned int"); }
319 | tSIGNED tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "signed char"); }
320 | tUNSIGNED tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "unsigned char"); }
321 | tFLOAT { $$ = DEBUG_TypeCast(DT_BASIC, "float"); }
322 | tDOUBLE { $$ = DEBUG_TypeCast(DT_BASIC, "double"); }
323 | tLONG tDOUBLE { $$ = DEBUG_TypeCast(DT_BASIC, "long double"); }
324 | tSTRUCT tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
325 | tUNION tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
326 | tENUM tIDENTIFIER { $$ = DEBUG_TypeCast(DT_ENUM, $2); }
328 expr_addr:
329 expr { $$ = DEBUG_EvalExpr($1); }
331 expr_value:
332 expr { DBG_ADDR addr = DEBUG_EvalExpr($1);
333 $$ = addr.off ? *(unsigned int *) addr.off : 0; }
335 * The expr rule builds an expression tree. When we are done, we call
336 * EvalExpr to evaluate the value of the expression. The advantage of
337 * the two-step approach is that it is possible to save expressions for
338 * use in 'display' commands, and in conditional watchpoints.
340 expr:
341 tNUM { $$ = DEBUG_ConstExpr($1); }
342 | tSTRING { $$ = DEBUG_StringExpr($1); }
343 | tREG { $$ = DEBUG_RegisterExpr($1); }
344 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
345 | expr OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
346 | expr '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
347 | tIDENTIFIER '(' ')' { $$ = DEBUG_CallExpr($1, 0); }
348 | tIDENTIFIER '(' expr ')' { $$ = DEBUG_CallExpr($1, 1, $3); }
349 | tIDENTIFIER '(' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 2, $3,
350 $5); }
351 | tIDENTIFIER '(' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7); }
352 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9); }
353 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9, $11); }
354 | expr '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
355 | expr ':' expr { $$ = DEBUG_BinopExpr(EXP_OP_SEG, $1, $3); }
356 | expr OP_LOR expr { $$ = DEBUG_BinopExpr(EXP_OP_LOR, $1, $3); }
357 | expr OP_LAND expr { $$ = DEBUG_BinopExpr(EXP_OP_LAND, $1, $3); }
358 | expr '|' expr { $$ = DEBUG_BinopExpr(EXP_OP_OR, $1, $3); }
359 | expr '&' expr { $$ = DEBUG_BinopExpr(EXP_OP_AND, $1, $3); }
360 | expr '^' expr { $$ = DEBUG_BinopExpr(EXP_OP_XOR, $1, $3); }
361 | expr OP_EQ expr { $$ = DEBUG_BinopExpr(EXP_OP_EQ, $1, $3); }
362 | expr '>' expr { $$ = DEBUG_BinopExpr(EXP_OP_GT, $1, $3); }
363 | expr '<' expr { $$ = DEBUG_BinopExpr(EXP_OP_LT, $1, $3); }
364 | expr OP_GE expr { $$ = DEBUG_BinopExpr(EXP_OP_GE, $1, $3); }
365 | expr OP_LE expr { $$ = DEBUG_BinopExpr(EXP_OP_LE, $1, $3); }
366 | expr OP_NE expr { $$ = DEBUG_BinopExpr(EXP_OP_NE, $1, $3); }
367 | expr OP_SHL expr { $$ = DEBUG_BinopExpr(EXP_OP_SHL, $1, $3); }
368 | expr OP_SHR expr { $$ = DEBUG_BinopExpr(EXP_OP_SHR, $1, $3); }
369 | expr '+' expr { $$ = DEBUG_BinopExpr(EXP_OP_ADD, $1, $3); }
370 | expr '-' expr { $$ = DEBUG_BinopExpr(EXP_OP_SUB, $1, $3); }
371 | expr '*' expr { $$ = DEBUG_BinopExpr(EXP_OP_MUL, $1, $3); }
372 | expr '/' expr { $$ = DEBUG_BinopExpr(EXP_OP_DIV, $1, $3); }
373 | expr '%' expr { $$ = DEBUG_BinopExpr(EXP_OP_REM, $1, $3); }
374 | '-' expr %prec OP_SIGN { $$ = DEBUG_UnopExpr(EXP_OP_NEG, $2); }
375 | '+' expr %prec OP_SIGN { $$ = $2; }
376 | '!' expr { $$ = DEBUG_UnopExpr(EXP_OP_NOT, $2); }
377 | '~' expr { $$ = DEBUG_UnopExpr(EXP_OP_LNOT, $2); }
378 | '(' expr ')' { $$ = $2; }
379 | '*' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_DEREF, $2); }
380 | '&' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_ADDR, $2); }
381 | type_cast expr %prec OP_DEREF { $$ = DEBUG_TypeCastExpr($1, $2); }
384 * The lvalue rule builds an expression tree. This is a limited form
385 * of expression that is suitable to be used as an lvalue.
387 lval_addr:
388 lval { $$ = DEBUG_EvalExpr($1); }
390 lval:
391 lvalue { $$ = $1; }
392 | '*' expr { $$ = DEBUG_UnopExpr(EXP_OP_FORCE_DEREF, $2); }
394 lvalue:
395 tNUM { $$ = DEBUG_ConstExpr($1); }
396 | tREG { $$ = DEBUG_RegisterExpr($1); }
397 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
398 | lvalue OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
399 | lvalue '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
400 | lvalue '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
404 void
405 issue_prompt(){
406 #ifdef DONT_USE_READLINE
407 fprintf(stderr,"Wine-dbg>");
408 #endif
411 void mode_command(int newmode)
413 if ((newmode == 16) || (newmode == 32)) dbg_mode = newmode;
414 else fprintf(stderr,"Invalid mode (use 16 or 32)\n");
418 /***********************************************************************
419 * DEBUG_Main
421 * Debugger main loop.
423 static void DEBUG_Main( int signal )
425 static int loaded_symbols = 0;
426 static BOOL frozen = FALSE;
427 static BOOL in_debugger = FALSE;
428 char SymbolTableFile[256];
429 int newmode;
430 BOOL ret_ok;
431 #ifdef YYDEBUG
432 yydebug = 0;
433 #endif
435 if (in_debugger)
437 fprintf( stderr, "Segmentation fault inside debugger, exiting.\n" );
438 exit(1);
440 in_debugger = TRUE;
441 yyin = stdin;
443 DEBUG_SetBreakpoints( FALSE );
445 if (!loaded_symbols)
447 loaded_symbols++;
449 if ( !frozen )
451 CLIENT_DebuggerRequest( DEBUGGER_FREEZE_ALL );
452 frozen = TRUE;
456 * Initialize the type handling stuff.
458 DEBUG_InitTypes();
461 * In some cases we can read the stabs information directly
462 * from the executable. If this is the case, we don't need
463 * to bother with trying to read a symbol file, as the stabs
464 * also have line number and local variable information.
465 * As long as gcc is used for the compiler, stabs will
466 * be the default. On SVr4, DWARF could be used, but we
467 * don't grok that yet, and in this case we fall back to using
468 * the wine.sym file.
470 if( DEBUG_ReadExecutableDbgInfo() == FALSE )
472 char *symfilename = "wine.sym";
473 struct stat statbuf;
474 if (-1 == stat(symfilename, &statbuf) )
475 symfilename = LIBDIR "wine.sym";
477 PROFILE_GetWineIniString( "wine", "SymbolTableFile", symfilename,
478 SymbolTableFile, sizeof(SymbolTableFile));
479 DEBUG_ReadSymbolTable( SymbolTableFile );
482 DEBUG_LoadEntryPoints();
483 DEBUG_ProcessDeferredDebug();
486 #if 0
487 fprintf(stderr, "Entering debugger PC=%x, mode=%d, count=%d\n",
488 EIP_reg(&DEBUG_context),
489 dbg_exec_mode, dbg_exec_count);
491 sleep(1);
492 #endif
494 if ((signal != SIGTRAP) || !DEBUG_ShouldContinue( dbg_exec_mode,
495 &dbg_exec_count ))
497 DBG_ADDR addr;
498 TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
500 addr.seg = CS_reg(&DEBUG_context);
501 addr.off = EIP_reg(&DEBUG_context);
502 if (ISV86(&DEBUG_context)) addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
503 addr.type = NULL;
504 DBG_FIX_ADDR_SEG( &addr, 0 );
506 GlobalUnlock16( GetCurrentTask() );
508 if ( !frozen )
510 CLIENT_DebuggerRequest( DEBUGGER_FREEZE_ALL );
511 frozen = TRUE;
514 /* Put the display in a correct state */
515 USER_Driver->pBeginDebugging();
517 newmode = ISV86(&DEBUG_context) ? 16 : IS_SELECTOR_32BIT(addr.seg) ? 32 : 16;
518 if (newmode != dbg_mode)
519 fprintf(stderr,"In %d bit mode.\n", dbg_mode = newmode);
521 DEBUG_DoDisplay();
523 if (signal != SIGTRAP) /* This is a real crash, dump some info */
525 DEBUG_InfoRegisters();
526 DEBUG_InfoStack();
527 if (dbg_mode == 16)
529 LDT_Print( SELECTOR_TO_ENTRY(DS_reg(&DEBUG_context)), 1 );
530 if (ES_reg(&DEBUG_context) != DS_reg(&DEBUG_context))
531 LDT_Print( SELECTOR_TO_ENTRY(ES_reg(&DEBUG_context)), 1 );
533 DEBUG_BackTrace();
535 else
538 * Do a quiet backtrace so that we have an idea of what the situation
539 * is WRT the source files.
541 DEBUG_SilentBackTrace();
544 if ((signal != SIGTRAP) ||
545 (dbg_exec_mode == EXEC_STEPI_OVER) ||
546 (dbg_exec_mode == EXEC_STEPI_INSTR))
548 /* Show where we crashed */
549 curr_frame = 0;
550 DEBUG_PrintAddress( &addr, dbg_mode, TRUE );
551 fprintf(stderr,": ");
552 if (DBG_CHECK_READ_PTR( &addr, 1 ))
554 DEBUG_Disasm( &addr, TRUE );
555 fprintf(stderr,"\n");
559 ret_ok = 0;
562 issue_prompt();
563 yyparse();
564 flush_symbols();
565 addr.seg = CS_reg(&DEBUG_context) | (addr.seg&0xffff0000);
566 addr.off = EIP_reg(&DEBUG_context);
567 DBG_FIX_ADDR_SEG( &addr, 0 );
568 ret_ok = DEBUG_ValidateRegisters();
569 if (ret_ok) ret_ok = DBG_CHECK_READ_PTR( &addr, 1 );
570 } while (!ret_ok);
573 dbg_exec_mode = DEBUG_RestartExecution( dbg_exec_mode, dbg_exec_count );
575 * This will have gotten absorbed into the breakpoint info
576 * if it was used. Otherwise it would have been ignored.
577 * In any case, we don't mess with it any more.
579 if( dbg_exec_mode == EXEC_CONT )
581 dbg_exec_count = 0;
583 if ( frozen )
585 CLIENT_DebuggerRequest( DEBUGGER_UNFREEZE_ALL );
586 frozen = FALSE;
590 in_debugger = FALSE;
592 USER_Driver->pEndDebugging();
597 /***********************************************************************
598 * DebugBreak (KERNEL.203) (KERNEL32.181)
600 void DebugBreak16( CONTEXT *regs )
602 char module[10];
603 if (!GetModuleName16( GetCurrentTask(), module, sizeof(module) ))
604 strcpy( module, "???" );
605 fprintf( stderr, "%s called DebugBreak\n", module );
606 DEBUG_context = *regs;
607 DEBUG_Main( SIGTRAP );
611 void ctx_debug( int signal, CONTEXT *regs )
613 DEBUG_context = *regs;
614 DEBUG_Main( signal );
615 *regs = DEBUG_context;
618 void wine_debug( int signal, SIGCONTEXT *regs )
620 #if 0
621 DWORD *stack = (DWORD *)ESP_sig(regs);
622 *(--stack) = 0;
623 *(--stack) = 0;
624 *(--stack) = EH_NONCONTINUABLE;
625 *(--stack) = EXCEPTION_ACCESS_VIOLATION;
626 *(--stack) = EIP_sig(regs);
627 ESP_sig(regs) = (DWORD)stack;
628 EIP_sig(regs) = (DWORD)RaiseException;
629 #else
630 DEBUG_SetSigContext( regs );
631 DEBUG_Main( signal );
632 DEBUG_GetSigContext( regs );
633 #endif
636 int yyerror(char * s)
638 fprintf(stderr,"%s\n", s);
639 return 0;