Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFA: parse Sun's STABS syntax for prototyped function types
@ 2002-02-08 23:00 Jim Blandy
  2002-02-09  7:38 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Blandy @ 2002-02-08 23:00 UTC (permalink / raw)
  To: gdb-patches


GCC doesn't emit this --- yet.  :)

Note the 'to do' items; that's why this is an RFA and not a patch.

2002-02-08  Jim Blandy  <jimb@redhat.com>

	* stabsread.c (read_type): Add code to parse Sun's syntax for
	prototyped function types.

Index: gdb/stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.24
diff -c -r1.24 stabsread.c
*** gdb/stabsread.c	2002/02/03 22:57:56	1.24
--- gdb/stabsread.c	2002/02/09 06:56:05
***************
*** 2586,2591 ****
--- 2586,2649 ----
        type = make_function_type (type1, dbx_lookup_type (typenums));
        break;
  
+     case 'g':                   /* Prototyped function.  (Sun)  */
+       {
+         const char *type_start = (*pp) - 1;
+         struct type *return_type = read_type (pp, objfile);
+         struct type *func_type
+           = make_function_type (return_type, dbx_lookup_type (typenums));
+         struct type_list {
+           struct type *type;
+           struct type_list *next;
+         } *arg_types = 0;
+         int num_args = 0;
+ 
+         /* To do:
+            - void argument list?
+            - '0' for varargs?
+            - Sun emits integer arguments as types which ref themselves?
+              (See comment in define_symbol)
+            - Complain if we didn't find the ending #.
+            - Check that complaint is created properly.  */
+         while (**pp && **pp != '#')
+           {
+             struct type *arg_type = read_type (pp, objfile);
+             struct type_list *new = alloca (sizeof (*new));
+             new->type = arg_type;
+             new->next = arg_types;
+             arg_types = new;
+             num_args++;
+           }
+         if (**pp == '#')
+           ++*pp;
+         else
+           {
+             static struct complaint msg =
+             {"Prototyped function type didn't end arguments with `#' ", 0, 0};
+             complain (&msg, type_start);
+           }
+ 
+         TYPE_FIELDS (func_type)
+           = (struct field *) TYPE_ALLOC (func_type,
+                                          num_args * sizeof (struct field));
+         memset (TYPE_FIELDS (func_type), 0, num_args * sizeof (struct field));
+         {
+           int i;
+           struct type_list *t;
+ 
+           /* We stuck each argument type onto the front of the list
+              when we read it, so the list is reversed.  Build the
+              fields array right-to-left.  */
+           for (t = arg_types, i = num_args - 1; t; t = t->next, i--)
+             TYPE_FIELD_TYPE (func_type, i) = t->type;
+         }
+         TYPE_NFIELDS (func_type) = num_args;
+         TYPE_FLAGS (func_type) |= TYPE_FLAG_PROTOTYPED;
+ 
+         type = func_type;
+         break;
+       }
+ 
      case 'k':			/* Const qualifier on some type (Sun) */
      case 'c':			/* Const qualifier on some type (OS9000) */
        /* Because 'c' means other things to AIX and 'k' is perfectly good,


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFA: parse Sun's STABS syntax for prototyped function types
  2002-02-08 23:00 RFA: parse Sun's STABS syntax for prototyped function types Jim Blandy
@ 2002-02-09  7:38 ` Daniel Jacobowitz
  2002-02-13 14:24   ` Jim Blandy
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2002-02-09  7:38 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb-patches

On Sat, Feb 09, 2002 at 02:01:57AM -0500, Jim Blandy wrote:
> 
> GCC doesn't emit this --- yet.  :)
> 
> Note the 'to do' items; that's why this is an RFA and not a patch.
> 
> 2002-02-08  Jim Blandy  <jimb@redhat.com>
> 
> 	* stabsread.c (read_type): Add code to parse Sun's syntax for
> 	prototyped function types.

How do you get a Sun compiler to emit these?  I tried two function
pointers:
        .stabs  "bar:G(0,27)=*(0,28)=f(0,3)",32,0,4,0   !(/tmp/acompAAA6Qaajn:84)
        .stabs  "foo:G(0,29)=*(0,30)=f(0,3)",32,0,4,0   !(/tmp/acompAAA6Qaajn:87)

Those're both unprototyped but the last one shouldn't be.  There are no
'g' types at all.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFA: parse Sun's STABS syntax for prototyped function types
  2002-02-09  7:38 ` Daniel Jacobowitz
@ 2002-02-13 14:24   ` Jim Blandy
  0 siblings, 0 replies; 3+ messages in thread
From: Jim Blandy @ 2002-02-13 14:24 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel Jacobowitz <drow@mvista.com> writes:

> On Sat, Feb 09, 2002 at 02:01:57AM -0500, Jim Blandy wrote:
> > 
> > GCC doesn't emit this --- yet.  :)
> > 
> > Note the 'to do' items; that's why this is an RFA and not a patch.
> > 
> > 2002-02-08  Jim Blandy  <jimb@redhat.com>
> > 
> > 	* stabsread.c (read_type): Add code to parse Sun's syntax for
> > 	prototyped function types.
> 
> How do you get a Sun compiler to emit these?  I tried two function
> pointers:
>         .stabs  "bar:G(0,27)=*(0,28)=f(0,3)",32,0,4,0   !(/tmp/acompAAA6Qaajn:84)
>         .stabs  "foo:G(0,29)=*(0,30)=f(0,3)",32,0,4,0   !(/tmp/acompAAA6Qaajn:87)
> 
> Those're both unprototyped but the last one shouldn't be.  There are no
> 'g' types at all.

I don't know.  I've never actually seen anyone's compiler emit them,
ever.  I'm just reading documentation.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-02-13 22:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-08 23:00 RFA: parse Sun's STABS syntax for prototyped function types Jim Blandy
2002-02-09  7:38 ` Daniel Jacobowitz
2002-02-13 14:24   ` Jim Blandy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox