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.
diff --git a/debugger/info.c b/debugger/info.c
index 19ca90c..606e50c 100644
--- a/debugger/info.c
+++ b/debugger/info.c
@@ -29,7 +29,7 @@
assert(value->cookie == DV_TARGET || value->cookie == DV_HOST);
if( value->type == NULL )
{
- fprintf(stderr, "Unable to evaluate expression\n");
+ DEBUG_Printf(DBG_CHN_MESG, "Unable to evaluate expression\n");
return;
}
@@ -41,34 +41,34 @@
case 'x':
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
{
- DEBUG_nchar += fprintf( stderr, "0x%08lx", (long unsigned int) res );
+ DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, "0x%08lx", (long unsigned int) res );
}
break;
case 'd':
- DEBUG_nchar += fprintf( stderr, "%ld\n", (long int) res );
+ DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, "%ld\n", (long int) res );
break;
case 'c':
- DEBUG_nchar += fprintf( stderr, "%d = '%c'",
- (char)(res & 0xff), (char)(res & 0xff) );
+ DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, "%d = '%c'",
+ (char)(res & 0xff), (char)(res & 0xff) );
break;
case 'i':
case 's':
case 'w':
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:
if( default_format != 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
{
@@ -80,7 +80,7 @@
*/
for (ptr = default_format; *ptr; ptr++)
{
- fprintf(stderr, "[%c]", *ptr);
+ DEBUG_Printf(DBG_CHN_MESG, "[%c]", *ptr);
if (*ptr == '%') state++;
else if (state == 1)
@@ -130,10 +130,10 @@
const char *name = DEBUG_FindNearestSymbol( addr, flag, &rtn.sym, 0,
&rtn.list );
- if (addr->seg) fprintf( stderr, "0x%04lx:", addr->seg&0xFFFF );
- if (addrlen == 16) fprintf( stderr, "0x%04lx", addr->off );
- else fprintf( stderr, "0x%08lx", addr->off );
- if (name) fprintf( stderr, " (%s)", name );
+ if (addr->seg) DEBUG_Printf( DBG_CHN_MESG, "0x%04lx:", addr->seg&0xFFFF );
+ if (addrlen == 16) DEBUG_Printf( DBG_CHN_MESG, "0x%04lx", addr->off );
+ else DEBUG_Printf( DBG_CHN_MESG, "0x%08lx", addr->off );
+ if (name) DEBUG_Printf( DBG_CHN_MESG, " (%s)", name );
return rtn;
}
/***********************************************************************
@@ -152,10 +152,10 @@
const char *name = DEBUG_FindNearestSymbol( addr, flag, &rtn.sym, ebp,
&rtn.list );
- if (addr->seg) fprintf( stderr, "0x%04lx:", addr->seg );
- if (addrlen == 16) fprintf( stderr, "0x%04lx", addr->off );
- else fprintf( stderr, "0x%08lx", addr->off );
- if (name) fprintf( stderr, " (%s)", name );
+ if (addr->seg) DEBUG_Printf( DBG_CHN_MESG, "0x%04lx:", addr->seg );
+ if (addrlen == 16) DEBUG_Printf( DBG_CHN_MESG, "0x%04lx", addr->off );
+ else DEBUG_Printf( DBG_CHN_MESG, "0x%08lx", addr->off );
+ if (name) DEBUG_Printf( DBG_CHN_MESG, " (%s)", name );
return rtn;
}
@@ -205,7 +205,7 @@
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 @@
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 */
@@ -244,19 +244,19 @@
{
WNDCLASSEXA wca;
- if (!GetClassInfoExA(0, name, &wca)) {
- fprintf(stderr, "Cannot find class '%s'\n", name);
+ if (!GetClassInfoEx(0, name, &wca)) {
+ DEBUG_Printf(DBG_CHN_MESG, "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);
+ DEBUG_Printf(DBG_CHN_MESG, "Class '%s':\n", name);
+ DEBUG_Printf(DBG_CHN_MESG,
+ "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...)
@@ -268,34 +268,34 @@
{
WNDCLASSEXA wca;
- if (!GetClassInfoExA(GetWindowLongA(hWnd, GWL_HINSTANCE), name, &wca)) {
- fprintf(stderr, "Cannot find class '%s'\n", name);
+ if (!GetClassInfoEx(GetWindowLong(hWnd, GWL_HINSTANCE), name, &wca)) {
+ DEBUG_Printf(DBG_CHN_MESG, "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);
+ DEBUG_Printf(DBG_CHN_MESG, "Class '%s':\n", name);
+ DEBUG_Printf(DBG_CHN_MESG,
+ "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:" );
+ DEBUG_Printf(DBG_CHN_MESG, "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));
+ DEBUG_Printf(DBG_CHN_MESG, " %02x", HIBYTE(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 {
@@ -311,9 +311,9 @@
ATOM atom;
HWND child;
- if (!GetClassNameA(hWnd, clsName, sizeof(clsName)))
+ if (!GetClassName(hWnd, clsName, sizeof(clsName)))
return;
- if ((atom = FindAtomA(clsName)) == 0)
+ if ((atom = FindAtom(clsName)) == 0)
return;
for (i = 0; i < cw->used; i++) {
@@ -346,12 +346,12 @@
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)
{
- fprintf(stderr, "No longer walking queues list\n");
+ DEBUG_Printf(DBG_CHN_MESG, "No longer walking queues list\n");
}
void DEBUG_InfoWindow(HWND hWnd)
@@ -363,9 +363,9 @@
int i;
WORD w;
- if (!GetClassNameA(hWnd, clsName, sizeof(clsName)))
+ if (!GetClassName(hWnd, clsName, sizeof(clsName)))
strcpy(clsName, "-- Unknown --");
- if (!GetWindowTextA(hWnd, wndName, sizeof(wndName)))
+ if (!GetWindowText(hWnd, wndName, sizeof(wndName)))
strcpy(wndName, "-- Empty --");
if (!GetClientRect(hWnd, &clientRect))
SetRectEmpty(&clientRect);
@@ -373,38 +373,38 @@
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));
+ DEBUG_Printf(DBG_CHN_MESG,
+ "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,
+ GetWindowLong(hWnd, GWL_HINSTANCE),
+ GetLastActivePopup(hWnd),
+ GetWindowLong(hWnd, GWL_ID),
+ GetWindowLong(hWnd, GWL_STYLE),
+ GetWindowLong(hWnd, GWL_EXSTYLE),
+ GetWindowLong(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++) {
+ if (GetClassLong(hWnd, GCL_CBWNDEXTRA)) {
+ DEBUG_Printf(DBG_CHN_MESG, "Extra bytes:" );
+ for (i = 0; i < GetClassLong(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));
+ DEBUG_Printf(DBG_CHN_MESG, " %02x", HIBYTE(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)
@@ -417,21 +417,21 @@
hWnd = GetDesktopWindow();
if (!indent) /* first time around */
- fprintf(stderr,
- "%-16.16s %-17.17s %-8.8s %s\n",
- "hwnd", "Class Name", " Style", " WndProc Text");
+ DEBUG_Printf(DBG_CHN_MESG,
+ "%-16.16s %-17.17s %-8.8s %s\n",
+ "hwnd", "Class Name", " Style", " WndProc Text");
do {
- if (!GetClassNameA(hWnd, clsName, sizeof(clsName)))
+ if (!GetClassName(hWnd, clsName, sizeof(clsName)))
strcpy(clsName, "-- Unknown --");
- if (!GetWindowTextA(hWnd, wndName, sizeof(wndName)))
+ if (!GetWindowText(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);
+ DEBUG_Printf(DBG_CHN_MESG, "%*s%04x%*s", indent, "", hWnd, 13-indent,"");
+ DEBUG_Printf(DBG_CHN_MESG, "%-17.17s %08lx %08lx %.14s\n",
+ clsName, GetWindowLong(hWnd, GWL_STYLE),
+ GetWindowLong(hWnd, GWL_WNDPROC), wndName);
if ((child = GetWindow(hWnd, GW_CHILD)) != 0)
DEBUG_WalkWindows(child, indent + 1 );
@@ -440,12 +440,12 @@
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)
{
- 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)
@@ -473,19 +473,19 @@
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] );
+ DEBUG_Printf(DBG_CHN_MESG,
+ "%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");
+ DEBUG_Printf(DBG_CHN_MESG, "No longer providing virtual mapping information\n");
}