Commit e5efa0ce authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Made the winedbg an external and WineLib program.

Centralized output handling (preparation for console usage). Fixed a few debug information reading options (stabs and sym). Started a framework to hold debugger's internal variables.
parent 5f6419fa
......@@ -28,7 +28,6 @@ TOOLSUBDIRS = tools
LIBSUBDIRS = \
controls \
console \
debugger \
dlls/advapi32 \
dlls/crtdll \
dlls/display \
......@@ -60,17 +59,25 @@ EMUSUBDIRS = \
miscemu \
server
PROGSUBDIRS = libtest programs
PROGSUBDIRS = \
debugger \
libtest \
programs
DOCSUBDIRS = documentation
INCSUBDIRS = include
# Stand-alone programs
PROGRAMS = \
loader/dos/dosmod \
server/wineserver \
windows/x11drv/wineclipsrv
# Programs that link with libwine
LIBPROGRAMS = \
debugger/winedbg
# Sub-directories to run make into
SUBDIRS = \
$(TOOLSUBDIRS) \
......@@ -90,7 +97,6 @@ LINTSUBDIRS = $(LIBSUBDIRS) $(DLLDIR) $(EMUSUBDIRS) $(DOCSUBDIRS)
LIBOBJS = \
controls/controls.o \
console/console.o \
debugger/debugger.o \
dlls/advapi32/advapi32.o \
dlls/crtdll/crtdll.o \
dlls/display/display.o \
......@@ -126,7 +132,7 @@ EXTRA_OBJS = $(LIBOBJS)
EMU_TARGET = @EMU_TARGET@
all: Make.rules $(PROGRAMS) $(EMU_TARGET)
all: Make.rules $(PROGRAMS) $(LIBPROGRAMS) $(EMU_TARGET)
@echo "Wine build complete."
LIBLINTS = $(LIBOBJS:.o=.ln)
......@@ -167,15 +173,16 @@ install_wine: wine
[ -f wine.sym ] && $(INSTALL_DATA) wine.sym $(libdir)/wine.sym
$(INSTALL_PROGRAM) wine $(bindir)/wine
install:: $(PROGRAMS) $(EMU_TARGET:%=install_%) $(LIBEXT:%=install_%)
install:: $(PROGRAMS) $(LIBPROGRAMS) $(EMU_TARGET:%=install_%) $(LIBEXT:%=install_%)
[ -d $(bindir) ] || $(MKDIR) $(bindir)
$(INSTALL_PROGRAM) server/wineserver $(bindir)/wineserver
$(INSTALL_PROGRAM) windows/x11drv/wineclipsrv $(bindir)/wineclipsrv
$(INSTALL_PROGRAM) loader/dos/dosmod $(bindir)/dosmod
$(INSTALL_PROGRAM) debugger/winedbg $(bindir)/winedbg
uninstall::
cd $(libdir) && $(RM) libwine.a libwine.so libwine.so.$(SOVERSION) wine.sym
cd $(bindir) && $(RM) wine wineserver wineclipsrv dosmod
cd $(bindir) && $(RM) wine wineserver wineclipsrv dosmod winedbg
lib$(MODULE).so.$(SOVERSION): $(OBJS) Makefile.in Make.rules.in
$(LDSHARED) $(OBJS) -o $@
......@@ -191,9 +198,11 @@ lib$(MODULE).a: $(OBJS) Makefile.in Make.rules.in
checklink::
$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c -L. -lwine $(LDOPTIONS) $(X_LIBS) $(XLIB) $(LIBS) && $(RM) checklink
$(EMUOBJS) $(LIBOBJS) $(DLLOBJS) $(PROGRAMS): $(TOOLSUBDIRS) dummy
$(EMUOBJS) $(LIBOBJS) $(DLLOBJS) $(PROGRAMS) $(LIBPROGRAMS): $(TOOLSUBDIRS) dummy
@cd `dirname $@` && $(MAKE) `basename $@`
$(LIBPROGRAMS): lib$(MODULE).$(LIBEXT) $(DLLOBJS)
$(LIBLINTS) $(EMULINTS): dummy
@cd `dirname $@` && $(MAKE) lint
......
Makefile
lex.yy.c
winedbg
winedbg.spec.c
y.tab.c
y.tab.h
DEFS = -D__WINE__ -DLIBDIR="\"$(libdir)\""
DEFS = -DWINELIB
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = debugger
MODULE = none
PROGRAMS = winedbg
ALL_LIBS = $(WINELIB) $(X_LIBS) $(XLIB) $(LIBS)
WRCEXTRA = -A -p $*
C_SRCS = \
break.c \
......@@ -24,19 +27,15 @@ C_SRCS = \
types.c \
winedbg.c
SPEC_SRCS = winedbg.spec
EXTRA_SRCS = dbg.y debug.l
EXTRA_OBJS = y.tab.o lex.yy.o
all: $(MODULE).o
all: $(PROGRAMS)
depend: y.tab.h
#
# This is a special test program that helps debug the internal debugger.
#
debug: $(MODULE).o dbgmain.o ../misc/xmalloc.o
$(CC) -o debug $(MODULE).o dbgmain.o ../misc/xmalloc.o
@MAKE_RULES@
y.tab.c y.tab.h: dbg.y
......@@ -45,4 +44,7 @@ y.tab.c y.tab.h: dbg.y
lex.yy.c: debug.l
$(LEX) -8 -I $(SRCDIR)/debug.l
winedbg: $(OBJS)
$(CC) -o $@ $(OBJS) $(LDOPTIONS) $(ALL_LIBS)
### Dependencies:
......@@ -185,7 +185,7 @@ void DEBUG_SetBreakpoints( BOOL set )
if (!DEBUG_WRITE_MEM( (void*)DEBUG_ToLinear(&breakpoints[i].addr),
&ch, sizeof(ch) ))
{
fprintf(stderr, "Invalid address for breakpoint %d, disabling it\n", i);
DEBUG_Printf(DBG_CHN_MESG, "Invalid address for breakpoint %d, disabling it\n", i);
breakpoints[i].enabled = FALSE;
}
}
......@@ -291,7 +291,7 @@ static int DEBUG_InitXPoint(int type, DBG_ADDR* addr)
}
}
fprintf( stderr, "Too many breakpoints. Please delete some.\n" );
DEBUG_Printf( DBG_CHN_MESG, "Too many breakpoints. Please delete some.\n" );
return -1;
}
......@@ -361,10 +361,10 @@ void DEBUG_AddBreakpoint( const DBG_VALUE *_value )
breakpoints[num].u.opcode = ch;
fprintf( stderr, "Breakpoint %d at ", num );
DEBUG_Printf( DBG_CHN_MESG, "Breakpoint %d at ", num );
DEBUG_PrintAddress( &breakpoints[num].addr, breakpoints[num].is32 ? 32 : 16,
TRUE );
fprintf( stderr, "\n" );
DEBUG_Printf( DBG_CHN_MESG, "\n" );
}
......@@ -382,7 +382,9 @@ void DEBUG_AddWatchpoint( const DBG_VALUE *_value, BOOL is_write )
assert(_value->cookie == DV_TARGET || _value->cookie == DV_HOST);
DEBUG_FixAddress( &value.addr, CS_reg(&DEBUG_context) );
#ifdef __i386__
DEBUG_FixAddress( &value.addr, DEBUG_context.SegCs );
#endif
if ( value.type != NULL && value.type == DEBUG_TypeIntConst )
{
......@@ -408,7 +410,7 @@ void DEBUG_AddWatchpoint( const DBG_VALUE *_value, BOOL is_write )
for (reg = 0; reg < 4 && (mask & (1 << reg)); reg++);
if (reg == 4)
{
fprintf(stderr, "All i386 hardware watchpoints have been set. Delete some\n");
DEBUG_Printf(DBG_CHN_MESG, "All i386 hardware watchpoints have been set. Delete some\n");
return;
}
#endif
......@@ -422,16 +424,16 @@ void DEBUG_AddWatchpoint( const DBG_VALUE *_value, BOOL is_write )
if (!DEBUG_GetWatchedValue( num, &breakpoints[num].u.w.oldval))
{
fprintf(stderr, "Bad address. Watchpoint not set\n");
DEBUG_Printf(DBG_CHN_MESG, "Bad address. Watchpoint not set\n");
breakpoints[num].refcount = 0;
}
breakpoints[num].u.w.rw = (is_write) ? TRUE : FALSE;
breakpoints[reg].u.w.reg = reg;
fprintf( stderr, "Watchpoint %d at ", num );
DEBUG_Printf( DBG_CHN_MESG, "Watchpoint %d at ", num );
DEBUG_PrintAddress( &breakpoints[num].addr, breakpoints[num].is32 ? 32:16, TRUE );
fprintf( stderr, "\n" );
DEBUG_Printf( DBG_CHN_MESG, "\n" );
}
/***********************************************************************
......@@ -443,7 +445,7 @@ void DEBUG_DelBreakpoint( int num )
{
if ((num <= 0) || (num >= next_bp) || breakpoints[num].refcount == 0)
{
fprintf( stderr, "Invalid breakpoint number %d\n", num );
DEBUG_Printf( DBG_CHN_MESG, "Invalid breakpoint number %d\n", num );
return;
}
......@@ -470,7 +472,7 @@ void DEBUG_EnableBreakpoint( int num, BOOL enable )
{
if ((num <= 0) || (num >= next_bp) || breakpoints[num].refcount == 0)
{
fprintf( stderr, "Invalid breakpoint number %d\n", num );
DEBUG_Printf( DBG_CHN_MESG, "Invalid breakpoint number %d\n", num );
return;
}
breakpoints[num].enabled = (enable) ? TRUE : FALSE;
......@@ -557,40 +559,40 @@ void DEBUG_InfoBreakpoints(void)
{
int i;
fprintf( stderr, "Breakpoints:\n" );
DEBUG_Printf( DBG_CHN_MESG, "Breakpoints:\n" );
for (i = 1; i < next_bp; i++)
{
if (breakpoints[i].refcount && breakpoints[i].type == DBG_BREAK)
{
fprintf( stderr, "%d: %c ", i, breakpoints[i].enabled ? 'y' : 'n');
DEBUG_Printf( DBG_CHN_MESG, "%d: %c ", i, breakpoints[i].enabled ? 'y' : 'n');
DEBUG_PrintAddress( &breakpoints[i].addr,
breakpoints[i].is32 ? 32 : 16, TRUE);
fprintf( stderr, " (%u)\n", breakpoints[i].refcount );
DEBUG_Printf( DBG_CHN_MESG, " (%u)\n", breakpoints[i].refcount );
if( breakpoints[i].condition != NULL )
{
fprintf(stderr, "\t\tstop when ");
DEBUG_Printf(DBG_CHN_MESG, "\t\tstop when ");
DEBUG_DisplayExpr(breakpoints[i].condition);
fprintf(stderr, "\n");
DEBUG_Printf(DBG_CHN_MESG, "\n");
}
}
}
fprintf( stderr, "Watchpoints:\n" );
DEBUG_Printf( DBG_CHN_MESG, "Watchpoints:\n" );
for (i = 1; i < next_bp; i++)
{
if (breakpoints[i].refcount && breakpoints[i].type == DBG_WATCH)
{
fprintf( stderr, "%d: %c ", i, breakpoints[i].enabled ? 'y' : 'n');
DEBUG_Printf( DBG_CHN_MESG, "%d: %c ", i, breakpoints[i].enabled ? 'y' : 'n');
DEBUG_PrintAddress( &breakpoints[i].addr,
breakpoints[i].is32 ? 32 : 16, TRUE);
fprintf( stderr, " on %d byte%s (%c)\n",
DEBUG_Printf( DBG_CHN_MESG, " on %d byte%s (%c)\n",
breakpoints[i].u.w.len + 1,
breakpoints[i].u.w.len > 0 ? "s" : "",
breakpoints[i].u.w.rw ? 'W' : 'R');
if( breakpoints[i].condition != NULL )
{
fprintf(stderr, "\t\tstop when ");
DEBUG_Printf(DBG_CHN_MESG, "\t\tstop when ");
DEBUG_DisplayExpr(breakpoints[i].condition);
fprintf(stderr, "\n");
DEBUG_Printf(DBG_CHN_MESG, "\n");
}
}
}
......@@ -613,9 +615,9 @@ static BOOL DEBUG_ShallBreak( int bpnum )
/*
* Something wrong - unable to evaluate this expression.
*/
fprintf(stderr, "Unable to evaluate expression ");
DEBUG_Printf(DBG_CHN_MESG, "Unable to evaluate expression ");
DEBUG_DisplayExpr(breakpoints[bpnum].condition);
fprintf(stderr, "\nTurning off condition\n");
DEBUG_Printf(DBG_CHN_MESG, "\nTurning off condition\n");
DEBUG_AddBPCondition(bpnum, NULL);
}
else if( !DEBUG_GetExprValue( &value, NULL) )
......@@ -658,10 +660,10 @@ BOOL DEBUG_ShouldContinue( DWORD code, enum exec_mode mode, int * count )
{
if (!DEBUG_ShallBreak(bpnum)) return TRUE;
fprintf( stderr, "Stopped on breakpoint %d at ", bpnum );
DEBUG_Printf( DBG_CHN_MESG, "Stopped on breakpoint %d at ", bpnum );
syminfo = DEBUG_PrintAddress( &breakpoints[bpnum].addr,
breakpoints[bpnum].is32 ? 32 : 16, TRUE );
fprintf( stderr, "\n" );
DEBUG_Printf( DBG_CHN_MESG, "\n" );
if( syminfo.list.sourcefile != NULL )
DEBUG_List(&syminfo.list, NULL, 0);
......@@ -674,16 +676,18 @@ BOOL DEBUG_ShouldContinue( DWORD code, enum exec_mode mode, int * count )
/* If not single-stepping, do not back up over the int3 instruction */
if (code == EXCEPTION_BREAKPOINT)
{
EIP_reg(&DEBUG_context)++;
#ifdef __i386__
DEBUG_context.Eip++;
addr.off++;
#endif
}
if (!DEBUG_ShallBreak(wpnum)) return TRUE;
fprintf(stderr, "Stopped on watchpoint %d at ", wpnum);
DEBUG_Printf(DBG_CHN_MESG, "Stopped on watchpoint %d at ", wpnum);
syminfo = DEBUG_PrintAddress( &addr, !addr.seg ? 32 :
DEBUG_GetSelectorType( addr.seg ), TRUE );
fprintf(stderr, " values: old=%lu new=%lu\n",
DEBUG_Printf(DBG_CHN_MESG, " values: old=%lu new=%lu\n",
oldval, breakpoints[wpnum].u.w.oldval);
if (syminfo.list.sourcefile != NULL)
DEBUG_List(&syminfo.list, NULL, 0);
......@@ -740,7 +744,7 @@ BOOL DEBUG_ShouldContinue( DWORD code, enum exec_mode mode, int * count )
}
/***********************************************************************
* DEBUG_RestartExecution
* DEBUG_SuspendExecution
*
* Remove all breakpoints before entering the debug loop
*/
......@@ -791,7 +795,7 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
{
if( mode == EXEC_CONT && count > 1 )
{
fprintf(stderr, "Not stopped at any breakpoint; argument ignored.\n");
DEBUG_Printf(DBG_CHN_MESG, "Not stopped at any breakpoint; argument ignored.\n");
}
}
......@@ -823,7 +827,7 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
&& status == FUNC_IS_TRAMPOLINE )
{
#if 0
fprintf(stderr, "Not stepping into trampoline at %x (no lines)\n",
DEBUG_Printf(DBG_CHN_MESG, "Not stepping into trampoline at %x (no lines)\n",
addr2.off);
#endif
mode = EXEC_STEP_OVER_TRAMPOLINE;
......@@ -832,7 +836,7 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
if( mode == EXEC_STEP_INSTR && status == FUNC_HAS_NO_LINES )
{
#if 0
fprintf(stderr, "Not stepping into function at %x (no lines)\n",
DEBUG_Printf(DBG_CHN_MESG, "Not stepping into function at %x (no lines)\n",
addr2.off);
#endif
mode = EXEC_STEP_OVER;
......@@ -844,8 +848,8 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
{
if( DEBUG_CheckLinenoStatus(&addr) == FUNC_HAS_NO_LINES )
{
fprintf(stderr, "Single stepping until exit from function, \n");
fprintf(stderr, "which has no line number information.\n");
DEBUG_Printf(DBG_CHN_MESG, "Single stepping until exit from function, \n");
DEBUG_Printf(DBG_CHN_MESG, "which has no line number information.\n");
ret_mode = mode = EXEC_FINISH;
}
......@@ -909,6 +913,8 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
DEBUG_context.EFlags |= STEP_FLAG;
#endif
break;
case EXEC_KILL:
break;
default:
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
}
......@@ -921,7 +927,7 @@ DEBUG_AddBPCondition(int num, struct expr * exp)
{
if ((num <= 0) || (num >= next_bp) || !breakpoints[num].refcount)
{
fprintf( stderr, "Invalid breakpoint number %d\n", num );
DEBUG_Printf( DBG_CHN_MESG, "Invalid breakpoint number %d\n", num );
return FALSE;
}
......
......@@ -95,7 +95,8 @@ line: command
| error tEOL { yyerrok; }
command:
tQUIT tEOL { DEBUG_Exit(0); }
tQUIT tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
DEBUG_CurrThread->dbg_exec_mode = EXEC_KILL; return 1; }
| tHELP tEOL { DEBUG_Help(); }
| tHELP tINFO tEOL { DEBUG_HelpInfo(); }
| tCONT tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
......@@ -210,7 +211,7 @@ break_command:
}
else
{
fprintf(stderr,"Unable to add breakpoint\n");
DEBUG_Printf(DBG_CHN_MESG,"Unable to add breakpoint\n");
}
}
| tBREAK tIDENTIFIER ':' tNUM tEOL { DBG_VALUE value;
......@@ -220,7 +221,7 @@ break_command:
}
else
{
fprintf(stderr,"Unable to add breakpoint\n");
DEBUG_Printf(DBG_CHN_MESG,"Unable to add breakpoint\n");
}
}
| tBREAK tNUM tEOL { struct name_hash *nh;
......@@ -237,7 +238,7 @@ break_command:
}
else
{
fprintf(stderr,"Unable to add breakpoint\n");
DEBUG_Printf(DBG_CHN_MESG,"Unable to add breakpoint\n");
}
}
......@@ -255,7 +256,7 @@ watch_command:
if( DEBUG_GetSymbolValue($2, -1, &value, TRUE) )
DEBUG_AddWatchpoint( &value, 1 );
else
fprintf(stderr,"Unable to add breakpoint\n");
DEBUG_Printf(DBG_CHN_MESG,"Unable to add breakpoint\n");
}
info_command:
......@@ -388,49 +389,43 @@ lvalue:
static void issue_prompt(void)
{
#ifdef DONT_USE_READLINE
fprintf(stderr, "Wine-dbg>");
DEBUG_Printf(DBG_CHN_MESG, "Wine-dbg>");
#endif
}
static void mode_command(int newmode)
{
if ((newmode == 16) || (newmode == 32)) DEBUG_CurrThread->dbg_mode = newmode;
else fprintf(stderr,"Invalid mode (use 16 or 32)\n");
else DEBUG_Printf(DBG_CHN_MESG,"Invalid mode (use 16 or 32)\n");
}
void DEBUG_Exit(DWORD ec)
{
ExitProcess(ec);
}
static WINE_EXCEPTION_FILTER(wine_dbg_cmd)
{
fprintf(stderr, "\nwine_dbg_cmd: ");
DEBUG_Printf(DBG_CHN_MESG, "\nwine_dbg_cmd: ");
switch (GetExceptionCode()) {
case DEBUG_STATUS_INTERNAL_ERROR:
fprintf(stderr, "WineDbg internal error\n");
DEBUG_Printf(DBG_CHN_MESG, "WineDbg internal error\n");
break;
case DEBUG_STATUS_NO_SYMBOL:
fprintf(stderr, "Undefined symbol\n");
DEBUG_Printf(DBG_CHN_MESG, "Undefined symbol\n");
break;
case DEBUG_STATUS_DIV_BY_ZERO:
fprintf(stderr, "Division by zero\n");
DEBUG_Printf(DBG_CHN_MESG, "Division by zero\n");
break;
case DEBUG_STATUS_BAD_TYPE:
fprintf(stderr, "No type or type mismatch\n");
DEBUG_Printf(DBG_CHN_MESG, "No type or type mismatch\n");
break;
default:
fprintf(stderr, "Exception %lx\n", GetExceptionCode());
DEBUG_Printf(DBG_CHN_MESG, "Exception %lx\n", GetExceptionCode());
break;
}
return EXCEPTION_EXECUTE_HANDLER;
}
/***********************************************************************
* DEBUG_Exit
*
* Kill current process.
*
*/
void DEBUG_Exit( DWORD exit_code )
{
TASK_KillTask( 0 ); /* FIXME: should not be necessary */
TerminateProcess( DEBUG_CurrProcess->handle, exit_code );
return EXCEPTION_EXECUTE_HANDLER;
}
/***********************************************************************
......@@ -456,17 +451,16 @@ BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code )
{
#ifdef __i386__
if (DEBUG_IsSelectorSystem(DEBUG_context.SegCs))
fprintf( stderr, " in 32-bit code (0x%08lx).\n", DEBUG_context.Eip );
DEBUG_Printf( DBG_CHN_MESG, " in 32-bit code (0x%08lx).\n", DEBUG_context.Eip );
else
fprintf( stderr, " in 16-bit code (%04x:%04lx).\n",
DEBUG_Printf( DBG_CHN_MESG, " in 16-bit code (%04x:%04lx).\n",
(WORD)DEBUG_context.SegCs, DEBUG_context.Eip );
#else
fprintf( stderr, " (%p).\n", GET_IP(&DEBUG_context) );
DEBUG_Printf( DBG_CHN_MESG, " (%p).\n", GET_IP(&DEBUG_context) );
#endif
}
if (DEBUG_LoadEntryPoints("Loading new modules symbols:\n"))
DEBUG_ProcessDeferredDebug();
DEBUG_LoadEntryPoints("Loading new modules symbols:\n");
if (force || !(is_debug && DEBUG_ShouldContinue( code,
DEBUG_CurrThread->dbg_exec_mode,
......@@ -478,13 +472,13 @@ BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code )
#ifdef __i386__
switch (newmode = DEBUG_GetSelectorType(addr.seg)) {
case 16: case 32: break;
default: fprintf(stderr, "Bad CS (%ld)\n", addr.seg); newmode = 32;
default: DEBUG_Printf(DBG_CHN_MESG, "Bad CS (%ld)\n", addr.seg); newmode = 32;
}
#else
newmode = 32;
#endif
if (newmode != DEBUG_CurrThread->dbg_mode)
fprintf(stderr,"In %d bit mode.\n", DEBUG_CurrThread->dbg_mode = newmode);
DEBUG_Printf(DBG_CHN_MESG,"In %d bit mode.\n", DEBUG_CurrThread->dbg_mode = newmode);
DEBUG_DoDisplay();
......@@ -520,9 +514,9 @@ BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code )
/* Show where we crashed */
curr_frame = 0;
DEBUG_PrintAddress( &addr, DEBUG_CurrThread->dbg_mode, TRUE );
fprintf(stderr,": ");
DEBUG_Printf(DBG_CHN_MESG,": ");
DEBUG_Disasm( &addr, TRUE );
fprintf( stderr, "\n" );
DEBUG_Printf( DBG_CHN_MESG, "\n" );
}
ret_ok = 0;
......@@ -531,16 +525,20 @@ BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code )
__TRY
{
issue_prompt();
yyparse();
if (yyparse()) {
DEBUG_CurrThread->dbg_exec_mode = EXEC_KILL;
ret_ok = TRUE;
} else {
flush_symbols();
DEBUG_GetCurrentAddress( &addr );
if ((ret_ok = DEBUG_ValidateRegisters()))
ret_ok = DEBUG_READ_MEM_VERBOSE((void*)DEBUG_ToLinear( &addr ), &ch, 1 );
ret_ok = DEBUG_ValidateRegisters() &&
DEBUG_READ_MEM_VERBOSE((void*)DEBUG_ToLinear(&addr), &ch, 1);
}
}
__EXCEPT(wine_dbg_cmd)
{
ret_ok = 0;
ret_ok = FALSE;
}
__ENDTRY;
......@@ -553,14 +551,14 @@ BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code )
* if it was used. Otherwise it would have been ignored.
* In any case, we don't mess with it any more.
*/
if ((DEBUG_CurrThread->dbg_exec_mode == EXEC_CONT) || (DEBUG_CurrThread->dbg_exec_mode == EXEC_PASS))
if (DEBUG_CurrThread->dbg_exec_mode == EXEC_CONT || DEBUG_CurrThread->dbg_exec_mode == EXEC_PASS)
DEBUG_CurrThread->dbg_exec_count = 0;
return (DEBUG_CurrThread->dbg_exec_mode == EXEC_PASS) ? 0 : DBG_CONTINUE;
return (DEBUG_CurrThread->dbg_exec_mode == EXEC_PASS) ? DBG_EXCEPTION_NOT_HANDLED : DBG_CONTINUE;
}
int yyerror(char* s)
{
fprintf(stderr,"%s\n", s);
DEBUG_Printf(DBG_CHN_MESG,"%s\n", s);
return 0;
}
......@@ -190,7 +190,7 @@ enum { return tENUM; }
. { if (syntax_error == 0)
{
syntax_error ++; fprintf(stderr, "Syntax Error\n");
syntax_error ++; DEBUG_Printf(DBG_CHN_MESG, "Syntax Error\n");
}
}
......@@ -239,7 +239,7 @@ static int dbg_read(char * buf, int size)
line = readline ("Wine-dbg>");
if (!line)
{
fprintf( stderr, "\n" );
DEBUG_Printf( DBG_CHN_MESG, "\n" );
DEBUG_Exit(0);
}
......@@ -264,7 +264,7 @@ static int dbg_read(char * buf, int size)
{
if (size < len + 1)
{
fprintf(stderr,"Fatal readline goof.\n");
DEBUG_Printf(DBG_CHN_MESG,"Fatal readline goof.\n");
DEBUG_Exit(0);
}
strcpy(buf, line);
......
......@@ -106,11 +106,12 @@ enum exec_mode
EXEC_STEPI_OVER, /* Stepping over a call */
EXEC_STEPI_INSTR, /* Single-stepping an instruction */
EXEC_FINISH, /* Step until we exit current frame */
EXEC_STEP_OVER_TRAMPOLINE /* Step over trampoline. Requires that
EXEC_STEP_OVER_TRAMPOLINE, /* Step over trampoline. Requires that
* we dig the real return value off the stack
* and set breakpoint there - not at the
* instr just after the call.
*/
EXEC_KILL /* terminate debugging session */
};
#define DBG_BREAK 0
......@@ -330,6 +331,7 @@ extern void DEBUG_WalkWindows(HWND hWnd, int indent);
extern int DEBUG_ReadMemory( const DBG_ADDR *address );
extern void DEBUG_WriteMemory( const DBG_ADDR *address, int value );
extern void DEBUG_ExamineMemory( const DBG_VALUE *addr, int count, char format);
extern void DEBUG_InvalAddr( const DBG_ADDR* addr );
extern void DEBUG_InvalLinAddr( void* addr );
#ifdef __i386__
extern void DEBUG_GetCurrentAddress( DBG_ADDR * );
......@@ -342,21 +344,19 @@ extern int DEBUG_IsSelectorSystem( WORD sel );
/* debugger/module.c */
extern int DEBUG_LoadEntryPoints( const char * prefix );
extern void DEBUG_LoadModule32( const char* name, DWORD base );
extern void DEBUG_LoadModule32( const char* name, HANDLE hFile, DWORD base );
extern DBG_MODULE* DEBUG_AddModule(const char* name, int type,
void* mod_addr, HMODULE hmod);
extern DBG_MODULE* DEBUG_FindModuleByName(const char* name, int type);
extern DBG_MODULE* DEBUG_FindModuleByHandle(HANDLE handle, int type);
extern DBG_MODULE* DEBUG_RegisterPEModule(HMODULE, u_long load_addr, const char* name);
extern DBG_MODULE* DEBUG_RegisterELFModule(u_long load_addr, const char* name);
extern int DEBUG_ProcessDeferredDebug(void);
extern void DEBUG_InfoShare(void);
/* debugger/msc.c */
extern int DEBUG_RegisterMSCDebugInfo(DBG_MODULE* module, void* nth, unsigned long nth_ofs);
extern int DEBUG_RegisterStabsDebugInfo(DBG_MODULE* module, void* nth, unsigned long nth_ofs);
extern int DEBUG_RegisterMSCDebugInfo(DBG_MODULE* module, HANDLE hFile, void* nth, unsigned long nth_ofs);
extern int DEBUG_RegisterStabsDebugInfo(DBG_MODULE* module, HANDLE hFile, void* nth, unsigned long nth_ofs);
extern void DEBUG_InitCVDataTypes(void);
extern int DEBUG_ProcessMSCDebugInfo(DBG_MODULE* module);
/* debugger/registers.c */
extern void DEBUG_SetRegister( enum debug_regs reg, int val );
......@@ -375,7 +375,8 @@ extern int DEBUG_GetCurrentFrame(struct name_hash ** name,
unsigned int * ebp);
/* debugger/stabs.c */
extern int DEBUG_ReadExecutableDbgInfo(void);
extern int DEBUG_ReadExecutableDbgInfo(const char* exe_name);
extern int DEBUG_ProcessElfObject(const char* filename, unsigned int load_offset);
extern int DEBUG_ParseStabs(char * addr, unsigned int load_offset, unsigned int staboff,
int stablen, unsigned int strtaboff, int strtablen);
......@@ -420,8 +421,16 @@ extern void DEBUG_Disassemble( const DBG_VALUE *, const DBG_VALUE*, int offset )
extern void DEBUG_ExternalDebugger(void);
/* debugger/dbg.y */
extern void DEBUG_Exit( DWORD exit_code );
extern BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code );
extern void DEBUG_Exit( DWORD );
/* debugger/winedbg.c */
#define DBG_CHN_MESG 1
#define DBG_CHN_ERR 2
#define DBG_CHN_WARN 4
#define DBG_CHN_FIXME 8
#define DBG_CHN_TRACE 16
extern int DEBUG_Printf(int chn, const char* format, ...);
/* Choose your allocator! */
#if 1
......@@ -455,4 +464,9 @@ extern HANDLE dbg_heap;
#define DEBUG_STATUS_DIV_BY_ZERO (DEBUG_STATUS_OFFSET+2)
#define DEBUG_STATUS_BAD_TYPE (DEBUG_STATUS_OFFSET+3)
#define DBG_IVAR(_var) DEBUG_IV_##_var
#define INTERNAL_VAR(_var,_val) extern int DBG_IVAR(_var);
#include "intvar.h"
#undef INTERNAL_VAR
#endif /* __WINE_DEBUGGER_H */
......@@ -60,9 +60,9 @@ DEBUG_InfoDisplay(void)
{
if( displaypoints[i].exp != NULL )
{
fprintf(stderr, "%d : ", i+1);
DEBUG_Printf(DBG_CHN_MESG, "%d : ", i+1);
DEBUG_DisplayExpr(displaypoints[i].exp);
fprintf(stderr, "\n");
DEBUG_Printf(DBG_CHN_MESG, "\n");
}
}
......@@ -85,16 +85,16 @@ DEBUG_DoDisplay(void)
value = DEBUG_EvalExpr(displaypoints[i].exp);
if( value.type == NULL )
{
fprintf(stderr, "Unable to evaluate expression ");
DEBUG_Printf(DBG_CHN_MESG, "Unable to evaluate expression ");
DEBUG_DisplayExpr(displaypoints[i].exp);
fprintf(stderr, "\nDisabling...\n");
DEBUG_Printf(DBG_CHN_MESG, "\nDisabling...\n");
DEBUG_DelDisplay(i);
}
else
{
fprintf(stderr, "%d : ", i + 1);
DEBUG_Printf(DBG_CHN_MESG, "%d : ", i + 1);
DEBUG_DisplayExpr(displaypoints[i].exp);
fprintf(stderr, " = ");
DEBUG_Printf(DBG_CHN_MESG, " = ");
if( displaypoints[i].format == 'i' )
{
DEBUG_ExamineMemory( &value,
......@@ -121,7 +121,7 @@ DEBUG_DelDisplay(int displaynum)
if( displaynum >= MAX_DISPLAY || displaynum == 0 || displaynum < -1 )
{
fprintf(stderr, "Invalid display number\n");
DEBUG_Printf(DBG_CHN_MESG, "Invalid display number\n");
return TRUE;
}
if( displaynum == -1 )
......
......@@ -418,7 +418,7 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp)
break;
}
#else
fprintf(stderr, "Function call no longer implemented\n");
DEBUG_Printf(DBG_CHN_MESG, "Function call no longer implemented\n");
/* would need to set up a call to this function, and then restore the current
* context afterwards...
*/
......@@ -637,7 +637,7 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp)
}
break;
default:
fprintf(stderr,"Unexpected expression (%d).\n", exp->type);
DEBUG_Printf(DBG_CHN_MESG,"Unexpected expression (%d).\n", exp->type);
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
break;
}
......@@ -656,111 +656,111 @@ DEBUG_DisplayExpr(const struct expr * exp)
switch(exp->type)
{
case EXPR_TYPE_CAST:
fprintf(stderr, "((");
DEBUG_Printf(DBG_CHN_MESG, "((");
DEBUG_PrintTypeCast(exp->un.cast.cast);
fprintf(stderr, ")");
DEBUG_Printf(DBG_CHN_MESG, ")");
DEBUG_DisplayExpr(exp->un.cast.expr);
fprintf(stderr, ")");
DEBUG_Printf(DBG_CHN_MESG, ")");
break;
case EXPR_TYPE_REGISTER:
DEBUG_PrintRegister(exp->un.rgister.reg);
break;
case EXPR_TYPE_US_CONST:
fprintf(stderr, "%ud", exp->un.u_const.value);
DEBUG_Printf(DBG_CHN_MESG, "%ud", exp->un.u_const.value);
break;
case EXPR_TYPE_CONST:
fprintf(stderr, "%d", exp->un.u_const.value);
DEBUG_Printf(DBG_CHN_MESG, "%d", exp->un.u_const.value);
break;
case EXPR_TYPE_STRING:
fprintf(stderr, "\"%s\"", exp->un.string.str);
DEBUG_Printf(DBG_CHN_MESG, "\"%s\"", exp->un.string.str);
break;
case EXPR_TYPE_SYMBOL:
fprintf(stderr, "%s" , exp->un.symbol.name);
DEBUG_Printf(DBG_CHN_MESG, "%s" , exp->un.symbol.name);
break;
case EXPR_TYPE_PSTRUCT:
DEBUG_DisplayExpr(exp->un.structure.exp1);
fprintf(stderr, "->%s", exp->un.structure.element_name);
DEBUG_Printf(DBG_CHN_MESG, "->%s", exp->un.structure.element_name);
break;
case EXPR_TYPE_STRUCT:
DEBUG_DisplayExpr(exp->un.structure.exp1);
fprintf(stderr, ".%s", exp->un.structure.element_name);
DEBUG_Printf(DBG_CHN_MESG, ".%s", exp->un.structure.element_name);
break;
case EXPR_TYPE_CALL:
fprintf(stderr, "%s(",exp->un.call.funcname);
DEBUG_Printf(DBG_CHN_MESG, "%s(",exp->un.call.funcname);
for(i=0; i < exp->un.call.nargs; i++)
{
DEBUG_DisplayExpr(exp->un.call.arg[i]);
if( i != exp->un.call.nargs - 1 )
{
fprintf(stderr, ", ");
DEBUG_Printf(DBG_CHN_MESG, ", ");
}
}
fprintf(stderr, ")");
DEBUG_Printf(DBG_CHN_MESG, ")");
break;
case EXPR_TYPE_BINOP:
fprintf(stderr, "( ");
DEBUG_Printf(DBG_CHN_MESG, "( ");
DEBUG_DisplayExpr(exp->un.binop.exp1);
switch(exp->un.binop.binop_type)
{
case EXP_OP_ADD:
fprintf(stderr, " + ");
DEBUG_Printf(DBG_CHN_MESG, " + ");
break;
case EXP_OP_SUB:
fprintf(stderr, " - ");
DEBUG_Printf(DBG_CHN_MESG, " - ");
break;
case EXP_OP_SEG:
fprintf(stderr, ":");
DEBUG_Printf(DBG_CHN_MESG, ":");
break;
case EXP_OP_LOR:
fprintf(stderr, " || ");
DEBUG_Printf(DBG_CHN_MESG, " || ");
break;
case EXP_OP_LAND:
fprintf(stderr, " && ");
DEBUG_Printf(DBG_CHN_MESG, " && ");
break;
case EXP_OP_OR:
fprintf(stderr, " | ");
DEBUG_Printf(DBG_CHN_MESG, " | ");
break;
case EXP_OP_AND:
fprintf(stderr, " & ");
DEBUG_Printf(DBG_CHN_MESG, " & ");
break;
case EXP_OP_XOR:
fprintf(stderr, " ^ ");
DEBUG_Printf(DBG_CHN_MESG, " ^ ");
break;
case EXP_OP_EQ:
fprintf(stderr, " == ");
DEBUG_Printf(DBG_CHN_MESG, " == ");
break;
case EXP_OP_GT:
fprintf(stderr, " > ");
DEBUG_Printf(DBG_CHN_MESG, " > ");
break;
case EXP_OP_LT:
fprintf(stderr, " < ");
DEBUG_Printf(DBG_CHN_MESG, " < ");
break;
case EXP_OP_GE:
fprintf(stderr, " >= ");
DEBUG_Printf(DBG_CHN_MESG, " >= ");
break;
case EXP_OP_LE:
fprintf(stderr, " <= ");
DEBUG_Printf(DBG_CHN_MESG, " <= ");
break;
case EXP_OP_NE:
fprintf(stderr, " != ");
DEBUG_Printf(DBG_CHN_MESG, " != ");
break;
case EXP_OP_SHL:
fprintf(stderr, " << ");
DEBUG_Printf(DBG_CHN_MESG, " << ");
break;
case EXP_OP_SHR:
fprintf(stderr, " >> ");
DEBUG_Printf(DBG_CHN_MESG, " >> ");
break;
case EXP_OP_MUL:
fprintf(stderr, " * ");
DEBUG_Printf(DBG_CHN_MESG, " * ");
break;
case EXP_OP_DIV:
fprintf(stderr, " / ");
DEBUG_Printf(DBG_CHN_MESG, " / ");
break;
case EXP_OP_REM:
fprintf(stderr, " %% ");
DEBUG_Printf(DBG_CHN_MESG, " %% ");
break;
case EXP_OP_ARR:
fprintf(stderr, "[");
DEBUG_Printf(DBG_CHN_MESG, "[");
break;
default:
break;
......@@ -768,33 +768,33 @@ DEBUG_DisplayExpr(const struct expr * exp)
DEBUG_DisplayExpr(exp->un.binop.exp2);
if( exp->un.binop.binop_type == EXP_OP_ARR )
{
fprintf(stderr, "]");
DEBUG_Printf(DBG_CHN_MESG, "]");
}
fprintf(stderr, " )");
DEBUG_Printf(DBG_CHN_MESG, " )");
break;
case EXPR_TYPE_UNOP:
switch(exp->un.unop.unop_type)
{
case EXP_OP_NEG:
fprintf(stderr, "-");
DEBUG_Printf(DBG_CHN_MESG, "-");
break;
case EXP_OP_NOT:
fprintf(stderr, "!");
DEBUG_Printf(DBG_CHN_MESG, "!");
break;
case EXP_OP_LNOT:
fprintf(stderr, "~");
DEBUG_Printf(DBG_CHN_MESG, "~");
break;
case EXP_OP_DEREF:
fprintf(stderr, "*");
DEBUG_Printf(DBG_CHN_MESG, "*");
break;
case EXP_OP_ADDR:
fprintf(stderr, "&");
DEBUG_Printf(DBG_CHN_MESG, "&");
break;
}
DEBUG_DisplayExpr(exp->un.unop.exp1);
break;
default:
fprintf(stderr,"Unexpected expression.\n");
DEBUG_Printf(DBG_CHN_MESG,"Unexpected expression.\n");
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
break;
}
......@@ -851,7 +851,7 @@ DEBUG_CloneExpr(const struct expr * exp)
rtn->un.unop.exp1 = DEBUG_CloneExpr(exp->un.unop.exp1);
break;
default:
fprintf(stderr,"Unexpected expression.\n");
DEBUG_Printf(DBG_CHN_MESG,"Unexpected expression.\n");
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
break;
}
......@@ -904,7 +904,7 @@ DEBUG_FreeExpr(struct expr * exp)
DEBUG_FreeExpr(exp->un.unop.exp1);
break;
default:
fprintf(stderr,"Unexpected expression.\n");
DEBUG_Printf(DBG_CHN_MESG,"Unexpected expression.\n");
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
break;
}
......
......@@ -146,7 +146,7 @@ DEBUG_ResortSymbols(void)
if( (nh->flags & SYM_INVALID) == 0 )
nsym++;
else
fprintf( stderr, "Symbol %s is invalid\n", nh->name );
DEBUG_Printf( DBG_CHN_MESG, "Symbol %s is invalid\n", nh->name );
}
}
......@@ -198,6 +198,10 @@ DEBUG_AddSymbol( const char * name, const DBG_VALUE *value, const char * source,
{
if( ((nh->flags & SYM_INVALID) != 0) && strcmp(name, nh->name) == 0 )
{
#if 0
DEBUG_Printf(DBG_CHN_MESG, "Changing address for symbol %s (%08lx:%08lx => %08lx:%08lx)\n",
name, nh->value.addr.seg, nh->value.addr.off, value->addr.seg, value->addr.off);
#endif
nh->value.addr = value->addr;
if( nh->value.type == NULL && value->type != NULL )
......@@ -223,6 +227,11 @@ DEBUG_AddSymbol( const char * name, const DBG_VALUE *value, const char * source,
}
}
#if 0
DEBUG_Printf(DBG_CHN_TRACE, "adding symbol (%s) from file '%s' at 0x%04lx:%08lx\n",
name, source, value->addr.seg, value->addr.off);
#endif
/*
* First see if we already have an entry for this symbol. If so
* return it, so we don't end up with duplicates.
......@@ -564,7 +573,7 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
}
nearest = addr_sorttab[mid];
#if 0
fprintf(stderr, "Found %x:%x when looking for %x:%x %x %s\n",
DEBUG_Printf(DBG_CHN_MESG, "Found %x:%x when looking for %x:%x %x %s\n",
addr_sorttab[mid ]->value.addr.seg,
addr_sorttab[mid ]->value.addr.off,
addr->seg, addr->off,
......@@ -722,7 +731,6 @@ void DEBUG_ReadSymbolTable( const char * filename )
{
FILE * symbolfile;
DBG_VALUE value;
int nargs;
char type;
char * cpnt;
char buffer[256];
......@@ -730,11 +738,11 @@ void DEBUG_ReadSymbolTable( const char * filename )
if (!(symbolfile = fopen(filename, "r")))
{
fprintf( stderr, "Unable to open symbol table %s\n", filename );
DEBUG_Printf( DBG_CHN_WARN, "Unable to open symbol table %s\n", filename );
return;
}
fprintf( stderr, "Reading symbols from file %s\n", filename );
DEBUG_Printf( DBG_CHN_MESG, "Reading symbols from file %s\n", filename );
value.type = NULL;
value.addr.seg = 0;
......@@ -760,7 +768,7 @@ void DEBUG_ReadSymbolTable( const char * filename )
}
if (!(*cpnt) || *cpnt == '\n') continue;
nargs = sscanf(buffer, "%lx %c %s", &value.addr.off, &type, name);
if (sscanf(buffer, "%lx %c %s", &value.addr.off, &type, name) == 3)
DEBUG_AddSymbol( name, &value, NULL, SYM_WINE );
}
fclose(symbolfile);
......@@ -837,7 +845,7 @@ DEBUG_DumpHashInfo(void)
{
depth++;
}
fprintf(stderr, "Bucket %d: %d\n", i, depth);
DEBUG_Printf(DBG_CHN_MESG, "Bucket %d: %d\n", i, depth);
}
}
......@@ -913,7 +921,7 @@ int DEBUG_CheckLinenoStatus( const DBG_ADDR *addr)
}
nearest = addr_sorttab[mid];
#if 0
fprintf(stderr, "Found %x:%x when looking for %x:%x %x %s\n",
DEBUG_Printf(DBG_CHN_MESG, "Found %x:%x when looking for %x:%x %x %s\n",
addr_sorttab[mid ]->value.addr.seg,
addr_sorttab[mid ]->value.addr.off,
addr->seg, addr->off,
......@@ -1055,11 +1063,11 @@ DEBUG_GetFuncInfo( struct list_id * ret, const char * filename,
{
if( filename != NULL )
{
fprintf(stderr, "No such function %s in %s\n", name, filename);
DEBUG_Printf(DBG_CHN_MESG, "No such function %s in %s\n", name, filename);
}
else
{
fprintf(stderr, "No such function %s\n", name);
DEBUG_Printf(DBG_CHN_MESG, "No such function %s\n", name);
}
ret->sourcefile = NULL;
ret->line = -1;
......@@ -1188,7 +1196,7 @@ DEBUG_InfoLocals(void)
{
ptr = (unsigned int *)(((DWORD)&DEBUG_context)
+ reg_ofs[curr_func->local_vars[i].regno - 1]);
fprintf(stderr, "%s:%s (optimized into register $%s) == 0x%8.8x\n",
DEBUG_Printf(DBG_CHN_MESG, "%s:%s (optimized into register $%s) == 0x%8.8x\n",
curr_func->name, curr_func->local_vars[i].name,
reg_name[curr_func->local_vars[i].regno - 1],
*ptr);
......@@ -1197,7 +1205,7 @@ DEBUG_InfoLocals(void)
{
DEBUG_READ_MEM_VERBOSE((void*)(ebp + curr_func->local_vars[i].offset),
&val, sizeof(val));
fprintf(stderr, "%s:%s == 0x%8.8x\n",
DEBUG_Printf(DBG_CHN_MESG, "%s:%s == 0x%8.8x\n",
curr_func->name, curr_func->local_vars[i].name, val);
}
}
......
INTERNAL_VAR(BreakAllThreadsStartup, FALSE)
INTERNAL_VAR(ExtDbgOnInvalidAddress, FALSE)
INTERNAL_VAR(ChannelMask, DBG_CHN_MESG)
......@@ -23,7 +23,7 @@
static void DEBUG_Die(const char* msg)
{
fprintf(stderr, msg);
DEBUG_Printf(DBG_CHN_MESG, msg);
exit(1);
}
......@@ -118,16 +118,21 @@ void DEBUG_GetCurrentAddress( DBG_ADDR *addr )
#endif
}
void DEBUG_InvalAddr( const DBG_ADDR* addr )
{
DEBUG_Printf(DBG_CHN_MESG,"*** Invalid address ");
DEBUG_PrintAddress(addr, DEBUG_CurrThread->dbg_mode, FALSE);
DEBUG_Printf(DBG_CHN_MESG,"\n");
if (DBG_IVAR(ExtDbgOnInvalidAddress)) DEBUG_ExternalDebugger();
}
void DEBUG_InvalLinAddr( void* addr )
{
DBG_ADDR address;
address.seg = 0;
address.off = (unsigned long)addr;
fprintf(stderr,"*** Invalid address ");
DEBUG_PrintAddress(&address, DEBUG_CurrThread->dbg_mode, FALSE);
fprintf(stderr,"\n");
DEBUG_InvalAddr( &address );
}
/***********************************************************************
......@@ -215,14 +220,14 @@ void DEBUG_ExamineMemory( const DBG_VALUE *_value, int count, char format )
}
else if (!value.addr.seg && !value.addr.off)
{
fprintf(stderr,"Invalid expression\n");
DEBUG_Printf(DBG_CHN_MESG,"Invalid expression\n");
return;
}
if (format != 'i' && count > 1)
{
DEBUG_PrintAddress( &value.addr, DEBUG_CurrThread->dbg_mode, FALSE );
fprintf(stderr,": ");
DEBUG_Printf(DBG_CHN_MESG,": ");
}
pnt = (void*)DEBUG_ToLinear( &value.addr );
......@@ -239,7 +244,7 @@ void DEBUG_ExamineMemory( const DBG_VALUE *_value, int count, char format )
pnt += sizeof(wch);
fputc( (char)wch, stderr );
}
fprintf(stderr,"\n");
DEBUG_Printf(DBG_CHN_MESG,"\n");
return;
}
case 's': {
......@@ -253,31 +258,31 @@ void DEBUG_ExamineMemory( const DBG_VALUE *_value, int count, char format )
pnt++;
fputc( ch, stderr );
}
fprintf(stderr,"\n");
DEBUG_Printf(DBG_CHN_MESG,"\n");
return;
}
case 'i':
while (count--)
{
DEBUG_PrintAddress( &value.addr, DEBUG_CurrThread->dbg_mode, TRUE );
fprintf(stderr,": ");
DEBUG_Printf(DBG_CHN_MESG,": ");
DEBUG_Disasm( &value.addr, TRUE );
fprintf(stderr,"\n");
DEBUG_Printf(DBG_CHN_MESG,"\n");
}
return;
#define DO_DUMP2(_t,_l,_f,_vv) { \
_t _v; \
for(i=0; i<count; i++) { \
if (!DEBUG_READ_MEM_VERBOSE(pnt, &_v, sizeof(_t))) break; \
fprintf(stderr,_f,(_vv)); \
DEBUG_Printf(DBG_CHN_MESG,_f,(_vv)); \
pnt += sizeof(_t); value.addr.off += sizeof(_t); \
if ((i % (_l)) == (_l)-1) { \
fprintf(stderr,"\n"); \
DEBUG_Printf(DBG_CHN_MESG,"\n"); \
DEBUG_PrintAddress( &value.addr, DEBUG_CurrThread->dbg_mode, FALSE );\
fprintf(stderr,": ");\
DEBUG_Printf(DBG_CHN_MESG,": ");\
} \
} \
fprintf(stderr,"\n"); \
DEBUG_Printf(DBG_CHN_MESG,"\n"); \
} \
return
#define DO_DUMP(_t,_l,_f) DO_DUMP2(_t,_l,_f,_v)
......
......@@ -12,6 +12,7 @@
#include "neexe.h"
#include "peexe.h"
#include "module.h"
#include "file.h"
#include "debugger.h"
#include "toolhelp.h"
......@@ -232,7 +233,7 @@ static void DEBUG_LoadModule16(HMODULE hModule, NE_MODULE* module, char* moduleA
/***********************************************************************
* DEBUG_LoadModule32
*/
void DEBUG_LoadModule32(const char* name, DWORD base)
void DEBUG_LoadModule32(const char* name, HANDLE hFile, DWORD base)
{
DBG_VALUE value;
char buffer[256];
......@@ -249,7 +250,7 @@ void DEBUG_LoadModule32(const char* name, DWORD base)
/* FIXME: we make the assumption that hModule == base */
wmod = DEBUG_RegisterPEModule((HMODULE)base, base, name);
fprintf(stderr, "Registring 32bit DLL '%s' at %08lx\n", name, base);
DEBUG_Printf(DBG_CHN_TRACE, "Registring 32bit DLL '%s' at %08lx\n", name, base);
value.type = NULL;
value.cookie = DV_TARGET;
......@@ -264,8 +265,8 @@ void DEBUG_LoadModule32(const char* name, DWORD base)
return;
if (wmod) {
DEBUG_RegisterMSCDebugInfo(wmod, &pe_header, pe_header_ofs);
DEBUG_RegisterStabsDebugInfo(wmod, &pe_header, pe_header_ofs);
DEBUG_RegisterStabsDebugInfo(wmod, hFile, &pe_header, pe_header_ofs);
DEBUG_RegisterMSCDebugInfo(wmod, hFile, &pe_header, pe_header_ofs);
}
/* Add start of DLL */
......@@ -282,11 +283,9 @@ void DEBUG_LoadModule32(const char* name, DWORD base)
pe_header.FileHeader.SizeOfOptionalHeader;
for (i = 0; i < pe_header.FileHeader.NumberOfSections; i++, pe_seg_ofs += sizeof(pe_seg)) {
if (!DEBUG_READ_MEM_VERBOSE((void*)(base + pe_seg_ofs), &pe_seg, sizeof(pe_seg)) ||
!DEBUG_READ_MEM_VERBOSE((void*)pe_seg.Name, bufstr, sizeof(bufstr)))
if (!DEBUG_READ_MEM_VERBOSE((void*)(base + pe_seg_ofs), &pe_seg, sizeof(pe_seg)))
continue;
bufstr[sizeof(bufstr) - 1] = 0;
sprintf(buffer, "%s.%s", name, bufstr);
sprintf(buffer, "%s.%s", name, pe_seg.Name);
value.addr.off = base + pe_seg.VirtualAddress;
DEBUG_AddSymbol(buffer, &value, NULL, SYM_WIN32 | SYM_FUNC);
}
......@@ -359,6 +358,10 @@ int DEBUG_LoadEntryPoints(const char* pfx)
int len;
/* FIXME: we assume that a module is never removed from memory */
/* FIXME: this is (currently plain wrong when debugger is started by
* attaching to an existing program => the 16 bit modules will
* not be shared... not much to do on debugger side... sigh
*/
if (ModuleFirst16(&entry)) do {
if (DEBUG_FindModuleByName(entry.szModule, DM_TYPE_UNKNOWN) ||
!(moduleAddr = NE_GetPtr(entry.hModule)) ||
......@@ -366,69 +369,28 @@ int DEBUG_LoadEntryPoints(const char* pfx)
(module.flags & NE_FFLAGS_WIN32) /* NE module */)
continue;
if (!first) {
if (pfx) fprintf(stderr, pfx);
fprintf(stderr, " ");
if (pfx) DEBUG_Printf(DBG_CHN_MESG, pfx);
DEBUG_Printf(DBG_CHN_MESG, " ");
rowcount = 3 + (pfx ? strlen(pfx) : 0);
first = 1;
}
len = strlen(entry.szModule);
if ((rowcount + len) > 76) {
fprintf(stderr, "\n ");
DEBUG_Printf(DBG_CHN_MESG, "\n ");
rowcount = 3;
}
fprintf(stderr, " %s", entry.szModule);
DEBUG_Printf(DBG_CHN_MESG, " %s", entry.szModule);
rowcount += len + 1;
DEBUG_LoadModule16(entry.hModule, &module, moduleAddr, entry.szModule);
} while (ModuleNext16(&entry));
if (first) fprintf(stderr, "\n");
if (first) DEBUG_Printf(DBG_CHN_MESG, "\n");
return first;
}
/***********************************************************************
* DEBUG_ProcessDeferredDebug
*
*/
int DEBUG_ProcessDeferredDebug(void)
{
DBG_MODULE* wmod;
int sts;
int last_proc = -1;
int need_print = 0;
int rowcount = 0;
int len;
for (wmod = DEBUG_CurrProcess->modules; wmod; wmod = wmod->next) {
if (wmod->status != DM_STATUS_NEW) continue;
if (last_proc != wmod->dbg_index) {
if (!need_print) {
fprintf(stderr, "DeferredDebug for:");
rowcount = 18;
need_print = 1;
}
if (rowcount + (len = strlen(wmod->module_name)) > 76) {
rowcount = 0;
fprintf(stderr, "\n");
} else {
fprintf(stderr, " ");
rowcount++;
}
rowcount += len;
fprintf(stderr, wmod->module_name);
last_proc = wmod->dbg_index;
}
sts = (wmod->extra_info) ? DEBUG_ProcessMSCDebugInfo(wmod) : TRUE;
wmod->status = (sts) ? DM_STATUS_LOADED : DM_STATUS_ERROR;
}
if (need_print) fprintf(stderr, "\n");
return TRUE;
}
/***********************************************************************
* DEBUG_InfoShare
*
* Display shared libarary information.
......@@ -438,7 +400,7 @@ void DEBUG_InfoShare(void)
DBG_MODULE* wmod;
const char* xtype;
fprintf(stderr, "Address\t\tModule\tName\n");
DEBUG_Printf(DBG_CHN_MESG, "Address\t\tModule\tName\n");
for (wmod = DEBUG_CurrProcess->modules; wmod; wmod = wmod->next) {
switch (wmod->type) {
......@@ -447,7 +409,7 @@ void DEBUG_InfoShare(void)
case DM_TYPE_ELF: xtype = "ELF"; break;
default: xtype = "???"; break;
}
fprintf(stderr, "0x%8.8x\t(%s)\t%s\n", (unsigned int)wmod->load_addr,
DEBUG_Printf(DBG_CHN_MESG, "0x%8.8x\t(%s)\t%s\n", (unsigned int)wmod->load_addr,
xtype, wmod->module_name);
}
}
......@@ -482,11 +444,11 @@ void DEBUG_DumpModule(DWORD mod)
if (!(wmod = DEBUG_FindModuleByHandle(mod, DM_TYPE_UNKNOWN)) &&
!(wmod = DEBUG_FindModuleByAddr((void*)mod, DM_TYPE_UNKNOWN))) {
fprintf(stderr, "'0x%08lx' is not a valid module handle or address\n", mod);
DEBUG_Printf(DBG_CHN_MESG, "'0x%08lx' is not a valid module handle or address\n", mod);
return;
}
fprintf(stderr, "Module '%s' (handle=0x%08x) at 0x%8.8x (%s/%s)\n",
DEBUG_Printf(DBG_CHN_MESG, "Module '%s' (handle=0x%08x) at 0x%8.8x (%s/%s)\n",
wmod->module_name, wmod->handle, (unsigned int)wmod->load_addr,
DEBUG_GetModuleType(wmod->type), DEBUG_GetModuleStatus(wmod->status));
}
......@@ -501,7 +463,7 @@ void DEBUG_WalkModules(void)
DBG_MODULE* wmod;
const char* xtype;
fprintf(stderr, "Address\t\tModule\tName\n");
DEBUG_Printf(DBG_CHN_MESG, "Address\t\tModule\tName\n");
for (wmod = DEBUG_CurrProcess->modules; wmod; wmod = wmod->next) {
switch (wmod->type) {
......@@ -511,7 +473,7 @@ void DEBUG_WalkModules(void)
default: xtype = "???"; break;
}
fprintf(stderr, "0x%8.8x\t(%s)\t%s\n",
DEBUG_Printf(DBG_CHN_MESG, "0x%8.8x\t(%s)\t%s\n",
(unsigned int)wmod->load_addr, DEBUG_GetModuleType(wmod->type),
wmod->module_name);
}
......
......@@ -85,7 +85,7 @@ int DEBUG_PrintRegister(enum debug_regs reg)
case REG_FS: val = "%%fs"; break;
case REG_GS: val = "%%gs"; break;
}
if (val) fprintf(stderr, val);
if (val) DEBUG_Printf(DBG_CHN_MESG, val);
return TRUE;
#else
return FALSE;
......@@ -195,11 +195,11 @@ char *DEBUG_Flags( DWORD flag, char *buf )
*/
void DEBUG_InfoRegisters(void)
{
fprintf(stderr,"Register dump:\n");
DEBUG_Printf(DBG_CHN_MESG,"Register dump:\n");
#ifdef __i386__
/* First get the segment registers out of the way */
fprintf( stderr," CS:%04x SS:%04x DS:%04x ES:%04x FS:%04x GS:%04x",
DEBUG_Printf( DBG_CHN_MESG," CS:%04x SS:%04x DS:%04x ES:%04x FS:%04x GS:%04x",
(WORD)DEBUG_context.SegCs, (WORD)DEBUG_context.SegSs,
(WORD)DEBUG_context.SegDs, (WORD)DEBUG_context.SegEs,
(WORD)DEBUG_context.SegFs, (WORD)DEBUG_context.SegGs );
......@@ -207,11 +207,11 @@ void DEBUG_InfoRegisters(void)
{
char flag[33];
fprintf( stderr,"\n IP:%04x SP:%04x BP:%04x FLAGS:%04x(%s)\n",
DEBUG_Printf( DBG_CHN_MESG,"\n IP:%04x SP:%04x BP:%04x FLAGS:%04x(%s)\n",
LOWORD(DEBUG_context.Eip), LOWORD(DEBUG_context.Esp),
LOWORD(DEBUG_context.Ebp), LOWORD(DEBUG_context.EFlags),
DEBUG_Flags(LOWORD(DEBUG_context.EFlags), flag));
fprintf( stderr," AX:%04x BX:%04x CX:%04x DX:%04x SI:%04x DI:%04x\n",
DEBUG_Printf( DBG_CHN_MESG," AX:%04x BX:%04x CX:%04x DX:%04x SI:%04x DI:%04x\n",
LOWORD(DEBUG_context.Eax), LOWORD(DEBUG_context.Ebx),
LOWORD(DEBUG_context.Ecx), LOWORD(DEBUG_context.Edx),
LOWORD(DEBUG_context.Esi), LOWORD(DEBUG_context.Edi) );
......@@ -220,14 +220,14 @@ void DEBUG_InfoRegisters(void)
{
char flag[33];
fprintf( stderr, "\n EIP:%08lx ESP:%08lx EBP:%08lx EFLAGS:%08lx(%s)\n",
DEBUG_Printf( DBG_CHN_MESG, "\n EIP:%08lx ESP:%08lx EBP:%08lx EFLAGS:%08lx(%s)\n",
DEBUG_context.Eip, DEBUG_context.Esp,
DEBUG_context.Ebp, DEBUG_context.EFlags,
DEBUG_Flags(DEBUG_context.EFlags, flag));
fprintf( stderr, " EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n",
DEBUG_Printf( DBG_CHN_MESG, " EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n",
DEBUG_context.Eax, DEBUG_context.Ebx,
DEBUG_context.Ecx, DEBUG_context.Edx );
fprintf( stderr, " ESI:%08lx EDI:%08lx\n",
DEBUG_Printf( DBG_CHN_MESG, " ESI:%08lx EDI:%08lx\n",
DEBUG_context.Esi, DEBUG_context.Edi );
}
#endif
......@@ -249,7 +249,7 @@ BOOL DEBUG_ValidateRegisters(void)
/* Check that a selector is a valid ring-3 LDT selector, or a NULL selector */
#define CHECK_SEG(seg,name) \
if (((seg) & ~3) && ((((seg) & 7) != 7) || !DEBUG_IsSelector(seg))) { \
fprintf( stderr, "*** Invalid value for %s register: %04x\n", \
DEBUG_Printf( DBG_CHN_MESG, "*** Invalid value for %s register: %04x\n", \
(name), (WORD)(seg) ); \
return FALSE; \
}
......@@ -268,13 +268,13 @@ BOOL DEBUG_ValidateRegisters(void)
if (!(DEBUG_context.SegCs & ~3))
{
fprintf( stderr, "*** Invalid value for CS register: %04x\n",
DEBUG_Printf( DBG_CHN_MESG, "*** Invalid value for CS register: %04x\n",
(WORD)DEBUG_context.SegCs );
return FALSE;
}
if (!(DEBUG_context.SegSs & ~3))
{
fprintf( stderr, "*** Invalid value for SS register: %04x\n",
DEBUG_Printf( DBG_CHN_MESG, "*** Invalid value for SS register: %04x\n",
(WORD)DEBUG_context.SegSs );
return FALSE;
}
......
......@@ -53,12 +53,12 @@ DEBUG_ShowDir(void)
{
struct searchlist * sl;
fprintf(stderr,"Search list :\n");
DEBUG_Printf(DBG_CHN_MESG,"Search list :\n");
for(sl = listhead; sl; sl = sl->next)
{
fprintf(stderr, "\t%s\n", sl->path);
DEBUG_Printf(DBG_CHN_MESG, "\t%s\n", sl->path);
}
fprintf(stderr, "\n");
DEBUG_Printf(DBG_CHN_MESG, "\n");
}
void
......@@ -186,7 +186,7 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
/*
* Still couldn't find it. Ask user for path to add.
*/
fprintf(stderr,"Enter path to file %s: ", sourcefile);
DEBUG_Printf(DBG_CHN_MESG,"Enter path to file %s: ", sourcefile);
fgets(tmppath, sizeof(tmppath), stdin);
if( tmppath[strlen(tmppath)-1] == '\n' )
......@@ -217,7 +217,7 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
ol->nlines = 0;
ol->linelist = NULL;
ofiles = ol;
fprintf(stderr,"Unable to open file %s\n", tmppath);
DEBUG_Printf(DBG_CHN_MESG,"Unable to open file %s\n", tmppath);
return FALSE;
}
}
......@@ -314,7 +314,7 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
memcpy(&buffer, addr + ol->linelist[i],
(ol->linelist[i+1] - ol->linelist[i]) - 1);
}
fprintf(stderr,"%d\t%s\n", i + 1, buffer);
DEBUG_Printf(DBG_CHN_MESG,"%d\t%s\n", i + 1, buffer);
}
munmap(addr, ol->size);
......@@ -343,7 +343,7 @@ DEBUG_List(struct list_id * source1, struct list_id * source2,
&& source2->sourcefile != NULL
&& strcmp(source1->sourcefile, source2->sourcefile) != 0 )
{
fprintf(stderr, "Ambiguous source file specification.\n");
DEBUG_Printf(DBG_CHN_MESG, "Ambiguous source file specification.\n");
return;
}
......@@ -367,7 +367,7 @@ DEBUG_List(struct list_id * source1, struct list_id * source2,
if( sourcefile == NULL )
{
fprintf(stderr, "No source file specified.\n");
DEBUG_Printf(DBG_CHN_MESG, "No source file specified.\n");
return;
}
......@@ -430,10 +430,10 @@ _disassemble(DBG_ADDR *addr)
char ch;
DEBUG_PrintAddress( addr, DEBUG_CurrThread->dbg_mode, TRUE );
fprintf(stderr,": ");
DEBUG_Printf(DBG_CHN_MESG,": ");
if (!DEBUG_READ_MEM_VERBOSE((void*)DEBUG_ToLinear(addr), &ch, sizeof(ch))) return 0;
DEBUG_Disasm( addr, TRUE );
fprintf(stderr,"\n");
DEBUG_Printf(DBG_CHN_MESG,"\n");
return 1;
}
......@@ -469,7 +469,7 @@ _disassemble_fixaddr(DBG_VALUE *value) {
}
else if (!value->addr.seg && !value->addr.off)
{
fprintf(stderr,"Invalid expression\n");
DEBUG_Printf(DBG_CHN_MESG,"Invalid expression\n");
return;
}
}
......
......@@ -64,7 +64,7 @@ void DEBUG_InfoStack(void)
value.addr.seg = DEBUG_context.SegSs;
value.addr.off = DEBUG_context.Esp;
fprintf(stderr,"Stack dump:\n");
DEBUG_Printf(DBG_CHN_MESG,"Stack dump:\n");
switch (DEBUG_GetSelectorType(value.addr.seg)) {
case 32: /* 32-bit mode */
DEBUG_ExamineMemory( &value, 24, 'x' );
......@@ -74,9 +74,9 @@ void DEBUG_InfoStack(void)
DEBUG_ExamineMemory( &value, 24, 'w' );
break;
default:
fprintf(stderr, "Bad segment (%ld)\n", value.addr.seg);
DEBUG_Printf(DBG_CHN_MESG, "Bad segment (%ld)\n", value.addr.seg);
}
fprintf(stderr,"\n");
DEBUG_Printf(DBG_CHN_MESG,"\n");
#endif
}
......@@ -87,7 +87,7 @@ static void DEBUG_ForceFrame(DBG_ADDR *stack, DBG_ADDR *code, int frameno, int b
frames = (struct bt_info *)DBG_realloc(frames,
nframe*sizeof(struct bt_info));
if (noisy)
fprintf(stderr,"%s%d ", (theframe == curr_frame ? "=>" : " "),
DEBUG_Printf(DBG_CHN_MESG,"%s%d ", (theframe == curr_frame ? "=>" : " "),
frameno);
frames[theframe].cs = code->seg;
frames[theframe].eip = code->off;
......@@ -101,7 +101,7 @@ static void DEBUG_ForceFrame(DBG_ADDR *stack, DBG_ADDR *code, int frameno, int b
frames[theframe].ss = stack->seg;
frames[theframe].ebp = stack->off;
if (noisy) {
fprintf( stderr, (bits == 16) ? " (bp=%04lx)\n" : " (ebp=%08lx)\n", stack->off );
DEBUG_Printf( DBG_CHN_MESG, (bits == 16) ? " (bp=%04lx)\n" : " (ebp=%08lx)\n", stack->off );
}
}
......@@ -115,11 +115,7 @@ static BOOL DEBUG_Frame16(DBG_ADDR *addr, unsigned int *cs, int frameno, int noi
if (!p) return FALSE;
if (!DEBUG_READ_MEM(p, &frame, sizeof(frame))) {
if (noisy) {
fprintf(stderr,"*** Invalid address ");
DEBUG_PrintAddress(addr, DEBUG_CurrThread->dbg_mode, FALSE);
fprintf(stderr,"\n");
}
if (noisy) DEBUG_InvalAddr(addr);
return FALSE;
}
if (!frame.bp) return FALSE;
......@@ -127,7 +123,7 @@ static BOOL DEBUG_Frame16(DBG_ADDR *addr, unsigned int *cs, int frameno, int noi
frames = (struct bt_info *)DBG_realloc(frames,
nframe*sizeof(struct bt_info));
if (noisy)
fprintf(stderr,"%s%d ", (theframe == curr_frame ? "=>" : " "),
DEBUG_Printf(DBG_CHN_MESG,"%s%d ", (theframe == curr_frame ? "=>" : " "),
frameno);
if (frame.bp & 1) *cs = frame.cs;
else {
......@@ -156,11 +152,11 @@ static BOOL DEBUG_Frame16(DBG_ADDR *addr, unsigned int *cs, int frameno, int noi
frames[theframe].ss = addr->seg = ss;
frames[theframe].ebp = addr->off = frame.bp & ~1;
if (noisy) {
fprintf( stderr, " (bp=%04lx", addr->off );
DEBUG_Printf( DBG_CHN_MESG, " (bp=%04lx", addr->off );
if (possible_cs) {
fprintf( stderr, ", far call assumed" );
DEBUG_Printf( DBG_CHN_MESG, ", far call assumed" );
}
fprintf( stderr, ")\n" );
DEBUG_Printf( DBG_CHN_MESG, ")\n" );
}
return TRUE;
}
......@@ -175,11 +171,7 @@ static BOOL DEBUG_Frame32(DBG_ADDR *addr, unsigned int *cs, int frameno, int noi
if (!p) return FALSE;
if (!DEBUG_READ_MEM(p, &frame, sizeof(frame))) {
if (noisy) {
fprintf(stderr,"*** Invalid address ");
DEBUG_PrintAddress(addr, DEBUG_CurrThread->dbg_mode, FALSE);
fprintf(stderr,"\n");
}
if (noisy) DEBUG_InvalAddr(addr);
return FALSE;
}
if (!frame.ip) return FALSE;
......@@ -188,7 +180,7 @@ static BOOL DEBUG_Frame32(DBG_ADDR *addr, unsigned int *cs, int frameno, int noi
frames = (struct bt_info *)DBG_realloc(frames,
nframe*sizeof(struct bt_info));
if (noisy)
fprintf(stderr,"%s%d ", (theframe == curr_frame ? "=>" : " "),
DEBUG_Printf(DBG_CHN_MESG,"%s%d ", (theframe == curr_frame ? "=>" : " "),
frameno);
frames[theframe].cs = addr->seg = *cs;
frames[theframe].eip = addr->off = frame.ip;
......@@ -199,7 +191,7 @@ static BOOL DEBUG_Frame32(DBG_ADDR *addr, unsigned int *cs, int frameno, int noi
DEBUG_FindNearestSymbol( addr, TRUE,
&frames[theframe].frame.sym, frame.bp,
&frames[theframe].frame.list);
if (noisy) fprintf( stderr, " (ebp=%08lx)\n", frame.bp );
if (noisy) DEBUG_Printf( DBG_CHN_MESG, " (ebp=%08lx)\n", frame.bp );
frames[theframe].ss = addr->seg = ss;
frames[theframe].ebp = frame.bp;
if (addr->off == frame.bp) return FALSE;
......@@ -226,13 +218,13 @@ void DEBUG_BackTrace(BOOL noisy)
STACK32FRAME frame32;
char ch;
if (noisy) fprintf( stderr, "Backtrace:\n" );
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "Backtrace:\n" );
nframe = 1;
if (frames) DBG_free( frames );
frames = (struct bt_info *) DBG_alloc( sizeof(struct bt_info) );
if (noisy)
fprintf(stderr,"%s%d ",(curr_frame == 0 ? "=>" : " "), frameno);
DEBUG_Printf(DBG_CHN_MESG,"%s%d ",(curr_frame == 0 ? "=>" : " "), frameno);
if (DEBUG_IsSelectorSystem(ss)) ss = 0;
if (DEBUG_IsSelectorSystem(cs)) cs = 0;
......@@ -250,7 +242,7 @@ void DEBUG_BackTrace(BOOL noisy)
&frames[0].frame.list);
frames[0].ss = addr.seg = ss;
frames[0].ebp = addr.off = DEBUG_context.Ebp;
if (noisy) fprintf( stderr, " (ebp=%08x)\n", frames[0].ebp );
if (noisy) DEBUG_Printf( DBG_CHN_MESG, " (ebp=%08x)\n", frames[0].ebp );
is16 = FALSE;
break;
case 16:
......@@ -263,11 +255,11 @@ void DEBUG_BackTrace(BOOL noisy)
&frames[0].frame.list);
frames[0].ss = addr.seg = ss;
frames[0].ebp = addr.off = LOWORD(DEBUG_context.Ebp);
if (noisy) fprintf( stderr, " (bp=%04x)\n", frames[0].ebp );
if (noisy) DEBUG_Printf( DBG_CHN_MESG, " (bp=%04x)\n", frames[0].ebp );
is16 = TRUE;
break;
default:
if (noisy) fprintf( stderr, "Bad segment '%u'\n", ss);
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "Bad segment '%u'\n", ss);
return;
}
......@@ -276,13 +268,13 @@ void DEBUG_BackTrace(BOOL noisy)
*/
cur_switch = (DWORD)DEBUG_CurrThread->teb + OFFSET_OF(TEB, cur_stack);
if (!DEBUG_READ_MEM((void*)cur_switch, &next_switch, sizeof(next_switch))) {
if (noisy) fprintf( stderr, "Can't read TEB:cur_stack\n");
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "Can't read TEB:cur_stack\n");
return;
}
if (is16) {
if (!DEBUG_READ_MEM((void*)next_switch, &frame32, sizeof(STACK32FRAME))) {
if (noisy) fprintf( stderr, "Bad stack frame %p\n",
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "Bad stack frame %p\n",
(STACK32FRAME*)next_switch );
return;
}
......@@ -295,7 +287,7 @@ void DEBUG_BackTrace(BOOL noisy)
p = DEBUG_ToLinear(&tmp);
if (!DEBUG_READ_MEM((void*)p, &frame16, sizeof(STACK16FRAME))) {
if (noisy) fprintf( stderr, "Bad stack frame %p\n", (STACK16FRAME*)p );
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "Bad stack frame %p\n", (STACK16FRAME*)p );
return;
}
cur_switch = (DWORD)frame16.frame32;
......@@ -315,7 +307,7 @@ void DEBUG_BackTrace(BOOL noisy)
if (is16) {
if (!DEBUG_READ_MEM((void*)next_switch, &frame32, sizeof(STACK32FRAME))) {
if (noisy) fprintf( stderr, "Bad stack frame %p\n", (STACK32FRAME*)next_switch );
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "Bad stack frame %p\n", (STACK32FRAME*)next_switch );
return;
}
......@@ -333,7 +325,7 @@ void DEBUG_BackTrace(BOOL noisy)
p = DEBUG_ToLinear(&tmp);
if (!DEBUG_READ_MEM((void*)p, &frame16, sizeof(STACK16FRAME))) {
if (noisy) fprintf( stderr, "Bad stack frame %p\n",
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "Bad stack frame %p\n",
(STACK16FRAME*)p );
return;
}
......@@ -348,7 +340,7 @@ void DEBUG_BackTrace(BOOL noisy)
p = DEBUG_ToLinear(&tmp);
if (!DEBUG_READ_MEM((void*)p, &frame16, sizeof(STACK16FRAME))) {
if (noisy) fprintf( stderr, "Bad stack frame %p\n",
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "Bad stack frame %p\n",
(STACK16FRAME*)p );
return;
}
......@@ -363,7 +355,7 @@ void DEBUG_BackTrace(BOOL noisy)
next_switch = cur_switch;
if (!DEBUG_READ_MEM((void*)next_switch, &frame32, sizeof(STACK32FRAME))) {
if (noisy) fprintf( stderr, "Bad stack frame %p\n",
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "Bad stack frame %p\n",
(STACK32FRAME*)next_switch );
return;
}
......@@ -383,7 +375,7 @@ void DEBUG_BackTrace(BOOL noisy)
: DEBUG_Frame32( &addr, &cs, ++frameno, noisy);
}
}
if (noisy) fprintf( stderr, "\n" );
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "\n" );
#endif
}
......
......@@ -794,7 +794,7 @@ DEBUG_Print( const DBG_VALUE *value, int count, char format, int level )
if (count != 1)
{
fprintf( stderr, "Count other than 1 is meaningless in 'print' command\n" );
DEBUG_Printf( DBG_CHN_MESG, "Count other than 1 is meaningless in 'print' command\n" );
return;
}
......@@ -802,8 +802,8 @@ DEBUG_Print( const DBG_VALUE *value, int count, char format, int level )
{
/* No type, just print the addr value */
if (value->addr.seg && (value->addr.seg != 0xffffffff))
DEBUG_nchar += fprintf( stderr, "0x%04lx: ", value->addr.seg );
DEBUG_nchar += fprintf( stderr, "0x%08lx", value->addr.off );
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, "0x%04lx: ", value->addr.seg );
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, "0x%08lx", value->addr.off );
goto leave;
}
......@@ -814,13 +814,13 @@ DEBUG_Print( const DBG_VALUE *value, int count, char format, int level )
if( DEBUG_nchar > DEBUG_maxchar )
{
fprintf(stderr, "...");
DEBUG_Printf(DBG_CHN_MESG, "...");
goto leave;
}
if( format == 'i' || format == 's' || format == 'w' || format == 'b' )
{
fprintf( stderr, "Format specifier '%c' is meaningless in 'print' command\n", format );
DEBUG_Printf( DBG_CHN_MESG, "Format specifier '%c' is meaningless in 'print' command\n", format );
format = '\0';
}
......@@ -833,24 +833,24 @@ DEBUG_Print( const DBG_VALUE *value, int count, char format, int level )
DEBUG_PrintBasic(value, 1, format);
break;
case DT_STRUCT:
DEBUG_nchar += fprintf(stderr, "{");
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "{");
for(m = value->type->un.structure.members; m; m = m->next)
{
val1 = *value;
DEBUG_FindStructElement(&val1, m->name, &xval);
DEBUG_nchar += fprintf(stderr, "%s=", m->name);
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "%s=", m->name);
DEBUG_Print(&val1, 1, format, level + 1);
if( m->next != NULL )
{
DEBUG_nchar += fprintf(stderr, ", ");
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, ", ");
}
if( DEBUG_nchar > DEBUG_maxchar )
{
fprintf(stderr, "...}");
DEBUG_Printf(DBG_CHN_MESG, "...}");
goto leave;
}
}
DEBUG_nchar += fprintf(stderr, "}");
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "}");
break;
case DT_ARRAY:
/*
......@@ -863,38 +863,38 @@ DEBUG_Print( const DBG_VALUE *value, int count, char format, int level )
* Special handling for character arrays.
*/
pnt = (char *) value->addr.off;
DEBUG_nchar += fprintf(stderr, "\"");
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "\"");
for( i=value->type->un.array.start; i < value->type->un.array.end; i++ )
{
fputc(*pnt++, stderr);
DEBUG_nchar++;
if( DEBUG_nchar > DEBUG_maxchar )
{
fprintf(stderr, "...\"");
DEBUG_Printf(DBG_CHN_MESG, "...\"");
goto leave;
}
}
DEBUG_nchar += fprintf(stderr, "\"");
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "\"");
break;
}
val1 = *value;
val1.type = value->type->un.array.basictype;
DEBUG_nchar += fprintf(stderr, "{");
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "{");
for( i=value->type->un.array.start; i <= value->type->un.array.end; i++ )
{
DEBUG_Print(&val1, 1, format, level + 1);
val1.addr.off += size;
if( i == value->type->un.array.end )
{
DEBUG_nchar += fprintf(stderr, "}");
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "}");
}
else
{
DEBUG_nchar += fprintf(stderr, ", ");
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, ", ");
}
if( DEBUG_nchar > DEBUG_maxchar )
{
fprintf(stderr, "...}");
DEBUG_Printf(DBG_CHN_MESG, "...}");
goto leave;
}
}
......@@ -908,7 +908,7 @@ leave:
if( level == 0 )
{
DEBUG_nchar += fprintf(stderr, "\n");
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "\n");
}
return;
}
......@@ -935,11 +935,11 @@ DEBUG_DumpTypes(void)
switch(dt->type)
{
case DT_BASIC:
fprintf(stderr, "0x%p - BASIC(%s)\n",
DEBUG_Printf(DBG_CHN_MESG, "0x%p - BASIC(%s)\n",
dt, name);
break;
case DT_POINTER:
fprintf(stderr, "0x%p - POINTER(%s)(%p)\n",
DEBUG_Printf(DBG_CHN_MESG, "0x%p - POINTER(%s)(%p)\n",
dt, name, dt->un.pointer.pointsto);
break;
case DT_STRUCT:
......@@ -954,27 +954,26 @@ DEBUG_DumpTypes(void)
nm++;
}
}
fprintf(stderr, "0x%p - STRUCT(%s) %d %d %s\n", dt, name,
DEBUG_Printf(DBG_CHN_MESG, "0x%p - STRUCT(%s) %d %d %s\n", dt, name,
dt->un.structure.size, nm, member_name);
break;
case DT_ARRAY:
fprintf(stderr, "0x%p - ARRAY(%s)(%p)\n",
DEBUG_Printf(DBG_CHN_MESG, "0x%p - ARRAY(%s)(%p)\n",
dt, name, dt->un.array.basictype);
break;
case DT_ENUM:
fprintf(stderr, "0x%p - ENUM(%s)\n",
dt, name);
DEBUG_Printf(DBG_CHN_MESG, "0x%p - ENUM(%s)\n", dt, name);
break;
case DT_BITFIELD:
fprintf(stderr, "0x%p - BITFIELD(%s)\n", dt, name);
DEBUG_Printf(DBG_CHN_MESG, "0x%p - BITFIELD(%s)\n", dt, name);
break;
case DT_FUNC:
fprintf(stderr, "0x%p - FUNC(%s)(%p)\n",
DEBUG_Printf(DBG_CHN_MESG, "0x%p - FUNC(%s)(%p)\n",
dt, name, dt->un.funct.rettype);
break;
case DT_CONST:
case DT_TYPEDEF:
fprintf(stderr, "What???\n");
DEBUG_Printf(DBG_CHN_MESG, "What???\n");
break;
}
}
......@@ -1025,31 +1024,31 @@ DEBUG_PrintTypeCast(const struct datatype * dt)
switch(dt->type)
{
case DT_BASIC:
fprintf(stderr, "%s", name);
DEBUG_Printf(DBG_CHN_MESG, "%s", name);
break;
case DT_POINTER:
DEBUG_PrintTypeCast(dt->un.pointer.pointsto);
fprintf(stderr, "*");
DEBUG_Printf(DBG_CHN_MESG, "*");
break;
case DT_STRUCT:
fprintf(stderr, "struct %s", name);
DEBUG_Printf(DBG_CHN_MESG, "struct %s", name);
break;
case DT_ARRAY:
fprintf(stderr, "%s[]", name);
DEBUG_Printf(DBG_CHN_MESG, "%s[]", name);
break;
case DT_ENUM:
fprintf(stderr, "enum %s", name);
DEBUG_Printf(DBG_CHN_MESG, "enum %s", name);
break;
case DT_BITFIELD:
fprintf(stderr, "unsigned %s", name);
DEBUG_Printf(DBG_CHN_MESG, "unsigned %s", name);
break;
case DT_FUNC:
DEBUG_PrintTypeCast(dt->un.funct.rettype);
fprintf(stderr, "(*%s)()", name);
DEBUG_Printf(DBG_CHN_MESG, "(*%s)()", name);
break;
case DT_CONST:
case DT_TYPEDEF:
fprintf(stderr, "What???\n");
DEBUG_Printf(DBG_CHN_MESG, "What???\n");
break;
}
......@@ -1062,12 +1061,12 @@ int DEBUG_PrintType( const DBG_VALUE *value )
if (!value->type)
{
fprintf(stderr, "Unknown type\n");
DEBUG_Printf(DBG_CHN_MESG, "Unknown type\n");
return FALSE;
}
if (!DEBUG_PrintTypeCast(value->type))
return FALSE;
fprintf(stderr, "\n");
DEBUG_Printf(DBG_CHN_MESG, "\n");
return TRUE;
}
name winedbg
mode guiexe
type win32
init WinMain
......@@ -96,15 +96,15 @@ static inline void WINE_UNUSED stack16_pop( int size )
/* Push a DWORD on the 32-bit stack */
static inline void WINE_UNUSED stack32_push( CONTEXT86 *context, DWORD val )
{
ESP_reg(context) -= sizeof(DWORD);
*(DWORD *)ESP_reg(context) = val;
context->Esp -= sizeof(DWORD);
*(DWORD *)context->Esp = val;
}
/* Pop a DWORD from the 32-bit stack */
static inline DWORD WINE_UNUSED stack32_pop( CONTEXT86 *context )
{
DWORD ret = *(DWORD *)ESP_reg(context);
ESP_reg(context) += sizeof(DWORD);
DWORD ret = *(DWORD *)context->Esp;
context->Esp += sizeof(DWORD);
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment