From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9251 invoked by alias); 12 May 2014 08:00:31 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org Received: (qmail 9227 invoked by uid 48); 12 May 2014 08:00:31 -0000 From: "f.heckenbach@fh-soft.de" To: gdb-prs@sourceware.org Subject: [Bug gdb/16933] New: p omits trailing 0 when printing a range of chars Date: Mon, 12 May 2014 08:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 7.7 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: f.heckenbach@fh-soft.de X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-q2/txt/msg00213.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=16933 Bug ID: 16933 Summary: p omits trailing 0 when printing a range of chars Product: gdb Version: 7.7 Status: NEW Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: f.heckenbach@fh-soft.de This bug was reported as Debian bug #666216 for gdb 7-0. According to Hector Oron, it is still reproducable with 7.7-1. 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 ...) -- You are receiving this mail because: You are on the CC list for the bug.