Format in vars window

Leon Pollak leonp at plris.com
Mon Mar 12 15:19:40 GMT 2007


On Monday 12 March 2007, Vladimir Prus wrote:
> On Sunday 11 March 2007 21:50, Andreas Pakulat wrote:
> > On 11.03.07 20:05:35, Leon Pollak wrote:
> > > On Sunday 11 March 2007, Andreas Pakulat wrote:
> > > > On 11.03.07 15:03:02, Leon Pollak wrote:
> > > > > Hello.
> > > > >
> > > > > There is a very nice new option in variables window of the debugger
> > > > > - formatting of the variable presentation in decimal, hex, etc...
> > > > > Very useful thing.
> > > > > I should like to ask, if possible, to add there a "string" option
> > > > > and print simply a line of chars.
> > > >
> > > > Huh? char* should be printed and it does work for me. The same is
> > > > true for QString's, I'm not sure about std::string.
> > > >
> > > > Andreas
> > >
> > > OK, thanks, did not used this option of (char*) to my char str[20]
> > > array, because "p str" in gdb worked... Inertia...
> > > Now, with this casting it works. But why to do casting? :-)
> >
> > Well, I guess there's a reason, however that would be something that
> > only Vladimir can answer. He barely reads this list, so I'm cc'ing
> > it to the kdevelop-devel list. Please continue the discussion there.
>
> Because gdb's default printing of char[20] is to print each element in
> turn. I suppose we can override that; what should we do if there's no
> terminating zero amoung those 20 chars? Just terminate the string at the
> 20th character?
>
> - Volodya
Volodya,
Below is an example of gdb output in my case:

<font color="blue">(gdb) p Opts.Str</font>
p Opts.Str
$48 = "0X0704 = 4, 
0X00000000\000,0X05060708,0X01020304,0X0D0E0F10,0X0BADDEAD\0000x040d = 8, 
0x04013421,0x02000000\n0x040f = 4, 0x00c80242\n0x040f = 4, 0x00c00942\n0x0104 
= 4, 0x00000000\n0x0105 = 4, 0x00000002\n0x010b"...
^done

I shall be glad to have something similar in format menu. I do not know when 
gdb decides to print '...'. In the above case Opts.Str is 1250 bytes long.
I personally think, that about 20-30 bytes should be enough in variables 
window - if one wants more, there are many other means. This is a quick view 
only.

Regards.
-- 
Leon




More information about the KDevelop mailing list