This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gdbserver] Restrict toolhelp.dll usage.


Hi,

I was experiencing some device hangs with current cvs gdbserver on Windows CE.

It happens that on some versions of Windows and Windows CE, we can't create
toolhelp snapshots while the inferior is stopped in a LOAD_DLL_DEBUG_EVENT due
to a dll load.  If we do, get a lockup similar to a loader lock.  I can't find
documentation describing this, but I see others having similar problems.  Eg,
from a post from OllyDgb people at:
http://www.woodmann.com/forum/showthread.php?t=8163

     "1.[Win2000] CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,debuggee)
      locks OllyDbg when debugged application is paused on debugging
      event which makes toolhelp functions unusable."

Tested on arm-wince-mingw32ce, and against a Cygwin gdbserver - no regressions.

Cheers,
Pedro Alves


2007-08-11  Pedro Alves  <pedro_alves@portugalmail.pt>

	* win32-low.c (handle_load_dll): Don't use toolhelp when waiting.

---
 gdb/gdbserver/win32-low.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Index: src/gdb/gdbserver/win32-low.c
===================================================================
--- src.orig/gdb/gdbserver/win32-low.c	2007-08-11 18:06:06.000000000 +0100
+++ src/gdb/gdbserver/win32-low.c	2007-08-11 18:37:10.000000000 +0100
@@ -1081,9 +1081,18 @@ handle_load_dll (void)
 
   dll_buf[0] = dll_buf[sizeof (dll_buf) - 1] = '\0';
 
-  if (!psapi_get_dll_name ((DWORD) (event->lpBaseOfDll), dll_buf)
-      && !toolhelp_get_dll_name ((DWORD) (event->lpBaseOfDll), dll_buf))
-    dll_buf[0] = dll_buf[sizeof (dll_buf) - 1] = '\0';
+  /* Windows does not report the image name of the dlls in the debug
+     event on attaches.  We resort to iterating over the list of
+     loaded dlls looking for a match by image base.  */
+  if (!psapi_get_dll_name ((DWORD) event->lpBaseOfDll, dll_buf))
+    {
+      if (!server_waiting)
+	/* On some versions of Windows and Windows CE, we can't create
+	   toolhelp snapshots while the inferior is stopped in a
+	   LOAD_DLL_DEBUG_EVENT due to a dll load, but we can while
+	   Windows is reporting the already loaded dlls.  */
+	toolhelp_get_dll_name ((DWORD) event->lpBaseOfDll, dll_buf);
+    }
 
   dll_name = dll_buf;
 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]