From owner-freebsd-bugs Sat Jan 5 14:10:11 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3663C37B419 for ; Sat, 5 Jan 2002 14:10:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g05MA1851082; Sat, 5 Jan 2002 14:10:01 -0800 (PST) (envelope-from gnats) Received: from femail9.sdc1.sfba.home.com (femail9.sdc1.sfba.home.com [24.0.95.89]) by hub.freebsd.org (Postfix) with ESMTP id CF4D937B417 for ; Sat, 5 Jan 2002 14:08:46 -0800 (PST) Received: from edgemaster.zombie.org ([65.10.134.214]) by femail9.sdc1.sfba.home.com (InterMail vM.4.01.03.20 201-229-121-120-20010223) with ESMTP id <20020105220846.NHFP6214.femail9.sdc1.sfba.home.com@edgemaster.zombie.org> for ; Sat, 5 Jan 2002 14:08:46 -0800 Received: by edgemaster.zombie.org (Postfix, from userid 1001) id E972566B04; Fri, 4 Jan 2002 03:52:23 -0600 (CST) Message-Id: <20020104095223.E972566B04@edgemaster.zombie.org> Date: Fri, 4 Jan 2002 03:52:23 -0600 (CST) From: Sean Kelly Reply-To: Sean Kelly To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/33584: 'gcc -ggdb' doesn't work with GDB Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 33584 >Category: bin >Synopsis: 'gcc -ggdb' doesn't work with GDB >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jan 05 14:10:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Sean Kelly >Release: FreeBSD 4.5-PRERELEASE i386 >Organization: >Environment: System: FreeBSD edgemaster.zombie.org 4.5-PRERELEASE FreeBSD 4.5-PRERELEASE #0: Tue Dec 25 03:26:19 CST 2001 root@edgemaster.zombie.org:/usr/obj/usr/src/sys/EDGEMASTER i386 gcc 2.95.3 gdb 4.18 >Description: According to the 'gcc' manpage, there is a '-ggdb' flag which adds more debugging information to the compiled binary. However, when one attempts to use 'gdb' on a binary compiled with -ggdb, oddities occur when dealing with pointers. >How-To-Repeat: Compile this code with '-ggdb': #include int pointtest(char *arg) { printf("pointtest(\"%s\")\n", arg); return 1; } int main(int argc, char *argv[]) { char *x = (char *)malloc(512); printf("argc=%d, argv=%X\n", argc, argv); strcpy(x, "Got Milk?"); pointtest(x); return 0; } Then 'gdb' it: $ gcc -ggdb -o gdbtest gdbtest.c $ gdb gdbtest (gdb) break main Breakpoint 1 at 0x804855e (gdb) run *keep 'step'ping through* 13 strcpy(x, "Got Milk?"); (gdb) step 14 pointtest(x); * BAD BEHAVIOR FOLLOWS * (gdb) print x $1 = 0xbfbffbac "\210ü¿¿" (gdb) print *x $2 = -120 '\210' (gdb) step pointtest (arg=0xbfbffb58 "¤û¿¿¡\204\004\b\001") at gdbtest.c:5 5 printf("pointtest(\"%s\")\n", arg); (gdb) step pointtest("Got Milk?") So it is clear that the program is working right, but gdb is totally broken when dealing with the pointers in the program. >Fix: Wish I knew. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message