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.
This commit is contained in:
parent
5f6419fafa
commit
e5efa0ceb6
23
Makefile.in
23
Makefile.in
|
@ -28,7 +28,6 @@ TOOLSUBDIRS = tools
|
||||||
LIBSUBDIRS = \
|
LIBSUBDIRS = \
|
||||||
controls \
|
controls \
|
||||||
console \
|
console \
|
||||||
debugger \
|
|
||||||
dlls/advapi32 \
|
dlls/advapi32 \
|
||||||
dlls/crtdll \
|
dlls/crtdll \
|
||||||
dlls/display \
|
dlls/display \
|
||||||
|
@ -60,17 +59,25 @@ EMUSUBDIRS = \
|
||||||
miscemu \
|
miscemu \
|
||||||
server
|
server
|
||||||
|
|
||||||
PROGSUBDIRS = libtest programs
|
PROGSUBDIRS = \
|
||||||
|
debugger \
|
||||||
|
libtest \
|
||||||
|
programs
|
||||||
|
|
||||||
DOCSUBDIRS = documentation
|
DOCSUBDIRS = documentation
|
||||||
|
|
||||||
INCSUBDIRS = include
|
INCSUBDIRS = include
|
||||||
|
|
||||||
|
# Stand-alone programs
|
||||||
PROGRAMS = \
|
PROGRAMS = \
|
||||||
loader/dos/dosmod \
|
loader/dos/dosmod \
|
||||||
server/wineserver \
|
server/wineserver \
|
||||||
windows/x11drv/wineclipsrv
|
windows/x11drv/wineclipsrv
|
||||||
|
|
||||||
|
# Programs that link with libwine
|
||||||
|
LIBPROGRAMS = \
|
||||||
|
debugger/winedbg
|
||||||
|
|
||||||
# Sub-directories to run make into
|
# Sub-directories to run make into
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
$(TOOLSUBDIRS) \
|
$(TOOLSUBDIRS) \
|
||||||
|
@ -90,7 +97,6 @@ LINTSUBDIRS = $(LIBSUBDIRS) $(DLLDIR) $(EMUSUBDIRS) $(DOCSUBDIRS)
|
||||||
LIBOBJS = \
|
LIBOBJS = \
|
||||||
controls/controls.o \
|
controls/controls.o \
|
||||||
console/console.o \
|
console/console.o \
|
||||||
debugger/debugger.o \
|
|
||||||
dlls/advapi32/advapi32.o \
|
dlls/advapi32/advapi32.o \
|
||||||
dlls/crtdll/crtdll.o \
|
dlls/crtdll/crtdll.o \
|
||||||
dlls/display/display.o \
|
dlls/display/display.o \
|
||||||
|
@ -126,7 +132,7 @@ EXTRA_OBJS = $(LIBOBJS)
|
||||||
|
|
||||||
EMU_TARGET = @EMU_TARGET@
|
EMU_TARGET = @EMU_TARGET@
|
||||||
|
|
||||||
all: Make.rules $(PROGRAMS) $(EMU_TARGET)
|
all: Make.rules $(PROGRAMS) $(LIBPROGRAMS) $(EMU_TARGET)
|
||||||
@echo "Wine build complete."
|
@echo "Wine build complete."
|
||||||
|
|
||||||
LIBLINTS = $(LIBOBJS:.o=.ln)
|
LIBLINTS = $(LIBOBJS:.o=.ln)
|
||||||
|
@ -167,15 +173,16 @@ install_wine: wine
|
||||||
[ -f wine.sym ] && $(INSTALL_DATA) wine.sym $(libdir)/wine.sym
|
[ -f wine.sym ] && $(INSTALL_DATA) wine.sym $(libdir)/wine.sym
|
||||||
$(INSTALL_PROGRAM) wine $(bindir)/wine
|
$(INSTALL_PROGRAM) wine $(bindir)/wine
|
||||||
|
|
||||||
install:: $(PROGRAMS) $(EMU_TARGET:%=install_%) $(LIBEXT:%=install_%)
|
install:: $(PROGRAMS) $(LIBPROGRAMS) $(EMU_TARGET:%=install_%) $(LIBEXT:%=install_%)
|
||||||
[ -d $(bindir) ] || $(MKDIR) $(bindir)
|
[ -d $(bindir) ] || $(MKDIR) $(bindir)
|
||||||
$(INSTALL_PROGRAM) server/wineserver $(bindir)/wineserver
|
$(INSTALL_PROGRAM) server/wineserver $(bindir)/wineserver
|
||||||
$(INSTALL_PROGRAM) windows/x11drv/wineclipsrv $(bindir)/wineclipsrv
|
$(INSTALL_PROGRAM) windows/x11drv/wineclipsrv $(bindir)/wineclipsrv
|
||||||
$(INSTALL_PROGRAM) loader/dos/dosmod $(bindir)/dosmod
|
$(INSTALL_PROGRAM) loader/dos/dosmod $(bindir)/dosmod
|
||||||
|
$(INSTALL_PROGRAM) debugger/winedbg $(bindir)/winedbg
|
||||||
|
|
||||||
uninstall::
|
uninstall::
|
||||||
cd $(libdir) && $(RM) libwine.a libwine.so libwine.so.$(SOVERSION) wine.sym
|
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
|
lib$(MODULE).so.$(SOVERSION): $(OBJS) Makefile.in Make.rules.in
|
||||||
$(LDSHARED) $(OBJS) -o $@
|
$(LDSHARED) $(OBJS) -o $@
|
||||||
|
@ -191,9 +198,11 @@ lib$(MODULE).a: $(OBJS) Makefile.in Make.rules.in
|
||||||
checklink::
|
checklink::
|
||||||
$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c -L. -lwine $(LDOPTIONS) $(X_LIBS) $(XLIB) $(LIBS) && $(RM) 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 $@`
|
@cd `dirname $@` && $(MAKE) `basename $@`
|
||||||
|
|
||||||
|
$(LIBPROGRAMS): lib$(MODULE).$(LIBEXT) $(DLLOBJS)
|
||||||
|
|
||||||
$(LIBLINTS) $(EMULINTS): dummy
|
$(LIBLINTS) $(EMULINTS): dummy
|
||||||
@cd `dirname $@` && $(MAKE) lint
|
@cd `dirname $@` && $(MAKE) lint
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
Makefile
|
Makefile
|
||||||
lex.yy.c
|
lex.yy.c
|
||||||
|
winedbg
|
||||||
|
winedbg.spec.c
|
||||||
y.tab.c
|
y.tab.c
|
||||||
y.tab.h
|
y.tab.h
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
DEFS = -D__WINE__ -DLIBDIR="\"$(libdir)\""
|
DEFS = -DWINELIB
|
||||||
TOPSRCDIR = @top_srcdir@
|
TOPSRCDIR = @top_srcdir@
|
||||||
TOPOBJDIR = ..
|
TOPOBJDIR = ..
|
||||||
SRCDIR = @srcdir@
|
SRCDIR = @srcdir@
|
||||||
VPATH = @srcdir@
|
VPATH = @srcdir@
|
||||||
MODULE = debugger
|
MODULE = none
|
||||||
|
PROGRAMS = winedbg
|
||||||
|
ALL_LIBS = $(WINELIB) $(X_LIBS) $(XLIB) $(LIBS)
|
||||||
|
WRCEXTRA = -A -p $*
|
||||||
|
|
||||||
C_SRCS = \
|
C_SRCS = \
|
||||||
break.c \
|
break.c \
|
||||||
|
@ -24,19 +27,15 @@ C_SRCS = \
|
||||||
types.c \
|
types.c \
|
||||||
winedbg.c
|
winedbg.c
|
||||||
|
|
||||||
|
SPEC_SRCS = winedbg.spec
|
||||||
|
|
||||||
EXTRA_SRCS = dbg.y debug.l
|
EXTRA_SRCS = dbg.y debug.l
|
||||||
EXTRA_OBJS = y.tab.o lex.yy.o
|
EXTRA_OBJS = y.tab.o lex.yy.o
|
||||||
|
|
||||||
all: $(MODULE).o
|
all: $(PROGRAMS)
|
||||||
|
|
||||||
depend: y.tab.h
|
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@
|
@MAKE_RULES@
|
||||||
|
|
||||||
y.tab.c y.tab.h: dbg.y
|
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.yy.c: debug.l
|
||||||
$(LEX) -8 -I $(SRCDIR)/debug.l
|
$(LEX) -8 -I $(SRCDIR)/debug.l
|
||||||
|
|
||||||
|
winedbg: $(OBJS)
|
||||||
|
$(CC) -o $@ $(OBJS) $(LDOPTIONS) $(ALL_LIBS)
|
||||||
|
|
||||||
### Dependencies:
|
### Dependencies:
|
||||||
|
|
|
@ -185,7 +185,7 @@ void DEBUG_SetBreakpoints( BOOL set )
|
||||||
if (!DEBUG_WRITE_MEM( (void*)DEBUG_ToLinear(&breakpoints[i].addr),
|
if (!DEBUG_WRITE_MEM( (void*)DEBUG_ToLinear(&breakpoints[i].addr),
|
||||||
&ch, sizeof(ch) ))
|
&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;
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,10 +361,10 @@ void DEBUG_AddBreakpoint( const DBG_VALUE *_value )
|
||||||
|
|
||||||
breakpoints[num].u.opcode = ch;
|
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,
|
DEBUG_PrintAddress( &breakpoints[num].addr, breakpoints[num].is32 ? 32 : 16,
|
||||||
TRUE );
|
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);
|
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 )
|
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++);
|
for (reg = 0; reg < 4 && (mask & (1 << reg)); reg++);
|
||||||
if (reg == 4)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -422,16 +424,16 @@ void DEBUG_AddWatchpoint( const DBG_VALUE *_value, BOOL is_write )
|
||||||
|
|
||||||
if (!DEBUG_GetWatchedValue( num, &breakpoints[num].u.w.oldval))
|
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].refcount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
breakpoints[num].u.w.rw = (is_write) ? TRUE : FALSE;
|
breakpoints[num].u.w.rw = (is_write) ? TRUE : FALSE;
|
||||||
breakpoints[reg].u.w.reg = reg;
|
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 );
|
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)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,7 +472,7 @@ void DEBUG_EnableBreakpoint( int num, BOOL enable )
|
||||||
{
|
{
|
||||||
if ((num <= 0) || (num >= next_bp) || breakpoints[num].refcount == 0)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
breakpoints[num].enabled = (enable) ? TRUE : FALSE;
|
breakpoints[num].enabled = (enable) ? TRUE : FALSE;
|
||||||
|
@ -557,40 +559,40 @@ void DEBUG_InfoBreakpoints(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fprintf( stderr, "Breakpoints:\n" );
|
DEBUG_Printf( DBG_CHN_MESG, "Breakpoints:\n" );
|
||||||
for (i = 1; i < next_bp; i++)
|
for (i = 1; i < next_bp; i++)
|
||||||
{
|
{
|
||||||
if (breakpoints[i].refcount && breakpoints[i].type == DBG_BREAK)
|
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,
|
DEBUG_PrintAddress( &breakpoints[i].addr,
|
||||||
breakpoints[i].is32 ? 32 : 16, TRUE);
|
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 )
|
if( breakpoints[i].condition != NULL )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\t\tstop when ");
|
DEBUG_Printf(DBG_CHN_MESG, "\t\tstop when ");
|
||||||
DEBUG_DisplayExpr(breakpoints[i].condition);
|
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++)
|
for (i = 1; i < next_bp; i++)
|
||||||
{
|
{
|
||||||
if (breakpoints[i].refcount && breakpoints[i].type == DBG_WATCH)
|
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,
|
DEBUG_PrintAddress( &breakpoints[i].addr,
|
||||||
breakpoints[i].is32 ? 32 : 16, TRUE);
|
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 + 1,
|
||||||
breakpoints[i].u.w.len > 0 ? "s" : "",
|
breakpoints[i].u.w.len > 0 ? "s" : "",
|
||||||
breakpoints[i].u.w.rw ? 'W' : 'R');
|
breakpoints[i].u.w.rw ? 'W' : 'R');
|
||||||
if( breakpoints[i].condition != NULL )
|
if( breakpoints[i].condition != NULL )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\t\tstop when ");
|
DEBUG_Printf(DBG_CHN_MESG, "\t\tstop when ");
|
||||||
DEBUG_DisplayExpr(breakpoints[i].condition);
|
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.
|
* 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);
|
DEBUG_DisplayExpr(breakpoints[bpnum].condition);
|
||||||
fprintf(stderr, "\nTurning off condition\n");
|
DEBUG_Printf(DBG_CHN_MESG, "\nTurning off condition\n");
|
||||||
DEBUG_AddBPCondition(bpnum, NULL);
|
DEBUG_AddBPCondition(bpnum, NULL);
|
||||||
}
|
}
|
||||||
else if( !DEBUG_GetExprValue( &value, 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;
|
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,
|
syminfo = DEBUG_PrintAddress( &breakpoints[bpnum].addr,
|
||||||
breakpoints[bpnum].is32 ? 32 : 16, TRUE );
|
breakpoints[bpnum].is32 ? 32 : 16, TRUE );
|
||||||
fprintf( stderr, "\n" );
|
DEBUG_Printf( DBG_CHN_MESG, "\n" );
|
||||||
|
|
||||||
if( syminfo.list.sourcefile != NULL )
|
if( syminfo.list.sourcefile != NULL )
|
||||||
DEBUG_List(&syminfo.list, NULL, 0);
|
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 not single-stepping, do not back up over the int3 instruction */
|
||||||
if (code == EXCEPTION_BREAKPOINT)
|
if (code == EXCEPTION_BREAKPOINT)
|
||||||
{
|
{
|
||||||
EIP_reg(&DEBUG_context)++;
|
#ifdef __i386__
|
||||||
|
DEBUG_context.Eip++;
|
||||||
addr.off++;
|
addr.off++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (!DEBUG_ShallBreak(wpnum)) return TRUE;
|
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 :
|
syminfo = DEBUG_PrintAddress( &addr, !addr.seg ? 32 :
|
||||||
DEBUG_GetSelectorType( addr.seg ), TRUE );
|
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);
|
oldval, breakpoints[wpnum].u.w.oldval);
|
||||||
if (syminfo.list.sourcefile != NULL)
|
if (syminfo.list.sourcefile != NULL)
|
||||||
DEBUG_List(&syminfo.list, NULL, 0);
|
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
|
* 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 )
|
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 )
|
&& status == FUNC_IS_TRAMPOLINE )
|
||||||
{
|
{
|
||||||
#if 0
|
#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);
|
addr2.off);
|
||||||
#endif
|
#endif
|
||||||
mode = EXEC_STEP_OVER_TRAMPOLINE;
|
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( mode == EXEC_STEP_INSTR && status == FUNC_HAS_NO_LINES )
|
||||||
{
|
{
|
||||||
#if 0
|
#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);
|
addr2.off);
|
||||||
#endif
|
#endif
|
||||||
mode = EXEC_STEP_OVER;
|
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 )
|
if( DEBUG_CheckLinenoStatus(&addr) == FUNC_HAS_NO_LINES )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Single stepping until exit from function, \n");
|
DEBUG_Printf(DBG_CHN_MESG, "Single stepping until exit from function, \n");
|
||||||
fprintf(stderr, "which has no line number information.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "which has no line number information.\n");
|
||||||
|
|
||||||
ret_mode = mode = EXEC_FINISH;
|
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;
|
DEBUG_context.EFlags |= STEP_FLAG;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
case EXEC_KILL:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
|
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)
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -896,7 +896,7 @@ static unsigned int db_get_task_value( const DBG_ADDR *addr,
|
||||||
char buffer[4];
|
char buffer[4];
|
||||||
|
|
||||||
if (size != 1 && size != 2 && size != 4) {
|
if (size != 1 && size != 2 && size != 4) {
|
||||||
fprintf(stderr, "Illegal size specified\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Illegal size specified\n");
|
||||||
} else {
|
} else {
|
||||||
DEBUG_READ_MEM((void*)DEBUG_ToLinear( addr ), buffer, size);
|
DEBUG_READ_MEM((void*)DEBUG_ToLinear( addr ), buffer, size);
|
||||||
|
|
||||||
|
@ -1020,22 +1020,21 @@ static void db_task_printsym(unsigned int addr, int size)
|
||||||
void db_print_address(char *seg, int size, struct i_addr *addrp, int byref)
|
void db_print_address(char *seg, int size, struct i_addr *addrp, int byref)
|
||||||
{
|
{
|
||||||
if (addrp->is_reg) {
|
if (addrp->is_reg) {
|
||||||
fprintf(stderr,"%s", db_reg[size][addrp->disp]);
|
DEBUG_Printf(DBG_CHN_MESG,"%s", db_reg[size][addrp->disp]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seg) {
|
if (seg) {
|
||||||
fprintf(stderr,"%s:", seg);
|
DEBUG_Printf(DBG_CHN_MESG,"%s:", seg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addrp->base != 0 || addrp->index != 0) {
|
if (addrp->base != 0 || addrp->index != 0) {
|
||||||
fprintf(stderr,"0x%x", addrp->disp);
|
DEBUG_Printf(DBG_CHN_MESG,"0x%x(", addrp->disp);
|
||||||
fprintf(stderr,"(");
|
|
||||||
if (addrp->base)
|
if (addrp->base)
|
||||||
fprintf(stderr,"%s", addrp->base);
|
DEBUG_Printf(DBG_CHN_MESG,"%s", addrp->base);
|
||||||
if (addrp->index)
|
if (addrp->index)
|
||||||
fprintf(stderr,",%s,%d", addrp->index, 1<<addrp->ss);
|
DEBUG_Printf(DBG_CHN_MESG,",%s,%d", addrp->index, 1<<addrp->ss);
|
||||||
fprintf(stderr,")");
|
DEBUG_Printf(DBG_CHN_MESG,")");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -1045,11 +1044,11 @@ void db_print_address(char *seg, int size, struct i_addr *addrp, int byref)
|
||||||
void* a1;
|
void* a1;
|
||||||
void* a2;
|
void* a2;
|
||||||
|
|
||||||
fprintf(stderr,"0x%x -> ", addrp->disp);
|
DEBUG_Printf(DBG_CHN_MESG,"0x%x -> ", addrp->disp);
|
||||||
if (!DEBUG_READ_MEM((void*)addrp->disp, &a1, sizeof(a1))) {
|
if (!DEBUG_READ_MEM((void*)addrp->disp, &a1, sizeof(a1))) {
|
||||||
fprintf(stderr, "(invalid source)");
|
DEBUG_Printf(DBG_CHN_MESG, "(invalid source)");
|
||||||
} else if (!DEBUG_READ_MEM(a1, &a2, sizeof(a2))) {
|
} else if (!DEBUG_READ_MEM(a1, &a2, sizeof(a2))) {
|
||||||
fprintf(stderr, "(invalid destination)");
|
DEBUG_Printf(DBG_CHN_MESG, "(invalid destination)");
|
||||||
} else {
|
} else {
|
||||||
db_task_printsym((unsigned long)a1, 0);
|
db_task_printsym((unsigned long)a1, 0);
|
||||||
}
|
}
|
||||||
|
@ -1085,30 +1084,30 @@ void db_disasm_esc( DBG_ADDR *addr, int inst, int short_addr,
|
||||||
* Normal address modes.
|
* Normal address modes.
|
||||||
*/
|
*/
|
||||||
db_read_address( addr, short_addr, regmodrm, &address);
|
db_read_address( addr, short_addr, regmodrm, &address);
|
||||||
fprintf(stderr,fp->f_name);
|
DEBUG_Printf(DBG_CHN_MESG,fp->f_name);
|
||||||
switch(fp->f_size) {
|
switch(fp->f_size) {
|
||||||
case SNGL:
|
case SNGL:
|
||||||
fprintf(stderr,"s");
|
DEBUG_Printf(DBG_CHN_MESG,"s");
|
||||||
break;
|
break;
|
||||||
case DBLR:
|
case DBLR:
|
||||||
fprintf(stderr,"l");
|
DEBUG_Printf(DBG_CHN_MESG,"l");
|
||||||
break;
|
break;
|
||||||
case EXTR:
|
case EXTR:
|
||||||
fprintf(stderr,"t");
|
DEBUG_Printf(DBG_CHN_MESG,"t");
|
||||||
break;
|
break;
|
||||||
case WORD:
|
case WORD:
|
||||||
fprintf(stderr,"s");
|
DEBUG_Printf(DBG_CHN_MESG,"s");
|
||||||
break;
|
break;
|
||||||
case LONG:
|
case LONG:
|
||||||
fprintf(stderr,"l");
|
DEBUG_Printf(DBG_CHN_MESG,"l");
|
||||||
break;
|
break;
|
||||||
case QUAD:
|
case QUAD:
|
||||||
fprintf(stderr,"q");
|
DEBUG_Printf(DBG_CHN_MESG,"q");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprintf(stderr,"\t");
|
DEBUG_Printf(DBG_CHN_MESG,"\t");
|
||||||
db_print_address(seg, BYTE, &address, 0);
|
db_print_address(seg, BYTE, &address, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1118,25 +1117,25 @@ void db_disasm_esc( DBG_ADDR *addr, int inst, int short_addr,
|
||||||
switch (fp->f_rrmode) {
|
switch (fp->f_rrmode) {
|
||||||
case op2(ST,STI):
|
case op2(ST,STI):
|
||||||
name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
|
name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
|
||||||
fprintf(stderr,"%s\t%%st,%%st(%d)",name,f_rm(regmodrm));
|
DEBUG_Printf(DBG_CHN_MESG,"%s\t%%st,%%st(%d)",name,f_rm(regmodrm));
|
||||||
break;
|
break;
|
||||||
case op2(STI,ST):
|
case op2(STI,ST):
|
||||||
name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
|
name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
|
||||||
fprintf(stderr,"%s\t%%st(%d),%%st",name, f_rm(regmodrm));
|
DEBUG_Printf(DBG_CHN_MESG,"%s\t%%st(%d),%%st",name, f_rm(regmodrm));
|
||||||
break;
|
break;
|
||||||
case op1(STI):
|
case op1(STI):
|
||||||
name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
|
name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
|
||||||
fprintf(stderr,"%s\t%%st(%d)",name, f_rm(regmodrm));
|
DEBUG_Printf(DBG_CHN_MESG,"%s\t%%st(%d)",name, f_rm(regmodrm));
|
||||||
break;
|
break;
|
||||||
case op1(X):
|
case op1(X):
|
||||||
fprintf(stderr,"%s", ((char **)fp->f_rrname)[f_rm(regmodrm)]);
|
DEBUG_Printf(DBG_CHN_MESG,"%s", ((char **)fp->f_rrname)[f_rm(regmodrm)]);
|
||||||
break;
|
break;
|
||||||
case op1(XA):
|
case op1(XA):
|
||||||
fprintf(stderr,"%s\t%%ax",
|
DEBUG_Printf(DBG_CHN_MESG,"%s\t%%ax",
|
||||||
((char **)fp->f_rrname)[f_rm(regmodrm)]);
|
((char **)fp->f_rrname)[f_rm(regmodrm)]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"<bad instruction>");
|
DEBUG_Printf(DBG_CHN_MESG,"<bad instruction>");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1174,7 +1173,7 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
switch (DEBUG_GetSelectorType(addr->seg)) {
|
switch (DEBUG_GetSelectorType(addr->seg)) {
|
||||||
case 16: db_disasm_16 = 1; break;
|
case 16: db_disasm_16 = 1; break;
|
||||||
case 32: db_disasm_16 = 0; break;
|
case 32: db_disasm_16 = 0; break;
|
||||||
default: fprintf(stderr, "Bad selector %ld\n", addr->seg); return;
|
default: DEBUG_Printf(DBG_CHN_MESG, "Bad selector %ld\n", addr->seg); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
get_value_inc( inst, addr, 1, FALSE );
|
get_value_inc( inst, addr, 1, FALSE );
|
||||||
|
@ -1224,15 +1223,15 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
break;
|
break;
|
||||||
case 0xf0:
|
case 0xf0:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
fprintf(stderr,"lock ");
|
DEBUG_Printf(DBG_CHN_MESG,"lock ");
|
||||||
break;
|
break;
|
||||||
case 0xf2:
|
case 0xf2:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
fprintf(stderr,"repne ");
|
DEBUG_Printf(DBG_CHN_MESG,"repne ");
|
||||||
break;
|
break;
|
||||||
case 0xf3:
|
case 0xf3:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
fprintf(stderr,"repe "); /* XXX repe VS rep */
|
DEBUG_Printf(DBG_CHN_MESG,"repe "); /* XXX repe VS rep */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
prefix = FALSE;
|
prefix = FALSE;
|
||||||
|
@ -1297,28 +1296,28 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
if (size == WORD)
|
if (size == WORD)
|
||||||
fprintf(stderr,i_name);
|
DEBUG_Printf(DBG_CHN_MESG,i_name);
|
||||||
else
|
else
|
||||||
fprintf(stderr,ip->i_extra);
|
DEBUG_Printf(DBG_CHN_MESG,ip->i_extra);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,i_name);
|
DEBUG_Printf(DBG_CHN_MESG,i_name);
|
||||||
}
|
}
|
||||||
if (i_size != NONE) {
|
if (i_size != NONE) {
|
||||||
if (i_size == BYTE) {
|
if (i_size == BYTE) {
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"b");
|
DEBUG_Printf(DBG_CHN_MESG,"b");
|
||||||
}
|
}
|
||||||
size = BYTE;
|
size = BYTE;
|
||||||
}
|
}
|
||||||
else if (i_size == WORD) {
|
else if (i_size == WORD) {
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"w");
|
DEBUG_Printf(DBG_CHN_MESG,"w");
|
||||||
}
|
}
|
||||||
size = WORD;
|
size = WORD;
|
||||||
}
|
}
|
||||||
|
@ -1326,28 +1325,28 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
{
|
{
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"w");
|
DEBUG_Printf(DBG_CHN_MESG,"w");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"l");
|
DEBUG_Printf(DBG_CHN_MESG,"l");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"\t");
|
DEBUG_Printf(DBG_CHN_MESG,"\t");
|
||||||
}
|
}
|
||||||
for (first = TRUE;
|
for (first = TRUE;
|
||||||
i_mode != 0;
|
i_mode != 0;
|
||||||
i_mode >>= 8, first = FALSE)
|
i_mode >>= 8, first = FALSE)
|
||||||
{
|
{
|
||||||
if (!first && db_display)
|
if (!first && db_display)
|
||||||
fprintf(stderr,",");
|
DEBUG_Printf(DBG_CHN_MESG,",");
|
||||||
|
|
||||||
switch (i_mode & 0xFF) {
|
switch (i_mode & 0xFF) {
|
||||||
|
|
||||||
|
@ -1361,7 +1360,7 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
case Eind:
|
case Eind:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"*");
|
DEBUG_Printf(DBG_CHN_MESG,"*");
|
||||||
db_print_address(seg, size, &address, 1);
|
db_print_address(seg, size, &address, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1383,42 +1382,42 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
case R:
|
case R:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s", db_reg[size][f_reg(regmodrm)]);
|
DEBUG_Printf(DBG_CHN_MESG,"%s", db_reg[size][f_reg(regmodrm)]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Rw:
|
case Rw:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s", db_reg[WORD][f_reg(regmodrm)]);
|
DEBUG_Printf(DBG_CHN_MESG,"%s", db_reg[WORD][f_reg(regmodrm)]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Ri:
|
case Ri:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s", db_reg[size][f_rm(inst)]);
|
DEBUG_Printf(DBG_CHN_MESG,"%s", db_reg[size][f_rm(inst)]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S:
|
case S:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s", db_seg_reg[f_reg(regmodrm)]);
|
DEBUG_Printf(DBG_CHN_MESG,"%s", db_seg_reg[f_reg(regmodrm)]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Si:
|
case Si:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s", db_seg_reg[f_reg(inst)]);
|
DEBUG_Printf(DBG_CHN_MESG,"%s", db_seg_reg[f_reg(inst)]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case A:
|
case A:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s", db_reg[size][0]); /* acc */
|
DEBUG_Printf(DBG_CHN_MESG,"%s", db_reg[size][0]); /* acc */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1426,22 +1425,22 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
if (seg)
|
if (seg)
|
||||||
fprintf(stderr,"%s:", seg);
|
DEBUG_Printf(DBG_CHN_MESG,"%s:", seg);
|
||||||
fprintf(stderr,"(%s)", short_addr ? "%bx" : "%ebx");
|
DEBUG_Printf(DBG_CHN_MESG,"(%s)", short_addr ? "%bx" : "%ebx");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CL:
|
case CL:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%%cl");
|
DEBUG_Printf(DBG_CHN_MESG,"%%cl");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DX:
|
case DX:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%%dx");
|
DEBUG_Printf(DBG_CHN_MESG,"%%dx");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1449,36 +1448,36 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
if (seg)
|
if (seg)
|
||||||
fprintf(stderr,"%s:", seg);
|
DEBUG_Printf(DBG_CHN_MESG,"%s:", seg);
|
||||||
fprintf(stderr,"(%s)", short_addr ? "%si" : "%esi");
|
DEBUG_Printf(DBG_CHN_MESG,"(%s)", short_addr ? "%si" : "%esi");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DI:
|
case DI:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%%es:(%s)", short_addr ? "%di" : "%edi");
|
DEBUG_Printf(DBG_CHN_MESG,"%%es:(%s)", short_addr ? "%di" : "%edi");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CR:
|
case CR:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%%cr%d", f_reg(regmodrm));
|
DEBUG_Printf(DBG_CHN_MESG,"%%cr%d", f_reg(regmodrm));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DR:
|
case DR:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%%dr%d", f_reg(regmodrm));
|
DEBUG_Printf(DBG_CHN_MESG,"%%dr%d", f_reg(regmodrm));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TR:
|
case TR:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%%tr%d", f_reg(regmodrm));
|
DEBUG_Printf(DBG_CHN_MESG,"%%tr%d", f_reg(regmodrm));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1487,7 +1486,7 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
get_value_inc(imm, addr, len, FALSE);/* unsigned */
|
get_value_inc(imm, addr, len, FALSE);/* unsigned */
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"$0x%x", imm);
|
DEBUG_Printf(DBG_CHN_MESG,"$0x%x", imm);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1496,7 +1495,7 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
get_value_inc(imm, addr, len, TRUE); /* signed */
|
get_value_inc(imm, addr, len, TRUE); /* signed */
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"$%d", imm);
|
DEBUG_Printf(DBG_CHN_MESG,"$%d", imm);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1504,7 +1503,7 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
get_value_inc(imm, addr, 1, FALSE); /* unsigned */
|
get_value_inc(imm, addr, 1, FALSE); /* unsigned */
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"$0x%x", imm);
|
DEBUG_Printf(DBG_CHN_MESG,"$0x%x", imm);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1512,7 +1511,7 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
get_value_inc(imm, addr, 1, TRUE); /* signed */
|
get_value_inc(imm, addr, 1, TRUE); /* signed */
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"$%d", imm);
|
DEBUG_Printf(DBG_CHN_MESG,"$%d", imm);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1520,7 +1519,7 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
get_value_inc(imm, addr, 2, FALSE); /* unsigned */
|
get_value_inc(imm, addr, 2, FALSE); /* unsigned */
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"$0x%x", imm);
|
DEBUG_Printf(DBG_CHN_MESG,"$0x%x", imm);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1528,7 +1527,7 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
get_value_inc(imm, addr, 4, FALSE);
|
get_value_inc(imm, addr, 4, FALSE);
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"$0x%x", imm);
|
DEBUG_Printf(DBG_CHN_MESG,"$0x%x", imm);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1545,7 +1544,7 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seg)
|
if (seg)
|
||||||
fprintf(stderr,"%s:0x%x",seg, displ);
|
DEBUG_Printf(DBG_CHN_MESG,"%s:0x%x",seg, displ);
|
||||||
else
|
else
|
||||||
db_task_printsym(displ, short_addr ? WORD : LONG);
|
db_task_printsym(displ, short_addr ? WORD : LONG);
|
||||||
break;
|
break;
|
||||||
|
@ -1587,14 +1586,14 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
|
||||||
case o1:
|
case o1:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"$1");
|
DEBUG_Printf(DBG_CHN_MESG,"$1");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case o3:
|
case o3:
|
||||||
if( db_display )
|
if( db_display )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"$3");
|
DEBUG_Printf(DBG_CHN_MESG,"$3");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,8 @@ line: command
|
||||||
| error tEOL { yyerrok; }
|
| error tEOL { yyerrok; }
|
||||||
|
|
||||||
command:
|
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 tEOL { DEBUG_Help(); }
|
||||||
| tHELP tINFO tEOL { DEBUG_HelpInfo(); }
|
| tHELP tINFO tEOL { DEBUG_HelpInfo(); }
|
||||||
| tCONT tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
|
| tCONT tEOL { DEBUG_CurrThread->dbg_exec_count = 1;
|
||||||
|
@ -210,7 +211,7 @@ break_command:
|
||||||
}
|
}
|
||||||
else
|
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;
|
| tBREAK tIDENTIFIER ':' tNUM tEOL { DBG_VALUE value;
|
||||||
|
@ -220,7 +221,7 @@ break_command:
|
||||||
}
|
}
|
||||||
else
|
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;
|
| tBREAK tNUM tEOL { struct name_hash *nh;
|
||||||
|
@ -237,7 +238,7 @@ break_command:
|
||||||
}
|
}
|
||||||
else
|
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) )
|
if( DEBUG_GetSymbolValue($2, -1, &value, TRUE) )
|
||||||
DEBUG_AddWatchpoint( &value, 1 );
|
DEBUG_AddWatchpoint( &value, 1 );
|
||||||
else
|
else
|
||||||
fprintf(stderr,"Unable to add breakpoint\n");
|
DEBUG_Printf(DBG_CHN_MESG,"Unable to add breakpoint\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
info_command:
|
info_command:
|
||||||
|
@ -388,49 +389,43 @@ lvalue:
|
||||||
static void issue_prompt(void)
|
static void issue_prompt(void)
|
||||||
{
|
{
|
||||||
#ifdef DONT_USE_READLINE
|
#ifdef DONT_USE_READLINE
|
||||||
fprintf(stderr, "Wine-dbg>");
|
DEBUG_Printf(DBG_CHN_MESG, "Wine-dbg>");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mode_command(int newmode)
|
static void mode_command(int newmode)
|
||||||
{
|
{
|
||||||
if ((newmode == 16) || (newmode == 32)) DEBUG_CurrThread->dbg_mode = 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)
|
static WINE_EXCEPTION_FILTER(wine_dbg_cmd)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\nwine_dbg_cmd: ");
|
DEBUG_Printf(DBG_CHN_MESG, "\nwine_dbg_cmd: ");
|
||||||
switch (GetExceptionCode()) {
|
switch (GetExceptionCode()) {
|
||||||
case DEBUG_STATUS_INTERNAL_ERROR:
|
case DEBUG_STATUS_INTERNAL_ERROR:
|
||||||
fprintf(stderr, "WineDbg internal error\n");
|
DEBUG_Printf(DBG_CHN_MESG, "WineDbg internal error\n");
|
||||||
break;
|
break;
|
||||||
case DEBUG_STATUS_NO_SYMBOL:
|
case DEBUG_STATUS_NO_SYMBOL:
|
||||||
fprintf(stderr, "Undefined symbol\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Undefined symbol\n");
|
||||||
break;
|
break;
|
||||||
case DEBUG_STATUS_DIV_BY_ZERO:
|
case DEBUG_STATUS_DIV_BY_ZERO:
|
||||||
fprintf(stderr, "Division by zero\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Division by zero\n");
|
||||||
break;
|
break;
|
||||||
case DEBUG_STATUS_BAD_TYPE:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Exception %lx\n", GetExceptionCode());
|
DEBUG_Printf(DBG_CHN_MESG, "Exception %lx\n", GetExceptionCode());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return EXCEPTION_EXECUTE_HANDLER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
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 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -456,17 +451,16 @@ BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code )
|
||||||
{
|
{
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
if (DEBUG_IsSelectorSystem(DEBUG_context.SegCs))
|
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
|
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 );
|
(WORD)DEBUG_context.SegCs, DEBUG_context.Eip );
|
||||||
#else
|
#else
|
||||||
fprintf( stderr, " (%p).\n", GET_IP(&DEBUG_context) );
|
DEBUG_Printf( DBG_CHN_MESG, " (%p).\n", GET_IP(&DEBUG_context) );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG_LoadEntryPoints("Loading new modules symbols:\n"))
|
DEBUG_LoadEntryPoints("Loading new modules symbols:\n");
|
||||||
DEBUG_ProcessDeferredDebug();
|
|
||||||
|
|
||||||
if (force || !(is_debug && DEBUG_ShouldContinue( code,
|
if (force || !(is_debug && DEBUG_ShouldContinue( code,
|
||||||
DEBUG_CurrThread->dbg_exec_mode,
|
DEBUG_CurrThread->dbg_exec_mode,
|
||||||
|
@ -478,13 +472,13 @@ BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code )
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
switch (newmode = DEBUG_GetSelectorType(addr.seg)) {
|
switch (newmode = DEBUG_GetSelectorType(addr.seg)) {
|
||||||
case 16: case 32: break;
|
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
|
#else
|
||||||
newmode = 32;
|
newmode = 32;
|
||||||
#endif
|
#endif
|
||||||
if (newmode != DEBUG_CurrThread->dbg_mode)
|
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();
|
DEBUG_DoDisplay();
|
||||||
|
|
||||||
|
@ -520,9 +514,9 @@ BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code )
|
||||||
/* Show where we crashed */
|
/* Show where we crashed */
|
||||||
curr_frame = 0;
|
curr_frame = 0;
|
||||||
DEBUG_PrintAddress( &addr, DEBUG_CurrThread->dbg_mode, TRUE );
|
DEBUG_PrintAddress( &addr, DEBUG_CurrThread->dbg_mode, TRUE );
|
||||||
fprintf(stderr,": ");
|
DEBUG_Printf(DBG_CHN_MESG,": ");
|
||||||
DEBUG_Disasm( &addr, TRUE );
|
DEBUG_Disasm( &addr, TRUE );
|
||||||
fprintf( stderr, "\n" );
|
DEBUG_Printf( DBG_CHN_MESG, "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ret_ok = 0;
|
ret_ok = 0;
|
||||||
|
@ -531,16 +525,20 @@ BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code )
|
||||||
__TRY
|
__TRY
|
||||||
{
|
{
|
||||||
issue_prompt();
|
issue_prompt();
|
||||||
yyparse();
|
if (yyparse()) {
|
||||||
|
DEBUG_CurrThread->dbg_exec_mode = EXEC_KILL;
|
||||||
|
ret_ok = TRUE;
|
||||||
|
} else {
|
||||||
flush_symbols();
|
flush_symbols();
|
||||||
|
|
||||||
DEBUG_GetCurrentAddress( &addr );
|
DEBUG_GetCurrentAddress( &addr );
|
||||||
if ((ret_ok = DEBUG_ValidateRegisters()))
|
ret_ok = DEBUG_ValidateRegisters() &&
|
||||||
ret_ok = DEBUG_READ_MEM_VERBOSE((void*)DEBUG_ToLinear( &addr ), &ch, 1 );
|
DEBUG_READ_MEM_VERBOSE((void*)DEBUG_ToLinear(&addr), &ch, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
__EXCEPT(wine_dbg_cmd)
|
__EXCEPT(wine_dbg_cmd)
|
||||||
{
|
{
|
||||||
ret_ok = 0;
|
ret_ok = FALSE;
|
||||||
}
|
}
|
||||||
__ENDTRY;
|
__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.
|
* if it was used. Otherwise it would have been ignored.
|
||||||
* In any case, we don't mess with it any more.
|
* 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;
|
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)
|
int yyerror(char* s)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s\n", s);
|
DEBUG_Printf(DBG_CHN_MESG,"%s\n", s);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,7 @@ enum { return tENUM; }
|
||||||
|
|
||||||
. { if (syntax_error == 0)
|
. { 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>");
|
line = readline ("Wine-dbg>");
|
||||||
if (!line)
|
if (!line)
|
||||||
{
|
{
|
||||||
fprintf( stderr, "\n" );
|
DEBUG_Printf( DBG_CHN_MESG, "\n" );
|
||||||
DEBUG_Exit(0);
|
DEBUG_Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ static int dbg_read(char * buf, int size)
|
||||||
{
|
{
|
||||||
if (size < len + 1)
|
if (size < len + 1)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Fatal readline goof.\n");
|
DEBUG_Printf(DBG_CHN_MESG,"Fatal readline goof.\n");
|
||||||
DEBUG_Exit(0);
|
DEBUG_Exit(0);
|
||||||
}
|
}
|
||||||
strcpy(buf, line);
|
strcpy(buf, line);
|
||||||
|
|
|
@ -106,11 +106,12 @@ enum exec_mode
|
||||||
EXEC_STEPI_OVER, /* Stepping over a call */
|
EXEC_STEPI_OVER, /* Stepping over a call */
|
||||||
EXEC_STEPI_INSTR, /* Single-stepping an instruction */
|
EXEC_STEPI_INSTR, /* Single-stepping an instruction */
|
||||||
EXEC_FINISH, /* Step until we exit current frame */
|
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
|
* we dig the real return value off the stack
|
||||||
* and set breakpoint there - not at the
|
* and set breakpoint there - not at the
|
||||||
* instr just after the call.
|
* instr just after the call.
|
||||||
*/
|
*/
|
||||||
|
EXEC_KILL /* terminate debugging session */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DBG_BREAK 0
|
#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 int DEBUG_ReadMemory( const DBG_ADDR *address );
|
||||||
extern void DEBUG_WriteMemory( const DBG_ADDR *address, int value );
|
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_ExamineMemory( const DBG_VALUE *addr, int count, char format);
|
||||||
|
extern void DEBUG_InvalAddr( const DBG_ADDR* addr );
|
||||||
extern void DEBUG_InvalLinAddr( void* addr );
|
extern void DEBUG_InvalLinAddr( void* addr );
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
extern void DEBUG_GetCurrentAddress( DBG_ADDR * );
|
extern void DEBUG_GetCurrentAddress( DBG_ADDR * );
|
||||||
|
@ -342,21 +344,19 @@ extern int DEBUG_IsSelectorSystem( WORD sel );
|
||||||
|
|
||||||
/* debugger/module.c */
|
/* debugger/module.c */
|
||||||
extern int DEBUG_LoadEntryPoints( const char * prefix );
|
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,
|
extern DBG_MODULE* DEBUG_AddModule(const char* name, int type,
|
||||||
void* mod_addr, HMODULE hmod);
|
void* mod_addr, HMODULE hmod);
|
||||||
extern DBG_MODULE* DEBUG_FindModuleByName(const char* name, int type);
|
extern DBG_MODULE* DEBUG_FindModuleByName(const char* name, int type);
|
||||||
extern DBG_MODULE* DEBUG_FindModuleByHandle(HANDLE handle, 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_RegisterPEModule(HMODULE, u_long load_addr, const char* name);
|
||||||
extern DBG_MODULE* DEBUG_RegisterELFModule(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);
|
extern void DEBUG_InfoShare(void);
|
||||||
|
|
||||||
/* debugger/msc.c */
|
/* debugger/msc.c */
|
||||||
extern int DEBUG_RegisterMSCDebugInfo(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, 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 void DEBUG_InitCVDataTypes(void);
|
||||||
extern int DEBUG_ProcessMSCDebugInfo(DBG_MODULE* module);
|
|
||||||
|
|
||||||
/* debugger/registers.c */
|
/* debugger/registers.c */
|
||||||
extern void DEBUG_SetRegister( enum debug_regs reg, int val );
|
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);
|
unsigned int * ebp);
|
||||||
|
|
||||||
/* debugger/stabs.c */
|
/* 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,
|
extern int DEBUG_ParseStabs(char * addr, unsigned int load_offset, unsigned int staboff,
|
||||||
int stablen, unsigned int strtaboff, int strtablen);
|
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);
|
extern void DEBUG_ExternalDebugger(void);
|
||||||
|
|
||||||
/* debugger/dbg.y */
|
/* debugger/dbg.y */
|
||||||
extern void DEBUG_Exit( DWORD exit_code );
|
|
||||||
extern BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD 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! */
|
/* Choose your allocator! */
|
||||||
#if 1
|
#if 1
|
||||||
|
@ -455,4 +464,9 @@ extern HANDLE dbg_heap;
|
||||||
#define DEBUG_STATUS_DIV_BY_ZERO (DEBUG_STATUS_OFFSET+2)
|
#define DEBUG_STATUS_DIV_BY_ZERO (DEBUG_STATUS_OFFSET+2)
|
||||||
#define DEBUG_STATUS_BAD_TYPE (DEBUG_STATUS_OFFSET+3)
|
#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 */
|
#endif /* __WINE_DEBUGGER_H */
|
||||||
|
|
|
@ -60,9 +60,9 @@ DEBUG_InfoDisplay(void)
|
||||||
{
|
{
|
||||||
if( displaypoints[i].exp != NULL )
|
if( displaypoints[i].exp != NULL )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%d : ", i+1);
|
DEBUG_Printf(DBG_CHN_MESG, "%d : ", i+1);
|
||||||
DEBUG_DisplayExpr(displaypoints[i].exp);
|
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);
|
value = DEBUG_EvalExpr(displaypoints[i].exp);
|
||||||
if( value.type == NULL )
|
if( value.type == NULL )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unable to evaluate expression ");
|
DEBUG_Printf(DBG_CHN_MESG, "Unable to evaluate expression ");
|
||||||
DEBUG_DisplayExpr(displaypoints[i].exp);
|
DEBUG_DisplayExpr(displaypoints[i].exp);
|
||||||
fprintf(stderr, "\nDisabling...\n");
|
DEBUG_Printf(DBG_CHN_MESG, "\nDisabling...\n");
|
||||||
DEBUG_DelDisplay(i);
|
DEBUG_DelDisplay(i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%d : ", i + 1);
|
DEBUG_Printf(DBG_CHN_MESG, "%d : ", i + 1);
|
||||||
DEBUG_DisplayExpr(displaypoints[i].exp);
|
DEBUG_DisplayExpr(displaypoints[i].exp);
|
||||||
fprintf(stderr, " = ");
|
DEBUG_Printf(DBG_CHN_MESG, " = ");
|
||||||
if( displaypoints[i].format == 'i' )
|
if( displaypoints[i].format == 'i' )
|
||||||
{
|
{
|
||||||
DEBUG_ExamineMemory( &value,
|
DEBUG_ExamineMemory( &value,
|
||||||
|
@ -121,7 +121,7 @@ DEBUG_DelDisplay(int displaynum)
|
||||||
|
|
||||||
if( displaynum >= MAX_DISPLAY || displaynum == 0 || displaynum < -1 )
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if( displaynum == -1 )
|
if( displaynum == -1 )
|
||||||
|
|
|
@ -418,7 +418,7 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
#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
|
/* would need to set up a call to this function, and then restore the current
|
||||||
* context afterwards...
|
* context afterwards...
|
||||||
*/
|
*/
|
||||||
|
@ -637,7 +637,7 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
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);
|
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -656,111 +656,111 @@ DEBUG_DisplayExpr(const struct expr * exp)
|
||||||
switch(exp->type)
|
switch(exp->type)
|
||||||
{
|
{
|
||||||
case EXPR_TYPE_CAST:
|
case EXPR_TYPE_CAST:
|
||||||
fprintf(stderr, "((");
|
DEBUG_Printf(DBG_CHN_MESG, "((");
|
||||||
DEBUG_PrintTypeCast(exp->un.cast.cast);
|
DEBUG_PrintTypeCast(exp->un.cast.cast);
|
||||||
fprintf(stderr, ")");
|
DEBUG_Printf(DBG_CHN_MESG, ")");
|
||||||
DEBUG_DisplayExpr(exp->un.cast.expr);
|
DEBUG_DisplayExpr(exp->un.cast.expr);
|
||||||
fprintf(stderr, ")");
|
DEBUG_Printf(DBG_CHN_MESG, ")");
|
||||||
break;
|
break;
|
||||||
case EXPR_TYPE_REGISTER:
|
case EXPR_TYPE_REGISTER:
|
||||||
DEBUG_PrintRegister(exp->un.rgister.reg);
|
DEBUG_PrintRegister(exp->un.rgister.reg);
|
||||||
break;
|
break;
|
||||||
case EXPR_TYPE_US_CONST:
|
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;
|
break;
|
||||||
case EXPR_TYPE_CONST:
|
case EXPR_TYPE_CONST:
|
||||||
fprintf(stderr, "%d", exp->un.u_const.value);
|
DEBUG_Printf(DBG_CHN_MESG, "%d", exp->un.u_const.value);
|
||||||
break;
|
break;
|
||||||
case EXPR_TYPE_STRING:
|
case EXPR_TYPE_STRING:
|
||||||
fprintf(stderr, "\"%s\"", exp->un.string.str);
|
DEBUG_Printf(DBG_CHN_MESG, "\"%s\"", exp->un.string.str);
|
||||||
break;
|
break;
|
||||||
case EXPR_TYPE_SYMBOL:
|
case EXPR_TYPE_SYMBOL:
|
||||||
fprintf(stderr, "%s" , exp->un.symbol.name);
|
DEBUG_Printf(DBG_CHN_MESG, "%s" , exp->un.symbol.name);
|
||||||
break;
|
break;
|
||||||
case EXPR_TYPE_PSTRUCT:
|
case EXPR_TYPE_PSTRUCT:
|
||||||
DEBUG_DisplayExpr(exp->un.structure.exp1);
|
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;
|
break;
|
||||||
case EXPR_TYPE_STRUCT:
|
case EXPR_TYPE_STRUCT:
|
||||||
DEBUG_DisplayExpr(exp->un.structure.exp1);
|
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;
|
break;
|
||||||
case EXPR_TYPE_CALL:
|
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++)
|
for(i=0; i < exp->un.call.nargs; i++)
|
||||||
{
|
{
|
||||||
DEBUG_DisplayExpr(exp->un.call.arg[i]);
|
DEBUG_DisplayExpr(exp->un.call.arg[i]);
|
||||||
if( i != exp->un.call.nargs - 1 )
|
if( i != exp->un.call.nargs - 1 )
|
||||||
{
|
{
|
||||||
fprintf(stderr, ", ");
|
DEBUG_Printf(DBG_CHN_MESG, ", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(stderr, ")");
|
DEBUG_Printf(DBG_CHN_MESG, ")");
|
||||||
break;
|
break;
|
||||||
case EXPR_TYPE_BINOP:
|
case EXPR_TYPE_BINOP:
|
||||||
fprintf(stderr, "( ");
|
DEBUG_Printf(DBG_CHN_MESG, "( ");
|
||||||
DEBUG_DisplayExpr(exp->un.binop.exp1);
|
DEBUG_DisplayExpr(exp->un.binop.exp1);
|
||||||
switch(exp->un.binop.binop_type)
|
switch(exp->un.binop.binop_type)
|
||||||
{
|
{
|
||||||
case EXP_OP_ADD:
|
case EXP_OP_ADD:
|
||||||
fprintf(stderr, " + ");
|
DEBUG_Printf(DBG_CHN_MESG, " + ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_SUB:
|
case EXP_OP_SUB:
|
||||||
fprintf(stderr, " - ");
|
DEBUG_Printf(DBG_CHN_MESG, " - ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_SEG:
|
case EXP_OP_SEG:
|
||||||
fprintf(stderr, ":");
|
DEBUG_Printf(DBG_CHN_MESG, ":");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_LOR:
|
case EXP_OP_LOR:
|
||||||
fprintf(stderr, " || ");
|
DEBUG_Printf(DBG_CHN_MESG, " || ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_LAND:
|
case EXP_OP_LAND:
|
||||||
fprintf(stderr, " && ");
|
DEBUG_Printf(DBG_CHN_MESG, " && ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_OR:
|
case EXP_OP_OR:
|
||||||
fprintf(stderr, " | ");
|
DEBUG_Printf(DBG_CHN_MESG, " | ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_AND:
|
case EXP_OP_AND:
|
||||||
fprintf(stderr, " & ");
|
DEBUG_Printf(DBG_CHN_MESG, " & ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_XOR:
|
case EXP_OP_XOR:
|
||||||
fprintf(stderr, " ^ ");
|
DEBUG_Printf(DBG_CHN_MESG, " ^ ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_EQ:
|
case EXP_OP_EQ:
|
||||||
fprintf(stderr, " == ");
|
DEBUG_Printf(DBG_CHN_MESG, " == ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_GT:
|
case EXP_OP_GT:
|
||||||
fprintf(stderr, " > ");
|
DEBUG_Printf(DBG_CHN_MESG, " > ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_LT:
|
case EXP_OP_LT:
|
||||||
fprintf(stderr, " < ");
|
DEBUG_Printf(DBG_CHN_MESG, " < ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_GE:
|
case EXP_OP_GE:
|
||||||
fprintf(stderr, " >= ");
|
DEBUG_Printf(DBG_CHN_MESG, " >= ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_LE:
|
case EXP_OP_LE:
|
||||||
fprintf(stderr, " <= ");
|
DEBUG_Printf(DBG_CHN_MESG, " <= ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_NE:
|
case EXP_OP_NE:
|
||||||
fprintf(stderr, " != ");
|
DEBUG_Printf(DBG_CHN_MESG, " != ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_SHL:
|
case EXP_OP_SHL:
|
||||||
fprintf(stderr, " << ");
|
DEBUG_Printf(DBG_CHN_MESG, " << ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_SHR:
|
case EXP_OP_SHR:
|
||||||
fprintf(stderr, " >> ");
|
DEBUG_Printf(DBG_CHN_MESG, " >> ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_MUL:
|
case EXP_OP_MUL:
|
||||||
fprintf(stderr, " * ");
|
DEBUG_Printf(DBG_CHN_MESG, " * ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_DIV:
|
case EXP_OP_DIV:
|
||||||
fprintf(stderr, " / ");
|
DEBUG_Printf(DBG_CHN_MESG, " / ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_REM:
|
case EXP_OP_REM:
|
||||||
fprintf(stderr, " %% ");
|
DEBUG_Printf(DBG_CHN_MESG, " %% ");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_ARR:
|
case EXP_OP_ARR:
|
||||||
fprintf(stderr, "[");
|
DEBUG_Printf(DBG_CHN_MESG, "[");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -768,33 +768,33 @@ DEBUG_DisplayExpr(const struct expr * exp)
|
||||||
DEBUG_DisplayExpr(exp->un.binop.exp2);
|
DEBUG_DisplayExpr(exp->un.binop.exp2);
|
||||||
if( exp->un.binop.binop_type == EXP_OP_ARR )
|
if( exp->un.binop.binop_type == EXP_OP_ARR )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "]");
|
DEBUG_Printf(DBG_CHN_MESG, "]");
|
||||||
}
|
}
|
||||||
fprintf(stderr, " )");
|
DEBUG_Printf(DBG_CHN_MESG, " )");
|
||||||
break;
|
break;
|
||||||
case EXPR_TYPE_UNOP:
|
case EXPR_TYPE_UNOP:
|
||||||
switch(exp->un.unop.unop_type)
|
switch(exp->un.unop.unop_type)
|
||||||
{
|
{
|
||||||
case EXP_OP_NEG:
|
case EXP_OP_NEG:
|
||||||
fprintf(stderr, "-");
|
DEBUG_Printf(DBG_CHN_MESG, "-");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_NOT:
|
case EXP_OP_NOT:
|
||||||
fprintf(stderr, "!");
|
DEBUG_Printf(DBG_CHN_MESG, "!");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_LNOT:
|
case EXP_OP_LNOT:
|
||||||
fprintf(stderr, "~");
|
DEBUG_Printf(DBG_CHN_MESG, "~");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_DEREF:
|
case EXP_OP_DEREF:
|
||||||
fprintf(stderr, "*");
|
DEBUG_Printf(DBG_CHN_MESG, "*");
|
||||||
break;
|
break;
|
||||||
case EXP_OP_ADDR:
|
case EXP_OP_ADDR:
|
||||||
fprintf(stderr, "&");
|
DEBUG_Printf(DBG_CHN_MESG, "&");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DEBUG_DisplayExpr(exp->un.unop.exp1);
|
DEBUG_DisplayExpr(exp->un.unop.exp1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"Unexpected expression.\n");
|
DEBUG_Printf(DBG_CHN_MESG,"Unexpected expression.\n");
|
||||||
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
|
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -851,7 +851,7 @@ DEBUG_CloneExpr(const struct expr * exp)
|
||||||
rtn->un.unop.exp1 = DEBUG_CloneExpr(exp->un.unop.exp1);
|
rtn->un.unop.exp1 = DEBUG_CloneExpr(exp->un.unop.exp1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"Unexpected expression.\n");
|
DEBUG_Printf(DBG_CHN_MESG,"Unexpected expression.\n");
|
||||||
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
|
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -904,7 +904,7 @@ DEBUG_FreeExpr(struct expr * exp)
|
||||||
DEBUG_FreeExpr(exp->un.unop.exp1);
|
DEBUG_FreeExpr(exp->un.unop.exp1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"Unexpected expression.\n");
|
DEBUG_Printf(DBG_CHN_MESG,"Unexpected expression.\n");
|
||||||
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
|
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ DEBUG_ResortSymbols(void)
|
||||||
if( (nh->flags & SYM_INVALID) == 0 )
|
if( (nh->flags & SYM_INVALID) == 0 )
|
||||||
nsym++;
|
nsym++;
|
||||||
else
|
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( ((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;
|
nh->value.addr = value->addr;
|
||||||
|
|
||||||
if( nh->value.type == NULL && value->type != NULL )
|
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
|
* First see if we already have an entry for this symbol. If so
|
||||||
* return it, so we don't end up with duplicates.
|
* 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];
|
nearest = addr_sorttab[mid];
|
||||||
#if 0
|
#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.seg,
|
||||||
addr_sorttab[mid ]->value.addr.off,
|
addr_sorttab[mid ]->value.addr.off,
|
||||||
addr->seg, addr->off,
|
addr->seg, addr->off,
|
||||||
|
@ -722,7 +731,6 @@ void DEBUG_ReadSymbolTable( const char * filename )
|
||||||
{
|
{
|
||||||
FILE * symbolfile;
|
FILE * symbolfile;
|
||||||
DBG_VALUE value;
|
DBG_VALUE value;
|
||||||
int nargs;
|
|
||||||
char type;
|
char type;
|
||||||
char * cpnt;
|
char * cpnt;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
@ -730,11 +738,11 @@ void DEBUG_ReadSymbolTable( const char * filename )
|
||||||
|
|
||||||
if (!(symbolfile = fopen(filename, "r")))
|
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;
|
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.type = NULL;
|
||||||
value.addr.seg = 0;
|
value.addr.seg = 0;
|
||||||
|
@ -760,7 +768,7 @@ void DEBUG_ReadSymbolTable( const char * filename )
|
||||||
}
|
}
|
||||||
if (!(*cpnt) || *cpnt == '\n') continue;
|
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 );
|
DEBUG_AddSymbol( name, &value, NULL, SYM_WINE );
|
||||||
}
|
}
|
||||||
fclose(symbolfile);
|
fclose(symbolfile);
|
||||||
|
@ -837,7 +845,7 @@ DEBUG_DumpHashInfo(void)
|
||||||
{
|
{
|
||||||
depth++;
|
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];
|
nearest = addr_sorttab[mid];
|
||||||
#if 0
|
#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.seg,
|
||||||
addr_sorttab[mid ]->value.addr.off,
|
addr_sorttab[mid ]->value.addr.off,
|
||||||
addr->seg, addr->off,
|
addr->seg, addr->off,
|
||||||
|
@ -1055,11 +1063,11 @@ DEBUG_GetFuncInfo( struct list_id * ret, const char * filename,
|
||||||
{
|
{
|
||||||
if( filename != NULL )
|
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
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No such function %s\n", name);
|
DEBUG_Printf(DBG_CHN_MESG, "No such function %s\n", name);
|
||||||
}
|
}
|
||||||
ret->sourcefile = NULL;
|
ret->sourcefile = NULL;
|
||||||
ret->line = -1;
|
ret->line = -1;
|
||||||
|
@ -1188,7 +1196,7 @@ DEBUG_InfoLocals(void)
|
||||||
{
|
{
|
||||||
ptr = (unsigned int *)(((DWORD)&DEBUG_context)
|
ptr = (unsigned int *)(((DWORD)&DEBUG_context)
|
||||||
+ reg_ofs[curr_func->local_vars[i].regno - 1]);
|
+ 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,
|
curr_func->name, curr_func->local_vars[i].name,
|
||||||
reg_name[curr_func->local_vars[i].regno - 1],
|
reg_name[curr_func->local_vars[i].regno - 1],
|
||||||
*ptr);
|
*ptr);
|
||||||
|
@ -1197,7 +1205,7 @@ DEBUG_InfoLocals(void)
|
||||||
{
|
{
|
||||||
DEBUG_READ_MEM_VERBOSE((void*)(ebp + curr_func->local_vars[i].offset),
|
DEBUG_READ_MEM_VERBOSE((void*)(ebp + curr_func->local_vars[i].offset),
|
||||||
&val, sizeof(val));
|
&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);
|
curr_func->name, curr_func->local_vars[i].name, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
122
debugger/info.c
122
debugger/info.c
|
@ -29,7 +29,7 @@ void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format )
|
||||||
assert(value->cookie == DV_TARGET || value->cookie == DV_HOST);
|
assert(value->cookie == DV_TARGET || value->cookie == DV_HOST);
|
||||||
if( value->type == NULL )
|
if( value->type == NULL )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unable to evaluate expression\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Unable to evaluate expression\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,20 +41,20 @@ void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format )
|
||||||
case 'x':
|
case 'x':
|
||||||
if (value->addr.seg)
|
if (value->addr.seg)
|
||||||
{
|
{
|
||||||
DEBUG_nchar += fprintf( stderr, "0x%04lx", (long unsigned int) res );
|
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, "0x%04lx", (long unsigned int) res );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUG_nchar += fprintf( stderr, "0x%08lx", (long unsigned int) res );
|
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, "0x%08lx", (long unsigned int) res );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
DEBUG_nchar += fprintf( stderr, "%ld\n", (long int) res );
|
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, "%ld\n", (long int) res );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
DEBUG_nchar += fprintf( stderr, "%d = '%c'",
|
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, "%d = '%c'",
|
||||||
(char)(res & 0xff), (char)(res & 0xff) );
|
(char)(res & 0xff), (char)(res & 0xff) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -62,13 +62,13 @@ void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format )
|
||||||
case 's':
|
case 's':
|
||||||
case 'w':
|
case 'w':
|
||||||
case 'b':
|
case '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 );
|
||||||
case 0:
|
case 0:
|
||||||
if( default_format != NULL )
|
if( default_format != NULL )
|
||||||
{
|
{
|
||||||
if (strstr(default_format, "%S") == NULL)
|
if (strstr(default_format, "%S") == NULL)
|
||||||
{
|
{
|
||||||
DEBUG_nchar += fprintf( stderr, default_format, res );
|
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, default_format, res );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -80,7 +80,7 @@ void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format )
|
||||||
*/
|
*/
|
||||||
for (ptr = default_format; *ptr; ptr++)
|
for (ptr = default_format; *ptr; ptr++)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "[%c]", *ptr);
|
DEBUG_Printf(DBG_CHN_MESG, "[%c]", *ptr);
|
||||||
|
|
||||||
if (*ptr == '%') state++;
|
if (*ptr == '%') state++;
|
||||||
else if (state == 1)
|
else if (state == 1)
|
||||||
|
@ -130,10 +130,10 @@ DEBUG_PrintAddress( const DBG_ADDR *addr, int addrlen, int flag )
|
||||||
const char *name = DEBUG_FindNearestSymbol( addr, flag, &rtn.sym, 0,
|
const char *name = DEBUG_FindNearestSymbol( addr, flag, &rtn.sym, 0,
|
||||||
&rtn.list );
|
&rtn.list );
|
||||||
|
|
||||||
if (addr->seg) fprintf( stderr, "0x%04lx:", addr->seg&0xFFFF );
|
if (addr->seg) DEBUG_Printf( DBG_CHN_MESG, "0x%04lx:", addr->seg&0xFFFF );
|
||||||
if (addrlen == 16) fprintf( stderr, "0x%04lx", addr->off );
|
if (addrlen == 16) DEBUG_Printf( DBG_CHN_MESG, "0x%04lx", addr->off );
|
||||||
else fprintf( stderr, "0x%08lx", addr->off );
|
else DEBUG_Printf( DBG_CHN_MESG, "0x%08lx", addr->off );
|
||||||
if (name) fprintf( stderr, " (%s)", name );
|
if (name) DEBUG_Printf( DBG_CHN_MESG, " (%s)", name );
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -152,10 +152,10 @@ DEBUG_PrintAddressAndArgs( const DBG_ADDR *addr, int addrlen,
|
||||||
const char *name = DEBUG_FindNearestSymbol( addr, flag, &rtn.sym, ebp,
|
const char *name = DEBUG_FindNearestSymbol( addr, flag, &rtn.sym, ebp,
|
||||||
&rtn.list );
|
&rtn.list );
|
||||||
|
|
||||||
if (addr->seg) fprintf( stderr, "0x%04lx:", addr->seg );
|
if (addr->seg) DEBUG_Printf( DBG_CHN_MESG, "0x%04lx:", addr->seg );
|
||||||
if (addrlen == 16) fprintf( stderr, "0x%04lx", addr->off );
|
if (addrlen == 16) DEBUG_Printf( DBG_CHN_MESG, "0x%04lx", addr->off );
|
||||||
else fprintf( stderr, "0x%08lx", addr->off );
|
else DEBUG_Printf( DBG_CHN_MESG, "0x%08lx", addr->off );
|
||||||
if (name) fprintf( stderr, " (%s)", name );
|
if (name) DEBUG_Printf( DBG_CHN_MESG, " (%s)", name );
|
||||||
|
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ void DEBUG_Help(void)
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
while(helptext[i]) fprintf(stderr,"%s\n", helptext[i++]);
|
while(helptext[i]) DEBUG_Printf(DBG_CHN_MESG,"%s\n", helptext[i++]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ void DEBUG_HelpInfo(void)
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
while(infotext[i]) fprintf(stderr,"%s\n", infotext[i++]);
|
while(infotext[i]) DEBUG_Printf(DBG_CHN_MESG,"%s\n", infotext[i++]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: merge InfoClass and InfoClass2 */
|
/* FIXME: merge InfoClass and InfoClass2 */
|
||||||
|
@ -244,13 +244,13 @@ void DEBUG_InfoClass(const char* name)
|
||||||
{
|
{
|
||||||
WNDCLASSEXA wca;
|
WNDCLASSEXA wca;
|
||||||
|
|
||||||
if (!GetClassInfoExA(0, name, &wca)) {
|
if (!GetClassInfoEx(0, name, &wca)) {
|
||||||
fprintf(stderr, "Cannot find class '%s'\n", name);
|
DEBUG_Printf(DBG_CHN_MESG, "Cannot find class '%s'\n", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Class '%s':\n", name);
|
DEBUG_Printf(DBG_CHN_MESG, "Class '%s':\n", name);
|
||||||
fprintf(stderr,
|
DEBUG_Printf(DBG_CHN_MESG,
|
||||||
"style=%08x wndProc=%08lx\n"
|
"style=%08x wndProc=%08lx\n"
|
||||||
"inst=%04x icon=%04x cursor=%04x bkgnd=%04x\n"
|
"inst=%04x icon=%04x cursor=%04x bkgnd=%04x\n"
|
||||||
"clsExtra=%d winExtra=%d\n",
|
"clsExtra=%d winExtra=%d\n",
|
||||||
|
@ -268,13 +268,13 @@ static void DEBUG_InfoClass2(HWND hWnd, const char* name)
|
||||||
{
|
{
|
||||||
WNDCLASSEXA wca;
|
WNDCLASSEXA wca;
|
||||||
|
|
||||||
if (!GetClassInfoExA(GetWindowLongA(hWnd, GWL_HINSTANCE), name, &wca)) {
|
if (!GetClassInfoEx(GetWindowLong(hWnd, GWL_HINSTANCE), name, &wca)) {
|
||||||
fprintf(stderr, "Cannot find class '%s'\n", name);
|
DEBUG_Printf(DBG_CHN_MESG, "Cannot find class '%s'\n", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Class '%s':\n", name);
|
DEBUG_Printf(DBG_CHN_MESG, "Class '%s':\n", name);
|
||||||
fprintf(stderr,
|
DEBUG_Printf(DBG_CHN_MESG,
|
||||||
"style=%08x wndProc=%08lx\n"
|
"style=%08x wndProc=%08lx\n"
|
||||||
"inst=%04x icon=%04x cursor=%04x bkgnd=%04x\n"
|
"inst=%04x icon=%04x cursor=%04x bkgnd=%04x\n"
|
||||||
"clsExtra=%d winExtra=%d\n",
|
"clsExtra=%d winExtra=%d\n",
|
||||||
|
@ -286,16 +286,16 @@ static void DEBUG_InfoClass2(HWND hWnd, const char* name)
|
||||||
int i;
|
int i;
|
||||||
WORD w;
|
WORD w;
|
||||||
|
|
||||||
fprintf(stderr, "Extra bytes:" );
|
DEBUG_Printf(DBG_CHN_MESG, "Extra bytes:" );
|
||||||
for (i = 0; i < wca.cbClsExtra / 2; i++) {
|
for (i = 0; i < wca.cbClsExtra / 2; i++) {
|
||||||
w = GetClassWord(hWnd, i * 2);
|
w = GetClassWord(hWnd, i * 2);
|
||||||
/* FIXME: depends on i386 endian-ity */
|
/* FIXME: depends on i386 endian-ity */
|
||||||
fprintf(stderr, " %02x", HIBYTE(w));
|
DEBUG_Printf(DBG_CHN_MESG, " %02x", HIBYTE(w));
|
||||||
fprintf(stderr, " %02x", LOBYTE(w));
|
DEBUG_Printf(DBG_CHN_MESG, " %02x", LOBYTE(w));
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n" );
|
DEBUG_Printf(DBG_CHN_MESG, "\n" );
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n" );
|
DEBUG_Printf(DBG_CHN_MESG, "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
struct class_walker {
|
struct class_walker {
|
||||||
|
@ -311,9 +311,9 @@ static void DEBUG_WalkClassesHelper(HWND hWnd, struct class_walker* cw)
|
||||||
ATOM atom;
|
ATOM atom;
|
||||||
HWND child;
|
HWND child;
|
||||||
|
|
||||||
if (!GetClassNameA(hWnd, clsName, sizeof(clsName)))
|
if (!GetClassName(hWnd, clsName, sizeof(clsName)))
|
||||||
return;
|
return;
|
||||||
if ((atom = FindAtomA(clsName)) == 0)
|
if ((atom = FindAtom(clsName)) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < cw->used; i++) {
|
for (i = 0; i < cw->used; i++) {
|
||||||
|
@ -346,12 +346,12 @@ void DEBUG_WalkClasses(void)
|
||||||
|
|
||||||
void DEBUG_DumpQueue(DWORD q)
|
void DEBUG_DumpQueue(DWORD q)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No longer doing info queue '0x%08lx'\n", q);
|
DEBUG_Printf(DBG_CHN_MESG, "No longer doing info queue '0x%08lx'\n", q);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DEBUG_WalkQueues(void)
|
void DEBUG_WalkQueues(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No longer walking queues list\n");
|
DEBUG_Printf(DBG_CHN_MESG, "No longer walking queues list\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DEBUG_InfoWindow(HWND hWnd)
|
void DEBUG_InfoWindow(HWND hWnd)
|
||||||
|
@ -363,9 +363,9 @@ void DEBUG_InfoWindow(HWND hWnd)
|
||||||
int i;
|
int i;
|
||||||
WORD w;
|
WORD w;
|
||||||
|
|
||||||
if (!GetClassNameA(hWnd, clsName, sizeof(clsName)))
|
if (!GetClassName(hWnd, clsName, sizeof(clsName)))
|
||||||
strcpy(clsName, "-- Unknown --");
|
strcpy(clsName, "-- Unknown --");
|
||||||
if (!GetWindowTextA(hWnd, wndName, sizeof(wndName)))
|
if (!GetWindowText(hWnd, wndName, sizeof(wndName)))
|
||||||
strcpy(wndName, "-- Empty --");
|
strcpy(wndName, "-- Empty --");
|
||||||
if (!GetClientRect(hWnd, &clientRect))
|
if (!GetClientRect(hWnd, &clientRect))
|
||||||
SetRectEmpty(&clientRect);
|
SetRectEmpty(&clientRect);
|
||||||
|
@ -373,7 +373,7 @@ void DEBUG_InfoWindow(HWND hWnd)
|
||||||
SetRectEmpty(&windowRect);
|
SetRectEmpty(&windowRect);
|
||||||
|
|
||||||
/* FIXME missing fields: hmemTaskQ, hrgnUpdate, dce, flags, pProp, scroll */
|
/* FIXME missing fields: hmemTaskQ, hrgnUpdate, dce, flags, pProp, scroll */
|
||||||
fprintf(stderr,
|
DEBUG_Printf(DBG_CHN_MESG,
|
||||||
"next=0x%04x child=0x%04x parent=0x%04x owner=0x%04x class='%s'\n"
|
"next=0x%04x child=0x%04x parent=0x%04x owner=0x%04x class='%s'\n"
|
||||||
"inst=%08lx active=%04x idmenu=%08lx\n"
|
"inst=%08lx active=%04x idmenu=%08lx\n"
|
||||||
"style=%08lx exstyle=%08lx wndproc=%08lx text='%s'\n"
|
"style=%08lx exstyle=%08lx wndproc=%08lx text='%s'\n"
|
||||||
|
@ -383,28 +383,28 @@ void DEBUG_InfoWindow(HWND hWnd)
|
||||||
GetParent(hWnd),
|
GetParent(hWnd),
|
||||||
GetWindow(hWnd, GW_OWNER),
|
GetWindow(hWnd, GW_OWNER),
|
||||||
clsName,
|
clsName,
|
||||||
GetWindowLongA(hWnd, GWL_HINSTANCE),
|
GetWindowLong(hWnd, GWL_HINSTANCE),
|
||||||
GetLastActivePopup(hWnd),
|
GetLastActivePopup(hWnd),
|
||||||
GetWindowLongA(hWnd, GWL_ID),
|
GetWindowLong(hWnd, GWL_ID),
|
||||||
GetWindowLongA(hWnd, GWL_STYLE),
|
GetWindowLong(hWnd, GWL_STYLE),
|
||||||
GetWindowLongA(hWnd, GWL_EXSTYLE),
|
GetWindowLong(hWnd, GWL_EXSTYLE),
|
||||||
GetWindowLongA(hWnd, GWL_WNDPROC),
|
GetWindowLong(hWnd, GWL_WNDPROC),
|
||||||
wndName,
|
wndName,
|
||||||
clientRect.left, clientRect.top, clientRect.right, clientRect.bottom,
|
clientRect.left, clientRect.top, clientRect.right, clientRect.bottom,
|
||||||
windowRect.left, windowRect.top, windowRect.right, windowRect.bottom,
|
windowRect.left, windowRect.top, windowRect.right, windowRect.bottom,
|
||||||
GetSystemMenu(hWnd, FALSE));
|
GetSystemMenu(hWnd, FALSE));
|
||||||
|
|
||||||
if (GetClassLongA(hWnd, GCL_CBWNDEXTRA)) {
|
if (GetClassLong(hWnd, GCL_CBWNDEXTRA)) {
|
||||||
fprintf(stderr, "Extra bytes:" );
|
DEBUG_Printf(DBG_CHN_MESG, "Extra bytes:" );
|
||||||
for (i = 0; i < GetClassLongA(hWnd, GCL_CBWNDEXTRA) / 2; i++) {
|
for (i = 0; i < GetClassLong(hWnd, GCL_CBWNDEXTRA) / 2; i++) {
|
||||||
w = GetWindowWord(hWnd, i * 2);
|
w = GetWindowWord(hWnd, i * 2);
|
||||||
/* FIXME: depends on i386 endian-ity */
|
/* FIXME: depends on i386 endian-ity */
|
||||||
fprintf(stderr, " %02x", HIBYTE(w));
|
DEBUG_Printf(DBG_CHN_MESG, " %02x", HIBYTE(w));
|
||||||
fprintf(stderr, " %02x", LOBYTE(w));
|
DEBUG_Printf(DBG_CHN_MESG, " %02x", LOBYTE(w));
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
DEBUG_Printf(DBG_CHN_MESG, "\n");
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
DEBUG_Printf(DBG_CHN_MESG, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DEBUG_WalkWindows(HWND hWnd, int indent)
|
void DEBUG_WalkWindows(HWND hWnd, int indent)
|
||||||
|
@ -417,21 +417,21 @@ void DEBUG_WalkWindows(HWND hWnd, int indent)
|
||||||
hWnd = GetDesktopWindow();
|
hWnd = GetDesktopWindow();
|
||||||
|
|
||||||
if (!indent) /* first time around */
|
if (!indent) /* first time around */
|
||||||
fprintf(stderr,
|
DEBUG_Printf(DBG_CHN_MESG,
|
||||||
"%-16.16s %-17.17s %-8.8s %s\n",
|
"%-16.16s %-17.17s %-8.8s %s\n",
|
||||||
"hwnd", "Class Name", " Style", " WndProc Text");
|
"hwnd", "Class Name", " Style", " WndProc Text");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!GetClassNameA(hWnd, clsName, sizeof(clsName)))
|
if (!GetClassName(hWnd, clsName, sizeof(clsName)))
|
||||||
strcpy(clsName, "-- Unknown --");
|
strcpy(clsName, "-- Unknown --");
|
||||||
if (!GetWindowTextA(hWnd, wndName, sizeof(wndName)))
|
if (!GetWindowText(hWnd, wndName, sizeof(wndName)))
|
||||||
strcpy(wndName, "-- Empty --");
|
strcpy(wndName, "-- Empty --");
|
||||||
|
|
||||||
/* FIXME: missing hmemTaskQ */
|
/* FIXME: missing hmemTaskQ */
|
||||||
fprintf(stderr, "%*s%04x%*s", indent, "", hWnd, 13-indent,"");
|
DEBUG_Printf(DBG_CHN_MESG, "%*s%04x%*s", indent, "", hWnd, 13-indent,"");
|
||||||
fprintf(stderr, "%-17.17s %08lx %08lx %.14s\n",
|
DEBUG_Printf(DBG_CHN_MESG, "%-17.17s %08lx %08lx %.14s\n",
|
||||||
clsName, GetWindowLongA(hWnd, GWL_STYLE),
|
clsName, GetWindowLong(hWnd, GWL_STYLE),
|
||||||
GetWindowLongA(hWnd, GWL_WNDPROC), wndName);
|
GetWindowLong(hWnd, GWL_WNDPROC), wndName);
|
||||||
|
|
||||||
if ((child = GetWindow(hWnd, GW_CHILD)) != 0)
|
if ((child = GetWindow(hWnd, GW_CHILD)) != 0)
|
||||||
DEBUG_WalkWindows(child, indent + 1 );
|
DEBUG_WalkWindows(child, indent + 1 );
|
||||||
|
@ -440,12 +440,12 @@ void DEBUG_WalkWindows(HWND hWnd, int indent)
|
||||||
|
|
||||||
void DEBUG_WalkProcess(void)
|
void DEBUG_WalkProcess(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No longer walking processes list\n");
|
DEBUG_Printf(DBG_CHN_MESG, "No longer walking processes list\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DEBUG_WalkModref(DWORD p)
|
void DEBUG_WalkModref(DWORD p)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No longer walking module references list\n");
|
DEBUG_Printf(DBG_CHN_MESG, "No longer walking module references list\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DEBUG_InfoSegments(DWORD start, int length)
|
void DEBUG_InfoSegments(DWORD start, int length)
|
||||||
|
@ -473,7 +473,7 @@ void DEBUG_InfoSegments(DWORD start, int length)
|
||||||
flags[1] = (le.HighWord.Bits.Type & 0x2) ? 'w' : '-';
|
flags[1] = (le.HighWord.Bits.Type & 0x2) ? 'w' : '-';
|
||||||
flags[2] = '-';
|
flags[2] = '-';
|
||||||
}
|
}
|
||||||
fprintf(stderr,
|
DEBUG_Printf(DBG_CHN_MESG,
|
||||||
"%04lx: sel=%04lx base=%08x limit=%08x %d-bit %c%c%c\n",
|
"%04lx: sel=%04lx base=%08x limit=%08x %d-bit %c%c%c\n",
|
||||||
i, (i<<3)|7,
|
i, (i<<3)|7,
|
||||||
(le.HighWord.Bits.BaseHi << 24) +
|
(le.HighWord.Bits.BaseHi << 24) +
|
||||||
|
@ -487,5 +487,5 @@ void DEBUG_InfoSegments(DWORD start, int length)
|
||||||
|
|
||||||
void DEBUG_InfoVirtual(void)
|
void DEBUG_InfoVirtual(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No longer providing virtual mapping information\n");
|
DEBUG_Printf(DBG_CHN_MESG, "No longer providing virtual mapping information\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
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)
|
static void DEBUG_Die(const char* msg)
|
||||||
{
|
{
|
||||||
fprintf(stderr, msg);
|
DEBUG_Printf(DBG_CHN_MESG, msg);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,16 +118,21 @@ void DEBUG_GetCurrentAddress( DBG_ADDR *addr )
|
||||||
#endif
|
#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 )
|
void DEBUG_InvalLinAddr( void* addr )
|
||||||
{
|
{
|
||||||
DBG_ADDR address;
|
DBG_ADDR address;
|
||||||
|
|
||||||
address.seg = 0;
|
address.seg = 0;
|
||||||
address.off = (unsigned long)addr;
|
address.off = (unsigned long)addr;
|
||||||
|
DEBUG_InvalAddr( &address );
|
||||||
fprintf(stderr,"*** Invalid address ");
|
|
||||||
DEBUG_PrintAddress(&address, DEBUG_CurrThread->dbg_mode, FALSE);
|
|
||||||
fprintf(stderr,"\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -215,14 +220,14 @@ void DEBUG_ExamineMemory( const DBG_VALUE *_value, int count, char format )
|
||||||
}
|
}
|
||||||
else if (!value.addr.seg && !value.addr.off)
|
else if (!value.addr.seg && !value.addr.off)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Invalid expression\n");
|
DEBUG_Printf(DBG_CHN_MESG,"Invalid expression\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format != 'i' && count > 1)
|
if (format != 'i' && count > 1)
|
||||||
{
|
{
|
||||||
DEBUG_PrintAddress( &value.addr, DEBUG_CurrThread->dbg_mode, FALSE );
|
DEBUG_PrintAddress( &value.addr, DEBUG_CurrThread->dbg_mode, FALSE );
|
||||||
fprintf(stderr,": ");
|
DEBUG_Printf(DBG_CHN_MESG,": ");
|
||||||
}
|
}
|
||||||
|
|
||||||
pnt = (void*)DEBUG_ToLinear( &value.addr );
|
pnt = (void*)DEBUG_ToLinear( &value.addr );
|
||||||
|
@ -239,7 +244,7 @@ void DEBUG_ExamineMemory( const DBG_VALUE *_value, int count, char format )
|
||||||
pnt += sizeof(wch);
|
pnt += sizeof(wch);
|
||||||
fputc( (char)wch, stderr );
|
fputc( (char)wch, stderr );
|
||||||
}
|
}
|
||||||
fprintf(stderr,"\n");
|
DEBUG_Printf(DBG_CHN_MESG,"\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case 's': {
|
case 's': {
|
||||||
|
@ -253,31 +258,31 @@ void DEBUG_ExamineMemory( const DBG_VALUE *_value, int count, char format )
|
||||||
pnt++;
|
pnt++;
|
||||||
fputc( ch, stderr );
|
fputc( ch, stderr );
|
||||||
}
|
}
|
||||||
fprintf(stderr,"\n");
|
DEBUG_Printf(DBG_CHN_MESG,"\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case 'i':
|
case 'i':
|
||||||
while (count--)
|
while (count--)
|
||||||
{
|
{
|
||||||
DEBUG_PrintAddress( &value.addr, DEBUG_CurrThread->dbg_mode, TRUE );
|
DEBUG_PrintAddress( &value.addr, DEBUG_CurrThread->dbg_mode, TRUE );
|
||||||
fprintf(stderr,": ");
|
DEBUG_Printf(DBG_CHN_MESG,": ");
|
||||||
DEBUG_Disasm( &value.addr, TRUE );
|
DEBUG_Disasm( &value.addr, TRUE );
|
||||||
fprintf(stderr,"\n");
|
DEBUG_Printf(DBG_CHN_MESG,"\n");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
#define DO_DUMP2(_t,_l,_f,_vv) { \
|
#define DO_DUMP2(_t,_l,_f,_vv) { \
|
||||||
_t _v; \
|
_t _v; \
|
||||||
for(i=0; i<count; i++) { \
|
for(i=0; i<count; i++) { \
|
||||||
if (!DEBUG_READ_MEM_VERBOSE(pnt, &_v, sizeof(_t))) break; \
|
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); \
|
pnt += sizeof(_t); value.addr.off += sizeof(_t); \
|
||||||
if ((i % (_l)) == (_l)-1) { \
|
if ((i % (_l)) == (_l)-1) { \
|
||||||
fprintf(stderr,"\n"); \
|
DEBUG_Printf(DBG_CHN_MESG,"\n"); \
|
||||||
DEBUG_PrintAddress( &value.addr, DEBUG_CurrThread->dbg_mode, FALSE );\
|
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
|
return
|
||||||
#define DO_DUMP(_t,_l,_f) DO_DUMP2(_t,_l,_f,_v)
|
#define DO_DUMP(_t,_l,_f) DO_DUMP2(_t,_l,_f,_v)
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "neexe.h"
|
#include "neexe.h"
|
||||||
#include "peexe.h"
|
#include "peexe.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
#include "file.h"
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
#include "toolhelp.h"
|
#include "toolhelp.h"
|
||||||
|
|
||||||
|
@ -232,7 +233,7 @@ static void DEBUG_LoadModule16(HMODULE hModule, NE_MODULE* module, char* moduleA
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* DEBUG_LoadModule32
|
* DEBUG_LoadModule32
|
||||||
*/
|
*/
|
||||||
void DEBUG_LoadModule32(const char* name, DWORD base)
|
void DEBUG_LoadModule32(const char* name, HANDLE hFile, DWORD base)
|
||||||
{
|
{
|
||||||
DBG_VALUE value;
|
DBG_VALUE value;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
@ -249,7 +250,7 @@ void DEBUG_LoadModule32(const char* name, DWORD base)
|
||||||
/* FIXME: we make the assumption that hModule == base */
|
/* FIXME: we make the assumption that hModule == base */
|
||||||
wmod = DEBUG_RegisterPEModule((HMODULE)base, base, name);
|
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.type = NULL;
|
||||||
value.cookie = DV_TARGET;
|
value.cookie = DV_TARGET;
|
||||||
|
@ -264,8 +265,8 @@ void DEBUG_LoadModule32(const char* name, DWORD base)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (wmod) {
|
if (wmod) {
|
||||||
DEBUG_RegisterMSCDebugInfo(wmod, &pe_header, pe_header_ofs);
|
DEBUG_RegisterStabsDebugInfo(wmod, hFile, &pe_header, pe_header_ofs);
|
||||||
DEBUG_RegisterStabsDebugInfo(wmod, &pe_header, pe_header_ofs);
|
DEBUG_RegisterMSCDebugInfo(wmod, hFile, &pe_header, pe_header_ofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add start of DLL */
|
/* Add start of DLL */
|
||||||
|
@ -282,11 +283,9 @@ void DEBUG_LoadModule32(const char* name, DWORD base)
|
||||||
pe_header.FileHeader.SizeOfOptionalHeader;
|
pe_header.FileHeader.SizeOfOptionalHeader;
|
||||||
|
|
||||||
for (i = 0; i < pe_header.FileHeader.NumberOfSections; i++, pe_seg_ofs += sizeof(pe_seg)) {
|
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)) ||
|
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)))
|
|
||||||
continue;
|
continue;
|
||||||
bufstr[sizeof(bufstr) - 1] = 0;
|
sprintf(buffer, "%s.%s", name, pe_seg.Name);
|
||||||
sprintf(buffer, "%s.%s", name, bufstr);
|
|
||||||
value.addr.off = base + pe_seg.VirtualAddress;
|
value.addr.off = base + pe_seg.VirtualAddress;
|
||||||
DEBUG_AddSymbol(buffer, &value, NULL, SYM_WIN32 | SYM_FUNC);
|
DEBUG_AddSymbol(buffer, &value, NULL, SYM_WIN32 | SYM_FUNC);
|
||||||
}
|
}
|
||||||
|
@ -359,6 +358,10 @@ int DEBUG_LoadEntryPoints(const char* pfx)
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* FIXME: we assume that a module is never removed from memory */
|
/* 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 (ModuleFirst16(&entry)) do {
|
||||||
if (DEBUG_FindModuleByName(entry.szModule, DM_TYPE_UNKNOWN) ||
|
if (DEBUG_FindModuleByName(entry.szModule, DM_TYPE_UNKNOWN) ||
|
||||||
!(moduleAddr = NE_GetPtr(entry.hModule)) ||
|
!(moduleAddr = NE_GetPtr(entry.hModule)) ||
|
||||||
|
@ -366,68 +369,27 @@ int DEBUG_LoadEntryPoints(const char* pfx)
|
||||||
(module.flags & NE_FFLAGS_WIN32) /* NE module */)
|
(module.flags & NE_FFLAGS_WIN32) /* NE module */)
|
||||||
continue;
|
continue;
|
||||||
if (!first) {
|
if (!first) {
|
||||||
if (pfx) fprintf(stderr, pfx);
|
if (pfx) DEBUG_Printf(DBG_CHN_MESG, pfx);
|
||||||
fprintf(stderr, " ");
|
DEBUG_Printf(DBG_CHN_MESG, " ");
|
||||||
rowcount = 3 + (pfx ? strlen(pfx) : 0);
|
rowcount = 3 + (pfx ? strlen(pfx) : 0);
|
||||||
first = 1;
|
first = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(entry.szModule);
|
len = strlen(entry.szModule);
|
||||||
if ((rowcount + len) > 76) {
|
if ((rowcount + len) > 76) {
|
||||||
fprintf(stderr, "\n ");
|
DEBUG_Printf(DBG_CHN_MESG, "\n ");
|
||||||
rowcount = 3;
|
rowcount = 3;
|
||||||
}
|
}
|
||||||
fprintf(stderr, " %s", entry.szModule);
|
DEBUG_Printf(DBG_CHN_MESG, " %s", entry.szModule);
|
||||||
rowcount += len + 1;
|
rowcount += len + 1;
|
||||||
|
|
||||||
DEBUG_LoadModule16(entry.hModule, &module, moduleAddr, entry.szModule);
|
DEBUG_LoadModule16(entry.hModule, &module, moduleAddr, entry.szModule);
|
||||||
} while (ModuleNext16(&entry));
|
} while (ModuleNext16(&entry));
|
||||||
|
|
||||||
if (first) fprintf(stderr, "\n");
|
if (first) DEBUG_Printf(DBG_CHN_MESG, "\n");
|
||||||
return first;
|
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
|
* DEBUG_InfoShare
|
||||||
*
|
*
|
||||||
|
@ -438,7 +400,7 @@ void DEBUG_InfoShare(void)
|
||||||
DBG_MODULE* wmod;
|
DBG_MODULE* wmod;
|
||||||
const char* xtype;
|
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) {
|
for (wmod = DEBUG_CurrProcess->modules; wmod; wmod = wmod->next) {
|
||||||
switch (wmod->type) {
|
switch (wmod->type) {
|
||||||
|
@ -447,7 +409,7 @@ void DEBUG_InfoShare(void)
|
||||||
case DM_TYPE_ELF: xtype = "ELF"; break;
|
case DM_TYPE_ELF: xtype = "ELF"; break;
|
||||||
default: xtype = "???"; 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);
|
xtype, wmod->module_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,11 +444,11 @@ void DEBUG_DumpModule(DWORD mod)
|
||||||
|
|
||||||
if (!(wmod = DEBUG_FindModuleByHandle(mod, DM_TYPE_UNKNOWN)) &&
|
if (!(wmod = DEBUG_FindModuleByHandle(mod, DM_TYPE_UNKNOWN)) &&
|
||||||
!(wmod = DEBUG_FindModuleByAddr((void*)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;
|
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,
|
wmod->module_name, wmod->handle, (unsigned int)wmod->load_addr,
|
||||||
DEBUG_GetModuleType(wmod->type), DEBUG_GetModuleStatus(wmod->status));
|
DEBUG_GetModuleType(wmod->type), DEBUG_GetModuleStatus(wmod->status));
|
||||||
}
|
}
|
||||||
|
@ -501,7 +463,7 @@ void DEBUG_WalkModules(void)
|
||||||
DBG_MODULE* wmod;
|
DBG_MODULE* wmod;
|
||||||
const char* xtype;
|
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) {
|
for (wmod = DEBUG_CurrProcess->modules; wmod; wmod = wmod->next) {
|
||||||
switch (wmod->type) {
|
switch (wmod->type) {
|
||||||
|
@ -511,7 +473,7 @@ void DEBUG_WalkModules(void)
|
||||||
default: xtype = "???"; break;
|
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),
|
(unsigned int)wmod->load_addr, DEBUG_GetModuleType(wmod->type),
|
||||||
wmod->module_name);
|
wmod->module_name);
|
||||||
}
|
}
|
||||||
|
|
345
debugger/msc.c
345
debugger/msc.c
|
@ -16,16 +16,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#endif
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#ifndef PATH_MAX
|
#ifndef PATH_MAX
|
||||||
|
@ -46,44 +38,79 @@ typedef struct {
|
||||||
|
|
||||||
#define MSC_INFO(module) ((MSC_DBG_INFO*)((module)->extra_info))
|
#define MSC_INFO(module) ((MSC_DBG_INFO*)((module)->extra_info))
|
||||||
|
|
||||||
|
static int DEBUG_ProcessMSCDebugInfo(DBG_MODULE* module);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dbg_filename must be at least MAX_PATHNAME_LEN bytes in size
|
* dbg_filename must be at least MAX_PATHNAME_LEN bytes in size
|
||||||
*/
|
*/
|
||||||
static void LocateDebugInfoFile(char *filename, char *dbg_filename)
|
static void DEBUG_LocateDebugInfoFile(const char *filename, char *dbg_filename)
|
||||||
{
|
{
|
||||||
char *str1 = DBG_alloc(MAX_PATHNAME_LEN*10);
|
char *str1 = DBG_alloc(MAX_PATHNAME_LEN);
|
||||||
char *str2 = DBG_alloc(MAX_PATHNAME_LEN);
|
char *str2 = DBG_alloc(MAX_PATHNAME_LEN*10);
|
||||||
char *file;
|
const char *file;
|
||||||
char *name_part;
|
char *name_part;
|
||||||
DOS_FULL_NAME fullname;
|
|
||||||
|
|
||||||
file = strrchr(filename, '\\');
|
file = strrchr(filename, '\\');
|
||||||
if( file == NULL ) file = filename; else file++;
|
if( file == NULL ) file = filename; else file++;
|
||||||
|
|
||||||
if (GetEnvironmentVariableA("_NT_SYMBOL_PATH", str1, MAX_PATHNAME_LEN))
|
if ((GetEnvironmentVariable("_NT_SYMBOL_PATH", str1, MAX_PATHNAME_LEN) &&
|
||||||
if (SearchPathA(str1, file, NULL, MAX_PATHNAME_LEN*10, str2, &name_part))
|
(SearchPath(str1, file, NULL, MAX_PATHNAME_LEN*10, str2, &name_part))) ||
|
||||||
goto ok;
|
(GetEnvironmentVariable("_NT_ALT_SYMBOL_PATH", str1, MAX_PATHNAME_LEN) &&
|
||||||
if (GetEnvironmentVariableA("_NT_ALT_SYMBOL_PATH", str1, MAX_PATHNAME_LEN))
|
(SearchPath(str1, file, NULL, MAX_PATHNAME_LEN*10, str2, &name_part))) ||
|
||||||
if (SearchPathA(str1, file, NULL, MAX_PATHNAME_LEN*10, str2, &name_part))
|
(SearchPath(NULL, file, NULL, MAX_PATHNAME_LEN*10, str2, &name_part)))
|
||||||
goto ok;
|
lstrcpyn(dbg_filename, str2, MAX_PATHNAME_LEN);
|
||||||
if (SearchPathA(NULL, file, NULL, MAX_PATHNAME_LEN*10, str2, &name_part))
|
|
||||||
goto ok;
|
|
||||||
else
|
else
|
||||||
{
|
lstrcpyn(dbg_filename, filename, MAX_PATHNAME_LEN);
|
||||||
quit:
|
|
||||||
memcpy(dbg_filename, filename, MAX_PATHNAME_LEN);
|
|
||||||
DBG_free(str1);
|
DBG_free(str1);
|
||||||
DBG_free(str2);
|
DBG_free(str2);
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* DEBUG_MapDebugInfoFile
|
||||||
|
*/
|
||||||
|
static void* DEBUG_MapDebugInfoFile(const char* name, DWORD offset, DWORD size,
|
||||||
|
HANDLE* hFile, HANDLE* hMap)
|
||||||
|
{
|
||||||
|
OFSTRUCT ofs;
|
||||||
|
DWORD g_offset; /* offset aligned on map granuality */
|
||||||
|
DWORD g_size; /* size to map, with offset aligned */
|
||||||
|
char* ret;
|
||||||
|
|
||||||
|
*hMap = 0;
|
||||||
|
|
||||||
|
if (name != NULL) {
|
||||||
|
char filename[MAX_PATHNAME_LEN];
|
||||||
|
|
||||||
|
DEBUG_LocateDebugInfoFile(name, filename);
|
||||||
|
if ((*hFile = OpenFile(filename, &ofs, OF_READ)) == HFILE_ERROR)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
ok:
|
|
||||||
if (DOSFS_GetFullName(str2, TRUE, &fullname))
|
if (!size) {
|
||||||
memcpy(dbg_filename, fullname.long_name, MAX_PATHNAME_LEN);
|
DWORD file_size = GetFileSize(*hFile, NULL);
|
||||||
else
|
if (file_size == (DWORD)-1) return NULL;
|
||||||
goto quit;
|
size = file_size - offset;
|
||||||
DBG_free(str1);
|
}
|
||||||
DBG_free(str2);
|
|
||||||
return;
|
g_offset = offset & ~0xFFFF; /* FIXME: is granularity portable ? */
|
||||||
|
g_size = offset + size - g_offset;
|
||||||
|
|
||||||
|
if ((*hMap = CreateFileMapping(*hFile, NULL, PAGE_READONLY, 0, 0, NULL)) == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if ((ret = MapViewOfFile(*hMap, FILE_MAP_READ, 0, g_offset, g_size)) != NULL)
|
||||||
|
ret += offset - g_offset;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* DEBUG_UnmapDebugInfoFile
|
||||||
|
*/
|
||||||
|
static void DEBUG_UnmapDebugInfoFile(HANDLE hFile, HANDLE hMap, void* addr)
|
||||||
|
{
|
||||||
|
if (addr) UnmapViewOfFile(addr);
|
||||||
|
if (hMap) CloseHandle(hMap);
|
||||||
|
if (hFile) CloseHandle(hFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
union any_size
|
union any_size
|
||||||
|
@ -790,7 +817,7 @@ DEBUG_ParseTypeTable(char * table, int len)
|
||||||
* This is a numeric leaf, I am too lazy to handle this right
|
* This is a numeric leaf, I am too lazy to handle this right
|
||||||
* now.
|
* now.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Ignoring large numberic leaf.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Ignoring large numberic leaf.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( type->array.namelen != 0 )
|
if( type->array.namelen != 0 )
|
||||||
|
@ -825,7 +852,7 @@ DEBUG_ParseTypeTable(char * table, int len)
|
||||||
* This is a numeric leaf, I am too lazy to handle this right
|
* This is a numeric leaf, I am too lazy to handle this right
|
||||||
* now.
|
* now.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Ignoring large numberic leaf.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Ignoring large numberic leaf.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( type->array32.namelen != 0 )
|
if( type->array32.namelen != 0 )
|
||||||
|
@ -900,7 +927,7 @@ DEBUG_ParseTypeTable(char * table, int len)
|
||||||
* This is a numeric leaf, I am too lazy to handle this right
|
* This is a numeric leaf, I am too lazy to handle this right
|
||||||
* now.
|
* now.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Ignoring large numberic leaf.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Ignoring large numberic leaf.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -920,7 +947,7 @@ DEBUG_ParseTypeTable(char * table, int len)
|
||||||
* This is a numeric leaf, I am too lazy to handle this right
|
* This is a numeric leaf, I am too lazy to handle this right
|
||||||
* now.
|
* now.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Ignoring large numberic leaf.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Ignoring large numberic leaf.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -935,7 +962,7 @@ DEBUG_ParseTypeTable(char * table, int len)
|
||||||
* object in the fieldlist, or some other problem which I wouldn't
|
* object in the fieldlist, or some other problem which I wouldn't
|
||||||
* really know how to handle until it came up.
|
* really know how to handle until it came up.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Unexpected entry in fieldlist\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Unexpected entry in fieldlist\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -990,7 +1017,7 @@ DEBUG_ParseTypeTable(char * table, int len)
|
||||||
* This is a numeric leaf, I am too lazy to handle this right
|
* This is a numeric leaf, I am too lazy to handle this right
|
||||||
* now.
|
* now.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Ignoring large numberic leaf.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Ignoring large numberic leaf.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1010,7 +1037,7 @@ DEBUG_ParseTypeTable(char * table, int len)
|
||||||
* This is a numeric leaf, I am too lazy to handle this right
|
* This is a numeric leaf, I am too lazy to handle this right
|
||||||
* now.
|
* now.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Ignoring large numberic leaf.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Ignoring large numberic leaf.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1025,7 +1052,7 @@ DEBUG_ParseTypeTable(char * table, int len)
|
||||||
* object in the fieldlist, or some other problem which I wouldn't
|
* object in the fieldlist, or some other problem which I wouldn't
|
||||||
* really know how to handle until it came up.
|
* really know how to handle until it came up.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Unexpected entry in fieldlist\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Unexpected entry in fieldlist\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1041,7 +1068,7 @@ DEBUG_ParseTypeTable(char * table, int len)
|
||||||
* This is a numeric leaf, I am too lazy to handle this right
|
* This is a numeric leaf, I am too lazy to handle this right
|
||||||
* now.
|
* now.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Ignoring large numberic leaf.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Ignoring large numberic leaf.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memset(symname, 0, sizeof(symname));
|
memset(symname, 0, sizeof(symname));
|
||||||
|
@ -1075,7 +1102,7 @@ DEBUG_ParseTypeTable(char * table, int len)
|
||||||
* This is a numeric leaf, I am too lazy to handle this right
|
* This is a numeric leaf, I am too lazy to handle this right
|
||||||
* now.
|
* now.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Ignoring large numberic leaf.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Ignoring large numberic leaf.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memset(symname, 0, sizeof(symname));
|
memset(symname, 0, sizeof(symname));
|
||||||
|
@ -1108,7 +1135,7 @@ DEBUG_ParseTypeTable(char * table, int len)
|
||||||
* This is a numeric leaf, I am too lazy to handle this right
|
* This is a numeric leaf, I am too lazy to handle this right
|
||||||
* now.
|
* now.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Ignoring large numberic leaf.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Ignoring large numberic leaf.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memset(symname, 0, sizeof(symname));
|
memset(symname, 0, sizeof(symname));
|
||||||
|
@ -1143,7 +1170,7 @@ DEBUG_ParseTypeTable(char * table, int len)
|
||||||
* This is a numeric leaf, I am too lazy to handle this right
|
* This is a numeric leaf, I am too lazy to handle this right
|
||||||
* now.
|
* now.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Ignoring large numberic leaf.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Ignoring large numberic leaf.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memset(symname, 0, sizeof(symname));
|
memset(symname, 0, sizeof(symname));
|
||||||
|
@ -1274,7 +1301,7 @@ DEBUG_InitCVDataTypes(void)
|
||||||
* We don't fully process it here for performance reasons.
|
* We don't fully process it here for performance reasons.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
DEBUG_RegisterMSCDebugInfo(DBG_MODULE* module, void* _nth, unsigned long nth_ofs)
|
DEBUG_RegisterMSCDebugInfo(DBG_MODULE* module, HANDLE hFile, void* _nth, unsigned long nth_ofs)
|
||||||
{
|
{
|
||||||
int has_codeview = FALSE;
|
int has_codeview = FALSE;
|
||||||
int rtn = FALSE;
|
int rtn = FALSE;
|
||||||
|
@ -1335,11 +1362,6 @@ DEBUG_RegisterMSCDebugInfo(DBG_MODULE* module, void* _nth, unsigned long nth_ofs
|
||||||
if( (dbg.Type != IMAGE_DEBUG_TYPE_MISC) ||
|
if( (dbg.Type != IMAGE_DEBUG_TYPE_MISC) ||
|
||||||
(nth->FileHeader.Characteristics & IMAGE_FILE_DEBUG_STRIPPED) != 0 )
|
(nth->FileHeader.Characteristics & IMAGE_FILE_DEBUG_STRIPPED) != 0 )
|
||||||
{
|
{
|
||||||
char fn[PATH_MAX];
|
|
||||||
int fd = -1;
|
|
||||||
DOS_FULL_NAME full_name;
|
|
||||||
char* dbg_info;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the important bits. What we do after this depends
|
* Read the important bits. What we do after this depends
|
||||||
* upon the type, but this is always enough so we are able
|
* upon the type, but this is always enough so we are able
|
||||||
|
@ -1349,30 +1371,26 @@ DEBUG_RegisterMSCDebugInfo(DBG_MODULE* module, void* _nth, unsigned long nth_ofs
|
||||||
* the DataDirectory array's content. One its entry contains the *beloved*
|
* the DataDirectory array's content. One its entry contains the *beloved*
|
||||||
* debug information. (Note the DataDirectory is mapped, not its content)
|
* debug information. (Note the DataDirectory is mapped, not its content)
|
||||||
*/
|
*/
|
||||||
/* FIXME: the module->handle value is not usable in the debugger's process */
|
HANDLE hMap;
|
||||||
if (GetModuleFileNameA(module->handle, fn, sizeof(fn)) > 0 &&
|
char* dbg_info;
|
||||||
DOSFS_GetFullName(fn, TRUE, &full_name) &&
|
|
||||||
(fd = open(full_name.long_name, O_RDONLY)) > 0)
|
|
||||||
{
|
|
||||||
dbg_info = mmap(NULL, dbg.SizeOfData,
|
|
||||||
PROT_READ, MAP_PRIVATE, fd, dbg.PointerToRawData);
|
|
||||||
close(fd);
|
|
||||||
if( dbg_info == (char *) 0xffffffff ) break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stderr, " (not mapped: fn='%s', lfn='%s', fd=%d)\n", fn, full_name.long_name, fd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!(module->extra_info = DBG_alloc(sizeof(MSC_DBG_INFO))))
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
DEBUG_Printf(DBG_CHN_TRACE, "PE debugging info at %ld<%ld>\n", dbg.PointerToRawData, dbg.SizeOfData);
|
||||||
|
dbg_info = DEBUG_MapDebugInfoFile(NULL, dbg.PointerToRawData, dbg.SizeOfData,
|
||||||
|
&hFile, &hMap);
|
||||||
|
|
||||||
|
if (dbg_info != NULL &&
|
||||||
|
(module->extra_info = DBG_alloc(sizeof(MSC_DBG_INFO))) != NULL) {
|
||||||
MSC_INFO(module)->dbg_info = dbg_info;
|
MSC_INFO(module)->dbg_info = dbg_info;
|
||||||
MSC_INFO(module)->dbg_size = dbg.SizeOfData;
|
MSC_INFO(module)->dbg_size = dbg.SizeOfData;
|
||||||
MSC_INFO(module)->dbgdir = dbg;
|
MSC_INFO(module)->dbgdir = dbg;
|
||||||
MSC_INFO(module)->sect_ofs = nth_ofs + OFFSET_OF(IMAGE_NT_HEADERS, OptionalHeader) +
|
MSC_INFO(module)->sect_ofs = nth_ofs + OFFSET_OF(IMAGE_NT_HEADERS, OptionalHeader) +
|
||||||
nth->FileHeader.SizeOfOptionalHeader;
|
nth->FileHeader.SizeOfOptionalHeader;
|
||||||
MSC_INFO(module)->nsect = nth->FileHeader.NumberOfSections;
|
MSC_INFO(module)->nsect = nth->FileHeader.NumberOfSections;
|
||||||
|
DEBUG_ProcessMSCDebugInfo(module);
|
||||||
|
DBG_free(MSC_INFO(module));
|
||||||
|
MSC_INFO(module) = NULL;
|
||||||
|
}
|
||||||
|
DEBUG_UnmapDebugInfoFile(0, hMap, dbg_info);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -1388,15 +1406,15 @@ DEBUG_RegisterMSCDebugInfo(DBG_MODULE* module, void* _nth, unsigned long nth_ofs
|
||||||
}
|
}
|
||||||
|
|
||||||
/* look for stabs information in PE header (it's how mingw compiler provides its
|
/* look for stabs information in PE header (it's how mingw compiler provides its
|
||||||
* debugging information
|
* debugging information), and also wine PE <-> ELF linking thru .wsolnk sections
|
||||||
*/
|
*/
|
||||||
int DEBUG_RegisterStabsDebugInfo(DBG_MODULE* module, void* _nth, unsigned long nth_ofs)
|
int DEBUG_RegisterStabsDebugInfo(DBG_MODULE* module, HANDLE hFile, void* _nth,
|
||||||
|
unsigned long nth_ofs)
|
||||||
{
|
{
|
||||||
IMAGE_SECTION_HEADER pe_seg;
|
IMAGE_SECTION_HEADER pe_seg;
|
||||||
unsigned long pe_seg_ofs;
|
unsigned long pe_seg_ofs;
|
||||||
int i, stabsize = 0, stabstrsize = 0;
|
int i, stabsize = 0, stabstrsize = 0, xcnlnksize = 0;
|
||||||
unsigned int stabs = 0, stabstr = 0;
|
unsigned int stabs = 0, stabstr = 0, xcnlnk = 0;
|
||||||
char bufstr[256];
|
|
||||||
PIMAGE_NT_HEADERS nth = (PIMAGE_NT_HEADERS)_nth;
|
PIMAGE_NT_HEADERS nth = (PIMAGE_NT_HEADERS)_nth;
|
||||||
|
|
||||||
pe_seg_ofs = nth_ofs + OFFSET_OF(IMAGE_NT_HEADERS, OptionalHeader) +
|
pe_seg_ofs = nth_ofs + OFFSET_OF(IMAGE_NT_HEADERS, OptionalHeader) +
|
||||||
|
@ -1404,28 +1422,49 @@ int DEBUG_RegisterStabsDebugInfo(DBG_MODULE* module, void* _nth, unsigned long n
|
||||||
|
|
||||||
for (i = 0; i < nth->FileHeader.NumberOfSections; i++, pe_seg_ofs += sizeof(pe_seg)) {
|
for (i = 0; i < nth->FileHeader.NumberOfSections; i++, pe_seg_ofs += sizeof(pe_seg)) {
|
||||||
if (!DEBUG_READ_MEM_VERBOSE((void*)((char *)module->load_addr + pe_seg_ofs),
|
if (!DEBUG_READ_MEM_VERBOSE((void*)((char *)module->load_addr + pe_seg_ofs),
|
||||||
&pe_seg, sizeof(pe_seg)) ||
|
&pe_seg, sizeof(pe_seg)))
|
||||||
!DEBUG_READ_MEM_VERBOSE((void*)pe_seg.Name, bufstr, sizeof(bufstr)))
|
continue;
|
||||||
{fprintf(stderr, "err3\n");continue;}
|
|
||||||
bufstr[sizeof(bufstr) - 1] = 0;
|
|
||||||
|
|
||||||
if (!strcasecmp(bufstr, ".stab")) {
|
if (!strcasecmp(pe_seg.Name, ".stab")) {
|
||||||
stabs = pe_seg.VirtualAddress;
|
stabs = pe_seg.VirtualAddress;
|
||||||
stabsize = pe_seg.SizeOfRawData;
|
stabsize = pe_seg.SizeOfRawData;
|
||||||
} else if (!strncasecmp(bufstr, ".stabstr", 8)) {
|
} else if (!strncasecmp(pe_seg.Name, ".stabstr", 8)) {
|
||||||
stabstr = pe_seg.VirtualAddress;
|
stabstr = pe_seg.VirtualAddress;
|
||||||
stabstrsize = pe_seg.SizeOfRawData;
|
stabstrsize = pe_seg.SizeOfRawData;
|
||||||
|
} else if (!strncasecmp(pe_seg.Name, ".xcnlnk", 7)) {
|
||||||
|
xcnlnk = pe_seg.VirtualAddress;
|
||||||
|
xcnlnksize = pe_seg.SizeOfRawData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stabstrsize && stabsize) {
|
if (stabstrsize && stabsize) {
|
||||||
#ifdef _WE_SUPPORT_THE_STAB_TYPES_USED_BY_MINGW_TOO
|
char* s1 = DBG_alloc(stabsize+stabstrsize);
|
||||||
/* Won't work currently, since MINGW32 uses some special typedefs
|
|
||||||
* which we do not handle yet. Support for them is a bit difficult.
|
if (s1) {
|
||||||
*/
|
if (DEBUG_READ_MEM_VERBOSE((char*)module->load_addr + stabs, s1, stabsize) &&
|
||||||
/* FIXME: load_addr is in a different address space... */
|
DEBUG_READ_MEM_VERBOSE((char*)module->load_addr + stabstr,
|
||||||
DEBUG_ParseStabs(module->load_addr, 0, stabs, stabsize, stabstr, stabstrsize);
|
s1 + stabsize, stabstrsize)) {
|
||||||
#endif
|
DEBUG_ParseStabs(s1, 0, 0, stabsize, stabsize, stabstrsize);
|
||||||
fprintf(stderr,"(stabs not loaded)");
|
} else {
|
||||||
|
DEBUG_Printf(DBG_CHN_MESG, "couldn't read data block\n");
|
||||||
|
}
|
||||||
|
DBG_free(s1);
|
||||||
|
} else {
|
||||||
|
DEBUG_Printf(DBG_CHN_MESG, "couldn't alloc %d bytes\n",
|
||||||
|
stabsize + stabstrsize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (xcnlnksize) {
|
||||||
|
DWORD addr;
|
||||||
|
char bufstr[256];
|
||||||
|
|
||||||
|
if (DEBUG_READ_MEM_VERBOSE((char*)module->load_addr + xcnlnk, &addr,
|
||||||
|
sizeof(addr)) &&
|
||||||
|
DEBUG_READ_MEM_VERBOSE((char*)addr, bufstr, sizeof(bufstr))) {
|
||||||
|
bufstr[sizeof(bufstr) - 1] = 0;
|
||||||
|
DEBUG_Printf(DBG_CHN_TRACE, "Got xcnlnk: argv0 '%s'\n", bufstr);
|
||||||
|
DEBUG_ReadExecutableDbgInfo(bufstr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1504,9 +1543,7 @@ DEBUG_ProcessCoff(DBG_MODULE* module)
|
||||||
curr_file->linecnt = 0;
|
curr_file->linecnt = 0;
|
||||||
curr_file->entries = NULL;
|
curr_file->entries = NULL;
|
||||||
curr_file->neps = curr_file->neps_alloc = 0;
|
curr_file->neps = curr_file->neps_alloc = 0;
|
||||||
#if 0
|
DEBUG_Printf(DBG_CHN_TRACE,"New file %s\n", curr_file->filename);
|
||||||
fprintf(stderr,"New file %s\n", curr_file->filename);
|
|
||||||
#endif
|
|
||||||
i += naux;
|
i += naux;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1527,14 +1564,14 @@ DEBUG_ProcessCoff(DBG_MODULE* module)
|
||||||
if( curr_file->linetab_offset != -1 )
|
if( curr_file->linetab_offset != -1 )
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "Duplicating sect from %s: %x %x %x %d %d\n",
|
DEBUG_Printf(DBG_CHN_TRACE, "Duplicating sect from %s: %x %x %x %d %d\n",
|
||||||
curr_file->filename,
|
curr_file->filename,
|
||||||
aux->Length,
|
aux->Length,
|
||||||
aux->NumberOfRelocations,
|
aux->NumberOfRelocations,
|
||||||
aux->NumberOfLinenumbers,
|
aux->NumberOfLinenumbers,
|
||||||
aux->Number,
|
aux->Number,
|
||||||
aux->Selection);
|
aux->Selection);
|
||||||
fprintf(stderr, "More sect %d %x %d %d %d\n",
|
DEBUG_Printf(DBG_CHN_TRACE, "More sect %d %x %d %d %d\n",
|
||||||
coff_sym->SectionNumber,
|
coff_sym->SectionNumber,
|
||||||
coff_sym->Value,
|
coff_sym->Value,
|
||||||
coff_sym->Type,
|
coff_sym->Type,
|
||||||
|
@ -1570,7 +1607,7 @@ DEBUG_ProcessCoff(DBG_MODULE* module)
|
||||||
#if 0
|
#if 0
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "New text sect from %s: %x %x %x %d %d\n",
|
DEBUG_Printf(DBG_CHN_TRACE, "New text sect from %s: %x %x %x %d %d\n",
|
||||||
curr_file->filename,
|
curr_file->filename,
|
||||||
aux->Length,
|
aux->Length,
|
||||||
aux->NumberOfRelocations,
|
aux->NumberOfRelocations,
|
||||||
|
@ -1638,7 +1675,7 @@ DEBUG_ProcessCoff(DBG_MODULE* module)
|
||||||
curr_file->neps_alloc * sizeof(struct name_hash *));
|
curr_file->neps_alloc * sizeof(struct name_hash *));
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr,"\tAdding static symbol %s\n", nampnt);
|
DEBUG_Printf(DBG_CHN_TRACE,"\tAdding static symbol %s\n", nampnt);
|
||||||
#endif
|
#endif
|
||||||
curr_file->entries[curr_file->neps++] =
|
curr_file->entries[curr_file->neps++] =
|
||||||
DEBUG_AddSymbol( nampnt, &new_value, this_file, SYM_WIN32 );
|
DEBUG_AddSymbol( nampnt, &new_value, this_file, SYM_WIN32 );
|
||||||
|
@ -1671,9 +1708,9 @@ DEBUG_ProcessCoff(DBG_MODULE* module)
|
||||||
new_value.addr.off = (int) ((char *)module->load_addr + coff_sym->Value);
|
new_value.addr.off = (int) ((char *)module->load_addr + coff_sym->Value);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "%d: %x %s\n", i, new_value.addr.off, nampnt);
|
DEBUG_Printf(DBG_CHN_TRACE, "%d: %x %s\n", i, new_value.addr.off, nampnt);
|
||||||
|
|
||||||
fprintf(stderr,"\tAdding global symbol %s\n", nampnt);
|
DEBUG_Printf(DBG_CHN_TRACE,"\tAdding global symbol %s\n", nampnt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1730,9 +1767,9 @@ DEBUG_ProcessCoff(DBG_MODULE* module)
|
||||||
new_value.addr.off = (int) ((char *)module->load_addr + coff_sym->Value);
|
new_value.addr.off = (int) ((char *)module->load_addr + coff_sym->Value);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "%d: %x %s\n", i, new_value.addr.off, nampnt);
|
DEBUG_Printf(DBG_CHN_TRACE, "%d: %x %s\n", i, new_value.addr.off, nampnt);
|
||||||
|
|
||||||
fprintf(stderr,"\tAdding global data symbol %s\n", nampnt);
|
DEBUG_Printf(DBG_CHN_TRACE,"\tAdding global data symbol %s\n", nampnt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1755,7 +1792,7 @@ DEBUG_ProcessCoff(DBG_MODULE* module)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr,"Skipping unknown entry %d %d %d\n", coff_sym->StorageClass,
|
DEBUG_Printf(DBG_CHN_TRACE,"Skipping unknown entry %d %d %d\n", coff_sym->StorageClass,
|
||||||
coff_sym->SectionNumber, naux);
|
coff_sym->SectionNumber, naux);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2547,12 +2584,10 @@ static void pdb_convert_symbols_header( PDB_SYMBOLS *symbols,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DEBUG_ProcessPDBFile( DBG_MODULE* module, char *full_filename )
|
static int DEBUG_ProcessPDBFile( DBG_MODULE* module, const char *full_filename )
|
||||||
{
|
{
|
||||||
char filename[MAX_PATHNAME_LEN];
|
HANDLE hFile, hMap;
|
||||||
struct stat statbuf;
|
char *image = NULL;
|
||||||
int fd = -1;
|
|
||||||
char *image = (char *) 0xffffffff;
|
|
||||||
PDB_HEADER *pdb = NULL;
|
PDB_HEADER *pdb = NULL;
|
||||||
PDB_TOC *toc = NULL;
|
PDB_TOC *toc = NULL;
|
||||||
PDB_ROOT *root = NULL;
|
PDB_ROOT *root = NULL;
|
||||||
|
@ -2565,28 +2600,10 @@ static int DEBUG_ProcessPDBFile( DBG_MODULE* module, char *full_filename )
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open and mmap() .PDB file
|
* Open and map() .PDB file
|
||||||
*/
|
*/
|
||||||
|
if ((image = DEBUG_MapDebugInfoFile(full_filename, 0, 0, &hFile, &hMap)) == NULL) {
|
||||||
LocateDebugInfoFile( full_filename, filename );
|
DEBUG_Printf( DBG_CHN_ERR, "-Unable to peruse .PDB file %s\n", full_filename );
|
||||||
|
|
||||||
if ( stat( filename, &statbuf ) == -1 )
|
|
||||||
{
|
|
||||||
fprintf( stderr, "-Unable to open .PDB file %s\n", filename );
|
|
||||||
goto leave;
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = open(filename, O_RDONLY);
|
|
||||||
if ( fd == -1 )
|
|
||||||
{
|
|
||||||
fprintf( stderr, "-Unable to open .PDB file %s\n", filename );
|
|
||||||
goto leave;
|
|
||||||
}
|
|
||||||
|
|
||||||
image = mmap( 0, statbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0 );
|
|
||||||
if ( image == (char *) 0xffffffff )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "-Unable to mmap .PDB file %s\n", filename);
|
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2615,7 +2632,7 @@ static int DEBUG_ProcessPDBFile( DBG_MODULE* module, char *full_filename )
|
||||||
case 19970604: /* VC 6.0 */
|
case 19970604: /* VC 6.0 */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf( stderr, "-Unknown root block version %ld\n", root->version );
|
DEBUG_Printf( DBG_CHN_ERR, "-Unknown root block version %ld\n", root->version );
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( types.version )
|
switch ( types.version )
|
||||||
|
@ -2625,7 +2642,7 @@ static int DEBUG_ProcessPDBFile( DBG_MODULE* module, char *full_filename )
|
||||||
case 19961031: /* VC 5.0 / 6.0 */
|
case 19961031: /* VC 5.0 / 6.0 */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf( stderr, "-Unknown type info version %ld\n", types.version );
|
DEBUG_Printf( DBG_CHN_ERR, "-Unknown type info version %ld\n", types.version );
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( symbols.version )
|
switch ( symbols.version )
|
||||||
|
@ -2635,7 +2652,7 @@ static int DEBUG_ProcessPDBFile( DBG_MODULE* module, char *full_filename )
|
||||||
case 19970606: /* VC 6.0 */
|
case 19970606: /* VC 6.0 */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf( stderr, "-Unknown symbol info version %ld\n", symbols.version );
|
DEBUG_Printf( DBG_CHN_ERR, "-Unknown symbol info version %ld\n", symbols.version );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2646,7 +2663,7 @@ static int DEBUG_ProcessPDBFile( DBG_MODULE* module, char *full_filename )
|
||||||
if ( root->TimeDateStamp
|
if ( root->TimeDateStamp
|
||||||
!= ((struct CodeViewDebug *)MSC_INFO(module)->dbg_info)->cv_timestamp )
|
!= ((struct CodeViewDebug *)MSC_INFO(module)->dbg_info)->cv_timestamp )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "-Wrong time stamp of .PDB file %s\n", filename);
|
DEBUG_Printf(DBG_CHN_ERR, "-Wrong time stamp of .PDB file %s\n", full_filename);
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2663,7 +2680,7 @@ static int DEBUG_ProcessPDBFile( DBG_MODULE* module, char *full_filename )
|
||||||
if ( symbols.pdbimport_size )
|
if ( symbols.pdbimport_size )
|
||||||
{
|
{
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
fprintf(stderr, "-Type server .PDB imports ignored!\n" );
|
DEBUG_Printf(DBG_CHN_ERR, "-Type server .PDB imports ignored!\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2738,8 +2755,7 @@ static int DEBUG_ProcessPDBFile( DBG_MODULE* module, char *full_filename )
|
||||||
if ( root ) pdb_free( root );
|
if ( root ) pdb_free( root );
|
||||||
if ( toc ) pdb_free( toc );
|
if ( toc ) pdb_free( toc );
|
||||||
|
|
||||||
if ( image != (char *) 0xffffffff ) munmap( image, statbuf.st_size );
|
DEBUG_UnmapDebugInfoFile(hFile, hMap, image);
|
||||||
if ( fd != -1 ) close( fd );
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -2750,52 +2766,24 @@ static int DEBUG_ProcessPDBFile( DBG_MODULE* module, char *full_filename )
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
DEBUG_ProcessDBGFile(DBG_MODULE* module, char * filename)
|
DEBUG_ProcessDBGFile(DBG_MODULE* module, const char* filename)
|
||||||
{
|
{
|
||||||
char * addr = (char *) 0xffffffff;
|
HANDLE hFile, hMap;
|
||||||
|
char * addr;
|
||||||
char * codeview;
|
char * codeview;
|
||||||
struct CV4_DirHead * codeview_dir;
|
struct CV4_DirHead * codeview_dir;
|
||||||
struct CV4_DirEnt * codeview_dent;
|
struct CV4_DirEnt * codeview_dent;
|
||||||
PIMAGE_DEBUG_DIRECTORY dbghdr;
|
PIMAGE_DEBUG_DIRECTORY dbghdr;
|
||||||
DBG_MODULE module2;
|
DBG_MODULE module2;
|
||||||
int fd = -1;
|
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
struct codeview_linetab_hdr * linetab;
|
struct codeview_linetab_hdr * linetab;
|
||||||
int nsect;
|
int nsect;
|
||||||
PIMAGE_SEPARATE_DEBUG_HEADER pdbg = NULL;
|
PIMAGE_SEPARATE_DEBUG_HEADER pdbg = NULL;
|
||||||
IMAGE_SECTION_HEADER * sectp;
|
IMAGE_SECTION_HEADER * sectp;
|
||||||
struct stat statbuf;
|
|
||||||
int status;
|
|
||||||
char dbg_file[MAX_PATHNAME_LEN];
|
|
||||||
|
|
||||||
LocateDebugInfoFile(filename, dbg_file);
|
if ((addr = DEBUG_MapDebugInfoFile(filename, 0, 0, &hFile, &hMap)) == NULL) {
|
||||||
status = stat(dbg_file, &statbuf);
|
DEBUG_Printf(DBG_CHN_ERR, "-Unable to peruse .DBG file %s\n", filename);
|
||||||
if( status == -1 )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "-Unable to open .DBG file %s\n", dbg_file);
|
|
||||||
goto leave;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now open the file, so that we can mmap() it.
|
|
||||||
*/
|
|
||||||
fd = open(dbg_file, O_RDONLY);
|
|
||||||
if( fd == -1 )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Unable to open .DBG file %s\n", dbg_file);
|
|
||||||
goto leave;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now mmap() the file.
|
|
||||||
*/
|
|
||||||
addr = mmap(0, statbuf.st_size, PROT_READ,
|
|
||||||
MAP_PRIVATE, fd, 0);
|
|
||||||
if( addr == (char *) 0xffffffff )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Unable to mmap .DBG file %s\n", dbg_file);
|
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2803,8 +2791,8 @@ DEBUG_ProcessDBGFile(DBG_MODULE* module, char * filename)
|
||||||
|
|
||||||
if( pdbg->TimeDateStamp != MSC_INFO(module)->dbgdir.TimeDateStamp )
|
if( pdbg->TimeDateStamp != MSC_INFO(module)->dbgdir.TimeDateStamp )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Warning - %s has incorrect internal timestamp\n",
|
DEBUG_Printf(DBG_CHN_ERR, "Warning - %s has incorrect internal timestamp\n",
|
||||||
dbg_file);
|
filename);
|
||||||
/* goto leave; */
|
/* goto leave; */
|
||||||
/*
|
/*
|
||||||
Well, sometimes this happens to DBG files which ARE REALLY the right .DBG
|
Well, sometimes this happens to DBG files which ARE REALLY the right .DBG
|
||||||
|
@ -2813,7 +2801,7 @@ DEBUG_ProcessDBGFile(DBG_MODULE* module, char * filename)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Processing symbols from %s...\n", dbg_file);
|
DEBUG_Printf(DBG_CHN_MESG, "Processing symbols from %s...\n", filename);
|
||||||
|
|
||||||
dbghdr = (PIMAGE_DEBUG_DIRECTORY) ( addr + sizeof(*pdbg)
|
dbghdr = (PIMAGE_DEBUG_DIRECTORY) ( addr + sizeof(*pdbg)
|
||||||
+ pdbg->NumberOfSections * sizeof(IMAGE_SECTION_HEADER)
|
+ pdbg->NumberOfSections * sizeof(IMAGE_SECTION_HEADER)
|
||||||
|
@ -2918,20 +2906,12 @@ DEBUG_ProcessDBGFile(DBG_MODULE* module, char * filename)
|
||||||
}
|
}
|
||||||
leave:
|
leave:
|
||||||
|
|
||||||
if( addr != (char *) 0xffffffff )
|
DEBUG_UnmapDebugInfoFile(hFile, hMap, addr);
|
||||||
{
|
|
||||||
munmap(addr, statbuf.st_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( fd != -1 )
|
|
||||||
{
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
DEBUG_ProcessMSCDebugInfo(DBG_MODULE* module)
|
DEBUG_ProcessMSCDebugInfo(DBG_MODULE* module)
|
||||||
{
|
{
|
||||||
struct CodeViewDebug * cvd;
|
struct CodeViewDebug * cvd;
|
||||||
|
@ -2946,9 +2926,7 @@ DEBUG_ProcessMSCDebugInfo(DBG_MODULE* module)
|
||||||
* Standard COFF debug information that VC++ adds when you
|
* Standard COFF debug information that VC++ adds when you
|
||||||
* use /debugtype:both with the linker.
|
* use /debugtype:both with the linker.
|
||||||
*/
|
*/
|
||||||
#if 0
|
DEBUG_Printf(DBG_CHN_TRACE, "Processing COFF symbols...\n");
|
||||||
fprintf(stderr, "Processing COFF symbols...\n");
|
|
||||||
#endif
|
|
||||||
sts = DEBUG_ProcessCoff(module);
|
sts = DEBUG_ProcessCoff(module);
|
||||||
break;
|
break;
|
||||||
case IMAGE_DEBUG_TYPE_CODEVIEW:
|
case IMAGE_DEBUG_TYPE_CODEVIEW:
|
||||||
|
@ -2967,9 +2945,7 @@ DEBUG_ProcessMSCDebugInfo(DBG_MODULE* module)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sts = DEBUG_ProcessPDBFile(module, cvd->cv_name);
|
sts = DEBUG_ProcessPDBFile(module, cvd->cv_name);
|
||||||
#if 0
|
DEBUG_Printf(DBG_CHN_TRACE, "Processing PDB file %s\n", cvd->cv_name);
|
||||||
fprintf(stderr, "Processing PDB file %s\n", cvd->cv_name);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case IMAGE_DEBUG_TYPE_MISC:
|
case IMAGE_DEBUG_TYPE_MISC:
|
||||||
/*
|
/*
|
||||||
|
@ -3007,6 +2983,7 @@ DEBUG_ProcessMSCDebugInfo(DBG_MODULE* module)
|
||||||
sts = FALSE;
|
sts = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
module->status = (sts) ? DM_STATUS_LOADED : DM_STATUS_ERROR;
|
||||||
return sts;
|
return sts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ int DEBUG_PrintRegister(enum debug_regs reg)
|
||||||
case REG_FS: val = "%%fs"; break;
|
case REG_FS: val = "%%fs"; break;
|
||||||
case REG_GS: val = "%%gs"; break;
|
case REG_GS: val = "%%gs"; break;
|
||||||
}
|
}
|
||||||
if (val) fprintf(stderr, val);
|
if (val) DEBUG_Printf(DBG_CHN_MESG, val);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#else
|
#else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -195,11 +195,11 @@ char *DEBUG_Flags( DWORD flag, char *buf )
|
||||||
*/
|
*/
|
||||||
void DEBUG_InfoRegisters(void)
|
void DEBUG_InfoRegisters(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Register dump:\n");
|
DEBUG_Printf(DBG_CHN_MESG,"Register dump:\n");
|
||||||
|
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
/* First get the segment registers out of the way */
|
/* 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.SegCs, (WORD)DEBUG_context.SegSs,
|
||||||
(WORD)DEBUG_context.SegDs, (WORD)DEBUG_context.SegEs,
|
(WORD)DEBUG_context.SegDs, (WORD)DEBUG_context.SegEs,
|
||||||
(WORD)DEBUG_context.SegFs, (WORD)DEBUG_context.SegGs );
|
(WORD)DEBUG_context.SegFs, (WORD)DEBUG_context.SegGs );
|
||||||
|
@ -207,11 +207,11 @@ void DEBUG_InfoRegisters(void)
|
||||||
{
|
{
|
||||||
char flag[33];
|
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.Eip), LOWORD(DEBUG_context.Esp),
|
||||||
LOWORD(DEBUG_context.Ebp), LOWORD(DEBUG_context.EFlags),
|
LOWORD(DEBUG_context.Ebp), LOWORD(DEBUG_context.EFlags),
|
||||||
DEBUG_Flags(LOWORD(DEBUG_context.EFlags), flag));
|
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.Eax), LOWORD(DEBUG_context.Ebx),
|
||||||
LOWORD(DEBUG_context.Ecx), LOWORD(DEBUG_context.Edx),
|
LOWORD(DEBUG_context.Ecx), LOWORD(DEBUG_context.Edx),
|
||||||
LOWORD(DEBUG_context.Esi), LOWORD(DEBUG_context.Edi) );
|
LOWORD(DEBUG_context.Esi), LOWORD(DEBUG_context.Edi) );
|
||||||
|
@ -220,14 +220,14 @@ void DEBUG_InfoRegisters(void)
|
||||||
{
|
{
|
||||||
char flag[33];
|
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.Eip, DEBUG_context.Esp,
|
||||||
DEBUG_context.Ebp, DEBUG_context.EFlags,
|
DEBUG_context.Ebp, DEBUG_context.EFlags,
|
||||||
DEBUG_Flags(DEBUG_context.EFlags, flag));
|
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.Eax, DEBUG_context.Ebx,
|
||||||
DEBUG_context.Ecx, DEBUG_context.Edx );
|
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 );
|
DEBUG_context.Esi, DEBUG_context.Edi );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -249,7 +249,7 @@ BOOL DEBUG_ValidateRegisters(void)
|
||||||
/* Check that a selector is a valid ring-3 LDT selector, or a NULL selector */
|
/* Check that a selector is a valid ring-3 LDT selector, or a NULL selector */
|
||||||
#define CHECK_SEG(seg,name) \
|
#define CHECK_SEG(seg,name) \
|
||||||
if (((seg) & ~3) && ((((seg) & 7) != 7) || !DEBUG_IsSelector(seg))) { \
|
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) ); \
|
(name), (WORD)(seg) ); \
|
||||||
return FALSE; \
|
return FALSE; \
|
||||||
}
|
}
|
||||||
|
@ -268,13 +268,13 @@ BOOL DEBUG_ValidateRegisters(void)
|
||||||
|
|
||||||
if (!(DEBUG_context.SegCs & ~3))
|
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 );
|
(WORD)DEBUG_context.SegCs );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!(DEBUG_context.SegSs & ~3))
|
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 );
|
(WORD)DEBUG_context.SegSs );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,12 +53,12 @@ DEBUG_ShowDir(void)
|
||||||
{
|
{
|
||||||
struct searchlist * sl;
|
struct searchlist * sl;
|
||||||
|
|
||||||
fprintf(stderr,"Search list :\n");
|
DEBUG_Printf(DBG_CHN_MESG,"Search list :\n");
|
||||||
for(sl = listhead; sl; sl = sl->next)
|
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
|
void
|
||||||
|
@ -186,7 +186,7 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
|
||||||
/*
|
/*
|
||||||
* Still couldn't find it. Ask user for path to add.
|
* 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);
|
fgets(tmppath, sizeof(tmppath), stdin);
|
||||||
|
|
||||||
if( tmppath[strlen(tmppath)-1] == '\n' )
|
if( tmppath[strlen(tmppath)-1] == '\n' )
|
||||||
|
@ -217,7 +217,7 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
|
||||||
ol->nlines = 0;
|
ol->nlines = 0;
|
||||||
ol->linelist = NULL;
|
ol->linelist = NULL;
|
||||||
ofiles = ol;
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,7 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
|
||||||
memcpy(&buffer, addr + ol->linelist[i],
|
memcpy(&buffer, addr + ol->linelist[i],
|
||||||
(ol->linelist[i+1] - ol->linelist[i]) - 1);
|
(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);
|
munmap(addr, ol->size);
|
||||||
|
@ -343,7 +343,7 @@ DEBUG_List(struct list_id * source1, struct list_id * source2,
|
||||||
&& source2->sourcefile != NULL
|
&& source2->sourcefile != NULL
|
||||||
&& strcmp(source1->sourcefile, source2->sourcefile) != 0 )
|
&& strcmp(source1->sourcefile, source2->sourcefile) != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Ambiguous source file specification.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Ambiguous source file specification.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ DEBUG_List(struct list_id * source1, struct list_id * source2,
|
||||||
|
|
||||||
if( sourcefile == NULL )
|
if( sourcefile == NULL )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No source file specified.\n");
|
DEBUG_Printf(DBG_CHN_MESG, "No source file specified.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,10 +430,10 @@ _disassemble(DBG_ADDR *addr)
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
DEBUG_PrintAddress( addr, DEBUG_CurrThread->dbg_mode, TRUE );
|
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;
|
if (!DEBUG_READ_MEM_VERBOSE((void*)DEBUG_ToLinear(addr), &ch, sizeof(ch))) return 0;
|
||||||
DEBUG_Disasm( addr, TRUE );
|
DEBUG_Disasm( addr, TRUE );
|
||||||
fprintf(stderr,"\n");
|
DEBUG_Printf(DBG_CHN_MESG,"\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ _disassemble_fixaddr(DBG_VALUE *value) {
|
||||||
}
|
}
|
||||||
else if (!value->addr.seg && !value->addr.off)
|
else if (!value->addr.seg && !value->addr.off)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Invalid expression\n");
|
DEBUG_Printf(DBG_CHN_MESG,"Invalid expression\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
222
debugger/stabs.c
222
debugger/stabs.c
|
@ -4,6 +4,7 @@
|
||||||
* File stabs.c - read stabs information from the wine executable itself.
|
* File stabs.c - read stabs information from the wine executable itself.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1996, Eric Youngdale.
|
* Copyright (C) 1996, Eric Youngdale.
|
||||||
|
* 1999, 2000 Eric Pouech
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -23,7 +24,6 @@
|
||||||
#define PATH_MAX _MAX_PATH
|
#define PATH_MAX _MAX_PATH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "options.h"
|
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
|
|
||||||
#if defined(__svr4__) || defined(__sun)
|
#if defined(__svr4__) || defined(__sun)
|
||||||
|
@ -240,7 +240,7 @@ DEBUG_FileSubNr2StabEnum(int filenr, int subnr)
|
||||||
{
|
{
|
||||||
struct datatype** ret;
|
struct datatype** ret;
|
||||||
|
|
||||||
/* fprintf(stderr, "creating type id for (%d,%d)\n", filenr, subnr); */
|
/* DEBUG_Printf(DBG_CHN_MESG, "creating type id for (%d,%d)\n", filenr, subnr); */
|
||||||
|
|
||||||
/* FIXME: I could perhaps create a dummy include_def for each compilation
|
/* FIXME: I could perhaps create a dummy include_def for each compilation
|
||||||
* unit which would allow not to handle those two cases separately
|
* unit which would allow not to handle those two cases separately
|
||||||
|
@ -271,7 +271,7 @@ DEBUG_FileSubNr2StabEnum(int filenr, int subnr)
|
||||||
}
|
}
|
||||||
ret = &idef->vector[subnr];
|
ret = &idef->vector[subnr];
|
||||||
}
|
}
|
||||||
/* fprintf(stderr,"(%d,%d) is %d\n",filenr,subnr,ret); */
|
/* DEBUG_Printf(DBG_CHN_MESG,"(%d,%d) is %d\n",filenr,subnr,ret); */
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ DEBUG_HandlePreviousTypedef(const char * name, const char * stab)
|
||||||
expect = DT_FUNC;
|
expect = DT_FUNC;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown type (%c).\n",ptr[1]);
|
DEBUG_Printf(DBG_CHN_MESG, "Unknown type (%c).\n",ptr[1]);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if( expect != -1 && expect != DEBUG_GetType(ktd->types[count]) )
|
if( expect != -1 && expect != DEBUG_GetType(ktd->types[count]) )
|
||||||
|
@ -491,7 +491,7 @@ DEBUG_ParseTypedefStab(char * ptr, const char * typename)
|
||||||
/*
|
/*
|
||||||
* If this ever happens, just bump the counter.
|
* If this ever happens, just bump the counter.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "Typedef nesting overflow\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Typedef nesting overflow\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,7 +535,7 @@ DEBUG_ParseTypedefStab(char * ptr, const char * typename)
|
||||||
curr_types[ntypes++] = *dt;
|
curr_types[ntypes++] = *dt;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown type (%c).\n",c[1]);
|
DEBUG_Printf(DBG_CHN_MESG, "Unknown type (%c).\n",c[1]);
|
||||||
}
|
}
|
||||||
typename = NULL;
|
typename = NULL;
|
||||||
|
|
||||||
|
@ -594,7 +594,7 @@ DEBUG_ParseTypedefStab(char * ptr, const char * typename)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unknown condition %p %p (%s)\n", *dt, *dt2, ptr);
|
DEBUG_Printf(DBG_CHN_MESG, "Unknown condition %p %p (%s)\n", *dt, *dt2, ptr);
|
||||||
}
|
}
|
||||||
if( *tc == '\0' )
|
if( *tc == '\0' )
|
||||||
*c = '\0';
|
*c = '\0';
|
||||||
|
@ -679,7 +679,7 @@ DEBUG_ParseTypedefStab(char * ptr, const char * typename)
|
||||||
{
|
{
|
||||||
failure = 1;
|
failure = 1;
|
||||||
/* ... but proceed parsing to the end of the stab */
|
/* ... but proceed parsing to the end of the stab */
|
||||||
fprintf(stderr, "failure on %s %s\n", ptr, ti);
|
DEBUG_Printf(DBG_CHN_MESG, "failure on %s %s\n", ptr, ti);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,7 +723,7 @@ DEBUG_ParseTypedefStab(char * ptr, const char * typename)
|
||||||
strcpy(c, tc + 1);
|
strcpy(c, tc + 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown type (%c).\n",c[1]);
|
DEBUG_Printf(DBG_CHN_MESG, "Unknown type (%c).\n",c[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -852,7 +852,7 @@ DEBUG_ParseStabs(char * addr, unsigned int load_offset,
|
||||||
* ignore them, and when we process the normal symbol table
|
* ignore them, and when we process the normal symbol table
|
||||||
* we should do the right thing.
|
* we should do the right thing.
|
||||||
*
|
*
|
||||||
* With a.out, they actually do make some amount of sense.
|
* With a.out or mingw, they actually do make some amount of sense.
|
||||||
*/
|
*/
|
||||||
new_value.addr.seg = 0;
|
new_value.addr.seg = 0;
|
||||||
new_value.type = DEBUG_ParseStabType(ptr);
|
new_value.type = DEBUG_ParseStabType(ptr);
|
||||||
|
@ -862,7 +862,7 @@ DEBUG_ParseStabs(char * addr, unsigned int load_offset,
|
||||||
stab_strcpy(symname, ptr);
|
stab_strcpy(symname, ptr);
|
||||||
#ifdef __ELF__
|
#ifdef __ELF__
|
||||||
curr_sym = DEBUG_AddSymbol( symname, &new_value, currpath,
|
curr_sym = DEBUG_AddSymbol( symname, &new_value, currpath,
|
||||||
SYM_WINE | SYM_DATA | SYM_INVALID);
|
SYM_WINE | SYM_DATA | SYM_INVALID );
|
||||||
#else
|
#else
|
||||||
curr_sym = DEBUG_AddSymbol( symname, &new_value, currpath,
|
curr_sym = DEBUG_AddSymbol( symname, &new_value, currpath,
|
||||||
SYM_WINE | SYM_DATA );
|
SYM_WINE | SYM_DATA );
|
||||||
|
@ -956,7 +956,10 @@ DEBUG_ParseStabs(char * addr, unsigned int load_offset,
|
||||||
* on, we will add the line number information and the
|
* on, we will add the line number information and the
|
||||||
* local symbols.
|
* local symbols.
|
||||||
*/
|
*/
|
||||||
if( !in_external_file )
|
if( !in_external_file)
|
||||||
|
{
|
||||||
|
stab_strcpy(symname, ptr);
|
||||||
|
if (*symname)
|
||||||
{
|
{
|
||||||
new_value.addr.seg = 0;
|
new_value.addr.seg = 0;
|
||||||
new_value.type = DEBUG_ParseStabType(ptr);
|
new_value.type = DEBUG_ParseStabType(ptr);
|
||||||
|
@ -969,10 +972,15 @@ DEBUG_ParseStabs(char * addr, unsigned int load_offset,
|
||||||
* all of the pages related to the stabs, and that
|
* all of the pages related to the stabs, and that
|
||||||
* sucks up swap space like crazy.
|
* sucks up swap space like crazy.
|
||||||
*/
|
*/
|
||||||
stab_strcpy(symname, ptr);
|
|
||||||
curr_func = DEBUG_AddSymbol( symname, &new_value, currpath,
|
curr_func = DEBUG_AddSymbol( symname, &new_value, currpath,
|
||||||
SYM_WINE | SYM_FUNC);
|
SYM_WINE | SYM_FUNC);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* some GCC seem to use a N_FUN "" to mark the end of a function */
|
||||||
|
curr_func = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -1054,14 +1062,14 @@ DEBUG_ParseStabs(char * addr, unsigned int load_offset,
|
||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unkown stab type 0x%02x\n", stab_ptr->n_type);
|
DEBUG_Printf(DBG_CHN_MESG, "Unkown stab type 0x%02x\n", stab_ptr->n_type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
stabbuff[0] = '\0';
|
stabbuff[0] = '\0';
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "%d %x %s\n", stab_ptr->n_type,
|
DEBUG_Printf(DBG_CHN_MESG, "%d %x %s\n", stab_ptr->n_type,
|
||||||
(unsigned int) stab_ptr->n_value,
|
(unsigned int) stab_ptr->n_value,
|
||||||
strs + (unsigned int) stab_ptr->n_un.n_name);
|
strs + (unsigned int) stab_ptr->n_un.n_name);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1110,7 +1118,8 @@ DEBUG_ProcessElfSymtab(char * addr, unsigned int load_offset,
|
||||||
* Ignore certain types of entries which really aren't of that much
|
* Ignore certain types of entries which really aren't of that much
|
||||||
* interest.
|
* interest.
|
||||||
*/
|
*/
|
||||||
if( ELF32_ST_TYPE(symp->st_info) == STT_SECTION )
|
if( ELF32_ST_TYPE(symp->st_info) == STT_SECTION ||
|
||||||
|
symp->st_shndx == STN_UNDEF )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1160,15 +1169,13 @@ DEBUG_ProcessElfSymtab(char * addr, unsigned int load_offset,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
int
|
int
|
||||||
DEBUG_ProcessElfObject(const char * filename, unsigned int load_offset)
|
DEBUG_ProcessElfObject(const char * filename, unsigned int load_offset)
|
||||||
{
|
{
|
||||||
int rtn = FALSE;
|
int rtn = FALSE;
|
||||||
struct stat statbuf;
|
char * addr = (char*)0xffffffff;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
int status;
|
struct stat statbuf;
|
||||||
char * addr = (char *) 0xffffffff;
|
|
||||||
Elf32_Ehdr * ehptr;
|
Elf32_Ehdr * ehptr;
|
||||||
Elf32_Shdr * spnt;
|
Elf32_Shdr * spnt;
|
||||||
char * shstrtab;
|
char * shstrtab;
|
||||||
|
@ -1177,15 +1184,13 @@ DEBUG_ProcessElfObject(const char * filename, unsigned int load_offset)
|
||||||
int stabsect;
|
int stabsect;
|
||||||
int stabstrsect;
|
int stabstrsect;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure we can stat and open this file.
|
* Make sure we can stat and open this file.
|
||||||
*/
|
*/
|
||||||
if( filename == NULL )
|
if( filename == NULL )
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
status = stat(filename, &statbuf);
|
if (stat(filename, &statbuf) == -1)
|
||||||
if( status == -1 )
|
|
||||||
{
|
{
|
||||||
char *s,*t,*fn,*paths;
|
char *s,*t,*fn,*paths;
|
||||||
if (strchr(filename,'/'))
|
if (strchr(filename,'/'))
|
||||||
|
@ -1207,25 +1212,28 @@ DEBUG_ProcessElfObject(const char * filename, unsigned int load_offset)
|
||||||
DBG_free(fn);
|
DBG_free(fn);
|
||||||
if (t) s = t+1; else break;
|
if (t) s = t+1; else break;
|
||||||
}
|
}
|
||||||
if (!s || !*s) fprintf(stderr," not found");
|
if (!s || !*s) DEBUG_Printf(DBG_CHN_MESG," not found");
|
||||||
DBG_free(paths);
|
DBG_free(paths);
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DEBUG_FindModuleByName(filename, DM_TYPE_ELF))
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
DEBUG_Printf(DBG_CHN_MESG, "Loading stabs debug symbols from %s (0x%08lx)\n",
|
||||||
|
filename, load_offset);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now open the file, so that we can mmap() it.
|
* Now open the file, so that we can mmap() it.
|
||||||
*/
|
*/
|
||||||
fd = open(filename, O_RDONLY);
|
if ((fd = open(filename, O_RDONLY)) == -1)
|
||||||
if( fd == -1 )
|
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now mmap() the file.
|
* Now mmap() the file.
|
||||||
*/
|
*/
|
||||||
addr = mmap(0, statbuf.st_size, PROT_READ,
|
addr = mmap(0, statbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||||
MAP_PRIVATE, fd, 0);
|
if (addr == (char*)0xffffffff)
|
||||||
if( addr == (char *) 0xffffffff )
|
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1255,20 +1263,22 @@ DEBUG_ProcessElfObject(const char * filename, unsigned int load_offset)
|
||||||
stabstrsect = i;
|
stabstrsect = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( stabsect == -1 || stabstrsect == -1 )
|
if( stabsect == -1 || stabstrsect == -1 ) {
|
||||||
|
DEBUG_Printf(DBG_CHN_WARN, "no .stab section\n");
|
||||||
goto leave;
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* OK, now just parse all of the stabs.
|
* OK, now just parse all of the stabs.
|
||||||
*/
|
*/
|
||||||
rtn = DEBUG_ParseStabs(addr, load_offset,
|
if (!(rtn = DEBUG_ParseStabs(addr, load_offset,
|
||||||
spnt[stabsect].sh_offset,
|
spnt[stabsect].sh_offset,
|
||||||
spnt[stabsect].sh_size,
|
spnt[stabsect].sh_size,
|
||||||
spnt[stabstrsect].sh_offset,
|
spnt[stabstrsect].sh_offset,
|
||||||
spnt[stabstrsect].sh_size);
|
spnt[stabstrsect].sh_size))) {
|
||||||
|
DEBUG_Printf(DBG_CHN_WARN, "bad stabs\n");
|
||||||
if( rtn != TRUE )
|
|
||||||
goto leave;
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
for(i=0; i < nsect; i++)
|
for(i=0; i < nsect; i++)
|
||||||
{
|
{
|
||||||
|
@ -1285,22 +1295,17 @@ DEBUG_ProcessElfObject(const char * filename, unsigned int load_offset)
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
|
|
||||||
if( addr != (char *) 0xffffffff )
|
if (addr != (char*)0xffffffff)
|
||||||
munmap(addr, statbuf.st_size);
|
munmap(addr, statbuf.st_size);
|
||||||
|
|
||||||
if( fd != -1 )
|
if (fd != -1) close(fd);
|
||||||
close(fd);
|
|
||||||
|
|
||||||
return (rtn);
|
|
||||||
|
|
||||||
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
DEBUG_ReadExecutableDbgInfo(void)
|
DEBUG_ReadExecutableDbgInfo(const char* exe_name)
|
||||||
{
|
{
|
||||||
const char * exe_name;
|
|
||||||
DBG_VALUE val;
|
|
||||||
u_long dyn_addr;
|
|
||||||
Elf32_Dyn dyn;
|
Elf32_Dyn dyn;
|
||||||
struct r_debug dbg_hdr;
|
struct r_debug dbg_hdr;
|
||||||
u_long lm_addr;
|
u_long lm_addr;
|
||||||
|
@ -1308,9 +1313,7 @@ DEBUG_ReadExecutableDbgInfo(void)
|
||||||
Elf32_Ehdr ehdr;
|
Elf32_Ehdr ehdr;
|
||||||
char bufstr[256];
|
char bufstr[256];
|
||||||
int rtn = FALSE;
|
int rtn = FALSE;
|
||||||
int rowcount;
|
DBG_VALUE val;
|
||||||
|
|
||||||
exe_name = argv0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure we can stat and open this file.
|
* Make sure we can stat and open this file.
|
||||||
|
@ -1319,19 +1322,20 @@ DEBUG_ReadExecutableDbgInfo(void)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
fprintf( stderr, "Loading symbols: %s", exe_name );
|
fprintf( stderr, "Loading symbols: %s", exe_name );
|
||||||
rowcount = 17 + strlen(exe_name);
|
|
||||||
DEBUG_ProcessElfObject(exe_name, 0);
|
DEBUG_ProcessElfObject(exe_name, 0);
|
||||||
|
|
||||||
|
/* previous step should have loaded symbol _DYNAMIC if it exists inside
|
||||||
|
* the main executable
|
||||||
|
*/
|
||||||
if (!DEBUG_GetSymbolValue("_DYNAMIC", -1, &val, FALSE)) {
|
if (!DEBUG_GetSymbolValue("_DYNAMIC", -1, &val, FALSE)) {
|
||||||
fprintf(stderr, "Can't find symbol _DYNAMIC\n");
|
fprintf(stderr, "Can't find symbol _DYNAMIC\n");
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
dyn_addr = val.addr.off;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!DEBUG_READ_MEM_VERBOSE((void*)dyn_addr, &dyn, sizeof(dyn)))
|
if (!DEBUG_READ_MEM_VERBOSE((void*)val.addr.off, &dyn, sizeof(dyn)))
|
||||||
goto leave;
|
goto leave;
|
||||||
dyn_addr += sizeof(dyn);
|
val.addr.off += sizeof(dyn);
|
||||||
} while (dyn.d_tag != DT_DEBUG && dyn.d_tag != DT_NULL);
|
} while (dyn.d_tag != DT_DEBUG && dyn.d_tag != DT_NULL);
|
||||||
if (dyn.d_tag == DT_NULL) goto leave;
|
if (dyn.d_tag == DT_NULL) goto leave;
|
||||||
|
|
||||||
|
@ -1351,28 +1355,12 @@ DEBUG_ReadExecutableDbgInfo(void)
|
||||||
{
|
{
|
||||||
if (!DEBUG_READ_MEM_VERBOSE((void*)lm_addr, &lm, sizeof(lm)))
|
if (!DEBUG_READ_MEM_VERBOSE((void*)lm_addr, &lm, sizeof(lm)))
|
||||||
goto leave;
|
goto leave;
|
||||||
if (!DEBUG_READ_MEM_VERBOSE((void*)lm.l_addr, &ehdr, sizeof(ehdr)))
|
if (lm.l_addr != 0 &&
|
||||||
continue;
|
DEBUG_READ_MEM_VERBOSE((void*)lm.l_addr, &ehdr, sizeof(ehdr)) &&
|
||||||
/*
|
ehdr.e_type == ET_DYN && /* only look at dynamic modules */
|
||||||
* We already got the stuff for the executable using the
|
lm.l_name != NULL &&
|
||||||
* argv[0] entry above. Here we only need to concentrate on any
|
DEBUG_READ_MEM_VERBOSE(lm.l_name, bufstr, sizeof(bufstr))) {
|
||||||
* shared libraries which may be loaded.
|
|
||||||
*/
|
|
||||||
if( (lm.l_addr == 0) || (ehdr.e_type != ET_DYN) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if( lm.l_name != NULL )
|
|
||||||
{
|
|
||||||
if (!DEBUG_READ_MEM_VERBOSE(lm.l_name, bufstr, sizeof(bufstr)))
|
|
||||||
continue;
|
|
||||||
bufstr[sizeof(bufstr) - 1] = '\0';
|
bufstr[sizeof(bufstr) - 1] = '\0';
|
||||||
if (rowcount + strlen(bufstr) > 76)
|
|
||||||
{
|
|
||||||
fprintf( stderr, "\n " );
|
|
||||||
rowcount = 3;
|
|
||||||
}
|
|
||||||
fprintf( stderr, " %s", bufstr );
|
|
||||||
rowcount += strlen(bufstr) + 1;
|
|
||||||
DEBUG_ProcessElfObject(bufstr, lm.l_addr);
|
DEBUG_ProcessElfObject(bufstr, lm.l_addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1380,95 +1368,21 @@ DEBUG_ReadExecutableDbgInfo(void)
|
||||||
rtn = TRUE;
|
rtn = TRUE;
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
fprintf( stderr, "\n" );
|
return rtn;
|
||||||
return (rtn);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !__ELF__ */
|
#else /* !__ELF__ */
|
||||||
|
|
||||||
#ifdef linux
|
int
|
||||||
/*
|
DEBUG_ProcessElfObject(const char * filename, unsigned int load_offset)
|
||||||
* a.out linux.
|
{
|
||||||
*/
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
DEBUG_ReadExecutableDbgInfo(void)
|
DEBUG_ReadExecutableDbgInfo(void)
|
||||||
{
|
{
|
||||||
char * addr = (char *) 0xffffffff;
|
return FALSE;
|
||||||
char * exe_name;
|
|
||||||
struct exec * ahdr;
|
|
||||||
int fd = -1;
|
|
||||||
int rtn = FALSE;
|
|
||||||
unsigned int staboff;
|
|
||||||
struct stat statbuf;
|
|
||||||
int status;
|
|
||||||
unsigned int stroff;
|
|
||||||
|
|
||||||
exe_name = argv0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure we can stat and open this file.
|
|
||||||
*/
|
|
||||||
if( exe_name == NULL )
|
|
||||||
goto leave;
|
|
||||||
|
|
||||||
status = stat(exe_name, &statbuf);
|
|
||||||
if( status == -1 )
|
|
||||||
goto leave;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now open the file, so that we can mmap() it.
|
|
||||||
*/
|
|
||||||
fd = open(exe_name, O_RDONLY);
|
|
||||||
if( fd == -1 )
|
|
||||||
goto leave;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now mmap() the file.
|
|
||||||
*/
|
|
||||||
addr = mmap(0, statbuf.st_size, PROT_READ,
|
|
||||||
MAP_PRIVATE, fd, 0);
|
|
||||||
if( addr == (char *) 0xffffffff )
|
|
||||||
goto leave;
|
|
||||||
|
|
||||||
ahdr = (struct exec *) addr;
|
|
||||||
|
|
||||||
staboff = N_SYMOFF(*ahdr);
|
|
||||||
stroff = N_STROFF(*ahdr);
|
|
||||||
rtn = DEBUG_ParseStabs(addr, 0,
|
|
||||||
staboff,
|
|
||||||
ahdr->a_syms,
|
|
||||||
stroff,
|
|
||||||
statbuf.st_size - stroff);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Give a nice status message here...
|
|
||||||
*/
|
|
||||||
fprintf( stderr, "Loading symbols: %s", exe_name );
|
|
||||||
|
|
||||||
rtn = TRUE;
|
|
||||||
|
|
||||||
leave:
|
|
||||||
|
|
||||||
if( addr != (char *) 0xffffffff )
|
|
||||||
munmap(addr, statbuf.st_size);
|
|
||||||
|
|
||||||
if( fd != -1 )
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
return (rtn);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* Non-linux, non-ELF platforms.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
DEBUG_ReadExecutableDbgInfo(void)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __ELF__ */
|
#endif /* __ELF__ */
|
||||||
|
|
|
@ -64,7 +64,7 @@ void DEBUG_InfoStack(void)
|
||||||
value.addr.seg = DEBUG_context.SegSs;
|
value.addr.seg = DEBUG_context.SegSs;
|
||||||
value.addr.off = DEBUG_context.Esp;
|
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)) {
|
switch (DEBUG_GetSelectorType(value.addr.seg)) {
|
||||||
case 32: /* 32-bit mode */
|
case 32: /* 32-bit mode */
|
||||||
DEBUG_ExamineMemory( &value, 24, 'x' );
|
DEBUG_ExamineMemory( &value, 24, 'x' );
|
||||||
|
@ -74,9 +74,9 @@ void DEBUG_InfoStack(void)
|
||||||
DEBUG_ExamineMemory( &value, 24, 'w' );
|
DEBUG_ExamineMemory( &value, 24, 'w' );
|
||||||
break;
|
break;
|
||||||
default:
|
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
|
#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,
|
frames = (struct bt_info *)DBG_realloc(frames,
|
||||||
nframe*sizeof(struct bt_info));
|
nframe*sizeof(struct bt_info));
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf(stderr,"%s%d ", (theframe == curr_frame ? "=>" : " "),
|
DEBUG_Printf(DBG_CHN_MESG,"%s%d ", (theframe == curr_frame ? "=>" : " "),
|
||||||
frameno);
|
frameno);
|
||||||
frames[theframe].cs = code->seg;
|
frames[theframe].cs = code->seg;
|
||||||
frames[theframe].eip = code->off;
|
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].ss = stack->seg;
|
||||||
frames[theframe].ebp = stack->off;
|
frames[theframe].ebp = stack->off;
|
||||||
if (noisy) {
|
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 (!p) return FALSE;
|
||||||
|
|
||||||
if (!DEBUG_READ_MEM(p, &frame, sizeof(frame))) {
|
if (!DEBUG_READ_MEM(p, &frame, sizeof(frame))) {
|
||||||
if (noisy) {
|
if (noisy) DEBUG_InvalAddr(addr);
|
||||||
fprintf(stderr,"*** Invalid address ");
|
|
||||||
DEBUG_PrintAddress(addr, DEBUG_CurrThread->dbg_mode, FALSE);
|
|
||||||
fprintf(stderr,"\n");
|
|
||||||
}
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!frame.bp) 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,
|
frames = (struct bt_info *)DBG_realloc(frames,
|
||||||
nframe*sizeof(struct bt_info));
|
nframe*sizeof(struct bt_info));
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf(stderr,"%s%d ", (theframe == curr_frame ? "=>" : " "),
|
DEBUG_Printf(DBG_CHN_MESG,"%s%d ", (theframe == curr_frame ? "=>" : " "),
|
||||||
frameno);
|
frameno);
|
||||||
if (frame.bp & 1) *cs = frame.cs;
|
if (frame.bp & 1) *cs = frame.cs;
|
||||||
else {
|
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].ss = addr->seg = ss;
|
||||||
frames[theframe].ebp = addr->off = frame.bp & ~1;
|
frames[theframe].ebp = addr->off = frame.bp & ~1;
|
||||||
if (noisy) {
|
if (noisy) {
|
||||||
fprintf( stderr, " (bp=%04lx", addr->off );
|
DEBUG_Printf( DBG_CHN_MESG, " (bp=%04lx", addr->off );
|
||||||
if (possible_cs) {
|
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;
|
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 (!p) return FALSE;
|
||||||
|
|
||||||
if (!DEBUG_READ_MEM(p, &frame, sizeof(frame))) {
|
if (!DEBUG_READ_MEM(p, &frame, sizeof(frame))) {
|
||||||
if (noisy) {
|
if (noisy) DEBUG_InvalAddr(addr);
|
||||||
fprintf(stderr,"*** Invalid address ");
|
|
||||||
DEBUG_PrintAddress(addr, DEBUG_CurrThread->dbg_mode, FALSE);
|
|
||||||
fprintf(stderr,"\n");
|
|
||||||
}
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!frame.ip) 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,
|
frames = (struct bt_info *)DBG_realloc(frames,
|
||||||
nframe*sizeof(struct bt_info));
|
nframe*sizeof(struct bt_info));
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf(stderr,"%s%d ", (theframe == curr_frame ? "=>" : " "),
|
DEBUG_Printf(DBG_CHN_MESG,"%s%d ", (theframe == curr_frame ? "=>" : " "),
|
||||||
frameno);
|
frameno);
|
||||||
frames[theframe].cs = addr->seg = *cs;
|
frames[theframe].cs = addr->seg = *cs;
|
||||||
frames[theframe].eip = addr->off = frame.ip;
|
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,
|
DEBUG_FindNearestSymbol( addr, TRUE,
|
||||||
&frames[theframe].frame.sym, frame.bp,
|
&frames[theframe].frame.sym, frame.bp,
|
||||||
&frames[theframe].frame.list);
|
&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].ss = addr->seg = ss;
|
||||||
frames[theframe].ebp = frame.bp;
|
frames[theframe].ebp = frame.bp;
|
||||||
if (addr->off == frame.bp) return FALSE;
|
if (addr->off == frame.bp) return FALSE;
|
||||||
|
@ -226,13 +218,13 @@ void DEBUG_BackTrace(BOOL noisy)
|
||||||
STACK32FRAME frame32;
|
STACK32FRAME frame32;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
if (noisy) fprintf( stderr, "Backtrace:\n" );
|
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "Backtrace:\n" );
|
||||||
|
|
||||||
nframe = 1;
|
nframe = 1;
|
||||||
if (frames) DBG_free( frames );
|
if (frames) DBG_free( frames );
|
||||||
frames = (struct bt_info *) DBG_alloc( sizeof(struct bt_info) );
|
frames = (struct bt_info *) DBG_alloc( sizeof(struct bt_info) );
|
||||||
if (noisy)
|
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(ss)) ss = 0;
|
||||||
if (DEBUG_IsSelectorSystem(cs)) cs = 0;
|
if (DEBUG_IsSelectorSystem(cs)) cs = 0;
|
||||||
|
@ -250,7 +242,7 @@ void DEBUG_BackTrace(BOOL noisy)
|
||||||
&frames[0].frame.list);
|
&frames[0].frame.list);
|
||||||
frames[0].ss = addr.seg = ss;
|
frames[0].ss = addr.seg = ss;
|
||||||
frames[0].ebp = addr.off = DEBUG_context.Ebp;
|
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;
|
is16 = FALSE;
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
|
@ -263,11 +255,11 @@ void DEBUG_BackTrace(BOOL noisy)
|
||||||
&frames[0].frame.list);
|
&frames[0].frame.list);
|
||||||
frames[0].ss = addr.seg = ss;
|
frames[0].ss = addr.seg = ss;
|
||||||
frames[0].ebp = addr.off = LOWORD(DEBUG_context.Ebp);
|
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;
|
is16 = TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (noisy) fprintf( stderr, "Bad segment '%u'\n", ss);
|
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "Bad segment '%u'\n", ss);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,13 +268,13 @@ void DEBUG_BackTrace(BOOL noisy)
|
||||||
*/
|
*/
|
||||||
cur_switch = (DWORD)DEBUG_CurrThread->teb + OFFSET_OF(TEB, cur_stack);
|
cur_switch = (DWORD)DEBUG_CurrThread->teb + OFFSET_OF(TEB, cur_stack);
|
||||||
if (!DEBUG_READ_MEM((void*)cur_switch, &next_switch, sizeof(next_switch))) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is16) {
|
if (is16) {
|
||||||
if (!DEBUG_READ_MEM((void*)next_switch, &frame32, sizeof(STACK32FRAME))) {
|
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 );
|
(STACK32FRAME*)next_switch );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -295,7 +287,7 @@ void DEBUG_BackTrace(BOOL noisy)
|
||||||
p = DEBUG_ToLinear(&tmp);
|
p = DEBUG_ToLinear(&tmp);
|
||||||
|
|
||||||
if (!DEBUG_READ_MEM((void*)p, &frame16, sizeof(STACK16FRAME))) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
cur_switch = (DWORD)frame16.frame32;
|
cur_switch = (DWORD)frame16.frame32;
|
||||||
|
@ -315,7 +307,7 @@ void DEBUG_BackTrace(BOOL noisy)
|
||||||
if (is16) {
|
if (is16) {
|
||||||
|
|
||||||
if (!DEBUG_READ_MEM((void*)next_switch, &frame32, sizeof(STACK32FRAME))) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +325,7 @@ void DEBUG_BackTrace(BOOL noisy)
|
||||||
p = DEBUG_ToLinear(&tmp);
|
p = DEBUG_ToLinear(&tmp);
|
||||||
|
|
||||||
if (!DEBUG_READ_MEM((void*)p, &frame16, sizeof(STACK16FRAME))) {
|
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 );
|
(STACK16FRAME*)p );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -348,7 +340,7 @@ void DEBUG_BackTrace(BOOL noisy)
|
||||||
p = DEBUG_ToLinear(&tmp);
|
p = DEBUG_ToLinear(&tmp);
|
||||||
|
|
||||||
if (!DEBUG_READ_MEM((void*)p, &frame16, sizeof(STACK16FRAME))) {
|
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 );
|
(STACK16FRAME*)p );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -363,7 +355,7 @@ void DEBUG_BackTrace(BOOL noisy)
|
||||||
|
|
||||||
next_switch = cur_switch;
|
next_switch = cur_switch;
|
||||||
if (!DEBUG_READ_MEM((void*)next_switch, &frame32, sizeof(STACK32FRAME))) {
|
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 );
|
(STACK32FRAME*)next_switch );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -383,7 +375,7 @@ void DEBUG_BackTrace(BOOL noisy)
|
||||||
: DEBUG_Frame32( &addr, &cs, ++frameno, noisy);
|
: DEBUG_Frame32( &addr, &cs, ++frameno, noisy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (noisy) fprintf( stderr, "\n" );
|
if (noisy) DEBUG_Printf( DBG_CHN_MESG, "\n" );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -794,7 +794,7 @@ DEBUG_Print( const DBG_VALUE *value, int count, char format, int level )
|
||||||
|
|
||||||
if (count != 1)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,8 +802,8 @@ DEBUG_Print( const DBG_VALUE *value, int count, char format, int level )
|
||||||
{
|
{
|
||||||
/* No type, just print the addr value */
|
/* No type, just print the addr value */
|
||||||
if (value->addr.seg && (value->addr.seg != 0xffffffff))
|
if (value->addr.seg && (value->addr.seg != 0xffffffff))
|
||||||
DEBUG_nchar += fprintf( stderr, "0x%04lx: ", value->addr.seg );
|
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, "0x%04lx: ", value->addr.seg );
|
||||||
DEBUG_nchar += fprintf( stderr, "0x%08lx", value->addr.off );
|
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, "0x%08lx", value->addr.off );
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -814,13 +814,13 @@ DEBUG_Print( const DBG_VALUE *value, int count, char format, int level )
|
||||||
|
|
||||||
if( DEBUG_nchar > DEBUG_maxchar )
|
if( DEBUG_nchar > DEBUG_maxchar )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "...");
|
DEBUG_Printf(DBG_CHN_MESG, "...");
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( format == 'i' || format == 's' || format == 'w' || format == 'b' )
|
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';
|
format = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,24 +833,24 @@ DEBUG_Print( const DBG_VALUE *value, int count, char format, int level )
|
||||||
DEBUG_PrintBasic(value, 1, format);
|
DEBUG_PrintBasic(value, 1, format);
|
||||||
break;
|
break;
|
||||||
case DT_STRUCT:
|
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)
|
for(m = value->type->un.structure.members; m; m = m->next)
|
||||||
{
|
{
|
||||||
val1 = *value;
|
val1 = *value;
|
||||||
DEBUG_FindStructElement(&val1, m->name, &xval);
|
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);
|
DEBUG_Print(&val1, 1, format, level + 1);
|
||||||
if( m->next != NULL )
|
if( m->next != NULL )
|
||||||
{
|
{
|
||||||
DEBUG_nchar += fprintf(stderr, ", ");
|
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, ", ");
|
||||||
}
|
}
|
||||||
if( DEBUG_nchar > DEBUG_maxchar )
|
if( DEBUG_nchar > DEBUG_maxchar )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "...}");
|
DEBUG_Printf(DBG_CHN_MESG, "...}");
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG_nchar += fprintf(stderr, "}");
|
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "}");
|
||||||
break;
|
break;
|
||||||
case DT_ARRAY:
|
case DT_ARRAY:
|
||||||
/*
|
/*
|
||||||
|
@ -863,38 +863,38 @@ DEBUG_Print( const DBG_VALUE *value, int count, char format, int level )
|
||||||
* Special handling for character arrays.
|
* Special handling for character arrays.
|
||||||
*/
|
*/
|
||||||
pnt = (char *) value->addr.off;
|
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++ )
|
for( i=value->type->un.array.start; i < value->type->un.array.end; i++ )
|
||||||
{
|
{
|
||||||
fputc(*pnt++, stderr);
|
fputc(*pnt++, stderr);
|
||||||
DEBUG_nchar++;
|
DEBUG_nchar++;
|
||||||
if( DEBUG_nchar > DEBUG_maxchar )
|
if( DEBUG_nchar > DEBUG_maxchar )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "...\"");
|
DEBUG_Printf(DBG_CHN_MESG, "...\"");
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG_nchar += fprintf(stderr, "\"");
|
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "\"");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
val1 = *value;
|
val1 = *value;
|
||||||
val1.type = value->type->un.array.basictype;
|
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++ )
|
for( i=value->type->un.array.start; i <= value->type->un.array.end; i++ )
|
||||||
{
|
{
|
||||||
DEBUG_Print(&val1, 1, format, level + 1);
|
DEBUG_Print(&val1, 1, format, level + 1);
|
||||||
val1.addr.off += size;
|
val1.addr.off += size;
|
||||||
if( i == value->type->un.array.end )
|
if( i == value->type->un.array.end )
|
||||||
{
|
{
|
||||||
DEBUG_nchar += fprintf(stderr, "}");
|
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUG_nchar += fprintf(stderr, ", ");
|
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, ", ");
|
||||||
}
|
}
|
||||||
if( DEBUG_nchar > DEBUG_maxchar )
|
if( DEBUG_nchar > DEBUG_maxchar )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "...}");
|
DEBUG_Printf(DBG_CHN_MESG, "...}");
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -908,7 +908,7 @@ leave:
|
||||||
|
|
||||||
if( level == 0 )
|
if( level == 0 )
|
||||||
{
|
{
|
||||||
DEBUG_nchar += fprintf(stderr, "\n");
|
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "\n");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -935,11 +935,11 @@ DEBUG_DumpTypes(void)
|
||||||
switch(dt->type)
|
switch(dt->type)
|
||||||
{
|
{
|
||||||
case DT_BASIC:
|
case DT_BASIC:
|
||||||
fprintf(stderr, "0x%p - BASIC(%s)\n",
|
DEBUG_Printf(DBG_CHN_MESG, "0x%p - BASIC(%s)\n",
|
||||||
dt, name);
|
dt, name);
|
||||||
break;
|
break;
|
||||||
case DT_POINTER:
|
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);
|
dt, name, dt->un.pointer.pointsto);
|
||||||
break;
|
break;
|
||||||
case DT_STRUCT:
|
case DT_STRUCT:
|
||||||
|
@ -954,27 +954,26 @@ DEBUG_DumpTypes(void)
|
||||||
nm++;
|
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);
|
dt->un.structure.size, nm, member_name);
|
||||||
break;
|
break;
|
||||||
case DT_ARRAY:
|
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);
|
dt, name, dt->un.array.basictype);
|
||||||
break;
|
break;
|
||||||
case DT_ENUM:
|
case DT_ENUM:
|
||||||
fprintf(stderr, "0x%p - ENUM(%s)\n",
|
DEBUG_Printf(DBG_CHN_MESG, "0x%p - ENUM(%s)\n", dt, name);
|
||||||
dt, name);
|
|
||||||
break;
|
break;
|
||||||
case DT_BITFIELD:
|
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;
|
break;
|
||||||
case DT_FUNC:
|
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);
|
dt, name, dt->un.funct.rettype);
|
||||||
break;
|
break;
|
||||||
case DT_CONST:
|
case DT_CONST:
|
||||||
case DT_TYPEDEF:
|
case DT_TYPEDEF:
|
||||||
fprintf(stderr, "What???\n");
|
DEBUG_Printf(DBG_CHN_MESG, "What???\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1025,31 +1024,31 @@ DEBUG_PrintTypeCast(const struct datatype * dt)
|
||||||
switch(dt->type)
|
switch(dt->type)
|
||||||
{
|
{
|
||||||
case DT_BASIC:
|
case DT_BASIC:
|
||||||
fprintf(stderr, "%s", name);
|
DEBUG_Printf(DBG_CHN_MESG, "%s", name);
|
||||||
break;
|
break;
|
||||||
case DT_POINTER:
|
case DT_POINTER:
|
||||||
DEBUG_PrintTypeCast(dt->un.pointer.pointsto);
|
DEBUG_PrintTypeCast(dt->un.pointer.pointsto);
|
||||||
fprintf(stderr, "*");
|
DEBUG_Printf(DBG_CHN_MESG, "*");
|
||||||
break;
|
break;
|
||||||
case DT_STRUCT:
|
case DT_STRUCT:
|
||||||
fprintf(stderr, "struct %s", name);
|
DEBUG_Printf(DBG_CHN_MESG, "struct %s", name);
|
||||||
break;
|
break;
|
||||||
case DT_ARRAY:
|
case DT_ARRAY:
|
||||||
fprintf(stderr, "%s[]", name);
|
DEBUG_Printf(DBG_CHN_MESG, "%s[]", name);
|
||||||
break;
|
break;
|
||||||
case DT_ENUM:
|
case DT_ENUM:
|
||||||
fprintf(stderr, "enum %s", name);
|
DEBUG_Printf(DBG_CHN_MESG, "enum %s", name);
|
||||||
break;
|
break;
|
||||||
case DT_BITFIELD:
|
case DT_BITFIELD:
|
||||||
fprintf(stderr, "unsigned %s", name);
|
DEBUG_Printf(DBG_CHN_MESG, "unsigned %s", name);
|
||||||
break;
|
break;
|
||||||
case DT_FUNC:
|
case DT_FUNC:
|
||||||
DEBUG_PrintTypeCast(dt->un.funct.rettype);
|
DEBUG_PrintTypeCast(dt->un.funct.rettype);
|
||||||
fprintf(stderr, "(*%s)()", name);
|
DEBUG_Printf(DBG_CHN_MESG, "(*%s)()", name);
|
||||||
break;
|
break;
|
||||||
case DT_CONST:
|
case DT_CONST:
|
||||||
case DT_TYPEDEF:
|
case DT_TYPEDEF:
|
||||||
fprintf(stderr, "What???\n");
|
DEBUG_Printf(DBG_CHN_MESG, "What???\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1062,12 +1061,12 @@ int DEBUG_PrintType( const DBG_VALUE *value )
|
||||||
|
|
||||||
if (!value->type)
|
if (!value->type)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unknown type\n");
|
DEBUG_Printf(DBG_CHN_MESG, "Unknown type\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!DEBUG_PrintTypeCast(value->type))
|
if (!DEBUG_PrintTypeCast(value->type))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
fprintf(stderr, "\n");
|
DEBUG_Printf(DBG_CHN_MESG, "\n");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/stat.h>
|
#include <string.h>
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
|
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
@ -16,21 +16,39 @@
|
||||||
#include "winuser.h"
|
#include "winuser.h"
|
||||||
|
|
||||||
#include "winreg.h"
|
#include "winreg.h"
|
||||||
#include "debugtools.h"
|
|
||||||
#include "options.h"
|
|
||||||
|
|
||||||
#ifdef DBG_need_heap
|
#ifdef DBG_need_heap
|
||||||
HANDLE dbg_heap = 0;
|
HANDLE dbg_heap = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DEFAULT_DEBUG_CHANNEL(winedbg);
|
|
||||||
|
|
||||||
DBG_PROCESS* DEBUG_CurrProcess = NULL;
|
DBG_PROCESS* DEBUG_CurrProcess = NULL;
|
||||||
DBG_THREAD* DEBUG_CurrThread = NULL;
|
DBG_THREAD* DEBUG_CurrThread = NULL;
|
||||||
CONTEXT DEBUG_context;
|
CONTEXT DEBUG_context;
|
||||||
|
|
||||||
static DBG_PROCESS* proc = NULL;
|
static DBG_PROCESS* proc = NULL;
|
||||||
static BOOL bBreakAllThreads = FALSE;
|
|
||||||
|
/* build internal vars table */
|
||||||
|
#define INTERNAL_VAR(_var,_val) int DBG_IVAR(_var) = _val;
|
||||||
|
#include "intvar.h"
|
||||||
|
#undef INTERNAL_VAR
|
||||||
|
|
||||||
|
int DEBUG_Printf(int chn, const char* format, ...)
|
||||||
|
{
|
||||||
|
char buf[1024];
|
||||||
|
va_list valist;
|
||||||
|
|
||||||
|
va_start(valist, format);
|
||||||
|
vsprintf(buf, format, valist);
|
||||||
|
va_end(valist);
|
||||||
|
#if 0
|
||||||
|
if (DBG_IVAR(ChannelMask) & chn)
|
||||||
|
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), NULL, NULL);
|
||||||
|
if (chn == DBG_CHN_MESG) fwrite(buf, strlen(buf), 1, stderr);
|
||||||
|
#else
|
||||||
|
if (DBG_IVAR(ChannelMask) & chn) fwrite(buf, strlen(buf), 1, stderr);
|
||||||
|
#endif
|
||||||
|
return strlen(buf);
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL DEBUG_Init(void)
|
static BOOL DEBUG_Init(void)
|
||||||
{
|
{
|
||||||
|
@ -39,10 +57,12 @@ static BOOL DEBUG_Init(void)
|
||||||
DWORD val;
|
DWORD val;
|
||||||
DWORD count = sizeof(val);
|
DWORD count = sizeof(val);
|
||||||
|
|
||||||
if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\WineDbg", &hkey)) {
|
if (!RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\WineDbg", &hkey)) {
|
||||||
if (!RegQueryValueExA(hkey, "BreakAllThreadsStartup", 0, &type, (LPSTR)&val, &count)) {
|
#define INTERNAL_VAR(_var,_val) \
|
||||||
bBreakAllThreads = val;
|
if (!RegQueryValueEx(hkey, #_var, 0, &type, (LPSTR)&val, &count)) \
|
||||||
}
|
DBG_IVAR(_var) = val;
|
||||||
|
#include "intvar.h"
|
||||||
|
#undef INTERNAL_VAR
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -51,7 +71,7 @@ static BOOL DEBUG_Init(void)
|
||||||
static WINE_EXCEPTION_FILTER(wine_dbg)
|
static WINE_EXCEPTION_FILTER(wine_dbg)
|
||||||
{
|
{
|
||||||
DEBUG_ExternalDebugger();
|
DEBUG_ExternalDebugger();
|
||||||
fprintf(stderr, "\nwine_dbg: Exception %lx\n", GetExceptionCode());
|
DEBUG_Printf(DBG_CHN_MESG, "\nwine_dbg: Exception %lx\n", GetExceptionCode());
|
||||||
return EXCEPTION_EXECUTE_HANDLER;
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +108,7 @@ static void DEBUG_DelThread(DBG_THREAD* p);
|
||||||
static void DEBUG_DelProcess(DBG_PROCESS* p)
|
static void DEBUG_DelProcess(DBG_PROCESS* p)
|
||||||
{
|
{
|
||||||
if (p->threads != NULL) {
|
if (p->threads != NULL) {
|
||||||
ERR("Shouldn't happen\n");
|
DEBUG_Printf(DBG_CHN_ERR, "Shouldn't happen\n");
|
||||||
while (p->threads) DEBUG_DelThread(p->threads);
|
while (p->threads) DEBUG_DelThread(p->threads);
|
||||||
}
|
}
|
||||||
if (p->prev) p->prev->next = p->next;
|
if (p->prev) p->prev->next = p->next;
|
||||||
|
@ -111,41 +131,6 @@ static void DEBUG_InitCurrProcess(void)
|
||||||
*/
|
*/
|
||||||
DEBUG_InitTypes();
|
DEBUG_InitTypes();
|
||||||
DEBUG_InitCVDataTypes();
|
DEBUG_InitCVDataTypes();
|
||||||
|
|
||||||
/*
|
|
||||||
* In some cases we can read the stabs information directly
|
|
||||||
* from the executable. If this is the case, we don't need
|
|
||||||
* to bother with trying to read a symbol file, as the stabs
|
|
||||||
* also have line number and local variable information.
|
|
||||||
* As long as gcc is used for the compiler, stabs will
|
|
||||||
* be the default. On SVr4, DWARF could be used, but we
|
|
||||||
* don't grok that yet, and in this case we fall back to using
|
|
||||||
* the wine.sym file.
|
|
||||||
*/
|
|
||||||
if( DEBUG_ReadExecutableDbgInfo() == FALSE )
|
|
||||||
{
|
|
||||||
char* symfilename = "wine.sym";
|
|
||||||
struct stat statbuf;
|
|
||||||
HKEY hWineConf, hkey;
|
|
||||||
DWORD count;
|
|
||||||
char symbolTableFile[256];
|
|
||||||
|
|
||||||
if (-1 == stat(symfilename, &statbuf) )
|
|
||||||
symfilename = LIBDIR "wine.sym";
|
|
||||||
|
|
||||||
strcpy(symbolTableFile, symfilename);
|
|
||||||
if (!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config", &hWineConf)) {
|
|
||||||
if (!RegOpenKeyA(hWineConf, "wine", &hkey)) {
|
|
||||||
count = sizeof(symbolTableFile);
|
|
||||||
RegQueryValueA(hkey, "SymbolTableFile", symbolTableFile, &count);
|
|
||||||
RegCloseKey(hkey);
|
|
||||||
}
|
|
||||||
RegCloseKey(hWineConf);
|
|
||||||
}
|
|
||||||
DEBUG_ReadSymbolTable(symbolTableFile);
|
|
||||||
}
|
|
||||||
DEBUG_LoadEntryPoints(NULL);
|
|
||||||
DEBUG_ProcessDeferredDebug();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL DEBUG_ProcessGetString(char* buffer, int size, HANDLE hp, LPSTR addr)
|
static BOOL DEBUG_ProcessGetString(char* buffer, int size, HANDLE hp, LPSTR addr)
|
||||||
|
@ -206,10 +191,9 @@ static DBG_THREAD* DEBUG_AddThread(DBG_PROCESS* p, DWORD tid,
|
||||||
|
|
||||||
static void DEBUG_InitCurrThread(void)
|
static void DEBUG_InitCurrThread(void)
|
||||||
{
|
{
|
||||||
if (!Options.debug) return;
|
|
||||||
|
|
||||||
if (DEBUG_CurrThread->start) {
|
if (DEBUG_CurrThread->start) {
|
||||||
if (DEBUG_CurrThread->process->num_threads == 1 || bBreakAllThreads) {
|
if (DEBUG_CurrThread->process->num_threads == 1 ||
|
||||||
|
DBG_IVAR(BreakAllThreadsStartup)) {
|
||||||
DBG_VALUE value;
|
DBG_VALUE value;
|
||||||
|
|
||||||
DEBUG_SetBreakpoints(FALSE);
|
DEBUG_SetBreakpoints(FALSE);
|
||||||
|
@ -239,7 +223,9 @@ static BOOL DEBUG_HandleException( EXCEPTION_RECORD *rec, BOOL first_chance, BOO
|
||||||
BOOL is_debug = FALSE;
|
BOOL is_debug = FALSE;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
if (first_chance && !Options.debug && !force ) return 0; /* pass to app first */
|
/* FIXME: need for a configuration var ? */
|
||||||
|
/* pass to app first ??? */
|
||||||
|
/* if (first_chance && !force) return 0; */
|
||||||
|
|
||||||
switch (rec->ExceptionCode)
|
switch (rec->ExceptionCode)
|
||||||
{
|
{
|
||||||
|
@ -247,83 +233,80 @@ static BOOL DEBUG_HandleException( EXCEPTION_RECORD *rec, BOOL first_chance, BOO
|
||||||
case EXCEPTION_SINGLE_STEP:
|
case EXCEPTION_SINGLE_STEP:
|
||||||
is_debug = TRUE;
|
is_debug = TRUE;
|
||||||
break;
|
break;
|
||||||
case CONTROL_C_EXIT:
|
|
||||||
if (!Options.debug) DEBUG_Exit(0);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_debug)
|
if (!is_debug)
|
||||||
{
|
{
|
||||||
/* print some infos */
|
/* print some infos */
|
||||||
fprintf( stderr, "%s: ",
|
DEBUG_Printf( DBG_CHN_MESG, "%s: ",
|
||||||
first_chance ? "First chance exception" : "Unhandled exception" );
|
first_chance ? "First chance exception" : "Unhandled exception" );
|
||||||
switch(rec->ExceptionCode)
|
switch(rec->ExceptionCode)
|
||||||
{
|
{
|
||||||
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
||||||
fprintf( stderr, "divide by zero" );
|
DEBUG_Printf( DBG_CHN_MESG, "divide by zero" );
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_INT_OVERFLOW:
|
case EXCEPTION_INT_OVERFLOW:
|
||||||
fprintf( stderr, "overflow" );
|
DEBUG_Printf( DBG_CHN_MESG, "overflow" );
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
||||||
fprintf( stderr, "array bounds " );
|
DEBUG_Printf( DBG_CHN_MESG, "array bounds " );
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
||||||
fprintf( stderr, "illegal instruction" );
|
DEBUG_Printf( DBG_CHN_MESG, "illegal instruction" );
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_STACK_OVERFLOW:
|
case EXCEPTION_STACK_OVERFLOW:
|
||||||
fprintf( stderr, "stack overflow" );
|
DEBUG_Printf( DBG_CHN_MESG, "stack overflow" );
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_PRIV_INSTRUCTION:
|
case EXCEPTION_PRIV_INSTRUCTION:
|
||||||
fprintf( stderr, "priviledged instruction" );
|
DEBUG_Printf( DBG_CHN_MESG, "priviledged instruction" );
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_ACCESS_VIOLATION:
|
case EXCEPTION_ACCESS_VIOLATION:
|
||||||
if (rec->NumberParameters == 2)
|
if (rec->NumberParameters == 2)
|
||||||
fprintf( stderr, "page fault on %s access to 0x%08lx",
|
DEBUG_Printf( DBG_CHN_MESG, "page fault on %s access to 0x%08lx",
|
||||||
rec->ExceptionInformation[0] ? "write" : "read",
|
rec->ExceptionInformation[0] ? "write" : "read",
|
||||||
rec->ExceptionInformation[1] );
|
rec->ExceptionInformation[1] );
|
||||||
else
|
else
|
||||||
fprintf( stderr, "page fault" );
|
DEBUG_Printf( DBG_CHN_MESG, "page fault" );
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_DATATYPE_MISALIGNMENT:
|
case EXCEPTION_DATATYPE_MISALIGNMENT:
|
||||||
fprintf( stderr, "Alignment" );
|
DEBUG_Printf( DBG_CHN_MESG, "Alignment" );
|
||||||
break;
|
break;
|
||||||
case CONTROL_C_EXIT:
|
case CONTROL_C_EXIT:
|
||||||
fprintf( stderr, "^C" );
|
DEBUG_Printf( DBG_CHN_MESG, "^C" );
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_CRITICAL_SECTION_WAIT:
|
case EXCEPTION_CRITICAL_SECTION_WAIT:
|
||||||
fprintf( stderr, "critical section %08lx wait failed",
|
DEBUG_Printf( DBG_CHN_MESG, "critical section %08lx wait failed",
|
||||||
rec->ExceptionInformation[0] );
|
rec->ExceptionInformation[0] );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf( stderr, "%08lx", rec->ExceptionCode );
|
DEBUG_Printf( DBG_CHN_MESG, "%08lx", rec->ExceptionCode );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
DEBUG_Printf(DBG_CHN_TRACE,
|
||||||
fprintf(stderr, "Entering debugger PC=%lx EFL=%08lx mode=%d count=%d\n",
|
"Entering debugger PC=%lx EFL=%08lx mode=%d count=%d\n",
|
||||||
DEBUG_context.Eip, DEBUG_context.EFlags,
|
DEBUG_context.Eip, DEBUG_context.EFlags,
|
||||||
DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count);
|
DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count);
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = DEBUG_Main( is_debug, force, rec->ExceptionCode );
|
ret = DEBUG_Main( is_debug, force, rec->ExceptionCode );
|
||||||
#if 1
|
|
||||||
fprintf(stderr, "Exiting debugger PC=%lx EFL=%08lx mode=%d count=%d\n",
|
DEBUG_Printf(DBG_CHN_TRACE,
|
||||||
|
"Exiting debugger PC=%lx EFL=%08lx mode=%d count=%d\n",
|
||||||
DEBUG_context.Eip, DEBUG_context.EFlags,
|
DEBUG_context.Eip, DEBUG_context.EFlags,
|
||||||
DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count);
|
DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count);
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD DEBUG_HandleDebugEvent(DEBUG_EVENT* de)
|
static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de, LPDWORD cont)
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
DWORD cont;
|
BOOL ret;
|
||||||
|
|
||||||
__TRY {
|
__TRY {
|
||||||
cont = 0L;
|
ret = TRUE;
|
||||||
|
*cont = 0L;
|
||||||
|
|
||||||
if ((DEBUG_CurrProcess = DEBUG_GetProcess(de->dwProcessId)) != NULL)
|
if ((DEBUG_CurrProcess = DEBUG_GetProcess(de->dwProcessId)) != NULL)
|
||||||
DEBUG_CurrThread = DEBUG_GetThread(DEBUG_CurrProcess, de->dwThreadId);
|
DEBUG_CurrThread = DEBUG_GetThread(DEBUG_CurrProcess, de->dwThreadId);
|
||||||
|
@ -332,45 +315,47 @@ static DWORD DEBUG_HandleDebugEvent(DEBUG_EVENT* de)
|
||||||
|
|
||||||
switch (de->dwDebugEventCode) {
|
switch (de->dwDebugEventCode) {
|
||||||
case EXCEPTION_DEBUG_EVENT:
|
case EXCEPTION_DEBUG_EVENT:
|
||||||
if (!DEBUG_CurrThread) break;
|
if (!DEBUG_CurrThread) {
|
||||||
|
DEBUG_Printf(DBG_CHN_ERR, "%08lx:%08lx: not a registered process or thread (perhaps a 16 bit one ?)\n",
|
||||||
|
de->dwProcessId, de->dwThreadId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
TRACE("%08lx:%08lx: exception code=%08lx %d\n",
|
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: exception code=%08lx %d\n",
|
||||||
de->dwProcessId, de->dwThreadId,
|
de->dwProcessId, de->dwThreadId,
|
||||||
de->u.Exception.ExceptionRecord.ExceptionCode,
|
de->u.Exception.ExceptionRecord.ExceptionCode,
|
||||||
DEBUG_CurrThread->wait_for_first_exception);
|
DEBUG_CurrThread->wait_for_first_exception);
|
||||||
|
|
||||||
DEBUG_context.ContextFlags = CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS|CONTEXT_DEBUG_REGISTERS;
|
DEBUG_context.ContextFlags = CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS|CONTEXT_DEBUG_REGISTERS;
|
||||||
if (!GetThreadContext(DEBUG_CurrThread->handle, &DEBUG_context)) {
|
if (!GetThreadContext(DEBUG_CurrThread->handle, &DEBUG_context)) {
|
||||||
WARN("Can't get thread's context\n");
|
DEBUG_Printf(DBG_CHN_WARN, "Can't get thread's context\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("%p:%p\n", de->u.Exception.ExceptionRecord.ExceptionAddress,
|
DEBUG_Printf(DBG_CHN_TRACE, "%p:%p\n", de->u.Exception.ExceptionRecord.ExceptionAddress,
|
||||||
(void*)DEBUG_context.Eip);
|
(void*)DEBUG_context.Eip);
|
||||||
|
|
||||||
cont = DEBUG_HandleException(&de->u.Exception.ExceptionRecord,
|
*cont = DEBUG_HandleException(&de->u.Exception.ExceptionRecord,
|
||||||
de->u.Exception.dwFirstChance,
|
de->u.Exception.dwFirstChance,
|
||||||
DEBUG_CurrThread->wait_for_first_exception);
|
DEBUG_CurrThread->wait_for_first_exception);
|
||||||
|
if (DEBUG_CurrThread->dbg_exec_mode == EXEC_KILL) {
|
||||||
if (DEBUG_CurrThread->wait_for_first_exception) {
|
ret = FALSE;
|
||||||
|
} else {
|
||||||
DEBUG_CurrThread->wait_for_first_exception = 0;
|
DEBUG_CurrThread->wait_for_first_exception = 0;
|
||||||
#ifdef __i386__
|
|
||||||
DEBUG_context.Eip--;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
SetThreadContext(DEBUG_CurrThread->handle, &DEBUG_context);
|
SetThreadContext(DEBUG_CurrThread->handle, &DEBUG_context);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CREATE_THREAD_DEBUG_EVENT:
|
case CREATE_THREAD_DEBUG_EVENT:
|
||||||
TRACE("%08lx:%08lx: create thread D @%p\n", de->dwProcessId, de->dwThreadId,
|
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: create thread D @%p\n", de->dwProcessId, de->dwThreadId,
|
||||||
de->u.CreateThread.lpStartAddress);
|
de->u.CreateThread.lpStartAddress);
|
||||||
|
|
||||||
if (DEBUG_CurrProcess == NULL) {
|
if (DEBUG_CurrProcess == NULL) {
|
||||||
ERR("Unknown process\n");
|
DEBUG_Printf(DBG_CHN_ERR, "Unknown process\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (DEBUG_GetThread(DEBUG_CurrProcess, de->dwThreadId) != NULL) {
|
if (DEBUG_GetThread(DEBUG_CurrProcess, de->dwThreadId) != NULL) {
|
||||||
TRACE("Thread already listed, skipping\n");
|
DEBUG_Printf(DBG_CHN_TRACE, "Thread already listed, skipping\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +365,7 @@ static DWORD DEBUG_HandleDebugEvent(DEBUG_EVENT* de)
|
||||||
de->u.CreateThread.lpStartAddress,
|
de->u.CreateThread.lpStartAddress,
|
||||||
de->u.CreateThread.lpThreadLocalBase);
|
de->u.CreateThread.lpThreadLocalBase);
|
||||||
if (!DEBUG_CurrThread) {
|
if (!DEBUG_CurrThread) {
|
||||||
ERR("Couldn't create thread\n");
|
DEBUG_Printf(DBG_CHN_ERR, "Couldn't create thread\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DEBUG_InitCurrThread();
|
DEBUG_InitCurrThread();
|
||||||
|
@ -389,26 +374,29 @@ static DWORD DEBUG_HandleDebugEvent(DEBUG_EVENT* de)
|
||||||
case CREATE_PROCESS_DEBUG_EVENT:
|
case CREATE_PROCESS_DEBUG_EVENT:
|
||||||
DEBUG_ProcessGetStringIndirect(buffer, sizeof(buffer),
|
DEBUG_ProcessGetStringIndirect(buffer, sizeof(buffer),
|
||||||
de->u.CreateProcessInfo.hProcess,
|
de->u.CreateProcessInfo.hProcess,
|
||||||
de->u.LoadDll.lpImageName);
|
de->u.CreateProcessInfo.lpImageName);
|
||||||
|
|
||||||
/* FIXME unicode ? de->u.CreateProcessInfo.fUnicode */
|
/* FIXME unicode ? de->u.CreateProcessInfo.fUnicode */
|
||||||
TRACE("%08lx:%08lx: create process %s @%p\n",
|
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: create process %s @%p (%ld<%ld>)\n",
|
||||||
de->dwProcessId, de->dwThreadId,
|
de->dwProcessId, de->dwThreadId,
|
||||||
buffer,
|
buffer,
|
||||||
de->u.CreateProcessInfo.lpStartAddress);
|
de->u.CreateProcessInfo.lpStartAddress,
|
||||||
|
de->u.CreateProcessInfo.dwDebugInfoFileOffset,
|
||||||
|
de->u.CreateProcessInfo.nDebugInfoSize);
|
||||||
|
|
||||||
if (DEBUG_GetProcess(de->dwProcessId) != NULL) {
|
if (DEBUG_GetProcess(de->dwProcessId) != NULL) {
|
||||||
TRACE("Skipping already defined process\n");
|
DEBUG_Printf(DBG_CHN_TRACE, "Skipping already defined process\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DEBUG_CurrProcess = DEBUG_AddProcess(de->dwProcessId,
|
DEBUG_CurrProcess = DEBUG_AddProcess(de->dwProcessId,
|
||||||
de->u.CreateProcessInfo.hProcess);
|
de->u.CreateProcessInfo.hProcess);
|
||||||
if (DEBUG_CurrProcess == NULL) {
|
if (DEBUG_CurrProcess == NULL) {
|
||||||
ERR("Unknown process\n");
|
DEBUG_Printf(DBG_CHN_ERR, "Unknown process\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("%08lx:%08lx: create thread I @%p\n", de->dwProcessId, de->dwThreadId,
|
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: create thread I @%p\n",
|
||||||
|
de->dwProcessId, de->dwThreadId,
|
||||||
de->u.CreateProcessInfo.lpStartAddress);
|
de->u.CreateProcessInfo.lpStartAddress);
|
||||||
|
|
||||||
DEBUG_CurrThread = DEBUG_AddThread(DEBUG_CurrProcess,
|
DEBUG_CurrThread = DEBUG_AddThread(DEBUG_CurrProcess,
|
||||||
|
@ -417,25 +405,23 @@ static DWORD DEBUG_HandleDebugEvent(DEBUG_EVENT* de)
|
||||||
de->u.CreateProcessInfo.lpStartAddress,
|
de->u.CreateProcessInfo.lpStartAddress,
|
||||||
de->u.CreateProcessInfo.lpThreadLocalBase);
|
de->u.CreateProcessInfo.lpThreadLocalBase);
|
||||||
if (!DEBUG_CurrThread) {
|
if (!DEBUG_CurrThread) {
|
||||||
ERR("Couldn't create thread\n");
|
DEBUG_Printf(DBG_CHN_ERR, "Couldn't create thread\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_InitCurrProcess();
|
DEBUG_InitCurrProcess();
|
||||||
DEBUG_InitCurrThread();
|
DEBUG_InitCurrThread();
|
||||||
#ifdef _WE_SUPPORT_THE_STAB_TYPES_USED_BY_MINGW_TOO
|
|
||||||
/* so far, process name is not set */
|
/* so far, process name is not set */
|
||||||
DEBUG_RegisterDebugInfo((DWORD)de->u.CreateProcessInfo.lpBaseOfImage,
|
DEBUG_LoadModule32("<Debugged process>", de->u.CreateProcessInfo.hFile,
|
||||||
"wine-exec");
|
(DWORD)de->u.CreateProcessInfo.lpBaseOfImage);
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXIT_THREAD_DEBUG_EVENT:
|
case EXIT_THREAD_DEBUG_EVENT:
|
||||||
TRACE("%08lx:%08lx: exit thread (%ld)\n",
|
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: exit thread (%ld)\n",
|
||||||
de->dwProcessId, de->dwThreadId, de->u.ExitThread.dwExitCode);
|
de->dwProcessId, de->dwThreadId, de->u.ExitThread.dwExitCode);
|
||||||
|
|
||||||
if (DEBUG_CurrThread == NULL) {
|
if (DEBUG_CurrThread == NULL) {
|
||||||
ERR("Unknown thread\n");
|
DEBUG_Printf(DBG_CHN_ERR, "Unknown thread\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* FIXME: remove break point set on thread startup */
|
/* FIXME: remove break point set on thread startup */
|
||||||
|
@ -443,22 +429,24 @@ static DWORD DEBUG_HandleDebugEvent(DEBUG_EVENT* de)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXIT_PROCESS_DEBUG_EVENT:
|
case EXIT_PROCESS_DEBUG_EVENT:
|
||||||
TRACE("%08lx:%08lx: exit process (%ld)\n",
|
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: exit process (%ld)\n",
|
||||||
de->dwProcessId, de->dwThreadId, de->u.ExitProcess.dwExitCode);
|
de->dwProcessId, de->dwThreadId, de->u.ExitProcess.dwExitCode);
|
||||||
|
|
||||||
if (DEBUG_CurrProcess == NULL) {
|
if (DEBUG_CurrProcess == NULL) {
|
||||||
ERR("Unknown process\n");
|
DEBUG_Printf(DBG_CHN_ERR, "Unknown process\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* just in case */
|
||||||
|
DEBUG_SetBreakpoints(FALSE);
|
||||||
/* kill last thread */
|
/* kill last thread */
|
||||||
DEBUG_DelThread(DEBUG_CurrProcess->threads);
|
DEBUG_DelThread(DEBUG_CurrProcess->threads);
|
||||||
/* FIXME: remove break point set on thread startup */
|
|
||||||
DEBUG_DelProcess(DEBUG_CurrProcess);
|
DEBUG_DelProcess(DEBUG_CurrProcess);
|
||||||
|
ret = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOAD_DLL_DEBUG_EVENT:
|
case LOAD_DLL_DEBUG_EVENT:
|
||||||
if (DEBUG_CurrThread == NULL) {
|
if (DEBUG_CurrThread == NULL) {
|
||||||
ERR("Unknown thread\n");
|
DEBUG_Printf(DBG_CHN_ERR, "Unknown thread\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DEBUG_ProcessGetStringIndirect(buffer, sizeof(buffer),
|
DEBUG_ProcessGetStringIndirect(buffer, sizeof(buffer),
|
||||||
|
@ -466,20 +454,23 @@ static DWORD DEBUG_HandleDebugEvent(DEBUG_EVENT* de)
|
||||||
de->u.LoadDll.lpImageName);
|
de->u.LoadDll.lpImageName);
|
||||||
|
|
||||||
/* FIXME unicode: de->u.LoadDll.fUnicode */
|
/* FIXME unicode: de->u.LoadDll.fUnicode */
|
||||||
TRACE("%08lx:%08lx: loads DLL %s @%p\n", de->dwProcessId, de->dwThreadId,
|
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: loads DLL %s @%p (%ld<%ld>)\n",
|
||||||
buffer, de->u.LoadDll.lpBaseOfDll);
|
de->dwProcessId, de->dwThreadId,
|
||||||
CharUpperA(buffer);
|
buffer, de->u.LoadDll.lpBaseOfDll,
|
||||||
DEBUG_LoadModule32( buffer, (DWORD)de->u.LoadDll.lpBaseOfDll);
|
de->u.LoadDll.dwDebugInfoFileOffset,
|
||||||
|
de->u.LoadDll.nDebugInfoSize);
|
||||||
|
CharUpper(buffer);
|
||||||
|
DEBUG_LoadModule32(buffer, de->u.LoadDll.hFile, (DWORD)de->u.LoadDll.lpBaseOfDll);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UNLOAD_DLL_DEBUG_EVENT:
|
case UNLOAD_DLL_DEBUG_EVENT:
|
||||||
TRACE("%08lx:%08lx: unload DLL @%p\n", de->dwProcessId, de->dwThreadId,
|
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: unload DLL @%p\n", de->dwProcessId, de->dwThreadId,
|
||||||
de->u.UnloadDll.lpBaseOfDll);
|
de->u.UnloadDll.lpBaseOfDll);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUTPUT_DEBUG_STRING_EVENT:
|
case OUTPUT_DEBUG_STRING_EVENT:
|
||||||
if (DEBUG_CurrThread == NULL) {
|
if (DEBUG_CurrThread == NULL) {
|
||||||
ERR("Unknown thread\n");
|
DEBUG_Printf(DBG_CHN_ERR, "Unknown thread\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,111 +479,119 @@ static DWORD DEBUG_HandleDebugEvent(DEBUG_EVENT* de)
|
||||||
de->u.DebugString.lpDebugStringData);
|
de->u.DebugString.lpDebugStringData);
|
||||||
|
|
||||||
/* fixme unicode de->u.DebugString.fUnicode ? */
|
/* fixme unicode de->u.DebugString.fUnicode ? */
|
||||||
TRACE("%08lx:%08lx: output debug string (%s)\n",
|
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: output debug string (%s)\n",
|
||||||
de->dwProcessId, de->dwThreadId,
|
de->dwProcessId, de->dwThreadId, buffer);
|
||||||
buffer);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIP_EVENT:
|
case RIP_EVENT:
|
||||||
TRACE("%08lx:%08lx: rip error=%ld type=%ld\n",
|
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: rip error=%ld type=%ld\n",
|
||||||
de->dwProcessId, de->dwThreadId, de->u.RipInfo.dwError,
|
de->dwProcessId, de->dwThreadId, de->u.RipInfo.dwError,
|
||||||
de->u.RipInfo.dwType);
|
de->u.RipInfo.dwType);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
TRACE("%08lx:%08lx: unknown event (%ld)\n",
|
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: unknown event (%ld)\n",
|
||||||
de->dwProcessId, de->dwThreadId, de->dwDebugEventCode);
|
de->dwProcessId, de->dwThreadId, de->dwDebugEventCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
} __EXCEPT(wine_dbg) {
|
} __EXCEPT(wine_dbg) {
|
||||||
cont = 0;
|
*cont = 0;
|
||||||
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
__ENDTRY;
|
__ENDTRY;
|
||||||
|
|
||||||
return cont;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD CALLBACK DEBUG_MainLoop(DWORD pid)
|
static DWORD CALLBACK DEBUG_MainLoop(DWORD pid)
|
||||||
{
|
{
|
||||||
DEBUG_EVENT de;
|
DEBUG_EVENT de;
|
||||||
DWORD cont;
|
DWORD cont;
|
||||||
|
BOOL ret = TRUE;
|
||||||
|
|
||||||
|
DEBUG_Printf(DBG_CHN_MESG, " on pid %ld\n", pid);
|
||||||
|
|
||||||
DEBUG_Init();
|
DEBUG_Init();
|
||||||
|
|
||||||
while (WaitForDebugEvent(&de, INFINITE)) {
|
while (ret && WaitForDebugEvent(&de, INFINITE)) {
|
||||||
cont = DEBUG_HandleDebugEvent(&de);
|
ret = DEBUG_HandleDebugEvent(&de, &cont);
|
||||||
ContinueDebugEvent(de.dwProcessId, de.dwThreadId, cont);
|
ContinueDebugEvent(de.dwProcessId, de.dwThreadId, cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("WineDbg terminated on pid %ld\n", pid);
|
DEBUG_Printf(DBG_CHN_MESG, "WineDbg terminated on pid %ld\n", pid);
|
||||||
|
|
||||||
return 0L;
|
ExitProcess(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD CALLBACK DEBUG_StarterFromPID(LPVOID pid)
|
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE prev, LPSTR _cmdline, int show)
|
||||||
{
|
{
|
||||||
TRACE("WineDbg started on pid %ld\n", (DWORD)pid);
|
char* argv[5];
|
||||||
|
char* cmdline = strdup(_cmdline);
|
||||||
|
char* ptr = cmdline;
|
||||||
|
int instr = FALSE;
|
||||||
|
int argc = 0;
|
||||||
|
|
||||||
if (!DebugActiveProcess((DWORD)pid)) {
|
while ((*ptr == ' ' || *ptr == '\t') && *ptr != 0) ptr++;
|
||||||
TRACE("Can't debug process %ld: %ld\n", (DWORD)pid, GetLastError());
|
argv[argc++] = ptr;
|
||||||
|
for (; *ptr; ptr++) {
|
||||||
|
if ((*ptr == ' ' || *ptr == '\t') && !instr) {
|
||||||
|
*ptr++ = 0;
|
||||||
|
while (*ptr == ' ' || *ptr == '\t') ptr++;
|
||||||
|
if (*ptr) argv[argc++] = ptr;
|
||||||
|
if (argc >= sizeof(argv) / sizeof(argv[0])) return 0;
|
||||||
|
} else if (*ptr == '"') {
|
||||||
|
instr = !instr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* would require to change .spec with a cuiexe type */
|
||||||
|
/* keep it as a guiexe for now, so that Wine won't touch the Unix stdin,
|
||||||
|
* stdout and stderr streams
|
||||||
|
*/
|
||||||
|
if (1 /*DBG_IVAR(UseXterm)*/) {
|
||||||
|
COORD pos;
|
||||||
|
|
||||||
|
/* This is a hack: it forces creation of an xterm, not done by default */
|
||||||
|
pos.x = 0; pos.y = 1;
|
||||||
|
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DEBUG_Printf(DBG_CHN_MESG, "Starting WineDbg... ");
|
||||||
|
if (argc == 2) {
|
||||||
|
DWORD pid = atoi(argv[0]);
|
||||||
|
HANDLE hEvent = atoi(argv[1]);
|
||||||
|
|
||||||
|
if (pid != 0 && hEvent != 0) {
|
||||||
|
free(cmdline);
|
||||||
|
|
||||||
|
if (!DebugActiveProcess(pid)) {
|
||||||
|
DEBUG_Printf(DBG_CHN_ERR, "Can't attach process %ld: %ld\n",
|
||||||
|
pid, GetLastError());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return DEBUG_MainLoop((DWORD)pid);
|
SetEvent(hEvent);
|
||||||
}
|
return DEBUG_MainLoop(pid);
|
||||||
|
}
|
||||||
void DEBUG_Attach(DWORD pid)
|
}
|
||||||
{
|
do {
|
||||||
CreateThread(NULL, 0, DEBUG_StarterFromPID, (LPVOID)pid, 0, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct dsfcl {
|
|
||||||
HANDLE hEvent;
|
|
||||||
LPSTR lpCmdLine;
|
|
||||||
int showWindow;
|
|
||||||
DWORD error;
|
|
||||||
};
|
|
||||||
|
|
||||||
static DWORD CALLBACK DEBUG_StarterFromCmdLine(LPVOID p)
|
|
||||||
{
|
|
||||||
PROCESS_INFORMATION info;
|
PROCESS_INFORMATION info;
|
||||||
STARTUPINFOA startup;
|
STARTUPINFOA startup;
|
||||||
BOOL ok = TRUE;
|
|
||||||
|
free(cmdline);
|
||||||
|
|
||||||
memset(&startup, 0, sizeof(startup));
|
memset(&startup, 0, sizeof(startup));
|
||||||
startup.cb = sizeof(startup);
|
startup.cb = sizeof(startup);
|
||||||
startup.dwFlags = STARTF_USESHOWWINDOW;
|
startup.dwFlags = STARTF_USESHOWWINDOW;
|
||||||
startup.wShowWindow = ((struct dsfcl*)p)->showWindow;
|
startup.wShowWindow = SW_SHOWNORMAL;
|
||||||
|
|
||||||
/* any value >= 32 will do, simulate a correct handle value */
|
if (CreateProcess(NULL, _cmdline, NULL, NULL,
|
||||||
((struct dsfcl*)p)->error = 0xFFFFFFFF;
|
|
||||||
if (!CreateProcessA(NULL, ((struct dsfcl*)p)->lpCmdLine, NULL, NULL,
|
|
||||||
FALSE, DEBUG_PROCESS, NULL, NULL, &startup, &info)) {
|
FALSE, DEBUG_PROCESS, NULL, NULL, &startup, &info)) {
|
||||||
((struct dsfcl*)p)->error = GetLastError();
|
return DEBUG_MainLoop(info.dwProcessId);
|
||||||
ok = FALSE;
|
|
||||||
}
|
}
|
||||||
SetEvent(((struct dsfcl*)p)->hEvent);
|
DEBUG_Printf(DBG_CHN_MESG, "Couldn't start process '%s'\n", _cmdline);
|
||||||
if (ok) DEBUG_MainLoop(info.dwProcessId);
|
} while (0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD DEBUG_WinExec(LPSTR lpCmdLine, int sw)
|
|
||||||
{
|
|
||||||
struct dsfcl s;
|
|
||||||
BOOL ret;
|
|
||||||
|
|
||||||
if ((s.hEvent = CreateEventA(NULL, FALSE, FALSE, NULL))) {
|
|
||||||
s.lpCmdLine = lpCmdLine;
|
|
||||||
s.showWindow = sw;
|
|
||||||
if (CreateThread(NULL, 0, DEBUG_StarterFromCmdLine, (LPVOID)&s, 0, NULL)) {
|
|
||||||
WaitForSingleObject(s.hEvent, INFINITE);
|
|
||||||
ret = s.error;
|
|
||||||
} else {
|
|
||||||
ret = 3; /* (dummy) error value for non created thread */
|
|
||||||
}
|
|
||||||
CloseHandle(s.hEvent);
|
|
||||||
} else {
|
|
||||||
ret = 1; /* (dummy) error value for non created event */
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
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 */
|
/* Push a DWORD on the 32-bit stack */
|
||||||
static inline void WINE_UNUSED stack32_push( CONTEXT86 *context, DWORD val )
|
static inline void WINE_UNUSED stack32_push( CONTEXT86 *context, DWORD val )
|
||||||
{
|
{
|
||||||
ESP_reg(context) -= sizeof(DWORD);
|
context->Esp -= sizeof(DWORD);
|
||||||
*(DWORD *)ESP_reg(context) = val;
|
*(DWORD *)context->Esp = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pop a DWORD from the 32-bit stack */
|
/* Pop a DWORD from the 32-bit stack */
|
||||||
static inline DWORD WINE_UNUSED stack32_pop( CONTEXT86 *context )
|
static inline DWORD WINE_UNUSED stack32_pop( CONTEXT86 *context )
|
||||||
{
|
{
|
||||||
DWORD ret = *(DWORD *)ESP_reg(context);
|
DWORD ret = *(DWORD *)context->Esp;
|
||||||
ESP_reg(context) += sizeof(DWORD);
|
context->Esp += sizeof(DWORD);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue