[RFA/windows] Spurious "dll not found" error messages on x64-windows.

Joel Brobecker
2010-02-04T04:13:03Z

When running 32bit programs on x64 windows, GDB produces the following
error messages:

(gdb) start
Temporary breakpoint 1 at 0x4015ae: file simple_main.adb, line 4.
Starting program: C:\[...]/simple_main.exe
[New Thread 31464.0x8cd4]
!!! -> Error: dll starting at 0x77a60000 not found.
!!! -> Error: dll starting at 0x77650000 not found.
!!! -> Error: dll starting at 0x77a60000 not found.
!!! -> Error: dll starting at 0x77990000 not found.

Temporary breakpoint 1, simple_main () at simple_main.adb:4
4 simple.test_simple;

This is something that was already discussed previously for gdbserver,
where these events were not well handled and eventually lead to a crash:
http://www.sourceware.org/ml/gdb-patches/2010-02/msg00011.html

A quick investigation showed that there were no dll-load-events that
correspond to these base addresses. A search on the net points at
the WOW layer which interfaces between the 32bit and 64bit worlds.

My first proposal is to silently ignore these spurious events during
the startup phase. We could probably refine this check by also verifying
that we are running a 32bit exe on 64bit Windows. But given that this
error did not trigger in the past, I think that'd be overkill. In fact,
I don't think that ditching the error would be a big loss (we could turn
it into a complaint if we want to be able to see it in special occasions).

gdb/ChangeLog:

* windows-nat.c (handle_unload_dll): Disable unknown-dll error
during the inferior startup phase.

Tested on x86_64-windows using a x86-windows compiler/debugger.
OK to apply?

Thanks,
--
Joel

---
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 2740366..4c2d1d8 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -783,7 +783,16 @@ handle_unload_dll (void *dummy)
return 1;
}

- error (_("Error: dll starting at %s not found."),
+ /* We did not find any DLL that was previously loaded at this address.
+ This is normally an error. However, we have observed that running
+ 32bit applications on x64 Windows causes us to receive 4 mysterious
+ UNLOAD_DLL_DEBUG_EVENTs during the startup phase. These events are
+ apparently caused by the WOW layer (this is the interface between
+ the 32bit and 64bit worlds). Because of these events, we only report
+ the error after the initialization phase is complete (there is not
+ much data that we can use to identify these spurious events). */
+ if (windows_initialization_done)
+ error (_("Error: dll starting at %s not found."),
host_address_to_string (lpBaseOfDll));

return 0;
--
1.6.3.3