Commit 527eea99 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

No longer directly accessing debuggee memory.

Execution context (mode, steps...) are now linked to a thread. Removed some X11 crst hacks. Rewrote info/walk commands. Removed direct debugger invocation code (and moved the rest to the new winedbg.c file).
parent 00641d5b
......@@ -20,7 +20,8 @@ C_SRCS = \
source.c \
stabs.c \
stack.c \
types.c
types.c \
winedbg.c
EXTRA_SRCS = dbg.y debug.l
EXTRA_OBJS = y.tab.o lex.yy.o
......
......@@ -892,27 +892,29 @@ static const int db_lengths[] = {
static unsigned int db_get_task_value( const DBG_ADDR *addr,
int size, int is_signed )
{
unsigned int result;
unsigned char *p = DBG_ADDR_TO_LIN( addr );
switch(size)
{
case 4:
if (is_signed) result = (unsigned int) *(int *)p;
else result = *(unsigned int *)p;
break;
case 2:
if (is_signed) result = (unsigned int) *(short int *)p;
else result = *(unsigned short int *)p;
break;
case 1:
if (is_signed) result = (unsigned int) *(char *)p;
else result = *(unsigned char *)p;
break;
default:
unsigned int result = 0;
char buffer[4];
if (size != 1 && size != 2 && size != 4) {
fprintf(stderr, "Illegal size specified\n");
result = 0;
break;
} else {
DEBUG_READ_MEM((void*)DEBUG_ToLinear( addr ), buffer, size);
switch(size)
{
case 4:
if (is_signed) result = (unsigned int) *(int *)buffer;
else result = *(unsigned int *)buffer;
break;
case 2:
if (is_signed) result = (unsigned int) *(short int *)buffer;
else result = *(unsigned short int *)buffer;
break;
case 1:
if (is_signed) result = (unsigned int) *(char *)buffer;
else result = *(unsigned char *)buffer;
break;
}
}
return result;
}
......@@ -1041,18 +1043,16 @@ void db_print_address(char *seg, int size, struct i_addr *addrp, int byref)
/* try to get destination of indirect call
does not work for segmented adresses */
if (!seg && byref) {
DBG_ADDR dbg_addr = {NULL, 0, 0};
void* a1;
void* a2;
dbg_addr.off = addrp->disp;
fprintf(stderr,"0x%x -> ", addrp->disp);
if (DEBUG_IsBadReadPtr( &dbg_addr, sizeof(LPDWORD))) {
fprintf(stderr, "(invalid source)");
} else {
dbg_addr.off = *(LPDWORD)(addrp->disp);
if (DEBUG_IsBadReadPtr( &dbg_addr, sizeof(DWORD)))
fprintf(stderr, "(invalid destination)");
else
db_task_printsym(dbg_addr.off, 0);
if (!DEBUG_READ_MEM((void*)addrp->disp, &a1, sizeof(a1))) {
fprintf(stderr, "(invalid source)");
} else if (!DEBUG_READ_MEM(a1, &a2, sizeof(a2))) {
fprintf(stderr, "(invalid destination)");
} else {
db_task_printsym((unsigned long)a1, 0);
}
}
else
......@@ -1172,7 +1172,11 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
* Set this so we get can supress the printout if we need to.
*/
db_display = display;
db_disasm_16 = IS_SELECTOR_V86(addr->seg) || !IS_SELECTOR_32BIT(addr->seg);
switch (DEBUG_GetSelectorType(addr->seg)) {
case 16: db_disasm_16 = 1; break;
case 32: db_disasm_16 = 0; break;
default: fprintf(stderr, "Bad selector %ld\n", addr->seg); return;
}
get_value_inc( inst, addr, 1, FALSE );
......
......@@ -119,7 +119,6 @@ $gs { yylval.reg = REG_GS; return tREG; }
<INITIAL>frame|fram|fra|fr { BEGIN(NOCMD); return tFRAME; }
<INITIAL>list|lis|li|l { BEGIN(PATH_EXPECTED); return tLIST; }
<INITIAL>enable|enabl|enab|ena { BEGIN(NOCMD); return tENABLE;}
<INITIAL>debugmsg|debugms|debugm|debug|debu|deb { BEGIN(DEBUGSTR); return tDEBUGMSG;}
<INITIAL>disable|disabl|disab|disa|dis { BEGIN(NOCMD); return tDISABLE; }
<INITIAL>disassemble|disassembl|disassemb|disassem|disasse|disass|disas { BEGIN(NOCMD); return tDISASSEMBLE; }
<INITIAL,INFO_CMD,DEL_CMD>display|displa|displ|disp { BEGIN(FORMAT_EXPECTED); return tDISPLAY; }
......
......@@ -11,9 +11,6 @@
#include <limits.h>
#include <sys/types.h>
#include "neexe.h"
#include "module.h"
#include "selectors.h"
#include "debugger.h"
#include <stdarg.h>
......
......@@ -299,7 +299,6 @@ DEBUG_EvalExpr(struct expr * exp)
DBG_ADDR exp1;
DBG_ADDR exp2;
unsigned int cexp[5];
int (*fptr)();
int scale1;
int scale2;
int scale3;
......@@ -332,12 +331,20 @@ DEBUG_EvalExpr(struct expr * exp)
rtn.seg = 0;
break;
case EXPR_TYPE_SYMBOL:
if( !DEBUG_GetSymbolValue(exp->un.symbol.name, -1, &rtn, FALSE ) )
{
rtn.type = NULL;
rtn.off = 0;
rtn.seg = 0;
};
if( !DEBUG_GetSymbolValue(exp->un.symbol.name, -1, &rtn, FALSE) )
{
#if 1
RaiseException(DEBUG_STATUS_NO_SYMBOL, 0, 0, NULL);
#else
static char ret[128];
/* FIXME: this is an ugly hack... but at least we know
* the symbol is not defined
*/
sprintf(ret, "\"Symbol %s is not defined.\"", exp->un.symbol.name);
rtn = DEBUG_EvalExpr(DEBUG_StringExpr(ret));
#endif
}
break;
case EXPR_TYPE_PSTRUCT:
exp1 = DEBUG_EvalExpr(exp->un.structure.exp1);
......@@ -388,6 +395,13 @@ DEBUG_EvalExpr(struct expr * exp)
break;
}
#if 0
/* FIXME: NEWDBG NIY */
/* Anyway, I wonder how this could work depending on the calling order of
* the function (cdecl vs pascal for example)
*/
int (*fptr)();
fptr = (int (*)()) rtn.off;
switch(exp->un.call.nargs)
{
......@@ -410,8 +424,16 @@ DEBUG_EvalExpr(struct expr * exp)
exp->un.call.result = (*fptr)(cexp[0], cexp[1], cexp[2], cexp[3], cexp[4]);
break;
}
#else
fprintf(stderr, "Function call no longer implemented\n");
/* would need to set up a call to this function, and then restore the current
* context afterwards...
*/
exp->un.call.result = 0;
#endif
rtn.type = DEBUG_TypeInt;
rtn.off = (unsigned int) &exp->un.call.result;
break;
case EXPR_TYPE_REGISTER:
rtn.type = DEBUG_TypeIntConst;
......@@ -419,11 +441,11 @@ DEBUG_EvalExpr(struct expr * exp)
rtn.off = (unsigned int) &exp->un.rgister.result;
#ifdef __i386__
if( exp->un.rgister.reg == REG_EIP )
rtn.seg = CS_reg(&DEBUG_context);
rtn.seg = DEBUG_context.SegCs;
else
rtn.seg = DS_reg(&DEBUG_context);
rtn.seg = DEBUG_context.SegDs;
#endif
DBG_FIX_ADDR_SEG( &rtn, 0 );
DEBUG_FixAddress( &rtn, 0 );
break;
case EXPR_TYPE_BINOP:
exp1 = DEBUG_EvalExpr(exp->un.binop.exp1);
......@@ -497,11 +519,7 @@ DEBUG_EvalExpr(struct expr * exp)
rtn.seg = VAL(exp1);
exp->un.binop.result = VAL(exp2);
#ifdef __i386__
if (ISV86(&DEBUG_context)) {
TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
rtn.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
GlobalUnlock16( GetCurrentTask() );
}
DEBUG_FixSegment(&rtn);
#endif
break;
case EXP_OP_LOR:
......@@ -623,12 +641,12 @@ DEBUG_EvalExpr(struct expr * exp)
exp->un.unop.result = ~VAL(exp1);
break;
case EXP_OP_DEREF:
rtn.seg = 0;
rtn.seg = 0;
rtn.off = (unsigned int) DEBUG_TypeDerefPointer(&exp1, &rtn.type);
break;
case EXP_OP_FORCE_DEREF:
rtn.seg = exp1.seg;
rtn.off = *(unsigned int *) exp1.off;
rtn.off = DEBUG_READ_MEM((void*)exp1.off, &rtn.off, sizeof(rtn.off));
break;
case EXP_OP_ADDR:
rtn.seg = 0;
......@@ -686,10 +704,6 @@ DEBUG_DisplayExpr(struct expr * exp)
fprintf(stderr, ".%s", exp->un.structure.element_name);
break;
case EXPR_TYPE_CALL:
/*
* First, evaluate all of the arguments. If any of them are not
* evaluable, then bail.
*/
fprintf(stderr, "%s(",exp->un.call.funcname);
for(i=0; i < exp->un.call.nargs; i++)
{
......@@ -841,10 +855,6 @@ DEBUG_CloneExpr(struct expr * exp)
rtn->un.structure.element_name = DBG_strdup(exp->un.structure.element_name);
break;
case EXPR_TYPE_CALL:
/*
* First, evaluate all of the arguments. If any of them are not
* evaluable, then bail.
*/
for(i=0; i < exp->un.call.nargs; i++)
{
rtn->un.call.arg[i] = DEBUG_CloneExpr(exp->un.call.arg[i]);
......@@ -898,10 +908,6 @@ DEBUG_FreeExpr(struct expr * exp)
DBG_free((char *) exp->un.structure.element_name);
break;
case EXPR_TYPE_CALL:
/*
* First, evaluate all of the arguments. If any of them are not
* evaluable, then bail.
*/
for(i=0; i < exp->un.call.nargs; i++)
{
DEBUG_FreeExpr(exp->un.call.arg[i]);
......
......@@ -14,7 +14,6 @@
#include "neexe.h"
#include "module.h"
#include "process.h"
#include "selectors.h"
#include "debugger.h"
#include "toolhelp.h"
......@@ -335,7 +334,7 @@ BOOL DEBUG_Normalize(struct name_hash * nh )
* Get the address of a named symbol.
*/
BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
DBG_ADDR *addr, int bp_flag )
DBG_ADDR *addr, int bp_flag )
{
char buffer[256];
struct name_hash *nh;
......@@ -450,7 +449,7 @@ BOOL DEBUG_SetSymbolValue( const char * name, const DBG_ADDR *addr )
if (!nh) return FALSE;
nh->addr = *addr;
nh->flags &= SYM_INVALID;
DBG_FIX_ADDR_SEG( &nh->addr, DS_reg(&DEBUG_context) );
DEBUG_FixAddress( &nh->addr, DEBUG_context.SegDs );
return TRUE;
}
......@@ -477,6 +476,7 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
char * lineinfo, *sourcefile;
int i;
char linebuff[16];
unsigned val;
if( rtn != NULL )
{
......@@ -637,9 +637,9 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
{
strcat(arglist, ", ");
}
DEBUG_READ_MEM_VERBOSE(ptr, &val, sizeof(val));
sprintf(argtmp, "%s=0x%x", nearest->local_vars[i].name, val);
sprintf(argtmp, "%s=0x%x", nearest->local_vars[i].name,
*ptr);
strcat(arglist, argtmp);
}
if( arglist[0] == '(' )
......@@ -1367,13 +1367,26 @@ BOOL DEBUG_GetStackSymbolValue( const char * name, DBG_ADDR *addr )
/* FIXME: what if regno == 0 ($eax) */
if( curr_func->local_vars[i].regno != 0 )
{
#if 0
/* FIXME: NEWDBG NIY */
/* this is a hack: addr points to the current processor context
* (as defined while entering the debugger), and uses a pointer
* to main memory (thus sharing the process address space *AND*
* the debugger address space, which is not good with address
* space separation in place)
*/
/*
* Register variable. Point to DEBUG_context field.
*/
addr->seg = 0;
addr->off = ((DWORD)&DEBUG_context) + reg_ofs[curr_func->local_vars[i].regno];
addr->off = ((DWORD)DEBUG_context) + reg_ofs[curr_func->local_vars[i].regno];
addr->type = curr_func->local_vars[i].type;
#else
fprintf(stderr, "No longer supported: value of register variable\n");
addr->seg = 0;
addr->off = 0;
addr->type = NULL;
#endif
return TRUE;
}
......@@ -1395,7 +1408,7 @@ DEBUG_InfoLocals()
unsigned int eip;
int i;
unsigned int * ptr;
int rtn = FALSE;
unsigned int val;
if( DEBUG_GetCurrentFrame(&curr_func, &eip, &ebp) == FALSE )
{
......@@ -1433,16 +1446,14 @@ DEBUG_InfoLocals()
}
else
{
ptr = (unsigned int *) (ebp + curr_func->local_vars[i].offset);
DEBUG_READ_MEM_VERBOSE((void*)(ebp + curr_func->local_vars[i].offset),
&val, sizeof(val));
fprintf(stderr, "%s:%s == 0x%8.8x\n",
curr_func->name, curr_func->local_vars[i].name,
*ptr);
curr_func->name, curr_func->local_vars[i].name, val);
}
}
rtn = TRUE;
return (rtn);
return TRUE;
}
int
......
......@@ -8,6 +8,10 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "toolhelp.h"
#include "debugger.h"
#include "expr.h"
......@@ -28,7 +32,7 @@ void DEBUG_PrintBasic( const DBG_ADDR *addr, int count, char format )
}
default_format = NULL;
value = DEBUG_GetExprValue((DBG_ADDR *) addr, &default_format);
value = DEBUG_GetExprValue(addr, &default_format);
switch(format)
{
......@@ -188,3 +192,264 @@ NULL
while(infotext[i]) fprintf(stderr,"%s\n", infotext[i++]);
}
/* FIXME: merge InfoClass and InfoClass2 */
void DEBUG_InfoClass(const char* name)
{
WNDCLASSEXA wca;
if (!GetClassInfoExA(0, name, &wca)) {
fprintf(stderr, "Cannot find class '%s'\n", name);
return;
}
fprintf(stderr, "Class '%s':\n", name);
fprintf(stderr,
"style=%08x wndProc=%08lx\n"
"inst=%04x icon=%04x cursor=%04x bkgnd=%04x\n"
"clsExtra=%d winExtra=%d\n",
wca.style, (DWORD)wca.lpfnWndProc, wca.hInstance,
wca.hIcon, wca.hCursor, wca.hbrBackground,
wca.cbClsExtra, wca.cbWndExtra);
/* FIXME:
* + print #windows (or even list of windows...)
* + print extra bytes => this requires a window handle on this very class...
*/
}
static void DEBUG_InfoClass2(HWND hWnd, const char* name)
{
WNDCLASSEXA wca;
if (!GetClassInfoExA(GetWindowLongA(hWnd, GWL_HINSTANCE), name, &wca)) {
fprintf(stderr, "Cannot find class '%s'\n", name);
return;
}
fprintf(stderr, "Class '%s':\n", name);
fprintf(stderr,
"style=%08x wndProc=%08lx\n"
"inst=%04x icon=%04x cursor=%04x bkgnd=%04x\n"
"clsExtra=%d winExtra=%d\n",
wca.style, (DWORD)wca.lpfnWndProc, wca.hInstance,
wca.hIcon, wca.hCursor, wca.hbrBackground,
wca.cbClsExtra, wca.cbWndExtra);
if (wca.cbClsExtra) {
int i;
WORD w;
fprintf(stderr, "Extra bytes:" );
for (i = 0; i < wca.cbClsExtra / 2; i++) {
w = GetClassWord(hWnd, i * 2);
/* FIXME: depends on i386 endian-ity */
fprintf(stderr, " %02x", HIBYTE(w));
fprintf(stderr, " %02x", LOBYTE(w));
}
fprintf(stderr, "\n" );
}
fprintf(stderr, "\n" );
}
struct class_walker {
ATOM* table;
int used;
int alloc;
};
static void DEBUG_WalkClassesHelper(HWND hWnd, struct class_walker* cw)
{
char clsName[128];
int i;
ATOM atom;
HWND child;
if (!GetClassNameA(hWnd, clsName, sizeof(clsName)))
return;
if ((atom = FindAtomA(clsName)) == 0)
return;
for (i = 0; i < cw->used; i++) {
if (cw->table[i] == atom)
break;
}
if (i == cw->used) {
if (cw->used >= cw->alloc) {
cw->alloc += 16;
cw->table = DBG_realloc(cw->table, cw->alloc * sizeof(ATOM));
}
cw->table[cw->used++] = atom;
DEBUG_InfoClass2(hWnd, clsName);
}
do {
if ((child = GetWindow(hWnd, GW_CHILD)) != 0)
DEBUG_WalkClassesHelper(child, cw);
} while ((hWnd = GetWindow(hWnd, GW_HWNDNEXT)) != 0);
}
void DEBUG_WalkClasses(void)
{
struct class_walker cw;
cw.table = NULL;
cw.used = cw.alloc = 0;
DEBUG_WalkClassesHelper(GetDesktopWindow(), &cw);
DBG_free(cw.table);
}
void DEBUG_DumpModule(DWORD mod)
{
fprintf(stderr, "No longer doing info module '0x%08lx'\n", mod);
}
void DEBUG_WalkModules(void)
{
fprintf(stderr, "No longer walking modules list\n");
}
void DEBUG_DumpQueue(DWORD q)
{
fprintf(stderr, "No longer doing info queue '0x%08lx'\n", q);
}
void DEBUG_WalkQueues(void)
{
fprintf(stderr, "No longer walking queues list\n");
}
void DEBUG_InfoWindow(HWND hWnd)
{
char clsName[128];
char wndName[128];
RECT clientRect;
RECT windowRect;
int i;
WORD w;
if (!GetClassNameA(hWnd, clsName, sizeof(clsName)))
strcpy(clsName, "-- Unknown --");
if (!GetWindowTextA(hWnd, wndName, sizeof(wndName)))
strcpy(wndName, "-- Empty --");
if (!GetClientRect(hWnd, &clientRect))
SetRectEmpty(&clientRect);
if (!GetWindowRect(hWnd, &windowRect))
SetRectEmpty(&windowRect);
/* FIXME missing fields: hmemTaskQ, hrgnUpdate, dce, flags, pProp, scroll */
fprintf(stderr,
"next=0x%04x child=0x%04x parent=0x%04x owner=0x%04x class='%s'\n"
"inst=%08lx active=%04x idmenu=%08lx\n"
"style=%08lx exstyle=%08lx wndproc=%08lx text='%s'\n"
"client=%d,%d-%d,%d window=%d,%d-%d,%d sysmenu=%04x\n",
GetWindow(hWnd, GW_HWNDNEXT),
GetWindow(hWnd, GW_CHILD),
GetParent(hWnd),
GetWindow(hWnd, GW_OWNER),
clsName,
GetWindowLongA(hWnd, GWL_HINSTANCE),
GetLastActivePopup(hWnd),
GetWindowLongA(hWnd, GWL_ID),
GetWindowLongA(hWnd, GWL_STYLE),
GetWindowLongA(hWnd, GWL_EXSTYLE),
GetWindowLongA(hWnd, GWL_WNDPROC),
wndName,
clientRect.left, clientRect.top, clientRect.right, clientRect.bottom,
windowRect.left, windowRect.top, windowRect.right, windowRect.bottom,
GetSystemMenu(hWnd, FALSE));
if (GetClassLongA(hWnd, GCL_CBWNDEXTRA)) {
fprintf(stderr, "Extra bytes:" );
for (i = 0; i < GetClassLongA(hWnd, GCL_CBWNDEXTRA) / 2; i++) {
w = GetWindowWord(hWnd, i * 2);
/* FIXME: depends on i386 endian-ity */
fprintf(stderr, " %02x", HIBYTE(w));
fprintf(stderr, " %02x", LOBYTE(w));
}
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
void DEBUG_WalkWindows(HWND hWnd, int indent)
{
char clsName[128];
char wndName[128];
HWND child;
if (!IsWindow(hWnd))
hWnd = GetDesktopWindow();
if (!indent) /* first time around */
fprintf(stderr,
"%-16.16s %-17.17s %-8.8s %s\n",
"hwnd", "Class Name", " Style", " WndProc Text");
do {
if (!GetClassNameA(hWnd, clsName, sizeof(clsName)))
strcpy(clsName, "-- Unknown --");
if (!GetWindowTextA(hWnd, wndName, sizeof(wndName)))
strcpy(wndName, "-- Empty --");
/* FIXME: missing hmemTaskQ */
fprintf(stderr, "%*s%04x%*s", indent, "", hWnd, 13-indent,"");
fprintf(stderr, "%-17.17s %08lx %08lx %.14s\n",
clsName, GetWindowLongA(hWnd, GWL_STYLE),
GetWindowLongA(hWnd, GWL_WNDPROC), wndName);
if ((child = GetWindow(hWnd, GW_CHILD)) != 0)
DEBUG_WalkWindows(child, indent + 1 );
} while ((hWnd = GetWindow(hWnd, GW_HWNDNEXT)) != 0);
}
void DEBUG_WalkProcess(void)
{
fprintf(stderr, "No longer walking processes list\n");
}
void DEBUG_WalkModref(DWORD p)
{
fprintf(stderr, "No longer walking module references list\n");
}
void DEBUG_InfoSegments(DWORD start, int length)
{
char flags[3];
DWORD i;
LDT_ENTRY le;
if (length == -1) length = (8192 - start);
for (i = start; i < start + length; i++)
{
if (!GetThreadSelectorEntry(DEBUG_CurrThread->handle, (i << 3)|7, &le))
continue;
if (le.HighWord.Bits.Type & 0x08)
{
flags[0] = (le.HighWord.Bits.Type & 0x2) ? 'r' : '-';
flags[1] = '-';
flags[2] = 'x';
}
else
{
flags[0] = 'r';
flags[1] = (le.HighWord.Bits.Type & 0x2) ? 'w' : '-';
flags[2] = '-';
}
fprintf(stderr,
"%04lx: sel=%04lx base=%08x limit=%08x %d-bit %c%c%c\n",
i, (i<<3)|7,
(le.HighWord.Bits.BaseHi << 24) +
(le.HighWord.Bits.BaseMid << 16) + le.BaseLow,
((le.HighWord.Bits.LimitHi << 8) + le.LimitLow) <<
(le.HighWord.Bits.Granularity ? 12 : 0),
le.HighWord.Bits.Default_Big ? 32 : 16,
flags[0], flags[1], flags[2] );
}
}
void DEBUG_InfoVirtual(void)
{
fprintf(stderr, "No longer providing virtual mapping information\n");
}
......@@ -22,11 +22,7 @@
#define PATH_MAX _MAX_PATH
#endif
#include "wine/winbase16.h"
#include "pe_image.h"
#include "peexe.h"
#include "debugger.h"
#include "task.h"
struct searchlist
{
......@@ -428,36 +424,17 @@ DEBUG_List(struct list_id * source1, struct list_id * source2,
DBG_ADDR DEBUG_LastDisassemble={NULL,0,0};
void DEBUG_GetCurrentAddress( DBG_ADDR *addr )
{
#ifdef __i386__
TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
addr->type = NULL;
addr->seg = CS_reg(&DEBUG_context);
addr->off = EIP_reg(&DEBUG_context);
if (ISV86(&DEBUG_context)) addr->seg |= (DWORD)(pTask? pTask->hModule : 0) << 16;
else if (IS_SELECTOR_SYSTEM(addr->seg)) addr->seg = 0;
GlobalUnlock16( GetCurrentTask() );
#else
addr->type = NULL;
addr->seg = 0;
addr->off = (DWORD)GET_IP(&DEBUG_context);
#endif
}
static int
_disassemble(DBG_ADDR *addr)
{
DEBUG_PrintAddress( addr, dbg_mode, TRUE );
fprintf(stderr,": ");
if (!DBG_CHECK_READ_PTR( addr, 1 )) return 0;
DEBUG_Disasm( addr, TRUE );
fprintf(stderr,"\n");
return 1;
char ch;
DEBUG_PrintAddress( addr, DEBUG_CurrThread->dbg_mode, TRUE );
fprintf(stderr,": ");
if (!DEBUG_READ_MEM_VERBOSE((void*)DEBUG_ToLinear(addr), &ch, sizeof(ch))) return 0;
DEBUG_Disasm( addr, TRUE );
fprintf(stderr,"\n");
return 1;
}
void
......@@ -465,7 +442,7 @@ _disassemble_fixaddr(DBG_ADDR *addr) {
DWORD seg2;
struct datatype *testtype;
DBG_FIX_ADDR_SEG(addr,CS_reg(&DEBUG_context));
DEBUG_FixAddress(addr, DEBUG_context.SegCs);
if( addr->type != NULL )
{
if( addr->type == DEBUG_TypeIntConst )
......@@ -482,7 +459,6 @@ _disassemble_fixaddr(DBG_ADDR *addr) {
}
else
{
if (!DBG_CHECK_READ_PTR( addr, 1 )) return;
DEBUG_TypeDerefPointer(addr, &testtype);
if( testtype != NULL || addr->type == DEBUG_TypeIntConst )
addr->off = DEBUG_GetExprValue(addr, NULL);
......
......@@ -134,8 +134,6 @@ static void stab_strcpy(char * dest, const char * source)
*dest++ = '\0';
}
extern void DEBUG_PrintAType(struct datatype*, int);
typedef struct {
char* name;
unsigned long value;
......
......@@ -345,7 +345,7 @@ DEBUG_InitTypes()
}
long long int
DEBUG_GetExprValue(DBG_ADDR * addr, char ** format)
DEBUG_GetExprValue(const DBG_ADDR * addr, char ** format)
{
DBG_ADDR address = *addr;
unsigned int rtn;
......@@ -360,12 +360,10 @@ DEBUG_GetExprValue(DBG_ADDR * addr, char ** format)
switch(addr->type->type)
{
case DT_BASIC:
if (!DBG_CHECK_READ_PTR( &address, addr->type->un.basic.basic_size))
{
return 0;
}
if (!DEBUG_READ_MEM_VERBOSE((void*)addr->off, &rtn, addr->type->un.basic.basic_size))
return 0;
memcpy(&rtn, (char *) addr->off, addr->type->un.basic.basic_size);
if( (addr->type->un.basic.b_signed)
&& ((addr->type->un.basic.basic_size & 3) != 0)
&& ((rtn >> (addr->type->un.basic.basic_size * 8 - 1)) != 0) )
......@@ -388,8 +386,9 @@ DEBUG_GetExprValue(DBG_ADDR * addr, char ** format)
}
break;
case DT_POINTER:
if (!DBG_CHECK_READ_PTR( &address, 1 )) return 0;
rtn = (unsigned int) *((unsigned char **)addr->off);
if (!DEBUG_READ_MEM_VERBOSE((void*)addr->off, &rtn, sizeof(void*)))
return 0;
type2 = addr->type->un.pointer.pointsto;
if (!type2)
......@@ -402,9 +401,8 @@ DEBUG_GetExprValue(DBG_ADDR * addr, char ** format)
if( type2->type == DT_BASIC && type2->un.basic.basic_size == 1 )
{
def_format = "\"%s\"";
address.off = rtn;
address.seg = 0;
if (!DBG_CHECK_READ_PTR( &address, 1 )) return 0;
if (!DEBUG_READ_MEM_VERBOSE((void*)rtn, &rtn, 1))
return 0;
break;
}
else
......@@ -414,13 +412,13 @@ DEBUG_GetExprValue(DBG_ADDR * addr, char ** format)
break;
case DT_ARRAY:
case DT_STRUCT:
if (!DBG_CHECK_READ_PTR( &address, 1 )) return 0;
rtn = (unsigned int) *((unsigned char **)addr->off);
if (!DEBUG_READ_MEM_VERBOSE((void*)addr->off, &rtn, sizeof(rtn)))
return 0;
def_format = "0x%8.8x";
break;
case DT_ENUM:
if (!DBG_CHECK_READ_PTR( &address, 1 )) return 0;
rtn = (unsigned int) *((unsigned char **)addr->off);
if (!DEBUG_READ_MEM_VERBOSE((void*)addr->off, &rtn, sizeof(rtn)))
return 0;
for(e = addr->type->un.enumeration.members; e; e = e->next )
{
if( e->value == rtn )
......@@ -452,22 +450,23 @@ DEBUG_GetExprValue(DBG_ADDR * addr, char ** format)
}
unsigned int
DEBUG_TypeDerefPointer(DBG_ADDR * addr, struct datatype ** newtype)
DEBUG_TypeDerefPointer(const DBG_ADDR * addr, struct datatype ** newtype)
{
DBG_ADDR address = *addr;
unsigned int val;
/*
* Make sure that this really makes sense.
*/
if( addr->type->type != DT_POINTER )
if( addr->type->type != DT_POINTER || !DEBUG_READ_MEM((void*)addr->off, &val, sizeof(val)))
{
*newtype = NULL;
return 0;
}
*newtype = addr->type->un.pointer.pointsto;
address.off = *(unsigned int*) (addr->off);
return (unsigned int)DBG_ADDR_TO_LIN(&address); /* FIXME: is this right (or "better") ? */
address.off = val;
return DEBUG_ToLinear(&address); /* FIXME: is this right (or "better") ? */
}
unsigned int
......@@ -718,7 +717,7 @@ int DEBUG_GetObjectSize(struct datatype * dt)
}
unsigned int
DEBUG_ArrayIndex(DBG_ADDR * addr, DBG_ADDR * result, int index)
DEBUG_ArrayIndex(const DBG_ADDR * addr, DBG_ADDR * result, int index)
{
int size;
......
......@@ -163,6 +163,7 @@ char dbch_wave[] = "\003wave";
char dbch_win[] = "\003win";
char dbch_win16drv[] = "\003win16drv";
char dbch_win32[] = "\003win32";
char dbch_winedbg[] = "\003winedbg";
char dbch_wing[] = "\003wing";
char dbch_winsock[] = "\003winsock";
char dbch_winspool[] = "\003winspool";
......@@ -170,7 +171,7 @@ char dbch_wnet[] = "\003wnet";
char dbch_x11[] = "\003x11";
char dbch_x11drv[] = "\003x11drv";
#define DEBUG_CHANNEL_COUNT 163
#define DEBUG_CHANNEL_COUNT 164
static char * const debug_channels[DEBUG_CHANNEL_COUNT] = {
dbch_accel,
......@@ -330,6 +331,7 @@ static char * const debug_channels[DEBUG_CHANNEL_COUNT] = {
dbch_win,
dbch_win16drv,
dbch_win32,
dbch_winedbg,
dbch_wing,
dbch_winsock,
dbch_winspool,
......
......@@ -7,7 +7,6 @@
#include <assert.h>
#include "wine/winbase16.h"
#include "callback.h"
#include "debugger.h"
#include "main.h"
#include "miscemu.h"
#include "module.h"
......@@ -22,6 +21,7 @@
static int MAIN_argc;
static char **MAIN_argv;
extern void DEBUG_StartDebugger(DWORD);
/***********************************************************************
* Main loop of initial task
......@@ -29,7 +29,6 @@ static char **MAIN_argv;
void MAIN_EmulatorRun( void )
{
char startProg[256], defProg[256];
HINSTANCE handle;
int i, tasks = 0;
MSG msg;
BOOL err_msg = FALSE;
......@@ -71,18 +70,31 @@ void MAIN_EmulatorRun( void )
/* Load and run executables given on command line */
for (i = 1; i < MAIN_argc; i++)
{
if ((handle = WinExec( MAIN_argv[i], SW_SHOWNORMAL )) < 32)
{
PROCESS_INFORMATION info;
STARTUPINFOA startup;
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_SHOWNORMAL;
if (!CreateProcessA(NULL, MAIN_argv[i], NULL, NULL, FALSE, 0,
NULL, NULL, &startup, &info)) {
err_msg = TRUE;
MESSAGE("wine: can't exec '%s': ", MAIN_argv[i]);
switch (handle)
{
case 2: MESSAGE("main executable or required DLL not found\n" ); break;
case 11: MESSAGE("invalid exe file\n" ); break;
default: MESSAGE("error=%d\n", handle ); break;
}
MESSAGE("wine: can't exec '%s': ", MAIN_argv[i]);
switch (GetLastError())
{
case 2: MESSAGE("file not found\n" ); break;
case 11: MESSAGE("invalid exe file\n" ); break;
default: MESSAGE("error=%ld\n", GetLastError() ); break;
}
}
else tasks++;
else
{
tasks++;
/* hack until wine debugger can be moved to a separate process */
DEBUG_StartDebugger(info.dwProcessId);
}
}
if (!tasks)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment