SendASPI32Command32 has to be __cdecl.
[wine/multimedia.git] / debugger / dbg.y
blob092bc63bdfbd8656e45bcb2edb66b88c6ac5f674
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"
26 #include "ts_xlib.h"
28 #include "expr.h"
30 extern FILE * yyin;
31 unsigned int dbg_mode = 0;
32 int curr_frame = 0;
34 static enum exec_mode dbg_exec_mode = EXEC_CONT;
35 static int dbg_exec_count = 0;
37 void issue_prompt(void);
38 void mode_command(int);
39 void flush_symbols(void);
40 int yylex(void);
41 int yyerror(char *);
43 extern void VIRTUAL_Dump(void); /* memory/virtual.c */
47 %union
49 DBG_ADDR address;
50 enum debug_regs reg;
51 char * string;
52 int integer;
53 struct list_id listing;
54 struct expr * expression;
55 struct datatype * type;
58 %token tCONT tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
59 %token tENABLE tDISABLE tBREAK tDELETE tSET tMODE tPRINT tEXAM tABORT
60 %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
61 %token tEOL tSTRING
62 %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
63 %token tSTEPI tNEXTI tFINISH tSHOW tDIR
64 %token <string> tPATH
65 %token <string> tIDENTIFIER tSTRING
66 %token <integer> tNUM tFORMAT
67 %token <reg> tREG
69 %token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED
70 %token tSTRUCT tUNION tENUM
72 /* %left ',' */
73 /* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
74 OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
75 OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
76 /* %left OP_COND */ /* ... ? ... : ... */
77 %left OP_LOR
78 %left OP_LAND
79 %left '|'
80 %left '^'
81 %left '&'
82 %left OP_EQ OP_NE
83 %left '<' '>' OP_LE OP_GE
84 %left OP_SHL OP_SHR
85 %left '+' '-'
86 %left '*' '/' '%'
87 %left OP_SIGN '!' '~' OP_DEREF /* OP_INC OP_DEC OP_ADDR */
88 %left '.' '[' OP_DRF
89 %nonassoc ':'
91 %type <expression> expr lval lvalue
92 %type <type> type_cast type_expr
93 %type <address> expr_addr lval_addr
94 %type <integer> expr_value
95 %type <string> pathname
97 %type <listing> list_arg
101 input: line { issue_prompt(); }
102 | input line { issue_prompt(); }
104 line: command
105 | tEOL
106 | error tEOL { yyerrok; }
108 command:
109 tQUIT tEOL { exit(0); }
110 | tHELP tEOL { DEBUG_Help(); }
111 | tHELP tINFO tEOL { DEBUG_HelpInfo(); }
112 | tCONT tEOL { dbg_exec_count = 1;
113 dbg_exec_mode = EXEC_CONT; return 0; }
114 | tCONT tNUM tEOL { dbg_exec_count = $2;
115 dbg_exec_mode = EXEC_CONT; return 0; }
116 | tSTEP tEOL { dbg_exec_count = 1;
117 dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
118 | tNEXT tEOL { dbg_exec_count = 1;
119 dbg_exec_mode = EXEC_STEP_OVER; return 0; }
120 | tSTEP tNUM tEOL { dbg_exec_count = $2;
121 dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
122 | tNEXT tNUM tEOL { dbg_exec_count = $2;
123 dbg_exec_mode = EXEC_STEP_OVER; return 0; }
124 | tSTEPI tEOL { dbg_exec_count = 1;
125 dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
126 | tNEXTI tEOL { dbg_exec_count = 1;
127 dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
128 | tSTEPI tNUM tEOL { dbg_exec_count = $2;
129 dbg_exec_mode = EXEC_STEPI_INSTR; return 0; }
130 | tNEXTI tNUM tEOL { dbg_exec_count = $2;
131 dbg_exec_mode = EXEC_STEPI_OVER; return 0; }
132 | tABORT tEOL { kill(getpid(), SIGABRT); }
133 | tMODE tNUM tEOL { mode_command($2); }
134 | tENABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, TRUE ); }
135 | tDISABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, FALSE ); }
136 | tDELETE tBREAK tNUM tEOL { DEBUG_DelBreakpoint( $3 ); }
137 | tBACKTRACE tEOL { DEBUG_BackTrace(); }
138 | tUP tEOL { DEBUG_SetFrame( curr_frame + 1 ); }
139 | tUP tNUM tEOL { DEBUG_SetFrame( curr_frame + $2 ); }
140 | tDOWN tEOL { DEBUG_SetFrame( curr_frame - 1 ); }
141 | tDOWN tNUM tEOL { DEBUG_SetFrame( curr_frame - $2 ); }
142 | tFRAME tNUM tEOL { DEBUG_SetFrame( $2 ); }
143 | tFINISH tEOL { dbg_exec_count = 0;
144 dbg_exec_mode = EXEC_FINISH; return 0; }
145 | tSHOW tDIR tEOL { DEBUG_ShowDir(); }
146 | tDIR pathname tEOL { DEBUG_AddPath( $2 ); }
147 | tDIR tEOL { DEBUG_NukePath(); }
148 | tDISPLAY tEOL { DEBUG_InfoDisplay(); }
149 | tDISPLAY expr tEOL { DEBUG_AddDisplay($2, 1, 0); }
150 | tDISPLAY tFORMAT expr tEOL { DEBUG_AddDisplay($3, $2 >> 8, $2 & 0xff); }
151 | tDELETE tDISPLAY tNUM tEOL { DEBUG_DelDisplay( $3 ); }
152 | tDELETE tDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
153 | tUNDISPLAY tNUM tEOL { DEBUG_DelDisplay( $2 ); }
154 | tUNDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
155 | tCOND tNUM tEOL { DEBUG_AddBPCondition($2, NULL); }
156 | tCOND tNUM expr tEOL { DEBUG_AddBPCondition($2, $3); }
157 | list_command
158 | disassemble_command
159 | set_command
160 | x_command
161 | print_command
162 | break_command
163 | info_command
164 | walk_command
166 set_command:
167 tSET tREG '=' expr_value tEOL { DEBUG_SetRegister( $2, $4 );
168 DEBUG_FreeExprMem(); }
169 | tSET lval_addr '=' expr_value tEOL { DEBUG_WriteMemory( &$2, $4 );
170 DEBUG_FreeExprMem(); }
172 pathname:
173 tIDENTIFIER { $$ = $1; }
174 | tPATH { $$ = $1; }
176 disassemble_command:
177 tDISASSEMBLE tEOL { DEBUG_Disassemble( NULL, NULL, 10 ); }
178 | tDISASSEMBLE expr_addr tEOL { DEBUG_Disassemble( & $2, NULL, 10 ); }
179 | tDISASSEMBLE expr_addr ',' expr_addr tEOL { DEBUG_Disassemble( & $2, & $4, 0 ); }
181 list_command:
182 tLIST tEOL { DEBUG_List( NULL, NULL, 10 ); }
183 | tLIST '-' tEOL { DEBUG_List( NULL, NULL, -10 ); }
184 | tLIST list_arg tEOL { DEBUG_List( & $2, NULL, 10 ); }
185 | tLIST ',' list_arg tEOL { DEBUG_List( NULL, & $3, -10 ); }
186 | tLIST list_arg ',' list_arg tEOL { DEBUG_List( & $2, & $4, 0 ); }
188 list_arg:
189 tNUM { $$.sourcefile = NULL; $$.line = $1; }
190 | pathname ':' tNUM { $$.sourcefile = $1; $$.line = $3; }
191 | tIDENTIFIER { DEBUG_GetFuncInfo( & $$, NULL, $1); }
192 | pathname ':' tIDENTIFIER { DEBUG_GetFuncInfo( & $$, $1, $3); }
193 | '*' expr_addr { DEBUG_FindNearestSymbol( & $2, FALSE, NULL,
194 0, & $$ );
195 DEBUG_FreeExprMem(); }
197 x_command:
198 tEXAM expr_addr tEOL { DEBUG_ExamineMemory( &$2, 1, 'x');
199 DEBUG_FreeExprMem(); }
200 | tEXAM tFORMAT expr_addr tEOL { DEBUG_ExamineMemory( &$3, $2>>8, $2&0xff );
201 DEBUG_FreeExprMem(); }
203 print_command:
204 tPRINT expr_addr tEOL { DEBUG_Print( &$2, 1, 0, 0 );
205 DEBUG_FreeExprMem(); }
206 | tPRINT tFORMAT expr_addr tEOL { DEBUG_Print( &$3, $2 >> 8, $2 & 0xff, 0 );
207 DEBUG_FreeExprMem(); }
209 break_command:
210 tBREAK '*' expr_addr tEOL { DEBUG_AddBreakpoint( &$3 );
211 DEBUG_FreeExprMem(); }
212 | tBREAK tIDENTIFIER tEOL { DBG_ADDR addr;
213 if( DEBUG_GetSymbolValue($2, -1, &addr, TRUE) )
215 DEBUG_AddBreakpoint( &addr );
217 else
219 fprintf(stderr,"Unable to add breakpoint\n");
222 | tBREAK tIDENTIFIER ':' tNUM tEOL { DBG_ADDR addr;
223 if( DEBUG_GetSymbolValue($2, $4, &addr, TRUE) )
225 DEBUG_AddBreakpoint( &addr );
227 else
229 fprintf(stderr,"Unable to add breakpoint\n");
232 | tBREAK tNUM tEOL { struct name_hash *nh;
233 DBG_ADDR addr = { NULL,
234 CS_reg(&DEBUG_context),
235 EIP_reg(&DEBUG_context) };
236 TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
237 if (ISV86(&DEBUG_context))
238 addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
239 DBG_FIX_ADDR_SEG( &addr, CS_reg(&DEBUG_context) );
240 GlobalUnlock16( GetCurrentTask() );
241 DEBUG_FindNearestSymbol(&addr, TRUE,
242 &nh, 0, NULL);
243 if( nh != NULL )
245 DEBUG_GetLineNumberAddr(nh,
246 $2, &addr, TRUE);
247 DEBUG_AddBreakpoint( &addr );
249 else
251 fprintf(stderr,"Unable to add breakpoint\n");
255 | tBREAK tEOL { DBG_ADDR addr = { NULL,
256 CS_reg(&DEBUG_context),
257 EIP_reg(&DEBUG_context) };
258 TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
259 if (ISV86(&DEBUG_context))
260 addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
261 GlobalUnlock16( GetCurrentTask() );
262 DEBUG_AddBreakpoint( &addr );
265 info_command:
266 tINFO tBREAK tEOL { DEBUG_InfoBreakpoints(); }
267 | tINFO tCLASS expr_value tEOL { CLASS_DumpClass( (CLASS *)$3 );
268 DEBUG_FreeExprMem(); }
269 | tINFO tSHARE tEOL { DEBUG_InfoShare(); }
270 | tINFO tMODULE expr_value tEOL { NE_DumpModule( $3 );
271 DEBUG_FreeExprMem(); }
272 | tINFO tQUEUE expr_value tEOL { QUEUE_DumpQueue( $3 );
273 DEBUG_FreeExprMem(); }
274 | tINFO tREGS tEOL { DEBUG_InfoRegisters(); }
275 | tINFO tSEGMENTS expr_value tEOL { LDT_Print( SELECTOR_TO_ENTRY($3), 1 );
276 DEBUG_FreeExprMem(); }
277 | tINFO tSEGMENTS tEOL { LDT_Print( 0, -1 ); }
278 | tINFO tSTACK tEOL { DEBUG_InfoStack(); }
279 | tINFO tMAPS tEOL { VIRTUAL_Dump(); }
280 | tINFO tWND expr_value tEOL { WIN_DumpWindow( $3 );
281 DEBUG_FreeExprMem(); }
282 | tINFO tLOCAL tEOL { DEBUG_InfoLocals(); }
283 | tINFO tDISPLAY tEOL { DEBUG_InfoDisplay(); }
285 walk_command:
286 tWALK tCLASS tEOL { CLASS_WalkClasses(); }
287 | tWALK tMODULE tEOL { NE_WalkModules(); }
288 | tWALK tQUEUE tEOL { QUEUE_WalkQueues(); }
289 | tWALK tWND tEOL { WIN_WalkWindows( 0, 0 ); }
290 | tWALK tWND tNUM tEOL { WIN_WalkWindows( $3, 0 ); }
293 type_cast:
294 '(' type_expr ')' { $$ = $2; }
296 type_expr:
297 type_expr '*' { $$ = DEBUG_FindOrMakePointerType($1); }
298 | tINT { $$ = DEBUG_TypeCast(DT_BASIC, "int"); }
299 | tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "char"); }
300 | tLONG tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long int"); }
301 | tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "unsigned int"); }
302 | tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long unsigned int"); }
303 | tLONG tLONG tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long long int"); }
304 | tLONG tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long long unsigned int"); }
305 | tSHORT tINT { $$ = DEBUG_TypeCast(DT_BASIC, "short int"); }
306 | tSHORT tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "short unsigned int"); }
307 | tSIGNED tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "signed char"); }
308 | tUNSIGNED tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "unsigned char"); }
309 | tFLOAT { $$ = DEBUG_TypeCast(DT_BASIC, "float"); }
310 | tDOUBLE { $$ = DEBUG_TypeCast(DT_BASIC, "double"); }
311 | tLONG tDOUBLE { $$ = DEBUG_TypeCast(DT_BASIC, "long double"); }
312 | tSTRUCT tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
313 | tUNION tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
314 | tENUM tIDENTIFIER { $$ = DEBUG_TypeCast(DT_ENUM, $2); }
316 expr_addr:
317 expr { $$ = DEBUG_EvalExpr($1); }
319 expr_value:
320 expr { DBG_ADDR addr = DEBUG_EvalExpr($1);
321 $$ = addr.off ? *(unsigned int *) addr.off : 0; }
323 * The expr rule builds an expression tree. When we are done, we call
324 * EvalExpr to evaluate the value of the expression. The advantage of
325 * the two-step approach is that it is possible to save expressions for
326 * use in 'display' commands, and in conditional watchpoints.
328 expr:
329 tNUM { $$ = DEBUG_ConstExpr($1); }
330 | tSTRING { $$ = DEBUG_StringExpr($1); }
331 | tREG { $$ = DEBUG_RegisterExpr($1); }
332 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
333 | expr OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
334 | expr '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
335 | tIDENTIFIER '(' ')' { $$ = DEBUG_CallExpr($1, 0); }
336 | tIDENTIFIER '(' expr ')' { $$ = DEBUG_CallExpr($1, 1, $3); }
337 | tIDENTIFIER '(' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 2, $3,
338 $5); }
339 | tIDENTIFIER '(' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7); }
340 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9); }
341 | tIDENTIFIER '(' expr ',' expr ',' expr ',' expr ',' expr ')' { $$ = DEBUG_CallExpr($1, 3, $3, $5, $7, $9, $11); }
342 | expr '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
343 | expr ':' expr { $$ = DEBUG_BinopExpr(EXP_OP_SEG, $1, $3); }
344 | expr OP_LOR expr { $$ = DEBUG_BinopExpr(EXP_OP_LOR, $1, $3); }
345 | expr OP_LAND expr { $$ = DEBUG_BinopExpr(EXP_OP_LAND, $1, $3); }
346 | expr '|' expr { $$ = DEBUG_BinopExpr(EXP_OP_OR, $1, $3); }
347 | expr '&' expr { $$ = DEBUG_BinopExpr(EXP_OP_AND, $1, $3); }
348 | expr '^' expr { $$ = DEBUG_BinopExpr(EXP_OP_XOR, $1, $3); }
349 | expr OP_EQ expr { $$ = DEBUG_BinopExpr(EXP_OP_EQ, $1, $3); }
350 | expr '>' expr { $$ = DEBUG_BinopExpr(EXP_OP_GT, $1, $3); }
351 | expr '<' expr { $$ = DEBUG_BinopExpr(EXP_OP_LT, $1, $3); }
352 | expr OP_GE expr { $$ = DEBUG_BinopExpr(EXP_OP_GE, $1, $3); }
353 | expr OP_LE expr { $$ = DEBUG_BinopExpr(EXP_OP_LE, $1, $3); }
354 | expr OP_NE expr { $$ = DEBUG_BinopExpr(EXP_OP_NE, $1, $3); }
355 | expr OP_SHL expr { $$ = DEBUG_BinopExpr(EXP_OP_SHL, $1, $3); }
356 | expr OP_SHR expr { $$ = DEBUG_BinopExpr(EXP_OP_SHR, $1, $3); }
357 | expr '+' expr { $$ = DEBUG_BinopExpr(EXP_OP_ADD, $1, $3); }
358 | expr '-' expr { $$ = DEBUG_BinopExpr(EXP_OP_SUB, $1, $3); }
359 | expr '*' expr { $$ = DEBUG_BinopExpr(EXP_OP_MUL, $1, $3); }
360 | expr '/' expr { $$ = DEBUG_BinopExpr(EXP_OP_DIV, $1, $3); }
361 | expr '%' expr { $$ = DEBUG_BinopExpr(EXP_OP_REM, $1, $3); }
362 | '-' expr %prec OP_SIGN { $$ = DEBUG_UnopExpr(EXP_OP_NEG, $2); }
363 | '+' expr %prec OP_SIGN { $$ = $2; }
364 | '!' expr { $$ = DEBUG_UnopExpr(EXP_OP_NOT, $2); }
365 | '~' expr { $$ = DEBUG_UnopExpr(EXP_OP_LNOT, $2); }
366 | '(' expr ')' { $$ = $2; }
367 | '*' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_DEREF, $2); }
368 | '&' expr %prec OP_DEREF { $$ = DEBUG_UnopExpr(EXP_OP_ADDR, $2); }
369 | type_cast expr %prec OP_DEREF { $$ = DEBUG_TypeCastExpr($1, $2); }
372 * The lvalue rule builds an expression tree. This is a limited form
373 * of expression that is suitable to be used as an lvalue.
375 lval_addr:
376 lval { $$ = DEBUG_EvalExpr($1); }
378 lval:
379 lvalue { $$ = $1; }
380 | '*' expr { $$ = DEBUG_UnopExpr(EXP_OP_FORCE_DEREF, $2); }
382 lvalue:
383 tNUM { $$ = DEBUG_ConstExpr($1); }
384 | tREG { $$ = DEBUG_RegisterExpr($1); }
385 | tIDENTIFIER { $$ = DEBUG_SymbolExpr($1); }
386 | lvalue OP_DRF tIDENTIFIER { $$ = DEBUG_StructPExpr($1, $3); }
387 | lvalue '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); }
388 | lvalue '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); }
392 void
393 issue_prompt(){
394 #ifdef DONT_USE_READLINE
395 fprintf(stderr,"Wine-dbg>");
396 #endif
399 void mode_command(int newmode)
401 if ((newmode == 16) || (newmode == 32)) dbg_mode = newmode;
402 else fprintf(stderr,"Invalid mode (use 16 or 32)\n");
406 /***********************************************************************
407 * DEBUG_Main
409 * Debugger main loop.
411 static void DEBUG_Main( int signal )
413 static int loaded_symbols = 0;
414 static BOOL32 in_debugger = FALSE;
415 char SymbolTableFile[256];
416 int newmode;
417 BOOL32 ret_ok;
418 #ifdef YYDEBUG
419 yydebug = 0;
420 #endif
422 if (in_debugger)
424 fprintf( stderr, "Segmentation fault inside debugger, exiting.\n" );
425 exit(1);
427 in_debugger = TRUE;
428 yyin = stdin;
430 DEBUG_SetBreakpoints( FALSE );
432 if (!loaded_symbols)
434 loaded_symbols++;
437 * Initialize the type handling stuff.
439 DEBUG_InitTypes();
442 * In some cases we can read the stabs information directly
443 * from the executable. If this is the case, we don't need
444 * to bother with trying to read a symbol file, as the stabs
445 * also have line number and local variable information.
446 * As long as gcc is used for the compiler, stabs will
447 * be the default. On SVr4, DWARF could be used, but we
448 * don't grok that yet, and in this case we fall back to using
449 * the wine.sym file.
451 if( DEBUG_ReadExecutableDbgInfo() == FALSE )
453 char *symfilename = "wine.sym";
454 struct stat statbuf;
455 if (-1 == stat(symfilename, &statbuf) )
456 symfilename = LIBDIR "wine.sym";
458 PROFILE_GetWineIniString( "wine", "SymbolTableFile", symfilename,
459 SymbolTableFile, sizeof(SymbolTableFile));
460 DEBUG_ReadSymbolTable( SymbolTableFile );
463 DEBUG_LoadEntryPoints();
464 DEBUG_ProcessDeferredDebug();
467 #if 0
468 fprintf(stderr, "Entering debugger PC=%x, mode=%d, count=%d\n",
469 EIP_reg(&DEBUG_context),
470 dbg_exec_mode, dbg_exec_count);
472 sleep(1);
473 #endif
475 if ((signal != SIGTRAP) || !DEBUG_ShouldContinue( dbg_exec_mode,
476 &dbg_exec_count ))
478 DBG_ADDR addr;
479 TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
481 addr.seg = CS_reg(&DEBUG_context);
482 addr.off = EIP_reg(&DEBUG_context);
483 if (ISV86(&DEBUG_context)) addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
484 addr.type = NULL;
485 DBG_FIX_ADDR_SEG( &addr, 0 );
487 GlobalUnlock16( GetCurrentTask() );
489 /* Put the display in a correct state */
491 TSXUngrabServer( display );
492 TSXFlush( display );
494 newmode = ISV86(&DEBUG_context) ? 16 : IS_SELECTOR_32BIT(addr.seg) ? 32 : 16;
495 if (newmode != dbg_mode)
496 fprintf(stderr,"In %d bit mode.\n", dbg_mode = newmode);
498 PROCESS_SuspendOtherThreads();
500 DEBUG_DoDisplay();
502 if (signal != SIGTRAP) /* This is a real crash, dump some info */
504 DEBUG_InfoRegisters();
505 DEBUG_InfoStack();
506 if (dbg_mode == 16)
508 LDT_Print( SELECTOR_TO_ENTRY(DS_reg(&DEBUG_context)), 1 );
509 if (ES_reg(&DEBUG_context) != DS_reg(&DEBUG_context))
510 LDT_Print( SELECTOR_TO_ENTRY(ES_reg(&DEBUG_context)), 1 );
512 DEBUG_BackTrace();
514 else
517 * Do a quiet backtrace so that we have an idea of what the situation
518 * is WRT the source files.
520 DEBUG_SilentBackTrace();
523 if ((signal != SIGTRAP) ||
524 (dbg_exec_mode == EXEC_STEPI_OVER) ||
525 (dbg_exec_mode == EXEC_STEPI_INSTR))
527 /* Show where we crashed */
528 curr_frame = 0;
529 DEBUG_PrintAddress( &addr, dbg_mode, TRUE );
530 fprintf(stderr,": ");
531 if (DBG_CHECK_READ_PTR( &addr, 1 ))
533 DEBUG_Disasm( &addr, TRUE );
534 fprintf(stderr,"\n");
538 ret_ok = 0;
541 issue_prompt();
542 yyparse();
543 flush_symbols();
544 addr.seg = CS_reg(&DEBUG_context) | (addr.seg&0xffff0000);
545 addr.off = EIP_reg(&DEBUG_context);
546 DBG_FIX_ADDR_SEG( &addr, 0 );
547 ret_ok = DEBUG_ValidateRegisters();
548 if (ret_ok) ret_ok = DBG_CHECK_READ_PTR( &addr, 1 );
549 } while (!ret_ok);
552 dbg_exec_mode = DEBUG_RestartExecution( dbg_exec_mode, dbg_exec_count );
554 * This will have gotten absorbed into the breakpoint info
555 * if it was used. Otherwise it would have been ignored.
556 * In any case, we don't mess with it any more.
558 if( dbg_exec_mode == EXEC_CONT )
560 dbg_exec_count = 0;
561 PROCESS_ResumeOtherThreads();
564 in_debugger = FALSE;
569 /***********************************************************************
570 * DebugBreak (KERNEL.203) (KERNEL32.181)
572 void DebugBreak( CONTEXT *regs )
574 char module[10];
575 if (!GetModuleName( GetCurrentTask(), module, sizeof(module) ))
576 strcpy( module, "???" );
577 fprintf( stderr, "%s called DebugBreak\n", module );
578 DEBUG_context = *regs;
579 DEBUG_Main( SIGTRAP );
583 void ctx_debug( int signal, CONTEXT *regs )
585 DEBUG_context = *regs;
586 DEBUG_Main( signal );
587 *regs = DEBUG_context;
590 void wine_debug( int signal, SIGCONTEXT *regs )
592 #if 0
593 DWORD *stack = (DWORD *)ESP_sig(regs);
594 *(--stack) = 0;
595 *(--stack) = 0;
596 *(--stack) = EH_NONCONTINUABLE;
597 *(--stack) = EXCEPTION_ACCESS_VIOLATION;
598 *(--stack) = EIP_sig(regs);
599 ESP_sig(regs) = (DWORD)stack;
600 EIP_sig(regs) = (DWORD)RaiseException;
601 #else
602 DEBUG_SetSigContext( regs );
603 DEBUG_Main( signal );
604 DEBUG_GetSigContext( regs );
605 #endif
608 int yyerror(char * s)
610 fprintf(stderr,"%s\n", s);
611 return 0;