This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.


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

Re: gdb-980122 behavior on linux with shared libraries


I am able to reproduce this problem under Solaris as well, even with
the gdb-4.16.85 snapshot, and it should happen on any system that uses
SVR4 dynamic loader semantics.

Below is a quick hack that reestablishes the old GDB behaviour, without
sacrificing the clearing of the solib structure. The problem with this
hack is that it will not error out, if GDB fails to insert a breakpoint
into the main program for some reason.

A cleaner way would be to check if the PC is _not_ contained in one of the
symfile_objfile sections, instead of using solib_address() via
DISABLE_UNSETTABLE_BREAK (solib_address now fails, as the solib list is not
yet initialized due to the preceding call to clear_solib).

Hopefully someone else cares enough to fix this before the 4.17 release,
I am currently very busy with other work, sorry.

*** gdb-4.16.85/breakpoint.c.orig	Sun Jan 25 09:53:45 1998
--- gdb-4.16.85/breakpoint.c	Mon Feb  9 20:41:21 1998
***************
*** 551,557 ****
  	  {
  	    /* Can't set the breakpoint.  */
  #if defined (DISABLE_UNSETTABLE_BREAK)
! 	    if (DISABLE_UNSETTABLE_BREAK (b->address))
  	      {
  		val = 0;
  		b->enable = shlib_disabled;
--- 551,557 ----
  	  {
  	    /* Can't set the breakpoint.  */
  #if defined (DISABLE_UNSETTABLE_BREAK)
! 	    if (1 || DISABLE_UNSETTABLE_BREAK (b->address))
  	      {
  		val = 0;
  		b->enable = shlib_disabled;

> Something is changed (and IMHO worse) with shared
> library breakpoints in post-May releases on linux.
> 
> 
> For years I've been doing:
> 	break on main	
> 	run
> 	stop at main
> 	select breakpoints after shared libaries
> 	at mapped in
> 	cont, run
> 
> (is there a better way...I recall this behavior on suns, now on linux, 
> libc is mapped in before running (so it seems))
> 
> : leisner@thingy; ldd $(type -p ld)
>         libbfd.so.2.8.1.0.15 => /usr/gnu/binutils-2.8.1.0.15/lib/libbfd.so.2.8.1.0.15 (0x4000a000)
>         libc.so.5 => /usr/local/lib/libc.so.5 (0x4009c000)
> 
> I expect this behavior:
> : leisner@thingy; gdb ld
> GNU gdb 970507
> (gdb) break main
> Breakpoint 1 at 0x8058a67: file ../../ld/ldmain.c, line 163.
> (gdb) r
> Starting program: /usr/gnu/binutils/bin/ld 
> 
> Breakpoint 1, main (argc=1, argv=0xbffff094) at ../../ld/ldmain.c:163
> 163       long start_time = get_run_time ();
> (gdb) break bfd_elf32_bfd_final_link
> Breakpoint 2 at 0x4004e660: file ../../bfd/elfcode.h, line 234.
> (gdb) r
> The program being debugged has been started already.
> Start it from the beginning? (y or n) y
> Starting program: /usr/gnu/binutils/bin/ld 
> Cannot insert breakpoint 2:
> Temporarily disabling shared library breakpoints:
> 2 
> 
> Breakpoint 1, main (argc=1, argv=0xbffff094) at ../../ld/ldmain.c:163
> 163       long start_time = get_run_time ();
> (gdb) quit 
> 
> 
> Which is what I expect...
> 
> Now I'm getting this:
> 
> : leisner@thingy; gdb-980122 ld
> GNU gdb 980122
> This GDB was configured as "i586-pc-linux-gnulibc1"...
> (gdb) break main
> Breakpoint 1 at 0x8058a67: file ../../ld/ldmain.c, line 163.
> (gdb) r
> Starting program: /usr/gnu/binutils/bin/ld 
> 
> Breakpoint 1, main (argc=1, argv=0xbffff094) at ../../ld/ldmain.c:163
> 163       long start_time = get_run_time ();
> (gdb) break bfd_elf32_bfd_final_link
> Breakpoint 2 at 0x4004e660: file ../../bfd/elfcode.h, line 234.
> (gdb) r
> The program being debugged has been started already.
> Start it from the beginning? (y or n) y
> Starting program: /usr/gnu/binutils/bin/ld 
> Cannot insert breakpoint 2:
> Cannot access memory at address 0x4004e660.
> 
> I looked at breakpoint.c and didn't see what would account for this behavior
> (except if its at a high level).
> 
> Note on sunos 4.1.4, I'm not getting this behavior (with a elf32 cross-linker):
> GNU gdb 980122
> Copyright 1997 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "sparc-sun-sunos4.1.4"...
> (gdb) break main
> Breakpoint 1 at 0x1d648: file ../../ld/ldmain.c, line 163.
> (gdb) r
> Starting program: /usr/marty/binutils/bin/ld 
> 
> Breakpoint 1, main (argc=1, argv=0xefffe68c) at ../../ld/ldmain.c:163
> 163       long start_time = get_run_time ();
> (gdb) break  bfd_elf32_bfd_final_link
> Breakpoint 2 at 0xef74c604: file ../../bfd/elflink.h, line 3210.
> (gdb) r
> The program being debugged has been started already.
> Start it from the beginning? (y or n) y
> Starting program: /usr/marty/binutils/bin/ld 
> 
> Breakpoint 1, main (argc=1, argv=0xefffe68c) at ../../ld/ldmain.c:163
> 163       long start_time = get_run_time ();
> 
> 
> Any ideas?
> marty		leisner@sdsp.mc.xerox.com   
> Don't  confuse education with schooling.
> 	Milton Friedman to Yogi Berra
> 
> 


-- 
Peter Schauer			pes@regent.e-technik.tu-muenchen.de