Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* RE: [RFC] Signed/unsigned character arrays are not strings
@ 2007-02-28 13:05 pkoning
  2007-03-01 11:01 ` Mark Kettenis
  0 siblings, 1 reply; 28+ messages in thread
From: pkoning @ 2007-02-28 13:05 UTC (permalink / raw)
  To: jimb, mark.kettenis
  Cc: drow, eliz, dewar, nickrob, jan.kratochvil, Mathieu.Lacage, gdb

> Okay, here's a horrible idea.  :)  With this patch:
> 
> $ cat chars.c
> #include <stdio.h>
> #include <stdint.h>
> 
> typedef char byte_t;
> 
> char *c = "chars";
> unsigned char *uc = "unsigned chars";
> signed char *sc = "signed chars";
> byte_t *b = "bytes";
> int8_t *i8 = "int8_t's";
> uint8_t *ui8 = "uint8_t's";

Neat.

I would tweak it a little.  People might be using typedefs
for character strings that wrap, say, "unsigned char".
So if you're going to do a heuristic on the name, treat
it as a character string if the name ends in "char" (not 
necessarily with a preceding space) or "char_t" (because
many people use _t as the suffix for typedef names).

	paul


^ permalink raw reply	[flat|nested] 28+ messages in thread
* Re: [RFC] Signed/unsigned character arrays are not strings
@ 2007-02-24 16:13 Nick Roberts
  2007-02-24 20:11 ` Daniel Jacobowitz
  0 siblings, 1 reply; 28+ messages in thread
From: Nick Roberts @ 2007-02-24 16:13 UTC (permalink / raw)
  To: gdb


On Thu, 25 Jan 2007 02:54:22 +0100, Jan Kratochvil wrote (gdb-patches):

> currently all these types are printed as strings:
> 	char
> 	signed char
> 	unsigned char
> the patch will reduce the printed strings only to
> 	char
> and the signed/unsigned version gets printed as an array of byte values
> (characters).  I hope nobody uses sign-specification for strings.
> On the other hand byte arrays become unreadable if printed as strings.

Emacs uses sign-specification for strings.  There is a user defined command
called xbacktrace that prints a backtrace of Lisp functions.  Previously it
got printed like:

(gdb) xbacktrace
"split-window" (0x838c8c9)
"split-window-vertically" (0x838c8c9)
"call-interactively" (0x85b3ac9)

It now gets printed as:

(gdb) xbacktrace
{115 's', 112 'p', 108 'l', 105 'i', 116 't', 45 '-', 119 'w', 105 'i',
  110 'n', 100 'd', 111 'o', 119 'w'} (0x838c8c9)
{115 's', 112 'p', 108 'l', 105 'i', 116 't', 45 '-', 119 'w', 105 'i',
  110 'n', 100 'd', 111 'o', 119 'w', 45 '-', 118 'v', 101 'e', 114 'r',
  116 't', 105 'i', 99 'c', 97 'a', 108 'l', 108 'l', 121 'y'} (0x838c8c9)
{99 'c', 97 'a', 108 'l', 108 'l', 45 '-', 105 'i', 110 'n', 116 't', 101 'e',
  114 'r', 97 'a', 99 'c', 116 't', 105 'i', 118 'v', 101 'e', 108 'l',
  121 'y'} (0x85b3ac9)

-- 
Nick                                           http://www.inet.net.nz/~nickrob


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2007-04-10 21:59 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-28 13:05 [RFC] Signed/unsigned character arrays are not strings pkoning
2007-03-01 11:01 ` Mark Kettenis
  -- strict thread matches above, loose matches on Subject: below --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox