This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Formatting of function pointer value
Daniel Jacobowitz wrote:
> On Fri, Jul 08, 2005 at 12:00:44PM +0400, Vladimir Prus wrote:
>>
>> Hello,
>> consider the following snippet:
>>
>> B* p2 = (B*)0x12345678;
>> int (*p3)(int) = (fp)0x000000AE;
>>
>> the value of p2 is printed like this:
>>
>> (gdb)info local
>> ....
>> p2 = (B *) 0xb8000540
>>
>>
>> the value of *p3 is printed like this:
>>
>> (gdb) print *p3
>> $1 = {int (int)} 0xb7ee6e9c <__DTOR_END__+4>
>>
>> I have a couple of questions:
>>
>> 1. Why in both cases the type of value is printed? There's already
>> 'whatis' command. I've checked that code and it's printed
>> unconditionally. As the result, a GDB frontend must strip the type.
>
> It is a feature, not a bug. Why is your frontend using the
> command-line interface?
Well, the debugger part in KDevelop was not written by me, so I don't know
why command-line interface, and not MI is used.
> DON'T do that! Use MI nowadays, please please
> please.
I'm sorry, but section 24 of gdb manual does not say why MI is better. Can
you give the reasons?
> The type is included because "print p2; $1 = 0x12345678" is very
> uninformative; that's how we print integers, not pointers.
I suppose that if I do "print p2" I have some idea what type of 'p2' is; I
don't print program variables at random.
- Volodya