Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* what does print /s do?
@ 2008-11-21 17:11 dave_rodgman
  2008-11-21 17:27 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: dave_rodgman @ 2008-11-21 17:11 UTC (permalink / raw)
  To: gdb

Hi,

I'm having trouble understanding exactly what print /s is intended to
do. I've read the manual, and it says:

(from http://sourceware.org/gdb/current/onlinedocs/gdb_10.html#SEC70)

> Regard as a string, if possible. With this format, pointers to single-byte data are displayed as null-terminated strings and
> arrays of single-byte data are displayed as fixed-length strings. Other values are displayed in their natural types.
>
> Without this format, GDB displays pointers to and arrays of char, unsigned char, and signed char as strings. Single-byte
> members of a vector are displayed as an integer array.

I have two questions:

1. What is the distinction between "pointer to single-byte data" and
"pointers to and arrays of char, unsigned char, and signed char"?
Or is this just poorly worded?

2. Under what circumstances does supplying or not supplying /s make a
difference to the output? I can't find a case where it makes a
difference. For example, when printing a pointer-to-char (here, "string"
is a char array)

(gdb) p /s string
$14 = "abc"
(gdb) p string
$15 = "abc"

If I attempt to do the inverse, i.e., use /s to force interpreting a
non-ptr-to-char as a string, /s is ignored:

(gdb) p /s (int *)string
$16 = (int *) 0x804a018
(gdb) p (int *)string
$17 = (int *) 0x804a018

thanks

Dave
-- 
  
  dave_rodgman@fastmail.co.uk


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

end of thread, other threads:[~2008-11-21 17:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-21 17:11 what does print /s do? dave_rodgman
2008-11-21 17:27 ` Daniel Jacobowitz

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