This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/11076] Printing character arrays


------- Additional Comments From sabrown256 at gmail dot com  2009-12-10 19:15 -------
Subject: Re:  Printing character arrays

ppluzhnikov at google dot com wrote:
> ------- Additional Comments From ppluzhnikov at google dot com  2009-12-10 17:13 -------
> This works just fine for me:
>
> int main()
> {
>   char a[100] = "foo bar baz";
>   return 0;
> }
>
> gcc -g t.c -o t
> gdb-7.0/build/gdb/gdb ./t
> GNU gdb (GDB) 7.0
> ...
> This GDB was configured as "x86_64-unknown-linux-gnu".
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>...
> Reading symbols from /tmp/t...done.
> (gdb) list
> 1       int main()
> 2       {
> 3         char a[100] = "foo bar baz";
> 4         return 0;
> 5       }
> (gdb) break 4
> Breakpoint 1 at 0x400546: file t.c, line 4.
> (gdb) run
>
> Breakpoint 1, main () at t.c:4
> 4         return 0;
> (gdb) print a
> $1 = "foo bar baz", '\000' <repeats 88 times>
>
> Please provide a complete test case, as well as complete log of your GDB session
> (as I have done above).
>
>   
I ran your example and got:

Current directory is /gapps/codes/dobby/db/
GNU gdb (GDB) 7.0-ubuntu
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /store/apps/codes/dobby/db/foo...done.
Breakpoint 1 at 0x40058e: file foo.c, line 4.
(gdb) r
Starting program: /store/apps/codes/dobby/db/foo

Breakpoint 1, main () at foo.c:4
(gdb) p a
$1 = ""
(gdb) p &a[0]
$2 = 0x7fffffffe0b0 "foo bar baz"
(gdb)

I will submit this to the Ubuntu folks.

Stewart



-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11076

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]