Skip site navigation (1)Skip section navigation (2)
Date:      Fri,  4 Jan 2002 03:52:23 -0600 (CST)
From:      Sean Kelly <smkelly@zombie.org>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/33584: 'gcc -ggdb' doesn't work with GDB
Message-ID:  <20020104095223.E972566B04@edgemaster.zombie.org>

next in thread | raw e-mail | index | archive | help

>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 <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:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020104095223.E972566B04>