This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Function pointer stab information - where are the argument types?


I'm new to the gcc lists, so I apologise deeply if this has already been
discussed to death.  I did perform a search of the archives and found
nothing relevant.  And I apologise in advance for an over-long post.

I'm using gcc 3.2 20020927 (prerelease) on cygwin.  If I compile the
following *simple* code with gcc with -gstabs (or -gstabs+) and -save-temps
(for the .s)

int (*f1)(void);
int (*f2)(int, char*);
int main(void)
{
    return(-1);
}

then the stabs in the .s show both f1 and f2 as having the same type, when
they're hardly interchangeable

 .stabs  "f1:G(1,1)=*(1,2)=f(0,1)",32,0,0,0
 .stabs  "f2:G(1,3)=*(1,4)=f(0,1)",32,0,0,0

Furthermore running "whatis f1" and "whatis f2" in gdb give identical
results (Running gdb -v gives GNU gdb 2002-12-19-cvs (cygwin-special))

 (gdb) whatis f1
 type = int (*)(void)
 (gdb) whatis f2
 type = int (*)(void)


>From similar discussion on gdb development lists (circa Feb 2002) it appears
gdb supports the 'g' stab to convey function argument type information.  In
fact to verify this I took a hex editor to the executable resulting from the
compilation above and edited the stab table for f2 from:
f2:G(1,3)=*(1,4)=f(0,1)<NUL>
to
f2:G(1,3)=*(1,4)=f(0,1)(0,1)(0,1)#<NUL>
just to see what would happen.  gdb reported:

 (gdb) whatis f2
 type = int (*)(int, int)


My question is, why does gcc not generate this stab information itself?  Is
the 'g' stab type unsupported/unofficial/deprecated (my guess would be no as
the gdb discussion originated around February)?  Is gcc just slow at
catching up on this (with other, more important developments, this would not
surprise me, and I will gladly attempt the patch myself)?  Or has a patch
already been made to a more recent codebase than 3.2?

The reason I need such information is because I'm using gcc as a
preprocessing step to determine the number and type of arguments of
functions defined in external source/header files.  As a specific example, I
need to programatically obtain the type of a function declared in a header
file (but not defined).  I could of course write my own C++ parser but I
figured I could make use of gcc natively by compiling dummy code such as the
following and then just parsing the stabs:

#include <windows.h>
typedef typeof(WinMain) t_winmain;

The intention being that, from the assembly.s file, I could determine the
type of the WinMain function declared in windows.h by parsing the stabs for
t_winmain.

I've already looked briefly at gcc-xml but it appears that it derives its
output from the stabs so suffers from the same problem.

Thanks in advance if anyone knows an easier way to achieve what I need;
otherwise what is the status of the 'g' stab and whether or not it should be
added to dbxout.c ?

d


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]