Package: gdb
Version: 7.0.1-2+b1
Severity: normal

*** Please type your report below this line ***

p omits trailing 0 when printing a range of chars.
To reproduce:

# echo 'char foo[5] = { 1, 2, 0, 4, 0 };' > foo.c
# gcc -c -g foo.c
# gdb foo.o
(gdb) p foo[0]@5
$1 = "\001\002\000\004"

What I really wanted would be "{1, 2, 0, 4, 0}", like for other
integer types, since I explicitly selected a single element and gave
a range (@5), but if it must print it as a string, it should at
least print all of the bytes.

I know that's probably due to C's notorious confusion between
integers and characters, and I also know there are other ways to
dump some bytes in gdb.

But still it seems plain wrong to print 4 chars if 5 items were
explicitly requested, just because the last one happens to be 0.
Note that it's not printing a 0-terminated string either: The
embedded "\000" is printed; just one terminating 0 is omitted.

(Which gets very confusing with larger arrays, if you look for
something near the end, thinking the last one printed is the last
one requested and then go hunting your off-by-one bug, only to
realize later there wasn't any ...)

-- System Information:
Debian Release: 6.0.2
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 3.2.2 (SMP w/6 CPU cores)
Locale: LANG=de_DE, LC_CTYPE=de_DE (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash

Versions of packages gdb depends on:
ii  gdbserver               7.0.1-2+b1       The GNU Debugger (remote server)
ii  libc6                   2.13-10          Embedded GNU C Library: Shared lib
ii  libexpat1               2.0.1-7          XML parsing C library - runtime li
ii  libncurses5             5.7+20100313-5   shared libraries for terminal hand
ii  libpython2.6            2.6.6-8+b1       Shared Python runtime library (ver
ii  libreadline6            6.1-3            GNU readline and history libraries
ii  zlib1g                  1:1.2.3.4.dfsg-3 compression library - runtime

gdb recommends no packages.

Versions of packages gdb suggests:
pn  gdb-doc                       <none>     (no description available)

-- no debconf information



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to