bug-gdb
[Top][All Lists]
Advanced

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

Re: Shouldn't gdb print the components of the function descriptor when y


From: Andrew Cagney
Subject: Re: Shouldn't gdb print the components of the function descriptor when you print a pointer to a function?
Date: Sat, 05 Jan 2002 12:36:41 -0500
User-agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:0.9.7) Gecko/20020103

So my problem was caused by the function descriptor not being visible
when I printed the pointer to the function with gdb. Why isn't gdb being
fixed so that the function descriptor is visible?


While I agree that being able to display the descriptor would be a useful feature, implementing it isn't that straight forward. It leads to all sort of edge conditions, I'll note three of them below.

Can I suggest sending further comments to address@hidden or recording the feature request with a bug report in http://sources.redhat.com/gdb/bugs:

enjoy,
Andrew

--

The descriptor isn't visible from C so there is no C construct available that lets you access it. vis:

(top-gdb) print main
$1 = {int (int, char **)} 0x1803458 <main>
(top-gdb) print &main
$2 = (int (*)(int, char **)) 0x1803458 <main>
(top-gdb) print *(&main)
$3 = {int (int, char **)} 0x1803458 <main>

A mechanism outside of the normal C expression / type system would be needed.

--

Adding to the fun, consider the code:

        extern void foo (void);
        long bar = &foo;

and the GDB sequence:

        (gdb) print bar
        (gdb) print &foo

For GDB to print identical values for ``bar'' and ``&foo'' it needs to find, in target memory, the descriptor for ``&foo'' that GCC created. GDB does try to do this.

--

Finally, GCC has this wonderful feature (not) where the user can specify:

        foo + 10

GCC converts it to something like:

        &foo + 10

For a descriptor based ABI, is turns out to be pretty meaningless. It is a random pointer into target data space. GDB doesn't emulate this since it leads to commands such as:

        (gdb) disassemble foo foo + 10

being meaningless.

.





reply via email to

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