* 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
* Re: what does print /s do?
2008-11-21 17:11 what does print /s do? dave_rodgman
@ 2008-11-21 17:27 ` Daniel Jacobowitz
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2008-11-21 17:27 UTC (permalink / raw)
To: dave_rodgman; +Cc: gdb
On Fri, Nov 21, 2008 at 05:10:10PM +0000, dave_rodgman@fastmail.co.uk wrote:
> 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?
char, unsigned char, and signed char are examples of single byte data.
Members of a vector are also examples of single byte data. For
instance, the contents of an AltiVec or SSE vector register can be
interpreted as strings using print /s.
> 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)
Try it with a vector type. /s only affects single byte data,
and (int *) in your example is four-byte data.
--
Daniel Jacobowitz
CodeSourcery
^ 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