gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: the GDB print command truncates long strings


From: Charles Manning
Subject: Re: the GDB print command truncates long strings
Date: Tue, 17 Mar 2009 10:15:57 +1300
User-agent: KMail/1.9.10

On Tuesday 17 March 2009 06:46:06 Francesco Montorsi wrote:
> Hi,
>      while debugging a program I've found that the print command truncates
> some long strings:
>
> (gdb) p (char*)format
> $7 = 0xd47e058 "datetime.h: a long long long long long long long long long
> long long long long long long long long long long long long string"...
>
> I need to explore the content of the string and want GDB to print it
> entirely... how can I do?

You can also use the x command.

x is also very useful for exploring buffers etc too.


(gdb) help x
Examine memory: x/FMT ADDRESS.
ADDRESS is an expression for the memory address to examine.
FMT is a repeat count followed by a format letter and a size letter.
Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),
  t(binary), f(float), a(address), i(instruction), c(char) and s(string).
Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).
The specified number of objects of the specified size are printed
according to the format.

Defaults for format and size letters are those previously used.
Default count is 1.  Default address is following last thing printed
with this command or "print".


Using x/ns will output n characters in string format, so it your string is up 
to, say 300 characters long you can say 

x/300s

For example here is an output for x/200s.

(gdb) x/200s yaffs_guts_c_version 
0x80605c0:       "$Id: yaffs_guts.c,v 1.82 2009-03-09 04:24:17 charles Exp $"
0x80605fb <__PRETTY_FUNCTION__.3188>:    "yaffs_GetBlockInfo"
0x806060e:       ""
0x806060f:       ""
0x8060610:       "**>> yaffs: getBlockInfo block %d is not valid\n"
0x8060640:       "yaffs_getblockinfo.h"
0x8060655:       "0"
0x8060657:       ""
0x8060658:       "Out of temp buffers at line %d, other held by lines:"
....





reply via email to

[Prev in Thread] Current Thread [Next in Thread]