From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16104 invoked by alias); 9 Feb 2002 07:00:26 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 15981 invoked from network); 9 Feb 2002 07:00:22 -0000 Received: from unknown (HELO zwingli.cygnus.com) (208.245.165.35) by sources.redhat.com with SMTP; 9 Feb 2002 07:00:22 -0000 Received: by zwingli.cygnus.com (Postfix, from userid 442) id DA50C5E9DE; Sat, 9 Feb 2002 02:01:57 -0500 (EST) From: Jim Blandy To: gdb-patches@sources.redhat.com Subject: RFA: parse Sun's STABS syntax for prototyped function types Message-Id: <20020209070157.DA50C5E9DE@zwingli.cygnus.com> Date: Fri, 08 Feb 2002 23:00:00 -0000 X-SW-Source: 2002-02/txt/msg00263.txt.bz2 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 * 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,