Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Nick Roberts <nickrob@snap.net.nz>
Cc: Daniel Jacobowitz <drow@false.org>, gdb@sourceware.org
Subject: Re: [RFC] Signed/unsigned character arrays are not strings
Date: Sat, 24 Feb 2007 21:07:00 -0000	[thread overview]
Message-ID: <20070224204626.GA24678@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <17888.39894.136355.447008@kahikatea.snap.net.nz>

[-- Attachment #1: Type: text/plain, Size: 1839 bytes --]

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  <gerd@gnu.org>
> 
> 	* 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

[-- Attachment #2: emacs-22.0.93-gdb-xprintstr-fix.patch --]
[-- Type: text/plain, Size: 502 bytes --]

--- 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

  reply	other threads:[~2007-02-24 20:46 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-24 16:13 Nick Roberts
2007-02-24 20:11 ` Daniel Jacobowitz
2007-02-24 20:53   ` Nick Roberts
2007-02-24 21:07     ` Jan Kratochvil [this message]
2007-02-25  8:00       ` Daniel Jacobowitz
2007-02-25 19:54         ` Nick Roberts
2007-02-25 21:07     ` mathieu lacage
2007-02-26  0:45       ` Jan Kratochvil
2007-02-27  7:17         ` Eli Zaretskii
2007-02-27  9:29         ` Daniel Jacobowitz
2007-02-27 12:02           ` Nick Roberts
2007-02-27 17:06             ` Robert Dewar
2007-02-27 18:42               ` Daniel Jacobowitz
2007-02-27 21:53                 ` Eli Zaretskii
2007-02-27 22:12                   ` Daniel Jacobowitz
2007-02-27 22:14                     ` Mark Kettenis
2007-02-28  0:47                       ` Paul Koning
2007-02-28  1:14                       ` Jim Blandy
2007-02-28  1:59                         ` Jim Blandy
2007-02-28  5:26                           ` Nick Roberts
2007-02-28 14:35                       ` Daniel Jacobowitz
2007-03-01  0:43                         ` Jim Blandy
2007-03-01  0:54                         ` Nick Roberts
2007-02-27 21:47               ` Eli Zaretskii
2007-02-27 22:12             ` Daniel Jacobowitz
2007-04-10 21:59         ` Daniel Jacobowitz
2007-02-28 13:05 pkoning
2007-03-01 11:01 ` Mark Kettenis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070224204626.GA24678@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=drow@false.org \
    --cc=gdb@sourceware.org \
    --cc=nickrob@snap.net.nz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox