Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@zwingli.cygnus.com>
To: gdb-patches@sources.redhat.com
Subject: RFA: parse Sun's STABS syntax for prototyped function types
Date: Fri, 08 Feb 2002 23:00:00 -0000	[thread overview]
Message-ID: <20020209070157.DA50C5E9DE@zwingli.cygnus.com> (raw)


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,


             reply	other threads:[~2002-02-09  7:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-08 23:00 Jim Blandy [this message]
2002-02-09  7:38 ` Daniel Jacobowitz
2002-02-13 14:24   ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020209070157.DA50C5E9DE@zwingli.cygnus.com \
    --to=jimb@zwingli.cygnus.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox