From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21726 invoked by alias); 21 Nov 2008 17:11:03 -0000 Received: (qmail 21642 invoked by uid 22791); 21 Nov 2008 17:11:02 -0000 X-Spam-Check-By: sourceware.org Received: from out1.smtp.messagingengine.com (HELO out1.smtp.messagingengine.com) (66.111.4.25) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 21 Nov 2008 17:10:12 +0000 Received: from compute2.internal (compute2.internal [10.202.2.42]) by out1.messagingengine.com (Postfix) with ESMTP id 30ED51BF7E7 for ; Fri, 21 Nov 2008 12:10:10 -0500 (EST) Received: from web5.messagingengine.com ([10.202.2.214]) by compute2.internal (MEProxy); Fri, 21 Nov 2008 12:10:10 -0500 Received: by web5.messagingengine.com (Postfix, from userid 99) id 169DD2D2C3; Fri, 21 Nov 2008 12:10:10 -0500 (EST) Message-Id: <1227287410.31127.1286073337@webmail.messagingengine.com> From: dave_rodgman@fastmail.co.uk To: gdb@sourceware.org Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="ISO-8859-1" MIME-Version: 1.0 X-Mailer: MessagingEngine.com Webmail Interface Subject: what does print /s do? Date: Fri, 21 Nov 2008 17:11:00 -0000 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: 2008-11/txt/msg00133.txt.bz2 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