Skip to content
Snippets Groups Projects
Forked from wine / wine
176065 commits behind the upstream repository.
  • Alexandre Julliard's avatar
    2ace16ac
    Release 960428 · 2ace16ac
    Alexandre Julliard authored
    Sun Apr 28 14:32:43 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>
    
    	* [Makefile.in]
    	Subdir memory is now also compiled for Winelib, in order to get
    	the Win32 heap functions.
    
    	* [if1632/Makefile.in]
    	Renamed winprocs and winprocs32 to wprocs and wprocs32 to avoid
    	DLL names > 8 characters.
    
    	* [loader/builtin.c] (New file)
    	Grouped all built-in DLLs code in a single file.
    
    	* [memory/global.c]
    	Use the Win32 heap code instead of malloc() to allocate linear
    	memory. This will help test the heap code.
    
    	* [memory/local.c]
    	Fixed FreeSelector() to clear DS and ES correctly for huge blocks.
    
    	* [tools/build.c] [if1632/relay.c]
    	Removed 'id' directive in spec files. For relay debugging, the DLL
    	entry point is now computed from the CS:IP entry point address.
    	Added 'heap' directive to specifiy a local heap for the DLL. USER
    	and GDI heap are now created this way.
    
    	* [windows/class.c] [include/class.h]
    	Changed the class structure to use pointers instead of handles.
    	Changed Get/SetClassWord/Long to use a switch statement; this
    	allows changing the layout of the CLASS structure.
    
    	* [windows/win.c] [include/win.h]
    	Use a CLASS * instead of a handle for the window class.
    
    Sat Apr 27 18:10:11 Martin von Loewis <loewis@informatik.hu-berlin.de>
    
    	* [if1632/kernel32.spec] [memory/global.c]
    	  [win32/memory.c] [win32/process.c]
    	GetProcessAffinityMask,GlobalLock,IsBadReadPtr,IsBadWritePtr,
    	LocalLock,SetThreadAffinityMask: new relays.
    
    	* [win32/cursoricon32.c]
    	Return same handle if a cursor is loaded multiple times.
    
    Sat Apr 27 15:13:37 1996  Bang Jun Young <bangjy@nownuri.nowcom.co.kr>
    
    	* [resources/sysres_Ko.rc]
            Added support for Korean [Ko] language.
    
    Fri Apr 26 00:49:05 1996  Huw D. M. Davies <h.davies1@physics.oxford.ac.uk>
    
    	* [objects/dc.c] [objects/font.c]
    	Fixed problem with SaveDC()/RestoreDC() and font cache 'used' count.
    
    	* [objects/metafile.c] [objects/dcvalues.c]
    	Fixed broken SetTextAlign() on metafiles.
    
    	* [objects/metafile.c]
    	Delete objects in handle table at end of PlayMetaFile().
    
    Wed Apr 24 19:21:01  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
    
    	* [if1632/ver.spec] [misc/ver.c] [include/ver.h] (New files)
    	VER.DLL (partially) implemented (VerFindFile,VerInstallFile)
    	[If it doesn't work for you, use -dll -ver and report it to me]
    
    	* [if1632/user32.spec] [if1632/kernel32.spec] [if1632/shell.spec]
    	  [if1632/shell32.spec] [misc/ole2nls.c] [windows/message.c]
    	  [windows/graphics.c]
    	Simple win32 functions, where we can just use the win16 counterpart.
    	Misc. stubs. 
    
    	* [misc/lstr.c]
    	Someone reported a _lstrlen(NULL). NULL is a valid argument. Fixed.
    
    	* [misc/registry.c]
    	Some alloclens were off by 1, one double fclose() fixed.
    	Requesting value 0 of a key with no values returns an error 
    	(should we always return a made up value NULL? what does win3.1?)
    
    Tue Apr 23 17:00:00 1996 Alex Korobka <alex@phm30.pharm.sunysb.edu>
    
    	* [misc/shell.c]
    	Implemented FindEnvironmentString(), DoEnvironmentSubst(),
    	ExtractIcon(), InternalExtractIcon() and ExtractAssociatedIcon().
    
    	* [misc/user.c]
    	Do extensive cleanup on application exit.
    
    	* [windows/hook.c] [windows/win.c] [windows/class.c]
    	Added miscellaneous cleanup routines.
    
    	* [controls/menu.c]
    	More efficient popup menu window handling.
    
    Mon Apr 22 21:35:22 1996  Albrecht Kleine  <kleine@ak.sax.de>
    
    	* [include/windows.h][objects/oembitmap.c][include/bitmaps/obm_trtype]
    	Added "TT-bitmap" for later usage in a ChooseFont() ownerdraw combobox.
    2ace16ac
    History
    Release 960428
    Alexandre Julliard authored
    Sun Apr 28 14:32:43 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>
    
    	* [Makefile.in]
    	Subdir memory is now also compiled for Winelib, in order to get
    	the Win32 heap functions.
    
    	* [if1632/Makefile.in]
    	Renamed winprocs and winprocs32 to wprocs and wprocs32 to avoid
    	DLL names > 8 characters.
    
    	* [loader/builtin.c] (New file)
    	Grouped all built-in DLLs code in a single file.
    
    	* [memory/global.c]
    	Use the Win32 heap code instead of malloc() to allocate linear
    	memory. This will help test the heap code.
    
    	* [memory/local.c]
    	Fixed FreeSelector() to clear DS and ES correctly for huge blocks.
    
    	* [tools/build.c] [if1632/relay.c]
    	Removed 'id' directive in spec files. For relay debugging, the DLL
    	entry point is now computed from the CS:IP entry point address.
    	Added 'heap' directive to specifiy a local heap for the DLL. USER
    	and GDI heap are now created this way.
    
    	* [windows/class.c] [include/class.h]
    	Changed the class structure to use pointers instead of handles.
    	Changed Get/SetClassWord/Long to use a switch statement; this
    	allows changing the layout of the CLASS structure.
    
    	* [windows/win.c] [include/win.h]
    	Use a CLASS * instead of a handle for the window class.
    
    Sat Apr 27 18:10:11 Martin von Loewis <loewis@informatik.hu-berlin.de>
    
    	* [if1632/kernel32.spec] [memory/global.c]
    	  [win32/memory.c] [win32/process.c]
    	GetProcessAffinityMask,GlobalLock,IsBadReadPtr,IsBadWritePtr,
    	LocalLock,SetThreadAffinityMask: new relays.
    
    	* [win32/cursoricon32.c]
    	Return same handle if a cursor is loaded multiple times.
    
    Sat Apr 27 15:13:37 1996  Bang Jun Young <bangjy@nownuri.nowcom.co.kr>
    
    	* [resources/sysres_Ko.rc]
            Added support for Korean [Ko] language.
    
    Fri Apr 26 00:49:05 1996  Huw D. M. Davies <h.davies1@physics.oxford.ac.uk>
    
    	* [objects/dc.c] [objects/font.c]
    	Fixed problem with SaveDC()/RestoreDC() and font cache 'used' count.
    
    	* [objects/metafile.c] [objects/dcvalues.c]
    	Fixed broken SetTextAlign() on metafiles.
    
    	* [objects/metafile.c]
    	Delete objects in handle table at end of PlayMetaFile().
    
    Wed Apr 24 19:21:01  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
    
    	* [if1632/ver.spec] [misc/ver.c] [include/ver.h] (New files)
    	VER.DLL (partially) implemented (VerFindFile,VerInstallFile)
    	[If it doesn't work for you, use -dll -ver and report it to me]
    
    	* [if1632/user32.spec] [if1632/kernel32.spec] [if1632/shell.spec]
    	  [if1632/shell32.spec] [misc/ole2nls.c] [windows/message.c]
    	  [windows/graphics.c]
    	Simple win32 functions, where we can just use the win16 counterpart.
    	Misc. stubs. 
    
    	* [misc/lstr.c]
    	Someone reported a _lstrlen(NULL). NULL is a valid argument. Fixed.
    
    	* [misc/registry.c]
    	Some alloclens were off by 1, one double fclose() fixed.
    	Requesting value 0 of a key with no values returns an error 
    	(should we always return a made up value NULL? what does win3.1?)
    
    Tue Apr 23 17:00:00 1996 Alex Korobka <alex@phm30.pharm.sunysb.edu>
    
    	* [misc/shell.c]
    	Implemented FindEnvironmentString(), DoEnvironmentSubst(),
    	ExtractIcon(), InternalExtractIcon() and ExtractAssociatedIcon().
    
    	* [misc/user.c]
    	Do extensive cleanup on application exit.
    
    	* [windows/hook.c] [windows/win.c] [windows/class.c]
    	Added miscellaneous cleanup routines.
    
    	* [controls/menu.c]
    	More efficient popup menu window handling.
    
    Mon Apr 22 21:35:22 1996  Albrecht Kleine  <kleine@ak.sax.de>
    
    	* [include/windows.h][objects/oembitmap.c][include/bitmaps/obm_trtype]
    	Added "TT-bitmap" for later usage in a ChooseFont() ownerdraw combobox.
dbg.y 10.10 KiB
%{
/*
 * Parser for command lines in the Wine debugger
 *
 * Copyright 1993 Eric Youngdale
 * Copyright 1995 Morten Welinder
 */

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include "class.h"
#include "module.h"
#include "options.h"
#include "queue.h"
#include "win.h"
#include "debugger.h"

extern FILE * yyin;
unsigned int dbg_mode = 0;

static enum exec_mode dbg_exec_mode = EXEC_CONT;

void issue_prompt(void);
void mode_command(int);
void flush_symbols(void);
int yylex(void);
int yyerror(char *);

%}

%union
{
    DBG_ADDR         address;
    enum debug_regs  reg;
    char *           string;
    int              integer;
}

%token tCONT tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK
%token tENABLE tDISABLE tBREAK tDELETE tSET tMODE tPRINT tEXAM tDEFINE tABORT
%token tCLASS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE 
%token tNO_SYMBOL tEOL
%token tSYMBOLFILE

%token <string> tIDENTIFIER
%token <integer> tNUM tFORMAT
%token <reg> tREG

/* %left ',' */
/* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \
         OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \
         OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */
/* %left OP_COND */ /* ... ? ... : ... */
%left OP_LOR
%left OP_LAND
%left '|'
%left '^'
%left '&'
%left OP_EQ OP_NE
%left '<' '>' OP_LE OP_GE
%left OP_SHL OP_SHR
%left '+' '-'
%left '*' '/' '%'
%left OP_SIGN '!' '~' OP_DEREF /* OP_INC OP_DEC OP_ADDR */
%nonassoc ':'

%type <integer> expr
%type <address> addr segaddr symbol
%%

input: line                    { issue_prompt(); }
    | input line               { issue_prompt(); }

line: command 
    | tEOL
    | error tEOL               { yyerrok; }

command:
      tQUIT tEOL               { exit(0); }
    | tHELP tEOL               { DEBUG_Help(); }
    | tCONT tEOL               { dbg_exec_mode = EXEC_CONT; return 0; }
    | tSTEP tEOL               { dbg_exec_mode = EXEC_STEP_INSTR; return 0; }
    | tNEXT tEOL               { dbg_exec_mode = EXEC_STEP_OVER; return 0; }
    | tLIST tEOL               { DEBUG_List( NULL, 15 ); }
    | tLIST addr tEOL          { DEBUG_List( &$2, 15 ); }
    | tABORT tEOL              { kill(getpid(), SIGABRT); }
    | tSYMBOLFILE tIDENTIFIER tEOL  { DEBUG_ReadSymbolTable( $2 ); }
    | tDEFINE tIDENTIFIER addr tEOL { DEBUG_AddSymbol( $2, &$3 ); }
    | tMODE tNUM tEOL          { mode_command($2); }
    | tENABLE tNUM tEOL        { DEBUG_EnableBreakpoint( $2, TRUE ); }
    | tDISABLE tNUM tEOL       { DEBUG_EnableBreakpoint( $2, FALSE ); }
    | tDELETE tBREAK tNUM tEOL { DEBUG_DelBreakpoint( $3 ); }
    | tBACKTRACE tEOL	       { DEBUG_BackTrace(); }
    | set_command
    | x_command
    | print_command
    | break_command
    | info_command
    | walk_command

set_command:
      tSET tREG '=' expr tEOL	     { DEBUG_SetRegister( $2, $4 ); }
    | tSET '*' addr '=' expr tEOL    { DEBUG_WriteMemory( &$3, $5 ); }
    | tSET tIDENTIFIER '=' addr tEOL { if (!DEBUG_SetSymbolValue( $2, &$4 ))
                                       {
                                           fprintf( stderr,
                                                 "Symbol %s not found\n", $2 );
                                           YYERROR;
                                       }
                                     }

x_command:
      tEXAM addr tEOL          { DEBUG_ExamineMemory( &$2, 1, 'x'); }
    | tEXAM tFORMAT addr tEOL  { DEBUG_ExamineMemory( &$3, $2>>8, $2&0xff ); }

print_command:
      tPRINT addr tEOL         { DEBUG_Print( &$2, 1, 'x' ); }
    | tPRINT tFORMAT addr tEOL { DEBUG_Print( &$3, $2 >> 8, $2 & 0xff ); }

break_command:
      tBREAK '*' addr tEOL     { DEBUG_AddBreakpoint( &$3 ); }
    | tBREAK symbol tEOL       { DEBUG_AddBreakpoint( &$2 ); }
    | tBREAK tEOL              { DBG_ADDR addr = { CS_reg(DEBUG_context),
                                                   EIP_reg(DEBUG_context) };
                                 DEBUG_AddBreakpoint( &addr );
                               }

info_command:
      tINFO tBREAK tEOL         { DEBUG_InfoBreakpoints(); }
    | tINFO tCLASS expr tEOL    { CLASS_DumpClass( (CLASS *)$3 ); }
    | tINFO tMODULE expr tEOL   { MODULE_DumpModule( $3 ); }
    | tINFO tQUEUE expr tEOL    { QUEUE_DumpQueue( $3 ); }
    | tINFO tREGS tEOL          { DEBUG_InfoRegisters(); }
    | tINFO tSEGMENTS expr tEOL { LDT_Print( SELECTOR_TO_ENTRY($3), 1 ); }
    | tINFO tSEGMENTS tEOL      { LDT_Print( 0, -1 ); }
    | tINFO tSTACK tEOL         { DEBUG_InfoStack(); }
    | tINFO tWND expr tEOL      { WIN_DumpWindow( $3 ); } 
walk_command:
      tWALK tCLASS tEOL         { CLASS_WalkClasses(); }
    | tWALK tMODULE tEOL        { MODULE_WalkModules(); }
    | tWALK tQUEUE tEOL         { QUEUE_WalkQueues(); }
    | tWALK tWND tEOL           { WIN_WalkWindows( 0, 0 ); }
    | tWALK tWND tNUM tEOL      { WIN_WalkWindows( $3, 0 ); }

symbol: tIDENTIFIER   { if (!DEBUG_GetSymbolValue( $1, &$$ ))
			{
			   fprintf( stderr, "Symbol %s not found\n", $1 );
			   YYERROR;
			}
		      } 

addr:
      expr                       { $$.seg = 0xffffffff; $$.off = $1; }
    | segaddr                    { $$ = $1; }

segaddr:
      expr ':' expr              { $$.seg = $1; $$.off = $3; }
    | symbol                     { $$ = $1; }

expr:
      tNUM                       { $$ = $1; }
    | tREG                       { $$ = DEBUG_GetRegister($1); }
    | expr OP_LOR expr           { $$ = $1 || $3; }
    | expr OP_LAND expr          { $$ = $1 && $3; }
    | expr '|' expr              { $$ = $1 | $3; }
    | expr '&' expr              { $$ = $1 & $3; }
    | expr '^' expr              { $$ = $1 ^ $3; }
    | expr OP_EQ expr            { $$ = $1 == $3; }
    | expr '>' expr              { $$ = $1 > $3; }
    | expr '<' expr              { $$ = $1 < $3; }
    | expr OP_GE expr            { $$ = $1 >= $3; }
    | expr OP_LE expr            { $$ = $1 <= $3; }
    | expr OP_NE expr            { $$ = $1 != $3; }
    | expr OP_SHL expr           { $$ = (unsigned)$1 << $3; }
    | expr OP_SHR expr           { $$ = (unsigned)$1 >> $3; }
    | expr '+' expr              { $$ = $1 + $3; }
    | expr '-' expr              { $$ = $1 - $3; }
    | expr '*' expr              { $$ = $1 * $3; }
    | expr '/' expr              { if ($3) 
                                       if ($3 == -1 && $1 == 0x80000000l)
                                           yyerror ("Division overflow");
                                       else $$ = $1 / $3;
                                   else yyerror ("Division by zero");
                                 }
    | expr '%' expr              { if ($3) 
                                       if ($3 == -1 && $1 == 0x80000000l)
                                           $$ = 0; /* A sensible result in this case.  */
                                       else $$ = $1 % $3;
                                   else yyerror ("Division by zero");
                                 }
    | '-' expr %prec OP_SIGN     { $$ = -$2; }
    | '+' expr %prec OP_SIGN     { $$ = $2; }
    | '!' expr                   { $$ = !$2; }
    | '~' expr                   { $$ = ~$2; }
    | '(' expr ')'               { $$ = $2; }
/* For parser technical reasons we can't use "addr" here.  */
    | '*' expr %prec OP_DEREF    { DBG_ADDR addr = { 0xffffffff, $2 };
                                   $$ = DEBUG_ReadMemory( &addr ); }
    | '*' segaddr %prec OP_DEREF { $$ = DEBUG_ReadMemory( &$2 ); }
	
%%

void 
issue_prompt(){
#ifndef USE_READLINE
	fprintf(stderr,"Wine-dbg>");
#endif
}

void mode_command(int newmode)
{
    if ((newmode == 16) || (newmode == 32)) dbg_mode = newmode;
    else fprintf(stderr,"Invalid mode (use 16 or 32)\n");
}



/***********************************************************************
 *           DEBUG_EnterDebugger
 *
 * Force an entry into the debugger.
 */
void DEBUG_EnterDebugger(void)
{
    kill( getpid(), SIGHUP );
}


void wine_debug( int signal, struct sigcontext_struct *regs )
{
    static int loaded_symbols = 0;
    char SymbolTableFile[256];
    int instr_len = 0, newmode;
#ifdef YYDEBUG
    yydebug = 0;
#endif

    yyin = stdin;
    DEBUG_context = (struct sigcontext_struct *)regs;

    DEBUG_SetBreakpoints( FALSE );

    if (!loaded_symbols)
    {
        loaded_symbols++;
        PROFILE_GetWineIniString( "wine", "SymbolTableFile", "wine.sym",
                                  SymbolTableFile, sizeof(SymbolTableFile) );
        DEBUG_ReadSymbolTable( SymbolTableFile );
        DEBUG_LoadEntryPoints();
    }

    if ((signal != SIGTRAP) || !DEBUG_ShouldContinue( regs, dbg_exec_mode ))
    {
        DBG_ADDR addr;

        addr.seg = CS_reg(DEBUG_context);
        addr.off = EIP_reg(DEBUG_context);
        DBG_FIX_ADDR_SEG( &addr, 0 );

        /* Put the display in a correct state */

        XUngrabPointer( display, CurrentTime );
        XUngrabServer( display );
        XFlush( display );

        if (!addr.seg) newmode = 32;
        else newmode = (GET_SEL_FLAGS(addr.seg) & LDT_FLAGS_32BIT) ? 32 : 16;

        if (newmode != dbg_mode)
            fprintf(stderr,"In %d bit mode.\n", dbg_mode = newmode);

        if (signal != SIGTRAP)  /* This is a real crash, dump some info */
        {
            DEBUG_InfoRegisters();
            DEBUG_InfoStack();
            if (dbg_mode == 16)
            {
                LDT_Print( SELECTOR_TO_ENTRY(DS_reg(DEBUG_context)), 1 );
                if (ES_reg(DEBUG_context) != DS_reg(DEBUG_context))
                    LDT_Print( SELECTOR_TO_ENTRY(ES_reg(DEBUG_context)), 1 );
            }
            DEBUG_BackTrace();
        }

        /* Show where we crashed */
        DEBUG_PrintAddress( &addr, dbg_mode );
        fprintf(stderr,":  ");
        if (DBG_CHECK_READ_PTR( &addr, 1 ))
        {
            DEBUG_Disasm( &addr );
            fprintf(stderr,"\n");
            instr_len = addr.off - EIP_reg(DEBUG_context);
        }

        do
        {
            issue_prompt();
            yyparse();
            flush_symbols();
            addr.seg = CS_reg(DEBUG_context);
            addr.off = EIP_reg(DEBUG_context);
            DBG_FIX_ADDR_SEG( &addr, 0 );
        } while (!DBG_CHECK_READ_PTR( &addr, 1 ));
    }

    DEBUG_RestartExecution( regs, dbg_exec_mode, instr_len );
}


int yyerror(char * s)
{
	fprintf(stderr,"%s\n", s);
        return 0;
}