[gnu.gdb.bug] GDB 3.2

TPOPOVIC.US2.oramail@dvlseq.oracle.com ("tpopovic.US2") (08/08/89)

Some bugs on GDB 3.2  - set up for use with a symmetry.

	NOTE: I fixed an error (in dep.c) when
	the following error msg was produced:
	make CC="gcc -g -traditional"
	 :
	        gcc -g  -c -g -I. dep.c
	dep.c: In function i386_follow_jump:
	dep.c:1141: conflicting types for `i386_follow_jump'
	dep.c:38: previous declaration of `i386_follow_jump'
	*** Error code 1
	Make: .  Stop.

	<in dep.c, I fixed the following:>
	/* next instruction is a jump, move to target */
	static
	long/*added*/ i386_follow_jump ()
	{
	  int long_delta;

Below is a transaction of a session with GDB.  I was using gdb
to debug GNU's C preprocessor (cccp) and discovered that values returned
from "[p]rint function()" calls are sometimes are incorrect.
Specifically, when I entered 
  p lookup(...)
the result is somehow truncated to 16 bits.  I.e. below the value returned
is 0x41c0 when it should be 0x141c0.  THIS ALWAYS OCCURRED.
<The CCCP code works but GDB isn't returning correct values.>
----------------------------------------------------------------------
Bpt 15, lookup (name=(unsigned char *) 0x30d0 "unix", len=4, hash=1370) (cccp.c line 4932)
(gdb) p bucket
$41 = (struct hashnode *) 0x141c0
Run till exit from #0  lookup (name=(unsigned char *) 0x30d0 "unix", len=4, hash=1370) (cccp.c line 4932)
0x3fffe829 in ?? ()
Value returned is $42 = (struct hashnode *) 0x41c0
(gdb) p $41->value.defn
----------------------------------------------------------------------
$41 != $42, BUT they should be EQUAL we are returning val $41, i.e.
$42 = return $41

Furthermore I examined the routine "install()"
but was unable to do a "p hp"  or "i lo" see below
----------------------------------------------------------------------
Bpt 6, install (name=(unsigned char *) 0x3fffeaa8 "sequent 1", len=7, type=T_MACRO, value=86080, hash=1344) (cccp.c line 4894)
(gdb) i lo
hp = Invalid cast.
(gdb) i lo
hp = Invalid cast.
(gdb) p hp
Invalid cast.
(gdb) i ar
name = (unsigned char *) 0x3fffeaa8 "sequent 1"
len = 7
type = T_MACRO
value = 86080
hash = 1344
----------------------------------------------------------------------

Also, I think that there is an error in routine:

                dump_defn_1 (base, start, length);    <in file cccp.c>
                :
                  while (p < limit) {
                    if (*p != '\n')
                      putchar (*p);
                    else if (*p == '\"' || *p =='\'') {
                      U_CHAR *p1 = skip_quoted_string (p, limit, 0, 0, 0, 0);
                      fwrite (p, p1 - p, 1, stdout);
                      p = p1 - 1;
                    }

        the if (y!='\n') xxx; else if (y=='xx'...)... doesn't make sense
        (the else part is only executed if y=='\n'  -  we
         hit this piece of code if y is '\n'...we will never have a true
         condition for the 2nd if statement) 

Overall, I think that GDB is an excellent product and these are the first
errors I have encountered.
Is there a quick fix for this (truncation) behavior?

-thxs,
Tom Popovich                      (415) 598-8028
Oracle Corporation
20 Davis Drive
Belmont, CA 94002
..!{uunet|apple|pyramid|...}!oracle.com!tpopovic


-----------------------[ session log ]--------------------------------

Current directory is /baseqa/tpopovic/gnu/gcc-1.35/
GDB 3.2, Copyright (C) 1988 Free Software Foundation, Inc.
There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for details.
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "info copying" to see the conditions.
Reading symbol data from /baseqa/tpopovic/gnu/gcc-1.35/cccp...done.
Breakpoint 1 at 0xa9cf
Type "help" for a list of commands.
(gdb) b do_include
Reading in symbols for cccp.c...done.
Breakpoint 2 at 0x46a4: file cccp.c, line 2362.
(gdb) run T/t1.c
Starting program: /baseqa/tpopovic/gnu/gcc-1.35/cccp T/t1.c

Bpt 2, do_include (buf=(unsigned char *) 0xeca0 "{\354\377?\001", limit=(unsigned char *) 0xec80 "", op=(struct file_buf *) 0x3fffebd8, keyword=(struct directive *) 0x16054) (cccp.c line 2362)
$1 = 0
(gdb) quit
The program is running.  Quit anyway? (y or n) y

Inferior Gdb finished
Current directory is /baseqa/tpopovic/gnu/gcc-1.35/
GDB 3.2, Copyright (C) 1988 Free Software Foundation, Inc.
There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for details.
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "info copying" to see the conditions.
Reading symbol data from /baseqa/tpopovic/gnu/gcc-1.35/cccp...done.
Breakpoint 1 at 0xa9cf
Type "help" for a list of commands.
(gdb) b do_define
Undefined command: "g".
(gdb) b do_define
Reading in symbols for cccp.c...done.
Breakpoint 2 at 0x50a6: file cccp.c, line 2823.
(gdb) b do_include
Breakpoint 3 at 0x46a4: file cccp.c, line 2362.
(gdb) run T/t2.c
Starting program: /baseqa/tpopovic/gnu/gcc-1.35/cccp T/t2.c

Bpt 2, do_define (buf=(unsigned char *) 0x3fffeaac "unix 1", limit=(unsigned char *) 0x3fffeab2 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2823)
(gdb) Breakpoint 4 at 0x510f: file cccp.c, line 2844.
(gdb) Continuing.

Bpt 4, do_define (buf=(unsigned char *) 0x3fffeaac "unix 1", limit=(unsigned char *) 0x3fffeab2 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2844)
(gdb) i lo
bp = (unsigned char *) 0x3fffeab0 " 1"
symname = (unsigned char *) 0x3fffeaac "unix 1"
sym_length = 4
defn = (DEFINITION *) 0x0
arglengths = 0
hashcode = 0
(gdb) Breakpoint 5 at 0x5350: file cccp.c, line 2917.
(gdb) c
Continuing.

Bpt 5, do_define (buf=(unsigned char *) 0x3fffeaac "unix 1", limit=(unsigned char *) 0x3fffeab2 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2917)
(gdb) i lo
bp = (unsigned char *) 0x3fffeab1 "1"
symname = (unsigned char *) 0x3fffeaac "unix 1"
sym_length = 4
defn = (DEFINITION *) 0x15000
arglengths = 0
hashcode = 0
(gdb) p defn
$1 = (DEFINITION *) 0x15000
install (name=(unsigned char *) 0x3fffeaac "unix 1", len=4, type=T_MACRO, value=86016, hash=1370) (cccp.c line 4871)
(gdb) i ar
name = (unsigned char *) 0x3fffeaac "unix 1"
len = 4
type = T_MACRO
value = 86016
hash = 1370
(gdb) p *(DEFINITION)value
ptrace: I/O error .
Cannot read memory: address 0xffffffff out of bounds.
(gdb) p *(DEFINITION*)value
Attempt to take contents of a non-pointer value.
(gdb) p *(DEFINITION*)value
$2 = {nargs = -1, length = 3, expansion = 0x15014 "1\n ", pattern = 0x0, argnames = 0x11d9 ""}
(gdb) Run till exit from #0  install (name=(unsigned char *) 0x3fffeaac "unix 1", len=4, type=T_MACRO, value=86016, hash=1370) (cccp.c line 4878)
0x5405 in do_define (buf=(unsigned char *) 0x3fffeaac "unix 1", limit=(unsigned char *) 0x3fffeab2 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2934)
Value returned is $3 = (struct hashnode *) 0x41c0
(gdb) p *lookup("unix",-1,-1)
p lookup("unix",-1,-1)
$4 = (struct hashnode *) 0x41c0
(gdb) p lookup("tunix",-1,-1)
$5 = {next = 0x40c968, prev = 0x3d76e800, bucket_hdr = 0x49e90000, type = -1962934269, length = 1082853445, name = 0xf1c0830c <Address 0xf1c0830c out of bounds>, value = {ival = 252311683, cpval = 0xf09f883 <Address 0xf09f883 out of bounds>, defn = 0xf09f
883}}
$6 = T_MACRO
(gdb) set $l=lookup("unix",-1,-1)
(gdb) p *$l
$7 = -1962934269
(gdb) p *$l
$8 = {next = 0x40c968, prev = 0x3d76e800, bucket_hdr = 0x49e90000, type = -1962934269, length = 1082853445, name = 0xf1c0830c <Address 0xf1c0830c out of bounds>, value = {ival = 252311683, cpval = 0xf09f883 <Address 0xf09f883 out of bounds>, defn = 0xf09f
883}}
(gdb) p lookup("tunix",-1,-1)
$9 = (struct hashnode *) 0x0
(gdb) c
Continuing.

Bpt 2, do_define (buf=(unsigned char *) 0x3fffeaac "i386 1", limit=(unsigned char *) 0x3fffeab2 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2823)
(gdb) set $i=lookup("i386",-1,-1)
(gdb) p *$l
p *$l->name
$10 = {next = 0x40c968, prev = 0x3d76e800, bucket_hdr = 0x49e90000, type = -1962934269, length = 1082853445, name = 0xf1c0830c <Address 0xf1c0830c out of bounds>, value = {ival = 252311683, cpval = 0xf09f883 <Address 0xf09f883 out of bounds>, defn = 0xf09
f883}}
(gdb) p *$l->name
ptrace: I/O error.
Cannot read memory: address 0xf1c0830c out of bounds.
Run till exit from #0  do_define (buf=(unsigned char *) 0x3fffeaac "i386 1", limit=(unsigned char *) 0x3fffeab2 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2823)

Bpt 4, do_define (buf=(unsigned char *) 0x3fffeaac "i386 1", limit=(unsigned char *) 0x3fffeab2 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2844)
Run till exit from #0  do_define (buf=(unsigned char *) 0x3fffeaac "i386 1", limit=(unsigned char *) 0x3fffeab2 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2844)

Bpt 5, do_define (buf=(unsigned char *) 0x3fffeaac "i386 1", limit=(unsigned char *) 0x3fffeab2 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2917)
Run till exit from #0  do_define (buf=(unsigned char *) 0x3fffeaac "i386 1", limit=(unsigned char *) 0x3fffeab2 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2917)
make_definition (str=(unsigned char *) 0x3fffeb19 "i386") (cccp.c line 5198)
Value returned is $11 = 0
$12 = 0
(gdb) p indepth
$13 = -1
0x1d23 in main (argc=2, argv=(char **) 0x3fffebd8, 1073736676) (cccp.c line 785)

Bpt 2, do_define (buf=(unsigned char *) 0x3fffeaa8 "sequent 1", limit=(unsigned char *) 0x3fffeab1 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2823)
(gdb) set $i=lookup("i386",-1,-1)
(gdb) p *$i
$14 = (struct hashnode *) 0x4200
(gdb) p *$i
$15 = {next = 0x42a90000, prev = 0x44ae0000, bucket_hdr = 0x44ae0000, type = 1134362624, length = 1166737408, name = 0xc788308 <Address 0xc788308 out of bounds>, value = {ival = -1962248943, cpval = 0x8b0a7511 <Address 0x8b0a7511 out of bounds>, defn = 0x
8b0a7511}}
(gdb) c
Continuing.

Bpt 4, do_define (buf=(unsigned char *) 0x3fffeaa8 "sequent 1", limit=(unsigned char *) 0x3fffeab1 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2844)

Bpt 5, do_define (buf=(unsigned char *) 0x3fffeaa8 "sequent 1", limit=(unsigned char *) 0x3fffeab1 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2917)
install (name=(unsigned char *) 0x3fffeaa8 "sequent 1", len=7, type=T_MACRO, value=86080, hash=1344) (cccp.c line 4871)
(gdb) Breakpoint 6 at 0x83b2: file cccp.c, line 4894.
(gdb) 






c
Note: breakpoint 6  also set at pc 0x83b2
Breakpoint 7 at 0x83b2: file cccp.c, line 4894.
(gdb) Note: breakpoints 6 and 7  also set at pc 0x83b2
Breakpoint 8 at 0x83b2: file cccp.c, line 4894.
(gdb) Note: breakpoints 6, 7 and 8  also set at pc 0x83b2
Breakpoint 9 at 0x83b2: file cccp.c, line 4894.
(gdb) Note: breakpoints 6, 7, 8 and 9  also set at pc 0x83b2
Breakpoint 10 at 0x83b2: file cccp.c, line 4894.
(gdb) Note: breakpoints 6, 7, 8, 9 and 10  also set at pc 0x83b2
Breakpoint 11 at 0x83b2: file cccp.c, line 4894.
(gdb) Note: breakpoints 6, 7, 8, 9, 10 and 11  also set at pc 0x83b2
Breakpoint 12 at 0x83b2: file cccp.c, line 4894.
(gdb) Note: breakpoints 6, 7, 8, 9, 10, 11 and 12  also set at pc 0x83b2
Breakpoint 13 at 0x83b2: file cccp.c, line 4894.
(gdb) Continuing.

Bpt 6, install (name=(unsigned char *) 0x3fffeaa8 "sequent 1", len=7, type=T_MACRO, value=86080, hash=1344) (cccp.c line 4894)
(gdb) i lo
hp = Invalid cast.
(gdb) i lo
hp = Invalid cast.
(gdb) p hp
Invalid cast.
(gdb) i ar
name = (unsigned char *) 0x3fffeaa8 "sequent 1"
len = 7
type = T_MACRO
value = 86080
hash = 1344
(gdb) p hp
Invalid cast.
(gdb) p p
$16 = (unsigned char *) 0x1425c ""
(gdb) 
(gdb) p q
$17 = (unsigned char *) 0x3fffeaa8 "sequent 1"
(gdb) p {unsigned long}hp
Invalid cast.
(gdb) p {unsigned long}hp
Invalid cast.
Run till exit from #0  install (name=(unsigned char *) 0x3fffeaa8 "sequent 1", len=7, type=T_MACRO, value=86080, hash=1344) (cccp.c line 4897)
0x5405 in do_define (buf=(unsigned char *) 0x3fffeaa8 "sequent 1", limit=(unsigned char *) 0x3fffeab1 "", op=(struct file_buf *) 0x0, keyword=(struct directive *) 0xd064) (cccp.c line 2934)
Value returned is $18 = (struct hashnode *) 0x4240
(gdb) p *$18
$19 = {next = 0x24648d03, prev = 0x7de85004, bucket_hdr = 0x89000064, type = 1979710533, length = 1088907492, name = 0x75ff0000 <Address 0x75ff0000 out of bounds>, value = {ival = 1808460028, cpval = 0x6bcae8fc <Address 0x6bcae8fc out of bounds>, defn = 0
x6bcae8fc}}
(gdb) (gdb) (gdb) make_definition (str=(unsigned char *) 0x3fffeb20 "sequent") (cccp.c line 5198)
(gdb) (gdb) 



c
0x1d23 in main (argc=2, argv=(char **) 0x3fffebd8, 1073736676) (cccp.c line 785)
(gdb) (gdb) (gdb) (gdb) Continuing.

Bpt 2, do_define (buf=(unsigned char *) 0x16007 " TESTING 1\n\n#ifndef  STDIO\n#include <stdio.h>\n#endif\n", limit=(unsigned char *) 0x16011 "\n\n#ifndef  STDIO\n#include <stdio.h>\n#endif\n", op=(struct file_buf *) 0xec80, keyword=(struct directive *) 0
xd064) (cccp.c line 2823)
(gdb) c
Continuing.

Bpt 4, do_define (buf=(unsigned char *) 0x16007 " TESTING 1\n\n#ifndef  STDIO\n#include <stdio.h>\n#endif\n", limit=(unsigned char *) 0x16011 "\n\n#ifndef  STDIO\n#include <stdio.h>\n#endif\n", op=(struct file_buf *) 0xec80, keyword=(struct directive *) 0
xd064) (cccp.c line 2844)

Bpt 5, do_define (buf=(unsigned char *) 0x16007 " TESTING 1\n\n#ifndef  STDIO\n#include <stdio.h>\n#endif\n", limit=(unsigned char *) 0x16011 "\n\n#ifndef  STDIO\n#include <stdio.h>\n#endif\n", op=(struct file_buf *) 0xec80, keyword=(struct directive *) 0
xd064) (cccp.c line 2917)
install (name=(unsigned char *) 0x16008 "TESTING 1\n\n#ifndef  STDIO\n#include <stdio.h>\n#endif\n", len=7, type=T_MACRO, value=86112, hash=950) (cccp.c line 4871)
(gdb) c
Continuing.

Bpt 6, install (name=(unsigned char *) 0x16008 "TESTING 1\n\n#ifndef  STDIO\n#include <stdio.h>\n#endif\n", len=7, type=T_MACRO, value=86112, hash=950) (cccp.c line 4894)
(gdb) p hp
Invalid cast.
(gdb) p i
$20 = 36
(gdb) p name
$21 = (unsigned char *) 0x16008 "TESTING 1\n\n#ifndef  STDIO\n#include <stdio.h>\n#endif\n"
(gdb) p *hp
Invalid cast.
(gdb) whatis hp
type = struct hashnode  {
    struct hashnode *next;
    struct hashnode *prev;
    struct hashnode **bucket_hdr;
    enum node_type type;
    int length;
    unsigned char *name;
    union hashval value;
} *
(gdb) p (unsigned long)hp
Invalid cast.
(gdb) p (unsigned long)hp
Invalid cast.
(gdb) p hashtab[bucket]
$22 = (struct hashnode *) 0x14280
(gdb) p *$22
$23 = {next = 0x0, prev = 0x0, bucket_hdr = 0x11788, type = T_MACRO, length = 7, name = 0x1429c "", value = {ival = 86112, cpval = 0x15060 "\377\377\377\377\003", defn = 0x15060}}
(gdb) whatis hashtab[bucket]
type = struct hashnode  {
    struct hashnode *next;
    struct hashnode *prev;
    struct hashnode **bucket_hdr;
    enum node_type type;
    int length;
    unsigned char *name;
    union hashval value;
} *
(gdb) set hp=hashtab[bucket]
Invalid cast.
(gdb) whatis hp
No symbol "is" in current context.
(gdb) whatis hp
type = struct hashnode  {
    struct hashnode *next;
    struct hashnode *prev;
    struct hashnode **bucket_hdr;
    enum node_type type;
    int length;
    unsigned char *name;
    union hashval value;
} *
(gdb) p hashtab[bucket]
$24 = (struct hashnode *) 0x14280
Run till exit from #0  install (name=(unsigned char *) 0x16008 "TESTING 1\n\n#ifndef  STDIO\n#include <stdio.h>\n#endif\n", len=7, type=T_MACRO, value=86112, hash=950) (cccp.c line 4894)
0x5405 in do_define (buf=(unsigned char *) 0x16007 " TESTING 1\n\n#ifndef  STDIO\n#include <stdio.h>\n#endif\n", limit=(unsigned char *) 0x16011 "\n\n#ifndef  STDIO\n#include <stdio.h>\n#endif\n", op=(struct file_buf *) 0xec80, keyword=(struct directive *
) 0xd064) (cccp.c line 2934)
Value returned is $25 = (struct hashnode *) 0x4280
(gdb) p lookup("TESTING",-1,-1)
?