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]

[RFA] win32-nat.c: Add dll names if debugevents is on


 This is a very simple patch that add
a line giving the name of the newly loaded 
or unloaded dll, 
when 'set debugevents on' is used.
  It does not change the
default behavior of cygwin/mingw32 gdb
as debugevents is off by default.

 I always found it frustrating to get the
events LOAD_DLL_DEBUG_EVENT and
UNLOAD_DLL_DEBUG_EVENT without getting the name of the 
dll.


This is the new behavior:

$ gdb-dllnames.exe ./run.exe
GNU gdb (GDB) 6.8.50.20080611-cvs
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-cygwin".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
(gdb) set debugevents on
(gdb) r
Starting program:
/usr/local/src/gdbcvs/build-bare/gdb/testsuite/gdb.base/run.ex
e
gdb: win32_init_thread_list
gdb: kernel event for pid=4068 tid=2992 code=CREATE_PROCESS_DEBUG_EVENT)
[New thread 4068.0xbb0]
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=LOAD_DLL_DEBUG_EVENT)
Loading dll "ntdll.dll".
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=LOAD_DLL_DEBUG_EVENT)
Loading dll "D:\WINDOWS\system32\kernel32.dll".
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=LOAD_DLL_DEBUG_EVENT)
Loading dll "E:\cygwin\home\Pierre\bin\cygwin1.dll".
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=LOAD_DLL_DEBUG_EVENT)
Loading dll "D:\WINDOWS\system32\ADVAPI32.DLL".
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=LOAD_DLL_DEBUG_EVENT)
Loading dll "D:\WINDOWS\system32\RPCRT4.dll".
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=LOAD_DLL_DEBUG_EVENT)
Loading dll "D:\WINDOWS\system32\Secur32.dll".
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=EXCEPTION_DEBUG_EVENT)
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=6f8 code=CREATE_THREAD_DEBUG_EVENT)
[New thread 4068.0x6f8]
ContinueDebugEvent (cpid=4068, ctid=1784, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=OUTPUT_DEBUG_STRING_EVENT)
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=OUTPUT_DEBUG_STRING_EVENT)
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=LOAD_DLL_DEBUG_EVENT)
Loading dll "D:\WINDOWS\system32\user32.dll".
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=LOAD_DLL_DEBUG_EVENT)
Loading dll "D:\WINDOWS\system32\GDI32.dll".
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=LOAD_DLL_DEBUG_EVENT)
Loading dll "D:\WINDOWS\system32\IMM32.DLL".
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
usage:  factorial <number>
gdb: kernel event for pid=4068 tid=1784 code=EXIT_THREAD_DEBUG_EVENT)
ContinueDebugEvent (cpid=4068, ctid=1784, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=LOAD_DLL_DEBUG_EVENT)
Loading dll "D:\WINDOWS\system32\psapi.dll".
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: kernel event for pid=4068 tid=2992 code=EXIT_PROCESS_DEBUG_EVENT)

Program exited with code 01.
ContinueDebugEvent (cpid=4068, ctid=2992, DBG_CONTINUE);
gdb: win32_close, inferior_ptid=2992
(gdb) q

Compared to the current behavior:

Pierre@d620-muller ~/gdbcvs/build-bare/gdb/testsuite/gdb.base
$ ../../gdb ./run.exe
GNU gdb (GDB) 6.8.50.20080611-cvs
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-cygwin".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
(gdb) set debugevents on
(gdb) r
Starting program:
/usr/local/src/gdbcvs/build-bare/gdb/testsuite/gdb.base/run.ex
e
gdb: win32_init_thread_list
gdb: kernel event for pid=260 tid=2540 code=CREATE_PROCESS_DEBUG_EVENT)
[New thread 260.0x9ec]
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=LOAD_DLL_DEBUG_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=LOAD_DLL_DEBUG_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=LOAD_DLL_DEBUG_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=LOAD_DLL_DEBUG_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=LOAD_DLL_DEBUG_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=LOAD_DLL_DEBUG_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=EXCEPTION_DEBUG_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=ec8 code=CREATE_THREAD_DEBUG_EVENT)
[New thread 260.0xec8]
ContinueDebugEvent (cpid=260, ctid=3784, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=OUTPUT_DEBUG_STRING_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=OUTPUT_DEBUG_STRING_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=LOAD_DLL_DEBUG_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=LOAD_DLL_DEBUG_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=LOAD_DLL_DEBUG_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
usage:  factorial <number>
gdb: kernel event for pid=260 tid=3784 code=EXIT_THREAD_DEBUG_EVENT)
ContinueDebugEvent (cpid=260, ctid=3784, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=LOAD_DLL_DEBUG_EVENT)
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: kernel event for pid=260 tid=2540 code=EXIT_PROCESS_DEBUG_EVENT)

Program exited with code 01.
ContinueDebugEvent (cpid=260, ctid=2540, DBG_CONTINUE);
gdb: win32_close, inferior_ptid=2540
(gdb) q

Is this OK to commit?


Pierre Muller
Pascal language support maintainer for GDB




ChangeLog entry:

2008-12-13  Pierre Muller  <muller@ics.u-strasbg.fr>

	* win32-nat.c (handle_load_dll): Give dll name
	if debug_events is on.
	(handle_unload_dll): Likewise.



$ cvs diff -up gdb/win32-nat.c
Index: gdb/win32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/win32-nat.c,v
retrieving revision 1.152
diff -u -p -r1.152 win32-nat.c
--- gdb/win32-nat.c     20 May 2008 18:36:36 -0000      1.152
+++ gdb/win32-nat.c     13 Jun 2008 11:27:18 -0000
@@ -744,6 +744,7 @@ handle_load_dll (void *dummy)
   if (!dll_name)
     return 1;

+  DEBUG_EVENTS (("gdb: Loading dll \"%s\".\n",dll_name));
   solib_end->next = win32_make_so (dll_name, (DWORD) event->lpBaseOfDll);
   solib_end = solib_end->next;

@@ -771,6 +772,9 @@ handle_unload_dll (void *dummy)
        so->next = sodel->next;
        if (!so->next)
          solib_end = so;
+       if (sodel->so_original_name)
+         DEBUG_EVENTS (("gdb: removing dll \"%s\".\n",
+                        sodel->so_original_name));
        win32_free_so (sodel);
        solib_add (NULL, 0, NULL, auto_solib_add);
        return 1;



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