🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #154

Bugs in GDB 4.6

#154
From: Sheetal V. Kakkad
Date: Sun, 02 Aug 1992 10:26
178 lines
5554 bytes
I am having problems with a few bugs in GDB 4.6. I have attached a
detailed report at the end of the message. Please contact me if you
need more information.

Thanks,

Sheetal

----------------------------------------------------------------------
Sheetal V. Kakkad	svkakkad@cs.utexas.edu	Office: (512) 471-9586
Dept of Computer Sciences, UT-Austin		Home:   (512) 450-1756
======================================================================


BUG REPORT for GDB 4.6


Configuration:
==============
Hardware	: DECstation 5000/200
OS		: Ultrix 4.2
GCC version	: GCC 2.2.2
GDB version	: GDB 4.6 (with GCC name mangling patch applied)

Bugs:
=====

1. Printing (void *) pointer in a struct if the pointer is the first
   element in the struct -- occurs only if the compilation switch is
   -g instead of -ggdb.
2. Printing a variable at the last line in the source (i.e. at closing
   brace of main) -- occurs only if the compilation switch is -g
   instead of -ggdb.
3. Problem in stepping through the program.

Sample source code:
===================

% cat foo.cc
#include <stdio.h>

struct foo
{
  void *x;
  long *y;
};

main ()
{
  foo *z = new foo;
  printf ("Hello\n");
}
%

Sample sessions:
================

For bug #1:
~~~~~~~~~~~
Compile the program with the -g switch:

% g++ -g -o foo foo.cc
% gdb foo
GDB is free software and you are welcome to 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.
GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
(gdb) break main
Breakpoint 1 at 0x4001c8: file foo.cc, line 10.
(gdb) run
Starting program: /v/lisboa/v1/svkakkad/foo 

Breakpoint 1, main () at foo.cc:10
10        foo *z = new foo;
(gdb) next
11        printf ("Hello\n");
(gdb) print *z
$1 = {x = {x = {x = {x = {x = {x = {x = {x = {x = {x = {x = {x = {x = {x = {
                              x = {x = {x = {x = {x = {x = {x = {x = {x = {
                                                x = {x = {x = {x = {x = {x = {
                                                            x = {x = {x = {
                                                                  x = {x = {
                                                                      x = {
                                                                        x = {

...... [continues scrolling] .......^C
(gdb) quit
The program is running.  Quit anyway? (y or n) y
%

However, compile the program with the -ggdb switch:

% g++ -ggdb -o foo foo.cc
% gdb foo
GDB is free software and you are welcome to 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.
GDB 4.6, Copyright 1992 Free Software Foundation, Inc...b
(gdb) break main
Breakpoint 1 at 0x4001c8: file foo.cc, line 10.
(gdb) run
Starting program: /v/lisboa/v1/svkakkad/foo 

Breakpoint 1, main () at foo.cc:10
10        foo *z = new foo;
(gdb) next
11        printf ("Hello\n");
(gdb) print *z
$1 = {x = 0x0, y = 0x0}
(gdb) quit
The program is running.  Quit anyway? (y or n) y
%

This inconsistency in GDB's behavior depending on the compilation
switch does not occur if the (void *) pointer is not the first element
in the struct.


For bug #2:
~~~~~~~~~~~
Error of 'No symbol "z" in current context' if program compiled with
-g switch.

% g++ -g -o foo foo.cc
% gdb foo
GDB is free software and you are welcome to 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.
GDB 4.6, Copyright 1992 Free Software Foundation, Inc...b
(gdb) break main
Breakpoint 1 at 0x4001c8: file foo.cc, line 10.
(gdb) run
Starting program: /v/lisboa/v1/svkakkad/foo 

Breakpoint 1, main () at foo.cc:10
10        foo *z = new foo;
(gdb) next
11        printf ("Hello\n");
(gdb) next
Hello
12      }
(gdb) print *z
No symbol "z" in current context.
(gdb) quit
The program is running.  Quit anyway? (y or n) y
%

I can print the value of *z (at line 12) if the program is compiled
with -ggdb switch.


For bug #3:
~~~~~~~~~~~
GDB is not stepping through the lines in source code:

% gdb foo
GDB is free software and you are welcome to 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.
GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
(gdb) break main
Breakpoint 1 at 0x4001c8: file foo.cc, line 10.
(gdb) run
Starting program: /v/lisboa/v1/svkakkad/foo

Breakpoint 1, main () at foo.cc:10
10        foo *z = new foo;
(gdb) step 
Hello

Program exited normally.
(gdb) quit
%

I increased the number of printf statements to about 10 and still got
the same results (program ran and terminated successfully) when I
tried to step. The compilation switches (-g or -ggdb) did not make any
difference here.
Technical Details
Message-ID: <9208022026.AA21394@boogie.cs.utexas.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.utexas.edu!svkakkad

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gdb.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.utexas.edu!svkakkad
From: svkakkad@cs.utexas.edu (Sheetal V. Kakkad)
Subject: Bugs in GDB 4.6
Message-ID: <9208022026.AA21394@boogie.cs.utexas.edu>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Sun, 2 Aug 1992 10:26:01 GMT
Approved: bug-gdb@prep.ai.mit.edu
Lines: 180