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