Fix Debugger for Flat PC and Non-Flat Frame
Robert Shearman
rob at codeweavers.com
Wed Sep 22 20:05:12 CDT 2004
Hi,
This is a rare case, but it can happen. The best example is
wine/dlls/kernel/relay16asm.s
Without this patch StackWalk would assert() on the second iteration.
Rob
Changelog:
Fix debugger for flat PC and non-flat frame.
-------------- next part --------------
Index: wine/dlls/dbghelp/stack.c
===================================================================
RCS file: /home/wine/wine/dlls/dbghelp/stack.c,v
retrieving revision 1.4
diff -u -p -r1.4 stack.c
--- wine/dlls/dbghelp/stack.c 30 Apr 2004 04:15:41 -0000 1.4
+++ wine/dlls/dbghelp/stack.c 23 Sep 2004 00:05:03 -0000
@@ -113,6 +113,13 @@ BOOL WINAPI StackWalk(DWORD MachineType,
{
THREAD_BASIC_INFORMATION info;
+ if ((frame->AddrPC.Mode == AddrModeFlat) &&
+ (frame->AddrFrame.Mode != AddrModeFlat))
+ {
+ WARN("Bad AddrPC.Mode / AddrFrame.Mode combination\n");
+ goto done_err;
+ }
+
/* Init done */
curr_mode = (frame->AddrPC.Mode == AddrModeFlat) ?
stm_32bit : stm_16bit;
Index: wine/programs/winedbg/stack.c
===================================================================
RCS file: /home/wine/wine/programs/winedbg/stack.c,v
retrieving revision 1.7
diff -u -p -r1.7 stack.c
--- wine/programs/winedbg/stack.c 22 Aug 2004 22:35:36 -0000 1.7
+++ wine/programs/winedbg/stack.c 23 Sep 2004 00:05:03 -0000
@@ -188,6 +188,13 @@ void stack_backtrace(DWORD tid, BOOL noi
memory_get_current_frame(&sf.AddrFrame);
memory_get_current_pc(&sf.AddrPC);
+ /* don't confuse StackWalk by passing in inconsistent addresses */
+ if ((sf.AddrPC.Mode == AddrModeFlat) && (sf.AddrFrame.Mode != AddrModeFlat))
+ {
+ sf.AddrFrame.Offset = memory_to_linear_addr(&sf.AddrFrame);
+ sf.AddrFrame.Mode = AddrModeFlat;
+ }
+
if (noisy) dbg_printf("Backtrace:\n");
while (StackWalk(IMAGE_FILE_MACHINE_I386, dbg_curr_process->handle,
thread->handle, &sf, &dbg_context, NULL, SymFunctionTableAccess,
More information about the wine-patches
mailing list