Added add_queue/remove_queue to server object operations.
[wine/multimedia.git] / debugger / dbg.y
blob03073429afc6ad28f9e50eff21a5bf38714a05dd
1 %{
2 /*
3 * Parser for command lines in the Wine debugger
5 * Copyright 1993 Eric Youngdale
6 * Copyright 1995 Morten Welinder
7 */
9 #include "ts_xlib.h"
11 #include <stdio.h>
12 #include <signal.h>
13 #include <sys/stat.h>
14 #include <unistd.h>
15 #include "winbase.h"
16 #include "class.h"
17 #include "module.h"
18 #include "task.h"
19 #include "options.h"
20 #include "queue.h"
21 #include "win.h"
22 #include "winnt.h"
23 #include "debugger.h"
24 #include "neexe.h"
25 #include "process.h"
27 #include "expr.h"
29 extern FILE * yyin;
30 unsigned int dbg_mode = 0;
31 int curr_frame = 0;
33 static enum exec_mode dbg_exec_mode = EXEC_CONT;
34 static int dbg_exec_count = 0;
36 void issue_prompt(void);
37 void mode_command(int);
38 void flush_symbols(void);
39 int yylex(void);
40 int yyerror(char *);
42 extern void VIRTUAL_Dump(void); /* memory/virtual.c */
46 %union
48 DBG_ADDR address;
49 enum debug_regs reg;
50 char * string;
51 int integer;
52 struct list_id listing;
53 struct expr * expression;
54 struct datatype * type;
57 %token tCONT tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
58 %token tENABLE tDISABLE tBREAK tDELETE tSET tMODE tPRINT tEXAM tABORT
59 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
60 %token tEOL tSTRING
61 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
62 %token tSTEPI tNEXTI tFINISH tSHOW tDIR
63 %token <string> tPATH
64 %token <string> tIDENTIFIER tSTRING
65 %token <integer> tNUM tFORMAT
66 %token <reg> tREG
68 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
69 %token tSTRUCT tUNION tENUM
71 /* %left ',' */
72 /* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
73 OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
74 OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
75 /* %left OP_COND */ /* ... ? ... : ... */
76 %left OP_LOR
77 %left OP_LAND
78 %left '|'
79 %left '^'
80 %left '&'
81 %left OP_EQ OP_NE
82 %left '<' '>' OP_LE OP_GE
83 %left OP_SHL OP_SHR
84 %left '+' '-'
85 %left '*' '/' '%'
86 %left OP_SIGN '!' '~' OP_DEREF /* OP_INC OP_DEC OP_ADDR */
87 %left '.' '[' OP_DRF
88 %nonassoc ':'
90 %type <expression> expr lval lvalue
91 %type <type> type_cast type_expr
92 %type <address> expr_addr lval_addr
93 %type <integer> expr_value
94 %type <string> pathname
96 %type <listing> list_arg
100 input: line { issue_prompt(); }
101 | input line { issue_prompt(); }
103 line: command
104 | tEOL
105 | error tEOL { yyerrok; }
107 command:
108 tQUIT tEOL { exit(0); }
109 | tHELP tEOL { DEBUG_Help(); }
110 | tHELP tINFO tEOL { DEBUG_HelpInfo(); }
111 | tCONT tEOL { dbg_exec_count = 1;
112 dbg_exec_mode = EXEC_CONT; return 0; }
113 | tCONT tNUM tEOL { dbg_exec_count = $2;
114 dbg_exec_mode = EXEC_CONT; return 0; }
115 | tSTEP tEOL { dbg_exec_count = 1;
116 dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
117 | tNEXT tEOL { dbg_exec_count = 1;
118 dbg_exec_mode = EXEC_STEP_OVER; return 0; }
119 | tSTEP tNUM tEOL { dbg_exec_count = $2;
120 dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
121 | tNEXT tNUM tEOL { dbg_exec_count = $2;
122 dbg_exec_mode = EXEC_STEP_OVER; return 0; }
123 | tSTEPI tEOL { dbg_exec_count = 1;
124 dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
125 | tNEXTI tEOL { dbg_exec_count = 1;
126 dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
127 | tSTEPI tNUM tEOL { dbg_exec_count = $2;
128 dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
129 | tNEXTI tNUM tEOL { dbg_exec_count = $2;
130 dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
131 | tABORT tEOL { kill(getpid(), SIGABRT); }
132 | tMODE tNUM tEOL { mode_command($2); }
133 | tENABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, TRUE ); }
134 | tDISABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, FALSE ); }
135 | tDELETE tBREAK tNUM tEOL { DEBUG_DelBreakpoint( $3 ); }
136 | tBACKTRACE tEOL { DEBUG_BackTrace(); }
137 | tUP tEOL { DEBUG_SetFrame( curr_frame + 1 ); }
138 | tUP tNUM tEOL { DEBUG_SetFrame( curr_frame + $2 ); }
139 | tDOWN tEOL { DEBUG_SetFrame( curr_frame - 1 ); }
140 | tDOWN tNUM tEOL { DEBUG_SetFrame( curr_frame - $2 ); }
141 | tFRAME tNUM tEOL { DEBUG_SetFrame( $2 ); }
142 | tFINISH tEOL { dbg_exec_count = 0;
143 dbg_exec_mode = EXEC_FINISH; return 0; }
144 | tSHOW tDIR tEOL { DEBUG_ShowDir(); }
145 | tDIR pathname tEOL { DEBUG_AddPath( $2 ); }
146 | tDIR tEOL { DEBUG_NukePath(); }
147 | tDISPLAY tEOL { DEBUG_InfoDisplay(); }
148 | tDISPLAY expr tEOL { DEBUG_AddDisplay($2, 1, 0); }
149 | tDISPLAY tFORMAT expr tEOL { DEBUG_AddDisplay($3, $2 >> 8, $2 & 0xff); }
150 | tDELETE tDISPLAY tNUM tEOL { DEBUG_DelDisplay( $3 ); }
151 | tDELETE tDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
152 | tUNDISPLAY tNUM tEOL { DEBUG_DelDisplay( $2 ); }
153 | tUNDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
154 | tCOND tNUM tEOL { DEBUG_AddBPCondition($2, NULL); }
155 | tCOND tNUM expr tEOL { DEBUG_AddBPCondition($2, $3); }
156 | list_command
157 | disassemble_command
158 | set_command
159 | x_command
160 | print_command
161 | break_command
162 | info_command
163 | walk_command
165 set_command:
166 tSET tREG '=' expr_value tEOL { DEBUG_SetRegister( $2, $4 );
167 DEBUG_FreeExprMem(); }
168 | tSET lval_addr '=' expr_value tEOL { DEBUG_WriteMemory( &$2, $4 );
169 DEBUG_FreeExprMem(); }
171 pathname:
172 tIDENTIFIER { $$ = $1; }
173 | tPATH { $$ = $1; }
175 disassemble_command:
176 tDISASSEMBLE tEOL { DEBUG_Disassemble( NULL, NULL, 10 ); }
177 | tDISASSEMBLE expr_addr tEOL { DEBUG_Disassemble( & $2, NULL, 10 ); }
178 | tDISASSEMBLE expr_addr ',' expr_addr tEOL { DEBUG_Disassemble( & $2, & $4, 0 ); }
180 list_command:
181 tLIST tEOL { DEBUG_List( NULL, NULL, 10 ); }
182 | tLIST '-' tEOL { DEBUG_List( NULL, NULL, -10 ); }
183 | tLIST list_arg tEOL { DEBUG_List( & $2, NULL, 10 ); }
184 | tLIST ',' list_arg tEOL { DEBUG_List( NULL, & $3, -10 ); }
185 | tLIST list_arg ',' list_arg tEOL { DEBUG_List( & $2, & $4, 0 ); }
187 list_arg:
188 tNUM { $$.sourcefile = NULL; $$.line = $1; }
189 | pathname ':' tNUM { $$.sourcefile = $1; $$.line = $3; }
190 | tIDENTIFIER { DEBUG_GetFuncInfo( & $$, NULL, $1); }
191 | pathname ':' tIDENTIFIER { DEBUG_GetFuncInfo( & $$, $1, $3); }
192 | '*' expr_addr { DEBUG_FindNearestSymbol( & $2, FALSE, NULL,
193 0, & $$ );
194 DEBUG_FreeExprMem(); }
196 x_command:
197 tEXAM expr_addr tEOL { DEBUG_ExamineMemory( &$2, 1, 'x');
198 DEBUG_FreeExprMem(); }
199 | tEXAM tFORMAT expr_addr tEOL { DEBUG_ExamineMemory( &$3, $2>>8, $2&0xff );
200 DEBUG_FreeExprMem(); }
202 print_command:
203 tPRINT expr_addr tEOL { DEBUG_Print( &$2, 1, 0, 0 );
204 DEBUG_FreeExprMem(); }
205 | tPRINT tFORMAT expr_addr tEOL { DEBUG_Print( &$3, $2 >> 8, $2 & 0xff, 0 );
206 DEBUG_FreeExprMem(); }
208 break_command:
209 tBREAK '*' expr_addr tEOL { DEBUG_AddBreakpoint( &$3 );
210 DEBUG_FreeExprMem(); }
211 | tBREAK tIDENTIFIER tEOL { DBG_ADDR addr;
212 if( DEBUG_GetSymbolValue($2, -1, &addr, TRUE) )
214 DEBUG_AddBreakpoint( &addr );
216 else
218 fprintf(stderr,"Unable to add breakpoint\n");
221 | tBREAK tIDENTIFIER ':' tNUM tEOL { DBG_ADDR addr;
222 if( DEBUG_GetSymbolValue($2, $4, &addr, TRUE) )
224 DEBUG_AddBreakpoint( &addr );
226 else
228 fprintf(stderr,"Unable to add breakpoint\n");
231 | tBREAK tNUM tEOL { struct name_hash *nh;
232 DBG_ADDR addr = { NULL,
233 CS_reg(&DEBUG_context),
234 EIP_reg(&DEBUG_context) };
235 TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
236 if (ISV86(&DEBUG_context))
237 addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
238 DBG_FIX_ADDR_SEG( &addr, CS_reg(&DEBUG_context) );
239 GlobalUnlock16( GetCurrentTask() );
240 DEBUG_FindNearestSymbol(&addr, TRUE,
241 &nh, 0, NULL);
242 if( nh != NULL )
244 DEBUG_GetLineNumberAddr(nh,
245 $2, &addr, TRUE);
246 DEBUG_AddBreakpoint( &addr );
248 else
250 fprintf(stderr,"Unable to add breakpoint\n");
254 | tBREAK tEOL { DBG_ADDR addr = { NULL,
255 CS_reg(&DEBUG_context),
256 EIP_reg(&DEBUG_context) };
257 TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
258 if (ISV86(&DEBUG_context))
259 addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
260 GlobalUnlock16( GetCurrentTask() );
261 DEBUG_AddBreakpoint( &addr );
264 info_command:
265 tINFO tBREAK tEOL { DEBUG_InfoBreakpoints(); }
266 | tINFO tCLASS expr_value tEOL { CLASS_DumpClass( (CLASS *)$3 );
267 DEBUG_FreeExprMem(); }
268 | tINFO tSHARE tEOL { DEBUG_InfoShare(); }
269 | tINFO tMODULE expr_value tEOL { NE_DumpModule( $3 );
270 DEBUG_FreeExprMem(); }
271 | tINFO tQUEUE expr_value tEOL { QUEUE_DumpQueue( $3 );
272 DEBUG_FreeExprMem(); }
273 | tINFO tREGS tEOL { DEBUG_InfoRegisters(); }
274 | tINFO tSEGMENTS expr_value tEOL { LDT_Print( SELECTOR_TO_ENTRY($3), 1 );
275 DEBUG_FreeExprMem(); }
276 | tINFO tSEGMENTS tEOL { LDT_Print( 0, -1 ); }
277 | tINFO tSTACK tEOL { DEBUG_InfoStack(); }
278 | tINFO tMAPS tEOL { VIRTUAL_Dump(); }
279 | tINFO tWND expr_value tEOL { WIN_DumpWindow( $3 );
280 DEBUG_FreeExprMem(); }
281 | tINFO tLOCAL tEOL { DEBUG_InfoLocals(); }
282 | tINFO tDISPLAY tEOL { DEBUG_InfoDisplay(); }
284 walk_command:
285 tWALK tCLASS tEOL { CLASS_WalkClasses(); }
286 | tWALK tMODULE tEOL { NE_WalkModules(); }
287 | tWALK tQUEUE tEOL { QUEUE_WalkQueues(); }
288 | tWALK tWND tEOL { WIN_WalkWindows( 0, 0 ); }
289 | tWALK tWND tNUM tEOL { WIN_WalkWindows( $3, 0 ); }
292 type_cast:
293 '(' type_expr ')' { $$ = $2; }
295 type_expr:
296 type_expr '*' { $$ = DEBUG_FindOrMakePointerType($1); }
297 | tINT { $$ = DEBUG_TypeCast(DT_BASIC, "int"); }
298 | tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "char"); }
299 | tLONG tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long int"); }
300 | tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "unsigned int"); }
301 | tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long unsigned int"); }
302 | tLONG tLONG tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long long int"); }
303 | tLONG tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long long unsigned int"); }
304 | tSHORT tINT { $$ = DEBUG_TypeCast(DT_BASIC, "short int"); }
305 | tSHORT tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "short unsigned int"); }
306 | tSIGNED tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "signed char"); }
307 | tUNSIGNED tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "unsigned char"); }
308 | tFLOAT { $$ = DEBUG_TypeCast(DT_BASIC, "float"); }
309 | tDOUBLE { $$ = DEBUG_TypeCast(DT_BASIC, "double"); }
310 | tLONG tDOUBLE { $$ = DEBUG_TypeCast(DT_BASIC, "long double"); }
311 | tSTRUCT tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
312 | tUNION tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
313 | tENUM tIDENTIFIER { $$ = DEBUG_TypeCast(DT_ENUM, $2); }
315 expr_addr:
316 expr { $$ = DEBUG_EvalExpr($1); }
318 expr_value:
319 expr { DBG_ADDR addr = DEBUG_EvalExpr($1);
320 $$ = addr.off ? *(unsigned int *) addr.off : 0; }
322 * The expr rule builds an expression tree. When we are done, we call
323 * EvalExpr to evaluate the value of the expression. The advantage of
324 * the two-step approach is that it is possible to save expressions for
325 * use in 'display' commands, and in conditional watchpoints.
327 expr:
328 tNUM { $$ = DEBUG_ConstExpr($1); }
329 | tSTRING { $$ = DEBUG_StringExpr($1); }
330 | tREG { $$ = DEBUG_RegisterExpr($1); }
331 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
332 | expr OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
333 | expr '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
334 | tIDENTIFIER '(' ')' { $$ = DEBUG_CallExpr($1, 0); }
335 | tIDENTIFIER '(' expr ')' { $$ = DEBUG_CallExpr($1, 1, $3); }
336 | tIDENTIFIER '(' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 2, $3,
337 $5); }
338 | tIDENTIFIER '(' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7); }
339 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9); }
340 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9, $11); }
341 | expr '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
342 | expr ':' expr { $$ = DEBUG_BinopExpr(EXP_OP_SEG, $1, $3); }
343 | expr OP_LOR expr { $$ = DEBUG_BinopExpr(EXP_OP_LOR, $1, $3); }
344 | expr OP_LAND expr { $$ = DEBUG_BinopExpr(EXP_OP_LAND, $1, $3); }
345 | expr '|' expr { $$ = DEBUG_BinopExpr(EXP_OP_OR, $1, $3); }
346 | expr '&' expr { $$ = DEBUG_BinopExpr(EXP_OP_AND, $1, $3); }
347 | expr '^' expr { $$ = DEBUG_BinopExpr(EXP_OP_XOR, $1, $3); }
348 | expr OP_EQ expr { $$ = DEBUG_BinopExpr(EXP_OP_EQ, $1, $3); }
349 | expr '>' expr { $$ = DEBUG_BinopExpr(EXP_OP_GT, $1, $3); }
350 | expr '<' expr { $$ = DEBUG_BinopExpr(EXP_OP_LT, $1, $3); }
351 | expr OP_GE expr { $$ = DEBUG_BinopExpr(EXP_OP_GE, $1, $3); }
352 | expr OP_LE expr { $$ = DEBUG_BinopExpr(EXP_OP_LE, $1, $3); }
353 | expr OP_NE expr { $$ = DEBUG_BinopExpr(EXP_OP_NE, $1, $3); }
354 | expr OP_SHL expr { $$ = DEBUG_BinopExpr(EXP_OP_SHL, $1, $3); }
355 | expr OP_SHR expr { $$ = DEBUG_BinopExpr(EXP_OP_SHR, $1, $3); }
356 | expr '+' expr { $$ = DEBUG_BinopExpr(EXP_OP_ADD, $1, $3); }
357 | expr '-' expr { $$ = DEBUG_BinopExpr(EXP_OP_SUB, $1, $3); }
358 | expr '*' expr { $$ = DEBUG_BinopExpr(EXP_OP_MUL, $1, $3); }
359 | expr '/' expr { $$ = DEBUG_BinopExpr(EXP_OP_DIV, $1, $3); }
360 | expr '%' expr { $$ = DEBUG_BinopExpr(EXP_OP_REM, $1, $3); }
361 | '-' expr %prec OP_SIGN { $$ = DEBUG_UnopExpr(EXP_OP_NEG, $2); }
362 | '+' expr %prec OP_SIGN { $$ = $2; }
363 | '!' expr { $$ = DEBUG_UnopExpr(EXP_OP_NOT, $2); }
364 | '~' expr { $$ = DEBUG_UnopExpr(EXP_OP_LNOT, $2); }
365 | '(' expr ')' { $$ = $2; }
366 | '*' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_DEREF, $2); }
367 | '&' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_ADDR, $2); }
368 | type_cast expr %prec OP_DEREF { $$ = DEBUG_TypeCastExpr($1, $2); }
371 * The lvalue rule builds an expression tree. This is a limited form
372 * of expression that is suitable to be used as an lvalue.
374 lval_addr:
375 lval { $$ = DEBUG_EvalExpr($1); }
377 lval:
378 lvalue { $$ = $1; }
379 | '*' expr { $$ = DEBUG_UnopExpr(EXP_OP_FORCE_DEREF, $2); }
381 lvalue:
382 tNUM { $$ = DEBUG_ConstExpr($1); }
383 | tREG { $$ = DEBUG_RegisterExpr($1); }
384 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
385 | lvalue OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
386 | lvalue '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
387 | lvalue '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
391 void
392 issue_prompt(){
393 #ifdef DONT_USE_READLINE
394 fprintf(stderr,"Wine-dbg>");
395 #endif
398 void mode_command(int newmode)
400 if ((newmode == 16) || (newmode == 32)) dbg_mode = newmode;
401 else fprintf(stderr,"Invalid mode (use 16 or 32)\n");
405 /***********************************************************************
406 * DEBUG_Main
408 * Debugger main loop.
410 static void DEBUG_Main( int signal )
412 static int loaded_symbols = 0;
413 static BOOL32 in_debugger = FALSE;
414 char SymbolTableFile[256];
415 int newmode;
416 BOOL32 ret_ok;
417 #ifdef YYDEBUG
418 yydebug = 0;
419 #endif
421 if (in_debugger)
423 fprintf( stderr, "Segmentation fault inside debugger, exiting.\n" );
424 exit(1);
426 in_debugger = TRUE;
427 yyin = stdin;
429 DEBUG_SetBreakpoints( FALSE );
431 if (!loaded_symbols)
433 loaded_symbols++;
436 * Initialize the type handling stuff.
438 DEBUG_InitTypes();
441 * In some cases we can read the stabs information directly
442 * from the executable. If this is the case, we don't need
443 * to bother with trying to read a symbol file, as the stabs
444 * also have line number and local variable information.
445 * As long as gcc is used for the compiler, stabs will
446 * be the default. On SVr4, DWARF could be used, but we
447 * don't grok that yet, and in this case we fall back to using
448 * the wine.sym file.
450 if( DEBUG_ReadExecutableDbgInfo() == FALSE )
452 char *symfilename = "wine.sym";
453 struct stat statbuf;
454 if (-1 == stat(symfilename, &statbuf) )
455 symfilename = LIBDIR "wine.sym";
457 PROFILE_GetWineIniString( "wine", "SymbolTableFile", symfilename,
458 SymbolTableFile, sizeof(SymbolTableFile));
459 DEBUG_ReadSymbolTable( SymbolTableFile );
462 DEBUG_LoadEntryPoints();
463 DEBUG_ProcessDeferredDebug();
466 #if 0
467 fprintf(stderr, "Entering debugger PC=%x, mode=%d, count=%d\n",
468 EIP_reg(&DEBUG_context),
469 dbg_exec_mode, dbg_exec_count);
471 sleep(1);
472 #endif
474 if ((signal != SIGTRAP) || !DEBUG_ShouldContinue( dbg_exec_mode,
475 &dbg_exec_count ))
477 DBG_ADDR addr;
478 TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
480 addr.seg = CS_reg(&DEBUG_context);
481 addr.off = EIP_reg(&DEBUG_context);
482 if (ISV86(&DEBUG_context)) addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
483 addr.type = NULL;
484 DBG_FIX_ADDR_SEG( &addr, 0 );
486 GlobalUnlock16( GetCurrentTask() );
488 /* Put the display in a correct state */
490 TSXUngrabServer( display );
491 TSXFlush( display );
493 newmode = ISV86(&DEBUG_context) ? 16 : IS_SELECTOR_32BIT(addr.seg) ? 32 : 16;
494 if (newmode != dbg_mode)
495 fprintf(stderr,"In %d bit mode.\n", dbg_mode = newmode);
497 PROCESS_SuspendOtherThreads();
499 DEBUG_DoDisplay();
501 if (signal != SIGTRAP) /* This is a real crash, dump some info */
503 DEBUG_InfoRegisters();
504 DEBUG_InfoStack();
505 if (dbg_mode == 16)
507 LDT_Print( SELECTOR_TO_ENTRY(DS_reg(&DEBUG_context)), 1 );
508 if (ES_reg(&DEBUG_context) != DS_reg(&DEBUG_context))
509 LDT_Print( SELECTOR_TO_ENTRY(ES_reg(&DEBUG_context)), 1 );
511 DEBUG_BackTrace();
513 else
516 * Do a quiet backtrace so that we have an idea of what the situation
517 * is WRT the source files.
519 DEBUG_SilentBackTrace();
522 if ((signal != SIGTRAP) ||
523 (dbg_exec_mode == EXEC_STEPI_OVER) ||
524 (dbg_exec_mode == EXEC_STEPI_INSTR))
526 /* Show where we crashed */
527 curr_frame = 0;
528 DEBUG_PrintAddress( &addr, dbg_mode, TRUE );
529 fprintf(stderr,": ");
530 if (DBG_CHECK_READ_PTR( &addr, 1 ))
532 DEBUG_Disasm( &addr, TRUE );
533 fprintf(stderr,"\n");
537 ret_ok = 0;
540 issue_prompt();
541 yyparse();
542 flush_symbols();
543 addr.seg = CS_reg(&DEBUG_context) | (addr.seg&0xffff0000);
544 addr.off = EIP_reg(&DEBUG_context);
545 DBG_FIX_ADDR_SEG( &addr, 0 );
546 ret_ok = DEBUG_ValidateRegisters();
547 if (ret_ok) ret_ok = DBG_CHECK_READ_PTR( &addr, 1 );
548 } while (!ret_ok);
551 dbg_exec_mode = DEBUG_RestartExecution( dbg_exec_mode, dbg_exec_count );
553 * This will have gotten absorbed into the breakpoint info
554 * if it was used. Otherwise it would have been ignored.
555 * In any case, we don't mess with it any more.
557 if( dbg_exec_mode == EXEC_CONT )
559 dbg_exec_count = 0;
560 PROCESS_ResumeOtherThreads();
563 in_debugger = FALSE;
568 /***********************************************************************
569 * DebugBreak (KERNEL.203) (KERNEL32.181)
571 void DebugBreak( CONTEXT *regs )
573 char module[10];
574 if (!GetModuleName( GetCurrentTask(), module, sizeof(module) ))
575 strcpy( module, "???" );
576 fprintf( stderr, "%s called DebugBreak\n", module );
577 DEBUG_context = *regs;
578 DEBUG_Main( SIGTRAP );
582 void ctx_debug( int signal, CONTEXT *regs )
584 DEBUG_context = *regs;
585 DEBUG_Main( signal );
586 *regs = DEBUG_context;
589 void wine_debug( int signal, SIGCONTEXT *regs )
591 #if 0
592 DWORD *stack = (DWORD *)ESP_sig(regs);
593 *(--stack) = 0;
594 *(--stack) = 0;
595 *(--stack) = EH_NONCONTINUABLE;
596 *(--stack) = EXCEPTION_ACCESS_VIOLATION;
597 *(--stack) = EIP_sig(regs);
598 ESP_sig(regs) = (DWORD)stack;
599 EIP_sig(regs) = (DWORD)RaiseException;
600 #else
601 DEBUG_SetSigContext( regs );
602 DEBUG_Main( signal );
603 DEBUG_GetSigContext( regs );
604 #endif
607 int yyerror(char * s)
609 fprintf(stderr,"%s\n", s);
610 return 0;