From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20379 invoked by alias); 24 Feb 2007 20:46:53 -0000 Received: (qmail 20371 invoked by uid 22791); 24 Feb 2007 20:46:53 -0000 X-Spam-Check-By: sourceware.org Received: from 195.22.55.53.adsl.nextra.cz (HELO host0.dyn.jankratochvil.net) (195.22.55.53) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 24 Feb 2007 20:46:46 +0000 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.0/8.13.8) with ESMTP id l1OKkUvg024833; Sat, 24 Feb 2007 21:46:31 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.0/8.14.0/Submit) id l1OKkRR4024832; Sat, 24 Feb 2007 21:46:27 +0100 Date: Sat, 24 Feb 2007 21:07:00 -0000 From: Jan Kratochvil To: Nick Roberts Cc: Daniel Jacobowitz , gdb@sourceware.org Subject: Re: [RFC] Signed/unsigned character arrays are not strings Message-ID: <20070224204626.GA24678@host0.dyn.jankratochvil.net> References: <17887.62990.937672.281975@kahikatea.snap.net.nz> <20070224161315.GA27534@caradoc.them.org> <17888.39894.136355.447008@kahikatea.snap.net.nz> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="PmA2V3Z32TCmWXqI" Content-Disposition: inline In-Reply-To: <17888.39894.136355.447008@kahikatea.snap.net.nz> User-Agent: Mutt/1.5.13 (2007-02-12) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-02/txt/msg00259.txt.bz2 --PmA2V3Z32TCmWXqI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1839 On Sat, 24 Feb 2007 21:11:02 +0100, Nick Roberts wrote: > > Does adding an appropriate (char *) cast fix the problem, and do you > > think it's reasonable? > > If you mean in .gdbinit, changing ... > output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte) ... > to: ... > output (char *) ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte) ... > makes no difference. You have an association bug there. In fact such workaround works [attached]. (gdb) xbacktrace 0x92e75aa "recursive-edit" (0xa420a23) 0x92e685c "byte-code" (0x825e7db) ... > I don't understand why unsigned chars should be printed as arrays except to > solve Jan's particular problem. Maybe Emacs uses unsigned char for 8 bit > character sets like iso_8859-1: > > 2000-01-04 Gerd Moellmann > > * lisp.h (struct Lisp_String): Make DATA member `unsigned char *'. Either you consider the type still as a normal C string and in this case it should be `{,const} char *'. Or you consider it as some arbitrary data (due to its character set not matching the system default one) and in this case it is is best to display the numerical value of each of its array element. Printing it just as a string just outputs invalid characters to the debugger's screen. I believe Emacs should revert to using `char *' but I do not know the reasons for the Gerd Moellmann's change above. > Like another change that Ulrich Drepper is proposing (%a) this patch changes > existing behaviour. Why not just add a new output format, or boolean variable? As in such case one can drop the patch completely as no-one would ever figure such new output format exists. Sure such decision would also make a sense. Regards, Jan --PmA2V3Z32TCmWXqI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="emacs-22.0.93-gdb-xprintstr-fix.patch" Content-length: 502 --- emacs-22.0.93/src/.gdbinit-orig 2007-01-21 23:51:40.000000000 +0100 +++ emacs-22.0.93/src/.gdbinit 2007-02-24 21:35:08.000000000 +0100 @@ -978,7 +978,7 @@ define xprintstr set $data = $arg0->data - output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte) + output (const char *) (($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)) end define xprintsym --PmA2V3Z32TCmWXqI--