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]

[commit] Fix early loading of ld.so


I added support to put an implicitly loaded ld.so on the shared
library list as soon as we found it.  This makes things much simpler
when debugging something that happens during dynamic loading.
Unfortunately it's hard to write a test for, but this time I've tried
since I approved a patch which broke it not long afterwards :-)

You don't need gdbserver to see this, but it's easiest.  Here's
a working GDB:

drow@caradoc:~% gdb /bin/ls
GNU gdb 6.6.90.20070912-debian
...
(gdb) tar rem :1234
Remote debugging using :1234
warning: Can not parse XML target description; XML support was disabled at compile time
(no debugging symbols found)
0x00002aaaaaaaba60 in ?? () from /lib64/ld-linux-x86-64.so.2
(gdb) i sharedlibrary
>From                To                  Syms Read   Shared Object
Library
0x00002aaaaaaaba60  0x00002aaaaaac1984  Yes         /lib64/ld-linux-x86-64.so.2

Here's a broken one:

drow@caradoc:~% /space/fsf/x86-64/commit-gdb/gdb/gdb /bin/ls
GNU gdb 6.7.50-20071003-cvs
...
(gdb) tar rem :1234
Remote debugging using :1234
0x00002aaaaaaaba60 in ?? ()
(gdb) i shared
No shared libraries loaded at this time.

Here's the obvious fix and a testcase version of the above.  I
tested it on x86_64-linux and committed it.

-- 
Daniel Jacobowitz
CodeSourcery

2007-10-09  Daniel Jacobowitz  <dan@codesourcery.com>

	* solib-svr4.c (enable_break): Add the dynamic linker also if
	auxv succeeds.

2007-10-09  Daniel Jacobowitz  <dan@codesourcery.com>

	* gdb.server/server-run.exp: Test for dynamic linker symbols.

Index: solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.76
diff -u -p -r1.76 solib-svr4.c
--- solib-svr4.c	17 Sep 2007 19:32:53 -0000	1.76
+++ solib-svr4.c	9 Oct 2007 17:40:09 -0000
@@ -986,6 +986,7 @@ enable_break (void)
       char *buf;
       CORE_ADDR load_addr = 0;
       int load_addr_found = 0;
+      int loader_found_in_list = 0;
       struct so_list *so;
       bfd *tmp_bfd = NULL;
       struct target_ops *tmp_bfd_target;
@@ -1038,6 +1039,7 @@ enable_break (void)
 	  if (strcmp (buf, so->so_original_name) == 0)
 	    {
 	      load_addr_found = 1;
+	      loader_found_in_list = 1;
 	      load_addr = LM_ADDR_CHECK (so, tmp_bfd);
 	      break;
 	    }
@@ -1058,9 +1060,11 @@ enable_break (void)
          fallback method because it has actually been working well in
          most cases.  */
       if (!load_addr_found)
+	load_addr = (read_pc ()
+		     - exec_entry_point (tmp_bfd, tmp_bfd_target));
+
+      if (!loader_found_in_list)
 	{
-	  load_addr = (read_pc ()
-		       - exec_entry_point (tmp_bfd, tmp_bfd_target));
 	  debug_loader_name = xstrdup (buf);
 	  debug_loader_offset_p = 1;
 	  debug_loader_offset = load_addr;
Index: testsuite/gdb.server/server-run.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.server/server-run.exp,v
retrieving revision 1.4
diff -u -p -r1.4 server-run.exp
--- testsuite/gdb.server/server-run.exp	23 Aug 2007 18:14:19 -0000	1.4
+++ testsuite/gdb.server/server-run.exp	9 Oct 2007 17:40:09 -0000
@@ -38,5 +38,12 @@ gdb_load $binfile
 gdbserver_run ""
 gdb_reinitialize_dir $srcdir/$subdir
 
+# We are now stopped at the program's entry point.  On targets which use
+# SVR4 dynamic linking, we should have automatically loaded symbols for
+# the dynamic linker.
+if { [istarget *-*-linux*] } {
+    gdb_test "info shared" "From.*To.*" "loaded dynamic linker"
+}
+
 gdb_breakpoint main
 gdb_test "continue" "Breakpoint.* main .*" "continue to main"


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