From smkelly@zombie.org  Sat Jan  5 14:08:47 2002
Return-Path: <smkelly@zombie.org>
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 <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>;
          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 <smkelly@zombie.org>
Reply-To: Sean Kelly <smkelly@zombie.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: 'gcc -ggdb' doesn't work with GDB
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         33584
>Category:       bin
>Synopsis:       'gcc -ggdb' doesn't work with GDB
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 05 14:10:01 PST 2002
>Closed-Date:    Sun Jan 6 07:29:59 PST 2002
>Last-Modified:  Wed Jan  9 17:10:01 PST 2002
>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 <stdio.h>

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:
State-Changed-From-To: open->closed 
State-Changed-By: roam 
State-Changed-When: Sun Jan 6 07:29:59 PST 2002 
State-Changed-Why:  
Duplicate of bin/23472; not that anyone has done anything about 
the original one :( 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=33584 

From: Kris Kennaway <kris@obsecurity.org>
To: Sean Kelly <smkelly@zombie.org>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/33584: 'gcc -ggdb' doesn't work with GDB
Date: Wed, 9 Jan 2002 17:06:25 -0800

 --+g7M9IMkV8truYOl
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 > >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.
 
 You probably should bring this up with the gdb maintainers, since it's
 not a FreeBSD bug.
 
 Kris
 
 --+g7M9IMkV8truYOl
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iD8DBQE8POkRWry0BWjoQKURAnKRAKD+xH1RNqn4wHS2djICxCFV24Y7ewCgrDVG
 F2gMCQY5ZB9LtCkh6Zan8hU=
 =yRTl
 -----END PGP SIGNATURE-----
 
 --+g7M9IMkV8truYOl--
>Unformatted:
