From owner-freebsd-current Thu Aug 24 21:42:38 2000 Delivered-To: freebsd-current@freebsd.org Received: from merc95.us.sas.com (merc95.us.sas.com [149.173.6.5]) by hub.freebsd.org (Postfix) with ESMTP id 2156937B42C for ; Thu, 24 Aug 2000 21:42:34 -0700 (PDT) Received: from merc95.us.sas.com ([127.0.0.1]) by merc95.us.sas.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2651.58) id RL3RBXVL; Fri, 25 Aug 2000 00:42:33 -0400 Received: from 10.28.149.26 by merc95.us.sas.com (InterScan E-Mail VirusWall NT); Fri, 25 Aug 2000 00:42:33 -0400 (Eastern Daylight Time) Received: from bb01f39.unx.sas.com (bb01f39.unx.sas.com [10.16.2.246]) by mozart.unx.sas.com (8.9.3 (PHNE_18979)/8.9.3) with ESMTP id AAA06434 for ; Fri, 25 Aug 2000 00:42:32 -0400 (EDT) Received: (from jwd@localhost) by bb01f39.unx.sas.com (8.9.3/8.9.1) id AAA89339 for freebsd-current@freebsd.org; Fri, 25 Aug 2000 00:42:31 -0400 (EDT) (envelope-from jwd) Date: Fri, 25 Aug 2000 00:42:31 -0400 From: John DeBoskey To: freebsd-current@freebsd.org Subject: gdb bug w/ dlopen()ed images Message-ID: <20000825004231.A89090@unx.sas.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, There appears to be a problem with gdb when debugging dynamically loaded images. On 5.0-current with sources current and built as of this evenning and a 4.1-STABLE system, the following incorrect result is seen: %gdb ./testmain GNU gdb 4.18 (gdb) b main Breakpoint 1 at 0x804853f: file testmain.c, line 11. (gdb) run Starting program: /usr/home/jwd/src/ldt/./testmain Breakpoint 1, main () at testmain.c:11 11 addr = dlopen("./first", RTLD_LAZY); (gdb) n 13 if (!addr) { (gdb) n 18 fp = dlsym(addr, "first"); (gdb) n 20 (*fp)(); (gdb) s 0x280f85b7 in first () at first.c:24 24 } built with gcc version 2.95.2 19991024 (release) The same test program run under gcb on 4.0-20000313-SNAP and 4.0-STABLE systems yield the correct result: %gdb ./testmain GNU gdb 4.18 (gdb) b main Breakpoint 1 at 0x80484ff: file testmain.c, line 11. (gdb) run Starting program: /usr00/home/jwd/ldt/./testmain Breakpoint 1, main () at testmain.c:11 11 addr = dlopen("./first", RTLD_LAZY); (gdb) n 13 if (!addr) { (gdb) n 18 fp = dlsym(addr, "first"); (gdb) n 20 (*fp)(); (gdb) s first () at first.c:10 10 addr = dlopen("./second", RTLD_LAZY); built with gcc version 2.95.2 19991024 (release). In looking at the stabs information, for the working version, we find: STABS> name=first:F(0,1), type=24, desc=6, value=896 STABS> name=, type=44, desc=6, value=0 STABS> name=, type=44, desc=7, value=7 STABS> name=, type=44, desc=10, value=7 STABS> name=, type=44, desc=12, value=30 STABS> name=, type=44, desc=13, value=36 STABS> name=, type=44, desc=14, value=60 STABS> name=, type=44, desc=17, value=76 STABS> name=, type=44, desc=19, value=99 STABS> name=, type=44, desc=21, value=104 STABS> name=, type=44, desc=23, value=119 STABS> name=, type=44, desc=24, value=123 STABS> name=, type=44, desc=24, value=123 STABS> name=first:F(0,1), type=24, desc=6, value=896 and the non-working stabs: STABS> name=first:F(0,1), type=24, desc=6, value=0 STABS> name=, type=44, desc=6, value=0 STABS> name=, type=44, desc=7, value=7 STABS> name=, type=44, desc=10, value=7 STABS> name=, type=44, desc=12, value=30 STABS> name=, type=44, desc=13, value=36 STABS> name=, type=44, desc=14, value=60 STABS> name=, type=44, desc=17, value=76 STABS> name=, type=44, desc=19, value=99 STABS> name=, type=44, desc=21, value=104 STABS> name=, type=44, desc=23, value=119 STABS> name=, type=44, desc=24, value=123 STABS> name=, type=44, desc=24, value=123 STABS> name=first:F(0,1), type=24, desc=6, value=0 Note that in the non-working version, the only difference is the value of 896 vs 0. 896 should be the start address of the function. There is a possibly relative commment in section G.2 of 'The "stabs" debug format' put out by Cygnus Support: http://sources.redhat.com/cygwin/stabs.html#SEC89 It seems to imply that a value=0 field should be a linker relocated stab. The test program(s) are simple and can be found at: http://people.freebsd.org/~jwd/ldt/ I've searched through the PR database but I can't find any entries that seem related (but then I'm not a GNATS expert either). If anyone knows anything or has any ideas on this, please let me know. Thanks! John -- FreeBSD... The choice of those who know how to choose... (anon) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message