* printing a string
@ 2008-01-08 6:06 ranjith kumar
2008-01-08 15:36 ` Dave Korn
0 siblings, 1 reply; 5+ messages in thread
From: ranjith kumar @ 2008-01-08 6:06 UTC (permalink / raw)
To: gdb
I know that a variable can be print in gdb by
"print var".
But how to print a string???
Thanks in advance.
__________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: printing a string
2008-01-08 6:06 printing a string ranjith kumar
@ 2008-01-08 15:36 ` Dave Korn
2008-01-09 10:50 ` Andrew STUBBS
0 siblings, 1 reply; 5+ messages in thread
From: Dave Korn @ 2008-01-08 15:36 UTC (permalink / raw)
To: 'ranjith kumar', gdb
On 08 January 2008 06:06, ranjith kumar wrote:
> I know that a variable can be print in gdb by
> "print var".
>
> But how to print a string???
"print" will display a string, if you're printing a variable of type "char
*", or a std::string.
Or you can use "x" (examine) with the "/s" modifier if you just have a
memory address.
cheers,
DaveK
--
Can't think of a witty .sigline today....
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: printing a string
2008-01-08 15:36 ` Dave Korn
@ 2008-01-09 10:50 ` Andrew STUBBS
2008-01-09 22:29 ` Jim Blandy
0 siblings, 1 reply; 5+ messages in thread
From: Andrew STUBBS @ 2008-01-09 10:50 UTC (permalink / raw)
To: 'ranjith kumar'; +Cc: gdb
Dave Korn wrote:
> On 08 January 2008 06:06, ranjith kumar wrote:
>
>> I know that a variable can be print in gdb by
>> "print var".
>>
>> But how to print a string???
>
> "print" will display a string, if you're printing a variable of type "char
> *", or a std::string.
>
> Or you can use "x" (examine) with the "/s" modifier if you just have a
> memory address.
Or, if your string is to long, or x/s is too ugly:
printf "%s\n", mystring
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: printing a string
2008-01-09 10:50 ` Andrew STUBBS
@ 2008-01-09 22:29 ` Jim Blandy
2008-01-10 10:49 ` Andrew STUBBS
0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2008-01-09 22:29 UTC (permalink / raw)
To: Andrew STUBBS; +Cc: 'ranjith kumar', gdb
Andrew STUBBS <andrew.stubbs at st.com> writes:
> Dave Korn wrote:
>> On 08 January 2008 06:06, ranjith kumar wrote:
>>
>>> I know that a variable can be print in gdb by
>>> "print var".
>>>
>>> But how to print a string???
>>
>> "print" will display a string, if you're printing a variable of type "char
>> *", or a std::string.
>>
>> Or you can use "x" (examine) with the "/s" modifier if you just have a
>> memory address.
>
> Or, if your string is to long, or x/s is too ugly:
>
> printf "%s\n", mystring
(Not 'set print elements'?)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: printing a string
2008-01-09 22:29 ` Jim Blandy
@ 2008-01-10 10:49 ` Andrew STUBBS
0 siblings, 0 replies; 5+ messages in thread
From: Andrew STUBBS @ 2008-01-10 10:49 UTC (permalink / raw)
To: Jim Blandy; +Cc: 'ranjith kumar', gdb
Jim Blandy wrote:
> Andrew STUBBS <andrew.stubbs at st.com> writes:
>> printf "%s\n", mystring
>
> (Not 'set print elements'?)
Well, 'set print elements 0' and 'set print repeats 0' gets you some of
the way there, but line-feeds still get converted to '\n', and if you
want to print shorter strings with x/s then you'll also need 'set print
null-stop on' .....
Basically, if you want to see a string as nature intended then printf
seems to be the easiest way, plus x/s remains useful for viewing the
contents of the string a different way.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-01-10 10:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-08 6:06 printing a string ranjith kumar
2008-01-08 15:36 ` Dave Korn
2008-01-09 10:50 ` Andrew STUBBS
2008-01-09 22:29 ` Jim Blandy
2008-01-10 10:49 ` Andrew STUBBS
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).