Environment variable support in AeDebug/Debugger
François Gouget
fgouget at codeweavers.com
Sun Oct 21 22:21:25 CDT 2001
In my previous patch I suggested putting the following for AeDebug:
"Debugger"=str(2):"%WINEDBG% --debugmsg -all -- --auto %ld %ld"
Why "%WINEDBG%"?
'win32/except.c' starts the debugger using CreateProcess. So it will
only find winedbg if it is in the Windows path. Unfortunately winedbg is
usually installed in '/usr/bin' which is not in the Windows path. One
solution is to put winedbg somewhere on the "c:" drive (via symlinks for
instance). The other solution is to set WINEDBG so that it point to
wherever it is that winedbg is installed. This can be done in a script
that then launches wine for instance.
But then, that requires that 'win32/except.c' expands environment
variable in the "Debugger" string. Hence this patch.
Changelog:
François Gouget <fgouget at codeweavers.com>
* win32/except.c
Expand environment variables in "Debugger" setting
Replace fixed-size buffers with dynamic ones
--
François Gouget
fgouget at codeweavers.com
-------------- next part --------------
Index: win32/except.c
===================================================================
RCS file: /home/wine/wine/win32/except.c,v
retrieving revision 1.47
diff -u -r1.47 except.c
--- win32/except.c 2001/10/21 15:18:15 1.47
+++ win32/except.c 2001/10/21 19:18:52
@@ -197,8 +197,10 @@
DWORD bAuto = FALSE;
PROCESS_INFORMATION info;
STARTUPINFOA startup;
- char buffer[256];
- char format[256];
+ char* cmdline = NULL;
+ char* format = NULL;
+ DWORD format_size;
+ BOOL ret = FALSE;
MESSAGE("wine: Unhandled exception, starting debugger...\n");
@@ -207,9 +209,21 @@
DWORD type;
DWORD count;
- count = sizeof(format);
- if (RegQueryValueExA(hDbgConf, "Debugger", 0, &type, format, &count))
- format[0] = 0;
+ format_size = 0;
+ if (!RegQueryValueExA(hDbgConf, "Debugger", 0, &type, NULL, &format_size)) {
+ format = HeapAlloc(GetProcessHeap(), 0, format_size);
+ RegQueryValueExA(hDbgConf, "Debugger", 0, &type, format, &format_size);
+ if (type==REG_EXPAND_SZ) {
+ char* tmp;
+
+ /* Expand environment variable references */
+ format_size=ExpandEnvironmentStringsA(format,NULL,0);
+ tmp=HeapAlloc(GetProcessHeap(), 0, format_size);
+ ExpandEnvironmentStringsA(format,tmp,format_size);
+ HeapFree(GetProcessHeap(), 0, format);
+ format=tmp;
+ }
+ }
count = sizeof(bAuto);
if (RegQueryValueExA(hDbgConf, "Auto", 0, &type, (char*)&bAuto, &count))
@@ -224,7 +238,7 @@
RegCloseKey(hDbgConf);
} else {
/* try a default setup... */
- strcpy( format, "debugger/winedbg %ld %ld" );
+ strcpy( format, "winedbg --debugmsg -all -- --auto %ld %ld" );
}
if (!bAuto)
@@ -235,30 +249,43 @@
if (mod) pMessageBoxA = (MessageBoxA_funcptr)GetProcAddress( mod, "MessageBoxA" );
if (pMessageBoxA)
{
+ char buffer[256];
format_exception_msg( epointers, buffer, sizeof(buffer) );
if (pMessageBoxA( 0, buffer, "Exception raised", MB_YESNO | MB_ICONHAND ) == IDNO)
{
TRACE("Killing process\n");
- return FALSE;
+ goto EXIT;
}
}
}
- TRACE("Starting debugger (fmt=%s)\n", format);
- sprintf(buffer, format, GetCurrentProcessId(), hEvent);
- memset(&startup, 0, sizeof(startup));
- startup.cb = sizeof(startup);
- startup.dwFlags = STARTF_USESHOWWINDOW;
- startup.wShowWindow = SW_SHOWNORMAL;
- if (CreateProcessA(NULL, buffer, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &info)) {
- /* wait for debugger to come up... */
- WaitForSingleObject(hEvent, INFINITE);
- return TRUE;
+ if (format) {
+ TRACE("Starting debugger (fmt=%s)\n", format);
+ cmdline=HeapAlloc(GetProcessHeap(), 0, format_size+2*20);
+ sprintf(cmdline, format, GetCurrentProcessId(), hEvent);
+ memset(&startup, 0, sizeof(startup));
+ startup.cb = sizeof(startup);
+ startup.dwFlags = STARTF_USESHOWWINDOW;
+ startup.wShowWindow = SW_SHOWNORMAL;
+ if (CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &info)) {
+ /* wait for debugger to come up... */
+ WaitForSingleObject(hEvent, INFINITE);
+ ret = TRUE;
+ goto EXIT;
+ }
+ } else {
+ cmdline = NULL;
}
ERR("Couldn't start debugger (%s) (%ld)\n"
"Read the Wine Developers Guide on how to set up winedbg or another debugger\n",
- buffer, GetLastError());
- return FALSE;
+ debugstr_a(cmdline), GetLastError());
+
+EXIT:
+ if (cmdline)
+ HeapFree(GetProcessHeap(), 0, cmdline);
+ if (format)
+ HeapFree(GetProcessHeap(), 0, format);
+ return ret;
}
/******************************************************************
More information about the wine-patches
mailing list