This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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]

Re: function pointer stabs (was Re: RFA: MI tests: tolerate prototypes)



I've been looking at Sun's STABS manual, which seems to only be
available from:
http://www.cs.ucsb.edu/facilities/software/cc-info/stabs.ps

That manual suggests that Sun's compiler emits an N_FUN stab of the
form:

    .stabs "foo:F<returntype>;<argtype>;<argtype>;..."

even for non-prototyped functions.  So the presence of argument types
separated by semicolons still doesn't reliably tell us that the
function was defined in prototype form, as I (and apparently
stabsread.c) assumed it did.  It seems to me that this duplicates the
information provided by the N_RSYM and N_PSYM stabs.  Whatever.

GDB parses this form already.  We just need to be aware that its
presence does *not* mean "This function was declared in prototype
form."

For types, Sun emits the 'f' type descriptor for unprototyped function
types, and the 'g' type descriptor for prototyped function types.  The
form seems to be:

        "g" RETURN-TYPE ARGUMENT-TYPE * "#"

The examples in the manual are:

  int (*fptr) (int, float)
  .stabs "fptr:G(0,21)=*(0,22)=g(0,3)(0,3)(0,17)#"

  The second (0,3) is for first argument int, and (0,17) is for second
  argument float. [sic]  More examples:

  typedef int (*func_type) (int (*) (int, float), float);
  struct a {
    int x;
    my_type* (*fptr1) (int (*) (int, float), float);        
    char y;
  };
  int (*xptr) (int (*) (), int (*) (void), int);
  // Note int(*)() is function with unknown parameter types

  .stabs "func_type:t(0,22)=*(0,23)=g(0,3)(0,50)=*(0,51)=
          g(0,3)(0,3)(0,17)#(0,17)#",
          N_LSYM,0x0,0x4,0x40
  .stabs "a:T(0,24)=s12x:(0,3),0,32;fptr1:(0,25)=*(0,26)=g(0,27)=
          *(0,3)(0,40)=*(0,41)=g(0,3)(0,3)(0,17)#(0,17)#,32,32;y:(0,1),64,8;;",
          N_LSYM,0x0,0xc,0x1
  .stabs "xptr:G(0,28)=*(0,29)=g(0,3)(0,60)=*(0,61)=f(0,3)(0,62)=*(0,63)=
          g(0,3)(0,20)#(0,3)#",N_GSYM,0x0,0x4,0x0

But in this case, 'f' really does mean "non-prototyped function", and
'g' really does mean "prototyped function."  So we can get accurate
information here.

I'd be happy if someone would double-check my reading.


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