* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information
@ 2002-05-14 22:06 Michael Elizabeth Chastain
0 siblings, 0 replies; 15+ messages in thread
From: Michael Elizabeth Chastain @ 2002-05-14 22:06 UTC (permalink / raw)
To: drow, ezannoni; +Cc: ezannoni, gdb-patches
> You are completely right, sorry. I wonder if MichaelC could kindly
> run it through his test harness. That was a big help with yesterday's
> patch. And if you can run the tests with the maintainers file script.
Argh ... the hard disk on my primary machine gave me a bronx cheer
(almost literally) earlier this evening, which means I'm in system
administration hell for the next 12 hours or so.
Michael C
^ permalink raw reply [flat|nested] 15+ messages in thread* [RFA] [4/5] Use DWARF-2 DW_AT_artificial information
@ 2002-01-15 12:31 Daniel Jacobowitz
2002-03-07 12:43 ` Daniel Jacobowitz
0 siblings, 1 reply; 15+ messages in thread
From: Daniel Jacobowitz @ 2002-01-15 12:31 UTC (permalink / raw)
To: gdb-patches
This one's a bit larger than the others. It also has a little more impact -
it adds a word of memory per argument per method per class. I don't think
the storage is an issue right now, and some day I intend to go through and
clean up our memory usage a little bit in places much more severe than this.
Other than that it's pretty straightforward. OK to commit?
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
2002-01-15 Daniel Jacobowitz <drow@mvista.com>
* gdbtypes.h (struct method_args): New.
(struct type): Change arg_types to method_args.
Change TYPE_ARG_TYPES to TYPE_METHOD_ARGS. Add TYPE_ARG_TYPE,
TYPE_FN_FIELD_ARG.
(smash_to_method_type): Update prototype to accept struct
method_args.
* gdbtypes.c (smash_to_method_type): Update to use TYPE_METHOD_ARGS.
(check_stub_method): Likewise. Initialize method arguments
to non-artificial.
(print_arg_types): Update to accept struct method_args. Print out
new field ``artificial'' for each argument.
(dump_fn_fieldlists): Fix indentation of type dumps.
(recursive_dump_type): Update to use TYPE_METHOD_ARGS.
* dwarf2read.c (dwarf2_add_member_fn): Update to use struct
method_args. Preserve TYPE_FIELD_ARTIFICIAL.
* stabsread.c (read_type): Update to use struct method_args.
(read_args): Likewise. Initialize artificial to 0.
* valops.c (hand_function_call): Update to use struct method_args.
(typecmp): Likewise.
(find_overload_match): Update to use TYPE_FN_FIELD_ARG.
* c-typeprint.c (cp_type_print_method_args): Update to accept
struct method_args. Skip leading artificial arguments.
(c_type_print_args): Likewise.
diff -urp src-p3/gdb/c-typeprint.c src-final/gdb/c-typeprint.c
--- src-p3/gdb/c-typeprint.c Tue Jan 15 14:38:27 2002
+++ src-final/gdb/c-typeprint.c Tue Jan 15 14:30:21 2002
@@ -41,7 +41,7 @@
/* Flag indicating target was compiled by HP compiler */
extern int hp_som_som_object_present;
-static void cp_type_print_method_args (struct type ** args, char *prefix,
+static void cp_type_print_method_args (struct method_args *args, char *prefix,
char *varstring, int staticp,
struct ui_file *stream);
@@ -150,26 +150,36 @@ cp_type_print_derivation_info (struct ui
/* Print the C++ method arguments ARGS to the file STREAM. */
static void
-cp_type_print_method_args (struct type **args, char *prefix, char *varstring,
- int staticp, struct ui_file *stream)
+cp_type_print_method_args (struct method_args *args, char *prefix,
+ char *varstring, int staticp,
+ struct ui_file *stream)
{
- int i;
+ struct method_args *curarg = NULL;
+
+ if (args != NULL)
+ {
+ /* Skip ``this'' and any leading artificial arguments. */
+ curarg = &args[!staticp];
+ while (curarg->artificial)
+ curarg++;
+ }
fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI);
fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI);
fputs_filtered ("(", stream);
- if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID)
+ if (curarg && curarg->type
+ && curarg->type->code != TYPE_CODE_VOID)
{
- i = !staticp; /* skip the class variable */
while (1)
{
- type_print (args[i++], "", stream, 0);
- if (!args[i])
+ type_print (curarg->type, "", stream, 0);
+ curarg++;
+ if (!curarg->type)
{
fprintf_filtered (stream, " ...");
break;
}
- else if (args[i]->code != TYPE_CODE_VOID)
+ else if (curarg->type->code != TYPE_CODE_VOID)
{
fprintf_filtered (stream, ", ");
}
@@ -336,33 +346,39 @@ static void
c_type_print_args (struct type *type, struct ui_file *stream)
{
int i;
- struct type **args;
+ struct method_args *args, *curarg;
fprintf_filtered (stream, "(");
- args = TYPE_ARG_TYPES (type);
+ args = TYPE_METHOD_ARGS (type);
if (args != NULL)
{
- if (args[1] == NULL)
+ /* Always skip ``this''. */
+ curarg = &args[1];
+
+ /* Skip any artificial arguments. */
+ while (curarg->artificial)
+ curarg++;
+
+ if (curarg->type == NULL)
{
fprintf_filtered (stream, "...");
}
- else if ((args[1]->code == TYPE_CODE_VOID) &&
+ else if ((curarg->type->code == TYPE_CODE_VOID) &&
(current_language->la_language == language_cplus))
{
fprintf_filtered (stream, "void");
}
else
{
- for (i = 1;
- args[i] != NULL && args[i]->code != TYPE_CODE_VOID;
- i++)
+ while (curarg->type != NULL
+ && curarg->type->code != TYPE_CODE_VOID)
{
- c_print_type (args[i], "", stream, -1, 0);
- if (args[i + 1] == NULL)
+ c_print_type (curarg->type, "", stream, -1, 0);
+ if ((curarg + 1)->type == NULL)
{
fprintf_filtered (stream, "...");
}
- else if (args[i + 1]->code != TYPE_CODE_VOID)
+ else if ((curarg + 1)->type->code != TYPE_CODE_VOID)
{
fprintf_filtered (stream, ",");
wrap_here (" ");
diff -urp src-p3/gdb/dwarf2read.c src-final/gdb/dwarf2read.c
--- src-p3/gdb/dwarf2read.c Tue Jan 15 14:38:27 2002
+++ src-final/gdb/dwarf2read.c Tue Jan 15 14:30:21 2002
@@ -2116,21 +2116,26 @@ dwarf2_add_member_fn (struct field_info
if (die->type && TYPE_CODE (die->type) == TYPE_CODE_FUNC)
{
struct type *return_type = TYPE_TARGET_TYPE (die->type);
- struct type **arg_types;
+ struct method_args *arg_types;
int nparams = TYPE_NFIELDS (die->type);
int iparams;
/* Copy argument types from the subroutine type. */
- arg_types = (struct type **)
- TYPE_ALLOC (fnp->type, (nparams + 1) * sizeof (struct type *));
+ arg_types = (struct method_args *)
+ TYPE_ALLOC (fnp->type, (nparams + 1) * sizeof (struct method_args));
for (iparams = 0; iparams < nparams; iparams++)
- arg_types[iparams] = TYPE_FIELD_TYPE (die->type, iparams);
+ {
+ arg_types[iparams].type = TYPE_FIELD_TYPE (die->type, iparams);
+ arg_types[iparams].artificial = TYPE_FIELD_ARTIFICIAL (die->type,
+ iparams);
+ }
/* Set last entry in argument type vector. */
if (TYPE_VARARGS (die->type))
- arg_types[nparams] = NULL;
+ arg_types[nparams].type = NULL;
else
- arg_types[nparams] = dwarf2_fundamental_type (objfile, FT_VOID);
+ arg_types[nparams].type = dwarf2_fundamental_type (objfile, FT_VOID);
+ arg_types[nparams].artificial = 0;
smash_to_method_type (fnp->type, type, return_type, arg_types);
diff -urp src-p3/gdb/gdbtypes.c src-final/gdb/gdbtypes.c
--- src-p3/gdb/gdbtypes.c Tue Jan 15 14:25:54 2002
+++ src-final/gdb/gdbtypes.c Tue Jan 15 14:30:21 2002
@@ -112,7 +112,7 @@ static void add_mangled_type (struct ext
static void cfront_mangle_name (struct type *, int, int);
#endif
static void print_bit_vector (B_TYPE *, int);
-static void print_arg_types (struct type **, int);
+static void print_arg_types (struct method_args *, int);
static void dump_fn_fieldlists (struct type *, int);
static void print_cplus_stuff (struct type *, int);
static void virtual_base_list_aux (struct type *dclass);
@@ -821,7 +821,7 @@ smash_to_member_type (struct type *type,
void
smash_to_method_type (struct type *type, struct type *domain,
- struct type *to_type, struct type **args)
+ struct type *to_type, struct method_args *args)
{
struct objfile *objfile;
@@ -831,7 +831,7 @@ smash_to_method_type (struct type *type,
TYPE_OBJFILE (type) = objfile;
TYPE_TARGET_TYPE (type) = to_type;
TYPE_DOMAIN_TYPE (type) = domain;
- TYPE_ARG_TYPES (type) = args;
+ TYPE_METHOD_ARGS (type) = args;
TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */
TYPE_CODE (type) = TYPE_CODE_METHOD;
}
@@ -1535,7 +1535,7 @@ check_stub_method (struct type *type, in
DMGL_PARAMS | DMGL_ANSI);
char *argtypetext, *p;
int depth = 0, argcount = 1;
- struct type **argtypes;
+ struct method_args *argtypes;
struct type *mtype;
/* Make sure we got back a function string that we can use. */
@@ -1571,11 +1571,13 @@ check_stub_method (struct type *type, in
/* We need two more slots: one for the THIS pointer, and one for the
NULL [...] or void [end of arglist]. */
- argtypes = (struct type **)
- TYPE_ALLOC (type, (argcount + 2) * sizeof (struct type *));
+ argtypes = (struct method_args *)
+ TYPE_ALLOC (type, (argcount + 2) * sizeof (struct method_args));
p = argtypetext;
/* FIXME: This is wrong for static member functions. */
- argtypes[0] = lookup_pointer_type (type);
+ argtypes[0].type = lookup_pointer_type (type);
+ /* Assume no artificial arguments. */
+ argtypes[0].artificial = 0;
argcount = 1;
if (*p != ')') /* () means no args, skip while */
@@ -1588,8 +1590,9 @@ check_stub_method (struct type *type, in
/* Avoid parsing of ellipsis, they will be handled below. */
if (strncmp (argtypetext, "...", p - argtypetext) != 0)
{
- argtypes[argcount] =
+ argtypes[argcount].type =
safe_parse_type (argtypetext, p - argtypetext);
+ argtypes[argcount].artificial = 0;
argcount += 1;
}
argtypetext = p + 1;
@@ -1610,11 +1613,13 @@ check_stub_method (struct type *type, in
if (p[-2] != '.') /* Not '...' */
{
- argtypes[argcount] = builtin_type_void; /* List terminator */
+ argtypes[argcount].type = builtin_type_void; /* List terminator */
+ argtypes[argcount].artificial = 0;
}
else
{
- argtypes[argcount] = NULL; /* Ellist terminator */
+ argtypes[argcount].type = NULL; /* Ellist terminator */
+ argtypes[argcount].artificial = 0;
}
xfree (demangled_name);
@@ -1626,7 +1631,7 @@ check_stub_method (struct type *type, in
/* Now update the old "stub" type into a real type. */
mtype = TYPE_FN_FIELD_TYPE (f, signature_id);
TYPE_DOMAIN_TYPE (mtype) = type;
- TYPE_ARG_TYPES (mtype) = argtypes;
+ TYPE_METHOD_ARGS (mtype) = argtypes;
TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB;
TYPE_FN_FIELD_STUB (f, signature_id) = 0;
}
@@ -2584,14 +2589,15 @@ print_bit_vector (B_TYPE *bits, int nbit
include it since we may get into a infinitely recursive situation. */
static void
-print_arg_types (struct type **args, int spaces)
+print_arg_types (struct method_args *args, int spaces)
{
if (args != NULL)
{
- while (*args != NULL)
+ while (args->type != NULL)
{
- recursive_dump_type (*args, spaces + 2);
- if ((*args++)->code == TYPE_CODE_VOID)
+ printfi_filtered (spaces, "artificial %d\n", args->artificial);
+ recursive_dump_type (args->type, spaces + 2);
+ if ((args++)->type->code == TYPE_CODE_VOID)
{
break;
}
@@ -2640,7 +2646,7 @@ dump_fn_fieldlists (struct type *type, i
gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout);
printf_filtered ("\n");
- print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces);
+ print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces+8);
printfi_filtered (spaces + 8, "fcontext ");
gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx),
gdb_stdout);
@@ -2978,10 +2984,10 @@ recursive_dump_type (struct type *type,
{
case TYPE_CODE_METHOD:
case TYPE_CODE_FUNC:
- printfi_filtered (spaces, "arg_types ");
- gdb_print_host_address (TYPE_ARG_TYPES (type), gdb_stdout);
+ printfi_filtered (spaces, "method_args ");
+ gdb_print_host_address (TYPE_METHOD_ARGS (type), gdb_stdout);
puts_filtered ("\n");
- print_arg_types (TYPE_ARG_TYPES (type), spaces);
+ print_arg_types (TYPE_METHOD_ARGS (type), spaces);
break;
case TYPE_CODE_STRUCT:
diff -urp src-p3/gdb/gdbtypes.h src-final/gdb/gdbtypes.h
--- src-p3/gdb/gdbtypes.h Tue Jan 15 14:38:27 2002
+++ src-final/gdb/gdbtypes.h Tue Jan 15 14:30:21 2002
@@ -73,6 +73,11 @@ struct block;
#define B_BYTES(x) ( 1 + ((x)>>3) )
#define B_CLRALL(a,x) memset ((a), 0, B_BYTES(x))
+struct method_args {
+ struct type *type;
+ int artificial;
+};
+
/* Different kinds of data types are distinguished by the `code' field. */
enum type_code
@@ -463,7 +468,7 @@ struct type
pointer after the last argument for functions with variable
arguments. */
- struct type **arg_types;
+ struct method_args *method_args;
/* CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to point to
cplus_struct_default, a default static instance of a struct
@@ -780,7 +785,8 @@ extern void allocate_cplus_struct_type (
#define TYPE_NINSTANTIATIONS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ninstantiations
#define TYPE_DECLARED_TYPE(thistype) TYPE_CPLUS_SPECIFIC(thistype)->declared_type
#define TYPE_TYPE_SPECIFIC(thistype) (thistype)->type_specific
-#define TYPE_ARG_TYPES(thistype) (thistype)->type_specific.arg_types
+#define TYPE_METHOD_ARGS(thistype) (thistype)->type_specific.method_args
+#define TYPE_ARG_TYPE(thistype,i) TYPE_METHOD_ARGS(thistype)[i].type
#define TYPE_CPLUS_SPECIFIC(thistype) (thistype)->type_specific.cplus_stuff
#define TYPE_FLOATFORMAT(thistype) (thistype)->type_specific.floatformat
#define TYPE_BASECLASS(thistype,index) (thistype)->fields[index].type
@@ -858,7 +864,8 @@ extern void allocate_cplus_struct_type (
#define TYPE_FN_FIELD(thisfn, n) (thisfn)[n]
#define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname
#define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type
-#define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_ARG_TYPES ((thisfn)[n].type)
+#define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_METHOD_ARGS ((thisfn)[n].type)
+#define TYPE_FN_FIELD_ARG(thisfn, n, i) TYPE_ARG_TYPE ((thisfn)[n].type, i)
#define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const)
#define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile)
#define TYPE_FN_FIELD_PRIVATE(thisfn, n) ((thisfn)[n].is_private)
@@ -1068,7 +1075,7 @@ extern struct type *lookup_member_type (
extern void
smash_to_method_type (struct type *, struct type *, struct type *,
- struct type **);
+ struct method_args *);
extern void
smash_to_member_type (struct type *, struct type *, struct type *);
diff -urp src-p3/gdb/hp-symtab-read.c src-final/gdb/hp-symtab-read.c
--- src-p3/gdb/hp-symtab-read.c Tue Jan 15 14:29:16 2002
+++ src-final/gdb/hp-symtab-read.c Tue Jan 15 14:30:21 2002
@@ -2555,19 +2555,20 @@ hpread_type_lookup (dnttpointer hp_type,
struct type *retvaltype;
int nargs;
int i;
- struct type **args_type;
+ struct method_args *args_type;
class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto,
objfile);
functype = hpread_type_lookup (dn_bufp->dptrmem.memtype,
objfile);
retvaltype = TYPE_TARGET_TYPE (functype);
nargs = TYPE_NFIELDS (functype);
- args_type = (struct type **) xmalloc ((nargs + 1) * sizeof (struct type *));
+ args_type = (struct method_args *) xmalloc ((nargs + 1) * sizeof (struct method_args));
for (i = 0; i < nargs; i++)
{
- args_type[i] = TYPE_FIELD_TYPE (functype, i);
+ args_type[i].type = TYPE_FIELD_TYPE (functype, i);
+ args_type[i].artificial = 0;
}
- args_type[nargs] = NULL;
+ args_type[nargs].type = NULL;
ptrmemtype = alloc_type (objfile);
smash_to_method_type (ptrmemtype, class_type, retvaltype, args_type);
return make_pointer_type (ptrmemtype, NULL);
diff -urp src-p3/gdb/stabsread.c src-final/gdb/stabsread.c
--- src-p3/gdb/stabsread.c Tue Jan 15 14:29:16 2002
+++ src-final/gdb/stabsread.c Tue Jan 15 14:30:22 2002
@@ -141,7 +141,7 @@ static struct type *read_struct_type (ch
static struct type *read_array_type (char **, struct type *,
struct objfile *);
-static struct type **read_args (char **, int, struct objfile *);
+static struct method_args *read_args (char **, int, struct objfile *);
static int
read_cpp_abbrev (struct field_info *, char **, struct type *,
@@ -2671,7 +2671,7 @@ again:
{
struct type *domain = read_type (pp, objfile);
struct type *return_type;
- struct type **args;
+ struct method_args *args;
if (**pp != ',')
/* Invalid member type data format. */
@@ -4748,21 +4748,23 @@ handle_true_range:
}
/* Read in an argument list. This is a list of types, separated by commas
- and terminated with END. Return the list of types read in, or (struct type
- **)-1 if there is an error. */
+ and terminated with END. Return the list of types read in, or (struct
+ method_args *)-1 if there is an error. */
-static struct type **
+static struct method_args *
read_args (char **pp, int end, struct objfile *objfile)
{
/* FIXME! Remove this arbitrary limit! */
- struct type *types[1024], **rval; /* allow for fns of 1023 parameters */
+ struct type *types[1024]; /* allow for fns of 1023 parameters */
+ struct method_args *rval;
int n = 0;
+ int i;
while (**pp != end)
{
if (**pp != ',')
/* Invalid argument list: no ','. */
- return (struct type **) -1;
+ return (struct method_args *) -1;
(*pp)++;
STABS_CONTINUE (pp, objfile);
types[n++] = read_type (pp, objfile);
@@ -4771,18 +4773,22 @@ read_args (char **pp, int end, struct ob
if (n == 1)
{
- rval = (struct type **) xmalloc (2 * sizeof (struct type *));
+ rval = (struct method_args *) xmalloc (2 * sizeof (struct method_args));
}
else if (TYPE_CODE (types[n - 1]) != TYPE_CODE_VOID)
{
- rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *));
- memset (rval + n, 0, sizeof (struct type *));
+ rval = (struct method_args *) xmalloc ((n + 1) * sizeof (struct method_args));
+ memset (rval + n, 0, sizeof (struct method_args));
}
else
{
- rval = (struct type **) xmalloc (n * sizeof (struct type *));
+ rval = (struct method_args *) xmalloc (n * sizeof (struct method_args));
+ }
+ for (i = 0; i < n; i++)
+ {
+ rval[i].type = types[i];
+ rval[i].artificial = 0;
}
- memcpy (rval, types, n * sizeof (struct type *));
return rval;
}
\f
diff -urp src-p3/gdb/valops.c src-final/gdb/valops.c
--- src-p3/gdb/valops.c Tue Jan 15 14:25:54 2002
+++ src-final/gdb/valops.c Tue Jan 15 14:30:22 2002
@@ -44,7 +44,7 @@ extern int hp_som_som_object_present;
extern int overload_debug;
/* Local functions. */
-static int typecmp (int staticp, struct type *t1[], struct value *t2[]);
+static int typecmp (int staticp, struct method_args *t1, struct value *t2[]);
static CORE_ADDR find_function_addr (struct value *, struct type **);
static struct value *value_arg_coerce (struct value *, struct type *, int);
@@ -1429,7 +1429,7 @@ hand_function_call (struct value *functi
if (TYPE_CODE (ftype) == TYPE_CODE_METHOD)
{
i = 0;
- while (TYPE_CODE (TYPE_ARG_TYPES (ftype)[i]) != TYPE_CODE_VOID)
+ while (TYPE_CODE (TYPE_ARG_TYPE (ftype, i)) != TYPE_CODE_VOID)
i++;
n_method_args = i;
if (nargs < i)
@@ -1446,7 +1446,7 @@ hand_function_call (struct value *functi
if (TYPE_CODE (ftype) == TYPE_CODE_METHOD)
{
if (i < n_method_args)
- args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPES (ftype)[i], 1);
+ args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPE (ftype, i), 1);
else
args[i] = value_arg_coerce (args[i], NULL, 0);
}
@@ -1941,7 +1941,7 @@ value_bitstring (char *ptr, int len)
requested operation is type secure, shouldn't we? FIXME. */
static int
-typecmp (int staticp, struct type *t1[], struct value *t2[])
+typecmp (int staticp, struct method_args t1[], struct value *t2[])
{
int i;
@@ -1951,16 +1951,17 @@ typecmp (int staticp, struct type *t1[],
return t2[1] != 0;
if (t1 == 0)
return 1;
- if (TYPE_CODE (t1[0]) == TYPE_CODE_VOID)
+ if (TYPE_CODE (t1[0].type) == TYPE_CODE_VOID)
return 0;
- if (t1[!staticp] == 0)
+ if (t1[!staticp].type == 0)
return 0;
- for (i = !staticp; t1[i] && TYPE_CODE (t1[i]) != TYPE_CODE_VOID; i++)
+ for (i = !staticp; t1[i].type && TYPE_CODE (t1[i].type) != TYPE_CODE_VOID;
+ i++)
{
struct type *tt1, *tt2;
if (!t2[i])
return i + 1;
- tt1 = check_typedef (t1[i]);
+ tt1 = check_typedef (t1[i].type);
tt2 = check_typedef (VALUE_TYPE (t2[i]));
if (TYPE_CODE (tt1) == TYPE_CODE_REF
/* We should be doing hairy argument matching, as below. */
@@ -1997,10 +1998,10 @@ typecmp (int staticp, struct type *t1[],
/* We should be doing much hairier argument matching (see section 13.2
of the ARM), but as a quick kludge, just check for the same type
code. */
- if (TYPE_CODE (t1[i]) != TYPE_CODE (VALUE_TYPE (t2[i])))
+ if (TYPE_CODE (t1[i].type) != TYPE_CODE (VALUE_TYPE (t2[i])))
return i + 1;
}
- if (!t1[i])
+ if (!t1[i].type)
return 0;
return t2[i] ? i + 1 : 0;
}
@@ -2744,7 +2745,8 @@ find_overload_match (struct type **arg_t
if (TYPE_FN_FIELD_ARGS(fns_ptr,ix))
{
- while (TYPE_CODE(TYPE_FN_FIELD_ARGS(fns_ptr,ix)[nparms]) != TYPE_CODE_VOID)
+ while (TYPE_CODE(TYPE_FN_FIELD_ARG(fns_ptr,ix,nparms))
+ != TYPE_CODE_VOID)
nparms++;
}
}
@@ -2758,7 +2760,7 @@ find_overload_match (struct type **arg_t
parm_types = (struct type **) xmalloc (nparms * (sizeof (struct type *)));
for (jj = 0; jj < nparms; jj++)
parm_types[jj] = (method
- ? (TYPE_FN_FIELD_ARGS (fns_ptr, ix)[jj])
+ ? (TYPE_FN_FIELD_ARG (fns_ptr, ix, jj))
: TYPE_FIELD_TYPE (SYMBOL_TYPE (oload_syms[ix]), jj));
/* Compare parameter types to supplied argument types */
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-01-15 12:31 Daniel Jacobowitz @ 2002-03-07 12:43 ` Daniel Jacobowitz 2002-03-07 12:55 ` Elena Zannoni 2002-05-14 14:13 ` Daniel Jacobowitz 0 siblings, 2 replies; 15+ messages in thread From: Daniel Jacobowitz @ 2002-03-07 12:43 UTC (permalink / raw) To: gdb-patches, Elena Zannoni Elena, did you ever get a chance to finish looking at this? On Tue, Jan 15, 2002 at 03:31:57PM -0500, Daniel Jacobowitz wrote: > This one's a bit larger than the others. It also has a little more impact - > it adds a word of memory per argument per method per class. I don't think > the storage is an issue right now, and some day I intend to go through and > clean up our memory usage a little bit in places much more severe than this. > > Other than that it's pretty straightforward. OK to commit? > > -- > Daniel Jacobowitz Carnegie Mellon University > MontaVista Software Debian GNU/Linux Developer > > 2002-01-15 Daniel Jacobowitz <drow@mvista.com> > > * gdbtypes.h (struct method_args): New. > (struct type): Change arg_types to method_args. > Change TYPE_ARG_TYPES to TYPE_METHOD_ARGS. Add TYPE_ARG_TYPE, > TYPE_FN_FIELD_ARG. > (smash_to_method_type): Update prototype to accept struct > method_args. > * gdbtypes.c (smash_to_method_type): Update to use TYPE_METHOD_ARGS. > (check_stub_method): Likewise. Initialize method arguments > to non-artificial. > (print_arg_types): Update to accept struct method_args. Print out > new field ``artificial'' for each argument. > (dump_fn_fieldlists): Fix indentation of type dumps. > (recursive_dump_type): Update to use TYPE_METHOD_ARGS. > > * dwarf2read.c (dwarf2_add_member_fn): Update to use struct > method_args. Preserve TYPE_FIELD_ARTIFICIAL. > * stabsread.c (read_type): Update to use struct method_args. > (read_args): Likewise. Initialize artificial to 0. > * valops.c (hand_function_call): Update to use struct method_args. > (typecmp): Likewise. > (find_overload_match): Update to use TYPE_FN_FIELD_ARG. > > * c-typeprint.c (cp_type_print_method_args): Update to accept > struct method_args. Skip leading artificial arguments. > (c_type_print_args): Likewise. > > diff -urp src-p3/gdb/c-typeprint.c src-final/gdb/c-typeprint.c > --- src-p3/gdb/c-typeprint.c Tue Jan 15 14:38:27 2002 > +++ src-final/gdb/c-typeprint.c Tue Jan 15 14:30:21 2002 > @@ -41,7 +41,7 @@ > /* Flag indicating target was compiled by HP compiler */ > extern int hp_som_som_object_present; > > -static void cp_type_print_method_args (struct type ** args, char *prefix, > +static void cp_type_print_method_args (struct method_args *args, char *prefix, > char *varstring, int staticp, > struct ui_file *stream); > > @@ -150,26 +150,36 @@ cp_type_print_derivation_info (struct ui > /* Print the C++ method arguments ARGS to the file STREAM. */ > > static void > -cp_type_print_method_args (struct type **args, char *prefix, char *varstring, > - int staticp, struct ui_file *stream) > +cp_type_print_method_args (struct method_args *args, char *prefix, > + char *varstring, int staticp, > + struct ui_file *stream) > { > - int i; > + struct method_args *curarg = NULL; > + > + if (args != NULL) > + { > + /* Skip ``this'' and any leading artificial arguments. */ > + curarg = &args[!staticp]; > + while (curarg->artificial) > + curarg++; > + } > > fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI); > fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI); > fputs_filtered ("(", stream); > - if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID) > + if (curarg && curarg->type > + && curarg->type->code != TYPE_CODE_VOID) > { > - i = !staticp; /* skip the class variable */ > while (1) > { > - type_print (args[i++], "", stream, 0); > - if (!args[i]) > + type_print (curarg->type, "", stream, 0); > + curarg++; > + if (!curarg->type) > { > fprintf_filtered (stream, " ..."); > break; > } > - else if (args[i]->code != TYPE_CODE_VOID) > + else if (curarg->type->code != TYPE_CODE_VOID) > { > fprintf_filtered (stream, ", "); > } > @@ -336,33 +346,39 @@ static void > c_type_print_args (struct type *type, struct ui_file *stream) > { > int i; > - struct type **args; > + struct method_args *args, *curarg; > > fprintf_filtered (stream, "("); > - args = TYPE_ARG_TYPES (type); > + args = TYPE_METHOD_ARGS (type); > if (args != NULL) > { > - if (args[1] == NULL) > + /* Always skip ``this''. */ > + curarg = &args[1]; > + > + /* Skip any artificial arguments. */ > + while (curarg->artificial) > + curarg++; > + > + if (curarg->type == NULL) > { > fprintf_filtered (stream, "..."); > } > - else if ((args[1]->code == TYPE_CODE_VOID) && > + else if ((curarg->type->code == TYPE_CODE_VOID) && > (current_language->la_language == language_cplus)) > { > fprintf_filtered (stream, "void"); > } > else > { > - for (i = 1; > - args[i] != NULL && args[i]->code != TYPE_CODE_VOID; > - i++) > + while (curarg->type != NULL > + && curarg->type->code != TYPE_CODE_VOID) > { > - c_print_type (args[i], "", stream, -1, 0); > - if (args[i + 1] == NULL) > + c_print_type (curarg->type, "", stream, -1, 0); > + if ((curarg + 1)->type == NULL) > { > fprintf_filtered (stream, "..."); > } > - else if (args[i + 1]->code != TYPE_CODE_VOID) > + else if ((curarg + 1)->type->code != TYPE_CODE_VOID) > { > fprintf_filtered (stream, ","); > wrap_here (" "); > diff -urp src-p3/gdb/dwarf2read.c src-final/gdb/dwarf2read.c > --- src-p3/gdb/dwarf2read.c Tue Jan 15 14:38:27 2002 > +++ src-final/gdb/dwarf2read.c Tue Jan 15 14:30:21 2002 > @@ -2116,21 +2116,26 @@ dwarf2_add_member_fn (struct field_info > if (die->type && TYPE_CODE (die->type) == TYPE_CODE_FUNC) > { > struct type *return_type = TYPE_TARGET_TYPE (die->type); > - struct type **arg_types; > + struct method_args *arg_types; > int nparams = TYPE_NFIELDS (die->type); > int iparams; > > /* Copy argument types from the subroutine type. */ > - arg_types = (struct type **) > - TYPE_ALLOC (fnp->type, (nparams + 1) * sizeof (struct type *)); > + arg_types = (struct method_args *) > + TYPE_ALLOC (fnp->type, (nparams + 1) * sizeof (struct method_args)); > for (iparams = 0; iparams < nparams; iparams++) > - arg_types[iparams] = TYPE_FIELD_TYPE (die->type, iparams); > + { > + arg_types[iparams].type = TYPE_FIELD_TYPE (die->type, iparams); > + arg_types[iparams].artificial = TYPE_FIELD_ARTIFICIAL (die->type, > + iparams); > + } > > /* Set last entry in argument type vector. */ > if (TYPE_VARARGS (die->type)) > - arg_types[nparams] = NULL; > + arg_types[nparams].type = NULL; > else > - arg_types[nparams] = dwarf2_fundamental_type (objfile, FT_VOID); > + arg_types[nparams].type = dwarf2_fundamental_type (objfile, FT_VOID); > + arg_types[nparams].artificial = 0; > > smash_to_method_type (fnp->type, type, return_type, arg_types); > > diff -urp src-p3/gdb/gdbtypes.c src-final/gdb/gdbtypes.c > --- src-p3/gdb/gdbtypes.c Tue Jan 15 14:25:54 2002 > +++ src-final/gdb/gdbtypes.c Tue Jan 15 14:30:21 2002 > @@ -112,7 +112,7 @@ static void add_mangled_type (struct ext > static void cfront_mangle_name (struct type *, int, int); > #endif > static void print_bit_vector (B_TYPE *, int); > -static void print_arg_types (struct type **, int); > +static void print_arg_types (struct method_args *, int); > static void dump_fn_fieldlists (struct type *, int); > static void print_cplus_stuff (struct type *, int); > static void virtual_base_list_aux (struct type *dclass); > @@ -821,7 +821,7 @@ smash_to_member_type (struct type *type, > > void > smash_to_method_type (struct type *type, struct type *domain, > - struct type *to_type, struct type **args) > + struct type *to_type, struct method_args *args) > { > struct objfile *objfile; > > @@ -831,7 +831,7 @@ smash_to_method_type (struct type *type, > TYPE_OBJFILE (type) = objfile; > TYPE_TARGET_TYPE (type) = to_type; > TYPE_DOMAIN_TYPE (type) = domain; > - TYPE_ARG_TYPES (type) = args; > + TYPE_METHOD_ARGS (type) = args; > TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */ > TYPE_CODE (type) = TYPE_CODE_METHOD; > } > @@ -1535,7 +1535,7 @@ check_stub_method (struct type *type, in > DMGL_PARAMS | DMGL_ANSI); > char *argtypetext, *p; > int depth = 0, argcount = 1; > - struct type **argtypes; > + struct method_args *argtypes; > struct type *mtype; > > /* Make sure we got back a function string that we can use. */ > @@ -1571,11 +1571,13 @@ check_stub_method (struct type *type, in > /* We need two more slots: one for the THIS pointer, and one for the > NULL [...] or void [end of arglist]. */ > > - argtypes = (struct type **) > - TYPE_ALLOC (type, (argcount + 2) * sizeof (struct type *)); > + argtypes = (struct method_args *) > + TYPE_ALLOC (type, (argcount + 2) * sizeof (struct method_args)); > p = argtypetext; > /* FIXME: This is wrong for static member functions. */ > - argtypes[0] = lookup_pointer_type (type); > + argtypes[0].type = lookup_pointer_type (type); > + /* Assume no artificial arguments. */ > + argtypes[0].artificial = 0; > argcount = 1; > > if (*p != ')') /* () means no args, skip while */ > @@ -1588,8 +1590,9 @@ check_stub_method (struct type *type, in > /* Avoid parsing of ellipsis, they will be handled below. */ > if (strncmp (argtypetext, "...", p - argtypetext) != 0) > { > - argtypes[argcount] = > + argtypes[argcount].type = > safe_parse_type (argtypetext, p - argtypetext); > + argtypes[argcount].artificial = 0; > argcount += 1; > } > argtypetext = p + 1; > @@ -1610,11 +1613,13 @@ check_stub_method (struct type *type, in > > if (p[-2] != '.') /* Not '...' */ > { > - argtypes[argcount] = builtin_type_void; /* List terminator */ > + argtypes[argcount].type = builtin_type_void; /* List terminator */ > + argtypes[argcount].artificial = 0; > } > else > { > - argtypes[argcount] = NULL; /* Ellist terminator */ > + argtypes[argcount].type = NULL; /* Ellist terminator */ > + argtypes[argcount].artificial = 0; > } > > xfree (demangled_name); > @@ -1626,7 +1631,7 @@ check_stub_method (struct type *type, in > /* Now update the old "stub" type into a real type. */ > mtype = TYPE_FN_FIELD_TYPE (f, signature_id); > TYPE_DOMAIN_TYPE (mtype) = type; > - TYPE_ARG_TYPES (mtype) = argtypes; > + TYPE_METHOD_ARGS (mtype) = argtypes; > TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB; > TYPE_FN_FIELD_STUB (f, signature_id) = 0; > } > @@ -2584,14 +2589,15 @@ print_bit_vector (B_TYPE *bits, int nbit > include it since we may get into a infinitely recursive situation. */ > > static void > -print_arg_types (struct type **args, int spaces) > +print_arg_types (struct method_args *args, int spaces) > { > if (args != NULL) > { > - while (*args != NULL) > + while (args->type != NULL) > { > - recursive_dump_type (*args, spaces + 2); > - if ((*args++)->code == TYPE_CODE_VOID) > + printfi_filtered (spaces, "artificial %d\n", args->artificial); > + recursive_dump_type (args->type, spaces + 2); > + if ((args++)->type->code == TYPE_CODE_VOID) > { > break; > } > @@ -2640,7 +2646,7 @@ dump_fn_fieldlists (struct type *type, i > gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout); > printf_filtered ("\n"); > > - print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces); > + print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces+8); > printfi_filtered (spaces + 8, "fcontext "); > gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx), > gdb_stdout); > @@ -2978,10 +2984,10 @@ recursive_dump_type (struct type *type, > { > case TYPE_CODE_METHOD: > case TYPE_CODE_FUNC: > - printfi_filtered (spaces, "arg_types "); > - gdb_print_host_address (TYPE_ARG_TYPES (type), gdb_stdout); > + printfi_filtered (spaces, "method_args "); > + gdb_print_host_address (TYPE_METHOD_ARGS (type), gdb_stdout); > puts_filtered ("\n"); > - print_arg_types (TYPE_ARG_TYPES (type), spaces); > + print_arg_types (TYPE_METHOD_ARGS (type), spaces); > break; > > case TYPE_CODE_STRUCT: > diff -urp src-p3/gdb/gdbtypes.h src-final/gdb/gdbtypes.h > --- src-p3/gdb/gdbtypes.h Tue Jan 15 14:38:27 2002 > +++ src-final/gdb/gdbtypes.h Tue Jan 15 14:30:21 2002 > @@ -73,6 +73,11 @@ struct block; > #define B_BYTES(x) ( 1 + ((x)>>3) ) > #define B_CLRALL(a,x) memset ((a), 0, B_BYTES(x)) > > +struct method_args { > + struct type *type; > + int artificial; > +}; > + > /* Different kinds of data types are distinguished by the `code' field. */ > > enum type_code > @@ -463,7 +468,7 @@ struct type > pointer after the last argument for functions with variable > arguments. */ > > - struct type **arg_types; > + struct method_args *method_args; > > /* CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to point to > cplus_struct_default, a default static instance of a struct > @@ -780,7 +785,8 @@ extern void allocate_cplus_struct_type ( > #define TYPE_NINSTANTIATIONS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ninstantiations > #define TYPE_DECLARED_TYPE(thistype) TYPE_CPLUS_SPECIFIC(thistype)->declared_type > #define TYPE_TYPE_SPECIFIC(thistype) (thistype)->type_specific > -#define TYPE_ARG_TYPES(thistype) (thistype)->type_specific.arg_types > +#define TYPE_METHOD_ARGS(thistype) (thistype)->type_specific.method_args > +#define TYPE_ARG_TYPE(thistype,i) TYPE_METHOD_ARGS(thistype)[i].type > #define TYPE_CPLUS_SPECIFIC(thistype) (thistype)->type_specific.cplus_stuff > #define TYPE_FLOATFORMAT(thistype) (thistype)->type_specific.floatformat > #define TYPE_BASECLASS(thistype,index) (thistype)->fields[index].type > @@ -858,7 +864,8 @@ extern void allocate_cplus_struct_type ( > #define TYPE_FN_FIELD(thisfn, n) (thisfn)[n] > #define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname > #define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type > -#define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_ARG_TYPES ((thisfn)[n].type) > +#define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_METHOD_ARGS ((thisfn)[n].type) > +#define TYPE_FN_FIELD_ARG(thisfn, n, i) TYPE_ARG_TYPE ((thisfn)[n].type, i) > #define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const) > #define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile) > #define TYPE_FN_FIELD_PRIVATE(thisfn, n) ((thisfn)[n].is_private) > @@ -1068,7 +1075,7 @@ extern struct type *lookup_member_type ( > > extern void > smash_to_method_type (struct type *, struct type *, struct type *, > - struct type **); > + struct method_args *); > > extern void > smash_to_member_type (struct type *, struct type *, struct type *); > diff -urp src-p3/gdb/hp-symtab-read.c src-final/gdb/hp-symtab-read.c > --- src-p3/gdb/hp-symtab-read.c Tue Jan 15 14:29:16 2002 > +++ src-final/gdb/hp-symtab-read.c Tue Jan 15 14:30:21 2002 > @@ -2555,19 +2555,20 @@ hpread_type_lookup (dnttpointer hp_type, > struct type *retvaltype; > int nargs; > int i; > - struct type **args_type; > + struct method_args *args_type; > class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto, > objfile); > functype = hpread_type_lookup (dn_bufp->dptrmem.memtype, > objfile); > retvaltype = TYPE_TARGET_TYPE (functype); > nargs = TYPE_NFIELDS (functype); > - args_type = (struct type **) xmalloc ((nargs + 1) * sizeof (struct type *)); > + args_type = (struct method_args *) xmalloc ((nargs + 1) * sizeof (struct method_args)); > for (i = 0; i < nargs; i++) > { > - args_type[i] = TYPE_FIELD_TYPE (functype, i); > + args_type[i].type = TYPE_FIELD_TYPE (functype, i); > + args_type[i].artificial = 0; > } > - args_type[nargs] = NULL; > + args_type[nargs].type = NULL; > ptrmemtype = alloc_type (objfile); > smash_to_method_type (ptrmemtype, class_type, retvaltype, args_type); > return make_pointer_type (ptrmemtype, NULL); > diff -urp src-p3/gdb/stabsread.c src-final/gdb/stabsread.c > --- src-p3/gdb/stabsread.c Tue Jan 15 14:29:16 2002 > +++ src-final/gdb/stabsread.c Tue Jan 15 14:30:22 2002 > @@ -141,7 +141,7 @@ static struct type *read_struct_type (ch > static struct type *read_array_type (char **, struct type *, > struct objfile *); > > -static struct type **read_args (char **, int, struct objfile *); > +static struct method_args *read_args (char **, int, struct objfile *); > > static int > read_cpp_abbrev (struct field_info *, char **, struct type *, > @@ -2671,7 +2671,7 @@ again: > { > struct type *domain = read_type (pp, objfile); > struct type *return_type; > - struct type **args; > + struct method_args *args; > > if (**pp != ',') > /* Invalid member type data format. */ > @@ -4748,21 +4748,23 @@ handle_true_range: > } > > /* Read in an argument list. This is a list of types, separated by commas > - and terminated with END. Return the list of types read in, or (struct type > - **)-1 if there is an error. */ > + and terminated with END. Return the list of types read in, or (struct > + method_args *)-1 if there is an error. */ > > -static struct type ** > +static struct method_args * > read_args (char **pp, int end, struct objfile *objfile) > { > /* FIXME! Remove this arbitrary limit! */ > - struct type *types[1024], **rval; /* allow for fns of 1023 parameters */ > + struct type *types[1024]; /* allow for fns of 1023 parameters */ > + struct method_args *rval; > int n = 0; > + int i; > > while (**pp != end) > { > if (**pp != ',') > /* Invalid argument list: no ','. */ > - return (struct type **) -1; > + return (struct method_args *) -1; > (*pp)++; > STABS_CONTINUE (pp, objfile); > types[n++] = read_type (pp, objfile); > @@ -4771,18 +4773,22 @@ read_args (char **pp, int end, struct ob > > if (n == 1) > { > - rval = (struct type **) xmalloc (2 * sizeof (struct type *)); > + rval = (struct method_args *) xmalloc (2 * sizeof (struct method_args)); > } > else if (TYPE_CODE (types[n - 1]) != TYPE_CODE_VOID) > { > - rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *)); > - memset (rval + n, 0, sizeof (struct type *)); > + rval = (struct method_args *) xmalloc ((n + 1) * sizeof (struct method_args)); > + memset (rval + n, 0, sizeof (struct method_args)); > } > else > { > - rval = (struct type **) xmalloc (n * sizeof (struct type *)); > + rval = (struct method_args *) xmalloc (n * sizeof (struct method_args)); > + } > + for (i = 0; i < n; i++) > + { > + rval[i].type = types[i]; > + rval[i].artificial = 0; > } > - memcpy (rval, types, n * sizeof (struct type *)); > return rval; > } > \f > diff -urp src-p3/gdb/valops.c src-final/gdb/valops.c > --- src-p3/gdb/valops.c Tue Jan 15 14:25:54 2002 > +++ src-final/gdb/valops.c Tue Jan 15 14:30:22 2002 > @@ -44,7 +44,7 @@ extern int hp_som_som_object_present; > extern int overload_debug; > /* Local functions. */ > > -static int typecmp (int staticp, struct type *t1[], struct value *t2[]); > +static int typecmp (int staticp, struct method_args *t1, struct value *t2[]); > > static CORE_ADDR find_function_addr (struct value *, struct type **); > static struct value *value_arg_coerce (struct value *, struct type *, int); > @@ -1429,7 +1429,7 @@ hand_function_call (struct value *functi > if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) > { > i = 0; > - while (TYPE_CODE (TYPE_ARG_TYPES (ftype)[i]) != TYPE_CODE_VOID) > + while (TYPE_CODE (TYPE_ARG_TYPE (ftype, i)) != TYPE_CODE_VOID) > i++; > n_method_args = i; > if (nargs < i) > @@ -1446,7 +1446,7 @@ hand_function_call (struct value *functi > if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) > { > if (i < n_method_args) > - args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPES (ftype)[i], 1); > + args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPE (ftype, i), 1); > else > args[i] = value_arg_coerce (args[i], NULL, 0); > } > @@ -1941,7 +1941,7 @@ value_bitstring (char *ptr, int len) > requested operation is type secure, shouldn't we? FIXME. */ > > static int > -typecmp (int staticp, struct type *t1[], struct value *t2[]) > +typecmp (int staticp, struct method_args t1[], struct value *t2[]) > { > int i; > > @@ -1951,16 +1951,17 @@ typecmp (int staticp, struct type *t1[], > return t2[1] != 0; > if (t1 == 0) > return 1; > - if (TYPE_CODE (t1[0]) == TYPE_CODE_VOID) > + if (TYPE_CODE (t1[0].type) == TYPE_CODE_VOID) > return 0; > - if (t1[!staticp] == 0) > + if (t1[!staticp].type == 0) > return 0; > - for (i = !staticp; t1[i] && TYPE_CODE (t1[i]) != TYPE_CODE_VOID; i++) > + for (i = !staticp; t1[i].type && TYPE_CODE (t1[i].type) != TYPE_CODE_VOID; > + i++) > { > struct type *tt1, *tt2; > if (!t2[i]) > return i + 1; > - tt1 = check_typedef (t1[i]); > + tt1 = check_typedef (t1[i].type); > tt2 = check_typedef (VALUE_TYPE (t2[i])); > if (TYPE_CODE (tt1) == TYPE_CODE_REF > /* We should be doing hairy argument matching, as below. */ > @@ -1997,10 +1998,10 @@ typecmp (int staticp, struct type *t1[], > /* We should be doing much hairier argument matching (see section 13.2 > of the ARM), but as a quick kludge, just check for the same type > code. */ > - if (TYPE_CODE (t1[i]) != TYPE_CODE (VALUE_TYPE (t2[i]))) > + if (TYPE_CODE (t1[i].type) != TYPE_CODE (VALUE_TYPE (t2[i]))) > return i + 1; > } > - if (!t1[i]) > + if (!t1[i].type) > return 0; > return t2[i] ? i + 1 : 0; > } > @@ -2744,7 +2745,8 @@ find_overload_match (struct type **arg_t > > if (TYPE_FN_FIELD_ARGS(fns_ptr,ix)) > { > - while (TYPE_CODE(TYPE_FN_FIELD_ARGS(fns_ptr,ix)[nparms]) != TYPE_CODE_VOID) > + while (TYPE_CODE(TYPE_FN_FIELD_ARG(fns_ptr,ix,nparms)) > + != TYPE_CODE_VOID) > nparms++; > } > } > @@ -2758,7 +2760,7 @@ find_overload_match (struct type **arg_t > parm_types = (struct type **) xmalloc (nparms * (sizeof (struct type *))); > for (jj = 0; jj < nparms; jj++) > parm_types[jj] = (method > - ? (TYPE_FN_FIELD_ARGS (fns_ptr, ix)[jj]) > + ? (TYPE_FN_FIELD_ARG (fns_ptr, ix, jj)) > : TYPE_FIELD_TYPE (SYMBOL_TYPE (oload_syms[ix]), jj)); > > /* Compare parameter types to supplied argument types */ > -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-03-07 12:43 ` Daniel Jacobowitz @ 2002-03-07 12:55 ` Elena Zannoni 2002-05-14 14:13 ` Daniel Jacobowitz 1 sibling, 0 replies; 15+ messages in thread From: Elena Zannoni @ 2002-03-07 12:55 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: gdb-patches, Elena Zannoni Daniel Jacobowitz writes: > Elena, did you ever get a chance to finish looking at this? > No sorry, i started looking at it, but got sidetracked on something else. I'll try to do this super soon. Apologies. Elena > On Tue, Jan 15, 2002 at 03:31:57PM -0500, Daniel Jacobowitz wrote: > > This one's a bit larger than the others. It also has a little more impact - > > it adds a word of memory per argument per method per class. I don't think > > the storage is an issue right now, and some day I intend to go through and > > clean up our memory usage a little bit in places much more severe than this. > > > > Other than that it's pretty straightforward. OK to commit? > > > > -- > > Daniel Jacobowitz Carnegie Mellon University > > MontaVista Software Debian GNU/Linux Developer > > > > 2002-01-15 Daniel Jacobowitz <drow@mvista.com> > > > > * gdbtypes.h (struct method_args): New. > > (struct type): Change arg_types to method_args. > > Change TYPE_ARG_TYPES to TYPE_METHOD_ARGS. Add TYPE_ARG_TYPE, > > TYPE_FN_FIELD_ARG. > > (smash_to_method_type): Update prototype to accept struct > > method_args. > > * gdbtypes.c (smash_to_method_type): Update to use TYPE_METHOD_ARGS. > > (check_stub_method): Likewise. Initialize method arguments > > to non-artificial. > > (print_arg_types): Update to accept struct method_args. Print out > > new field ``artificial'' for each argument. > > (dump_fn_fieldlists): Fix indentation of type dumps. > > (recursive_dump_type): Update to use TYPE_METHOD_ARGS. > > > > * dwarf2read.c (dwarf2_add_member_fn): Update to use struct > > method_args. Preserve TYPE_FIELD_ARTIFICIAL. > > * stabsread.c (read_type): Update to use struct method_args. > > (read_args): Likewise. Initialize artificial to 0. > > * valops.c (hand_function_call): Update to use struct method_args. > > (typecmp): Likewise. > > (find_overload_match): Update to use TYPE_FN_FIELD_ARG. > > > > * c-typeprint.c (cp_type_print_method_args): Update to accept > > struct method_args. Skip leading artificial arguments. > > (c_type_print_args): Likewise. > > > > diff -urp src-p3/gdb/c-typeprint.c src-final/gdb/c-typeprint.c > > --- src-p3/gdb/c-typeprint.c Tue Jan 15 14:38:27 2002 > > +++ src-final/gdb/c-typeprint.c Tue Jan 15 14:30:21 2002 > > @@ -41,7 +41,7 @@ > > /* Flag indicating target was compiled by HP compiler */ > > extern int hp_som_som_object_present; > > > > -static void cp_type_print_method_args (struct type ** args, char *prefix, > > +static void cp_type_print_method_args (struct method_args *args, char *prefix, > > char *varstring, int staticp, > > struct ui_file *stream); > > > > @@ -150,26 +150,36 @@ cp_type_print_derivation_info (struct ui > > /* Print the C++ method arguments ARGS to the file STREAM. */ > > > > static void > > -cp_type_print_method_args (struct type **args, char *prefix, char *varstring, > > - int staticp, struct ui_file *stream) > > +cp_type_print_method_args (struct method_args *args, char *prefix, > > + char *varstring, int staticp, > > + struct ui_file *stream) > > { > > - int i; > > + struct method_args *curarg = NULL; > > + > > + if (args != NULL) > > + { > > + /* Skip ``this'' and any leading artificial arguments. */ > > + curarg = &args[!staticp]; > > + while (curarg->artificial) > > + curarg++; > > + } > > > > fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI); > > fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI); > > fputs_filtered ("(", stream); > > - if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID) > > + if (curarg && curarg->type > > + && curarg->type->code != TYPE_CODE_VOID) > > { > > - i = !staticp; /* skip the class variable */ > > while (1) > > { > > - type_print (args[i++], "", stream, 0); > > - if (!args[i]) > > + type_print (curarg->type, "", stream, 0); > > + curarg++; > > + if (!curarg->type) > > { > > fprintf_filtered (stream, " ..."); > > break; > > } > > - else if (args[i]->code != TYPE_CODE_VOID) > > + else if (curarg->type->code != TYPE_CODE_VOID) > > { > > fprintf_filtered (stream, ", "); > > } > > @@ -336,33 +346,39 @@ static void > > c_type_print_args (struct type *type, struct ui_file *stream) > > { > > int i; > > - struct type **args; > > + struct method_args *args, *curarg; > > > > fprintf_filtered (stream, "("); > > - args = TYPE_ARG_TYPES (type); > > + args = TYPE_METHOD_ARGS (type); > > if (args != NULL) > > { > > - if (args[1] == NULL) > > + /* Always skip ``this''. */ > > + curarg = &args[1]; > > + > > + /* Skip any artificial arguments. */ > > + while (curarg->artificial) > > + curarg++; > > + > > + if (curarg->type == NULL) > > { > > fprintf_filtered (stream, "..."); > > } > > - else if ((args[1]->code == TYPE_CODE_VOID) && > > + else if ((curarg->type->code == TYPE_CODE_VOID) && > > (current_language->la_language == language_cplus)) > > { > > fprintf_filtered (stream, "void"); > > } > > else > > { > > - for (i = 1; > > - args[i] != NULL && args[i]->code != TYPE_CODE_VOID; > > - i++) > > + while (curarg->type != NULL > > + && curarg->type->code != TYPE_CODE_VOID) > > { > > - c_print_type (args[i], "", stream, -1, 0); > > - if (args[i + 1] == NULL) > > + c_print_type (curarg->type, "", stream, -1, 0); > > + if ((curarg + 1)->type == NULL) > > { > > fprintf_filtered (stream, "..."); > > } > > - else if (args[i + 1]->code != TYPE_CODE_VOID) > > + else if ((curarg + 1)->type->code != TYPE_CODE_VOID) > > { > > fprintf_filtered (stream, ","); > > wrap_here (" "); > > diff -urp src-p3/gdb/dwarf2read.c src-final/gdb/dwarf2read.c > > --- src-p3/gdb/dwarf2read.c Tue Jan 15 14:38:27 2002 > > +++ src-final/gdb/dwarf2read.c Tue Jan 15 14:30:21 2002 > > @@ -2116,21 +2116,26 @@ dwarf2_add_member_fn (struct field_info > > if (die->type && TYPE_CODE (die->type) == TYPE_CODE_FUNC) > > { > > struct type *return_type = TYPE_TARGET_TYPE (die->type); > > - struct type **arg_types; > > + struct method_args *arg_types; > > int nparams = TYPE_NFIELDS (die->type); > > int iparams; > > > > /* Copy argument types from the subroutine type. */ > > - arg_types = (struct type **) > > - TYPE_ALLOC (fnp->type, (nparams + 1) * sizeof (struct type *)); > > + arg_types = (struct method_args *) > > + TYPE_ALLOC (fnp->type, (nparams + 1) * sizeof (struct method_args)); > > for (iparams = 0; iparams < nparams; iparams++) > > - arg_types[iparams] = TYPE_FIELD_TYPE (die->type, iparams); > > + { > > + arg_types[iparams].type = TYPE_FIELD_TYPE (die->type, iparams); > > + arg_types[iparams].artificial = TYPE_FIELD_ARTIFICIAL (die->type, > > + iparams); > > + } > > > > /* Set last entry in argument type vector. */ > > if (TYPE_VARARGS (die->type)) > > - arg_types[nparams] = NULL; > > + arg_types[nparams].type = NULL; > > else > > - arg_types[nparams] = dwarf2_fundamental_type (objfile, FT_VOID); > > + arg_types[nparams].type = dwarf2_fundamental_type (objfile, FT_VOID); > > + arg_types[nparams].artificial = 0; > > > > smash_to_method_type (fnp->type, type, return_type, arg_types); > > > > diff -urp src-p3/gdb/gdbtypes.c src-final/gdb/gdbtypes.c > > --- src-p3/gdb/gdbtypes.c Tue Jan 15 14:25:54 2002 > > +++ src-final/gdb/gdbtypes.c Tue Jan 15 14:30:21 2002 > > @@ -112,7 +112,7 @@ static void add_mangled_type (struct ext > > static void cfront_mangle_name (struct type *, int, int); > > #endif > > static void print_bit_vector (B_TYPE *, int); > > -static void print_arg_types (struct type **, int); > > +static void print_arg_types (struct method_args *, int); > > static void dump_fn_fieldlists (struct type *, int); > > static void print_cplus_stuff (struct type *, int); > > static void virtual_base_list_aux (struct type *dclass); > > @@ -821,7 +821,7 @@ smash_to_member_type (struct type *type, > > > > void > > smash_to_method_type (struct type *type, struct type *domain, > > - struct type *to_type, struct type **args) > > + struct type *to_type, struct method_args *args) > > { > > struct objfile *objfile; > > > > @@ -831,7 +831,7 @@ smash_to_method_type (struct type *type, > > TYPE_OBJFILE (type) = objfile; > > TYPE_TARGET_TYPE (type) = to_type; > > TYPE_DOMAIN_TYPE (type) = domain; > > - TYPE_ARG_TYPES (type) = args; > > + TYPE_METHOD_ARGS (type) = args; > > TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */ > > TYPE_CODE (type) = TYPE_CODE_METHOD; > > } > > @@ -1535,7 +1535,7 @@ check_stub_method (struct type *type, in > > DMGL_PARAMS | DMGL_ANSI); > > char *argtypetext, *p; > > int depth = 0, argcount = 1; > > - struct type **argtypes; > > + struct method_args *argtypes; > > struct type *mtype; > > > > /* Make sure we got back a function string that we can use. */ > > @@ -1571,11 +1571,13 @@ check_stub_method (struct type *type, in > > /* We need two more slots: one for the THIS pointer, and one for the > > NULL [...] or void [end of arglist]. */ > > > > - argtypes = (struct type **) > > - TYPE_ALLOC (type, (argcount + 2) * sizeof (struct type *)); > > + argtypes = (struct method_args *) > > + TYPE_ALLOC (type, (argcount + 2) * sizeof (struct method_args)); > > p = argtypetext; > > /* FIXME: This is wrong for static member functions. */ > > - argtypes[0] = lookup_pointer_type (type); > > + argtypes[0].type = lookup_pointer_type (type); > > + /* Assume no artificial arguments. */ > > + argtypes[0].artificial = 0; > > argcount = 1; > > > > if (*p != ')') /* () means no args, skip while */ > > @@ -1588,8 +1590,9 @@ check_stub_method (struct type *type, in > > /* Avoid parsing of ellipsis, they will be handled below. */ > > if (strncmp (argtypetext, "...", p - argtypetext) != 0) > > { > > - argtypes[argcount] = > > + argtypes[argcount].type = > > safe_parse_type (argtypetext, p - argtypetext); > > + argtypes[argcount].artificial = 0; > > argcount += 1; > > } > > argtypetext = p + 1; > > @@ -1610,11 +1613,13 @@ check_stub_method (struct type *type, in > > > > if (p[-2] != '.') /* Not '...' */ > > { > > - argtypes[argcount] = builtin_type_void; /* List terminator */ > > + argtypes[argcount].type = builtin_type_void; /* List terminator */ > > + argtypes[argcount].artificial = 0; > > } > > else > > { > > - argtypes[argcount] = NULL; /* Ellist terminator */ > > + argtypes[argcount].type = NULL; /* Ellist terminator */ > > + argtypes[argcount].artificial = 0; > > } > > > > xfree (demangled_name); > > @@ -1626,7 +1631,7 @@ check_stub_method (struct type *type, in > > /* Now update the old "stub" type into a real type. */ > > mtype = TYPE_FN_FIELD_TYPE (f, signature_id); > > TYPE_DOMAIN_TYPE (mtype) = type; > > - TYPE_ARG_TYPES (mtype) = argtypes; > > + TYPE_METHOD_ARGS (mtype) = argtypes; > > TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB; > > TYPE_FN_FIELD_STUB (f, signature_id) = 0; > > } > > @@ -2584,14 +2589,15 @@ print_bit_vector (B_TYPE *bits, int nbit > > include it since we may get into a infinitely recursive situation. */ > > > > static void > > -print_arg_types (struct type **args, int spaces) > > +print_arg_types (struct method_args *args, int spaces) > > { > > if (args != NULL) > > { > > - while (*args != NULL) > > + while (args->type != NULL) > > { > > - recursive_dump_type (*args, spaces + 2); > > - if ((*args++)->code == TYPE_CODE_VOID) > > + printfi_filtered (spaces, "artificial %d\n", args->artificial); > > + recursive_dump_type (args->type, spaces + 2); > > + if ((args++)->type->code == TYPE_CODE_VOID) > > { > > break; > > } > > @@ -2640,7 +2646,7 @@ dump_fn_fieldlists (struct type *type, i > > gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout); > > printf_filtered ("\n"); > > > > - print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces); > > + print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces+8); > > printfi_filtered (spaces + 8, "fcontext "); > > gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx), > > gdb_stdout); > > @@ -2978,10 +2984,10 @@ recursive_dump_type (struct type *type, > > { > > case TYPE_CODE_METHOD: > > case TYPE_CODE_FUNC: > > - printfi_filtered (spaces, "arg_types "); > > - gdb_print_host_address (TYPE_ARG_TYPES (type), gdb_stdout); > > + printfi_filtered (spaces, "method_args "); > > + gdb_print_host_address (TYPE_METHOD_ARGS (type), gdb_stdout); > > puts_filtered ("\n"); > > - print_arg_types (TYPE_ARG_TYPES (type), spaces); > > + print_arg_types (TYPE_METHOD_ARGS (type), spaces); > > break; > > > > case TYPE_CODE_STRUCT: > > diff -urp src-p3/gdb/gdbtypes.h src-final/gdb/gdbtypes.h > > --- src-p3/gdb/gdbtypes.h Tue Jan 15 14:38:27 2002 > > +++ src-final/gdb/gdbtypes.h Tue Jan 15 14:30:21 2002 > > @@ -73,6 +73,11 @@ struct block; > > #define B_BYTES(x) ( 1 + ((x)>>3) ) > > #define B_CLRALL(a,x) memset ((a), 0, B_BYTES(x)) > > > > +struct method_args { > > + struct type *type; > > + int artificial; > > +}; > > + > > /* Different kinds of data types are distinguished by the `code' field. */ > > > > enum type_code > > @@ -463,7 +468,7 @@ struct type > > pointer after the last argument for functions with variable > > arguments. */ > > > > - struct type **arg_types; > > + struct method_args *method_args; > > > > /* CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to point to > > cplus_struct_default, a default static instance of a struct > > @@ -780,7 +785,8 @@ extern void allocate_cplus_struct_type ( > > #define TYPE_NINSTANTIATIONS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ninstantiations > > #define TYPE_DECLARED_TYPE(thistype) TYPE_CPLUS_SPECIFIC(thistype)->declared_type > > #define TYPE_TYPE_SPECIFIC(thistype) (thistype)->type_specific > > -#define TYPE_ARG_TYPES(thistype) (thistype)->type_specific.arg_types > > +#define TYPE_METHOD_ARGS(thistype) (thistype)->type_specific.method_args > > +#define TYPE_ARG_TYPE(thistype,i) TYPE_METHOD_ARGS(thistype)[i].type > > #define TYPE_CPLUS_SPECIFIC(thistype) (thistype)->type_specific.cplus_stuff > > #define TYPE_FLOATFORMAT(thistype) (thistype)->type_specific.floatformat > > #define TYPE_BASECLASS(thistype,index) (thistype)->fields[index].type > > @@ -858,7 +864,8 @@ extern void allocate_cplus_struct_type ( > > #define TYPE_FN_FIELD(thisfn, n) (thisfn)[n] > > #define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname > > #define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type > > -#define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_ARG_TYPES ((thisfn)[n].type) > > +#define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_METHOD_ARGS ((thisfn)[n].type) > > +#define TYPE_FN_FIELD_ARG(thisfn, n, i) TYPE_ARG_TYPE ((thisfn)[n].type, i) > > #define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const) > > #define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile) > > #define TYPE_FN_FIELD_PRIVATE(thisfn, n) ((thisfn)[n].is_private) > > @@ -1068,7 +1075,7 @@ extern struct type *lookup_member_type ( > > > > extern void > > smash_to_method_type (struct type *, struct type *, struct type *, > > - struct type **); > > + struct method_args *); > > > > extern void > > smash_to_member_type (struct type *, struct type *, struct type *); > > diff -urp src-p3/gdb/hp-symtab-read.c src-final/gdb/hp-symtab-read.c > > --- src-p3/gdb/hp-symtab-read.c Tue Jan 15 14:29:16 2002 > > +++ src-final/gdb/hp-symtab-read.c Tue Jan 15 14:30:21 2002 > > @@ -2555,19 +2555,20 @@ hpread_type_lookup (dnttpointer hp_type, > > struct type *retvaltype; > > int nargs; > > int i; > > - struct type **args_type; > > + struct method_args *args_type; > > class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto, > > objfile); > > functype = hpread_type_lookup (dn_bufp->dptrmem.memtype, > > objfile); > > retvaltype = TYPE_TARGET_TYPE (functype); > > nargs = TYPE_NFIELDS (functype); > > - args_type = (struct type **) xmalloc ((nargs + 1) * sizeof (struct type *)); > > + args_type = (struct method_args *) xmalloc ((nargs + 1) * sizeof (struct method_args)); > > for (i = 0; i < nargs; i++) > > { > > - args_type[i] = TYPE_FIELD_TYPE (functype, i); > > + args_type[i].type = TYPE_FIELD_TYPE (functype, i); > > + args_type[i].artificial = 0; > > } > > - args_type[nargs] = NULL; > > + args_type[nargs].type = NULL; > > ptrmemtype = alloc_type (objfile); > > smash_to_method_type (ptrmemtype, class_type, retvaltype, args_type); > > return make_pointer_type (ptrmemtype, NULL); > > diff -urp src-p3/gdb/stabsread.c src-final/gdb/stabsread.c > > --- src-p3/gdb/stabsread.c Tue Jan 15 14:29:16 2002 > > +++ src-final/gdb/stabsread.c Tue Jan 15 14:30:22 2002 > > @@ -141,7 +141,7 @@ static struct type *read_struct_type (ch > > static struct type *read_array_type (char **, struct type *, > > struct objfile *); > > > > -static struct type **read_args (char **, int, struct objfile *); > > +static struct method_args *read_args (char **, int, struct objfile *); > > > > static int > > read_cpp_abbrev (struct field_info *, char **, struct type *, > > @@ -2671,7 +2671,7 @@ again: > > { > > struct type *domain = read_type (pp, objfile); > > struct type *return_type; > > - struct type **args; > > + struct method_args *args; > > > > if (**pp != ',') > > /* Invalid member type data format. */ > > @@ -4748,21 +4748,23 @@ handle_true_range: > > } > > > > /* Read in an argument list. This is a list of types, separated by commas > > - and terminated with END. Return the list of types read in, or (struct type > > - **)-1 if there is an error. */ > > + and terminated with END. Return the list of types read in, or (struct > > + method_args *)-1 if there is an error. */ > > > > -static struct type ** > > +static struct method_args * > > read_args (char **pp, int end, struct objfile *objfile) > > { > > /* FIXME! Remove this arbitrary limit! */ > > - struct type *types[1024], **rval; /* allow for fns of 1023 parameters */ > > + struct type *types[1024]; /* allow for fns of 1023 parameters */ > > + struct method_args *rval; > > int n = 0; > > + int i; > > > > while (**pp != end) > > { > > if (**pp != ',') > > /* Invalid argument list: no ','. */ > > - return (struct type **) -1; > > + return (struct method_args *) -1; > > (*pp)++; > > STABS_CONTINUE (pp, objfile); > > types[n++] = read_type (pp, objfile); > > @@ -4771,18 +4773,22 @@ read_args (char **pp, int end, struct ob > > > > if (n == 1) > > { > > - rval = (struct type **) xmalloc (2 * sizeof (struct type *)); > > + rval = (struct method_args *) xmalloc (2 * sizeof (struct method_args)); > > } > > else if (TYPE_CODE (types[n - 1]) != TYPE_CODE_VOID) > > { > > - rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *)); > > - memset (rval + n, 0, sizeof (struct type *)); > > + rval = (struct method_args *) xmalloc ((n + 1) * sizeof (struct method_args)); > > + memset (rval + n, 0, sizeof (struct method_args)); > > } > > else > > { > > - rval = (struct type **) xmalloc (n * sizeof (struct type *)); > > + rval = (struct method_args *) xmalloc (n * sizeof (struct method_args)); > > + } > > + for (i = 0; i < n; i++) > > + { > > + rval[i].type = types[i]; > > + rval[i].artificial = 0; > > } > > - memcpy (rval, types, n * sizeof (struct type *)); > > return rval; > > } > > \f > > diff -urp src-p3/gdb/valops.c src-final/gdb/valops.c > > --- src-p3/gdb/valops.c Tue Jan 15 14:25:54 2002 > > +++ src-final/gdb/valops.c Tue Jan 15 14:30:22 2002 > > @@ -44,7 +44,7 @@ extern int hp_som_som_object_present; > > extern int overload_debug; > > /* Local functions. */ > > > > -static int typecmp (int staticp, struct type *t1[], struct value *t2[]); > > +static int typecmp (int staticp, struct method_args *t1, struct value *t2[]); > > > > static CORE_ADDR find_function_addr (struct value *, struct type **); > > static struct value *value_arg_coerce (struct value *, struct type *, int); > > @@ -1429,7 +1429,7 @@ hand_function_call (struct value *functi > > if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) > > { > > i = 0; > > - while (TYPE_CODE (TYPE_ARG_TYPES (ftype)[i]) != TYPE_CODE_VOID) > > + while (TYPE_CODE (TYPE_ARG_TYPE (ftype, i)) != TYPE_CODE_VOID) > > i++; > > n_method_args = i; > > if (nargs < i) > > @@ -1446,7 +1446,7 @@ hand_function_call (struct value *functi > > if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) > > { > > if (i < n_method_args) > > - args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPES (ftype)[i], 1); > > + args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPE (ftype, i), 1); > > else > > args[i] = value_arg_coerce (args[i], NULL, 0); > > } > > @@ -1941,7 +1941,7 @@ value_bitstring (char *ptr, int len) > > requested operation is type secure, shouldn't we? FIXME. */ > > > > static int > > -typecmp (int staticp, struct type *t1[], struct value *t2[]) > > +typecmp (int staticp, struct method_args t1[], struct value *t2[]) > > { > > int i; > > > > @@ -1951,16 +1951,17 @@ typecmp (int staticp, struct type *t1[], > > return t2[1] != 0; > > if (t1 == 0) > > return 1; > > - if (TYPE_CODE (t1[0]) == TYPE_CODE_VOID) > > + if (TYPE_CODE (t1[0].type) == TYPE_CODE_VOID) > > return 0; > > - if (t1[!staticp] == 0) > > + if (t1[!staticp].type == 0) > > return 0; > > - for (i = !staticp; t1[i] && TYPE_CODE (t1[i]) != TYPE_CODE_VOID; i++) > > + for (i = !staticp; t1[i].type && TYPE_CODE (t1[i].type) != TYPE_CODE_VOID; > > + i++) > > { > > struct type *tt1, *tt2; > > if (!t2[i]) > > return i + 1; > > - tt1 = check_typedef (t1[i]); > > + tt1 = check_typedef (t1[i].type); > > tt2 = check_typedef (VALUE_TYPE (t2[i])); > > if (TYPE_CODE (tt1) == TYPE_CODE_REF > > /* We should be doing hairy argument matching, as below. */ > > @@ -1997,10 +1998,10 @@ typecmp (int staticp, struct type *t1[], > > /* We should be doing much hairier argument matching (see section 13.2 > > of the ARM), but as a quick kludge, just check for the same type > > code. */ > > - if (TYPE_CODE (t1[i]) != TYPE_CODE (VALUE_TYPE (t2[i]))) > > + if (TYPE_CODE (t1[i].type) != TYPE_CODE (VALUE_TYPE (t2[i]))) > > return i + 1; > > } > > - if (!t1[i]) > > + if (!t1[i].type) > > return 0; > > return t2[i] ? i + 1 : 0; > > } > > @@ -2744,7 +2745,8 @@ find_overload_match (struct type **arg_t > > > > if (TYPE_FN_FIELD_ARGS(fns_ptr,ix)) > > { > > - while (TYPE_CODE(TYPE_FN_FIELD_ARGS(fns_ptr,ix)[nparms]) != TYPE_CODE_VOID) > > + while (TYPE_CODE(TYPE_FN_FIELD_ARG(fns_ptr,ix,nparms)) > > + != TYPE_CODE_VOID) > > nparms++; > > } > > } > > @@ -2758,7 +2760,7 @@ find_overload_match (struct type **arg_t > > parm_types = (struct type **) xmalloc (nparms * (sizeof (struct type *))); > > for (jj = 0; jj < nparms; jj++) > > parm_types[jj] = (method > > - ? (TYPE_FN_FIELD_ARGS (fns_ptr, ix)[jj]) > > + ? (TYPE_FN_FIELD_ARG (fns_ptr, ix, jj)) > > : TYPE_FIELD_TYPE (SYMBOL_TYPE (oload_syms[ix]), jj)); > > > > /* Compare parameter types to supplied argument types */ > > > > -- > Daniel Jacobowitz Carnegie Mellon University > MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-03-07 12:43 ` Daniel Jacobowitz 2002-03-07 12:55 ` Elena Zannoni @ 2002-05-14 14:13 ` Daniel Jacobowitz 2002-05-14 21:36 ` Elena Zannoni 1 sibling, 1 reply; 15+ messages in thread From: Daniel Jacobowitz @ 2002-05-14 14:13 UTC (permalink / raw) To: gdb-patches, Elena Zannoni I hate to be a nag, but this patch would be useful for some of my current work. Do you have a chance to look at it? On Thu, Mar 07, 2002 at 03:43:11PM -0500, Daniel Jacobowitz wrote: > Elena, did you ever get a chance to finish looking at this? > > On Tue, Jan 15, 2002 at 03:31:57PM -0500, Daniel Jacobowitz wrote: > > This one's a bit larger than the others. It also has a little more impact - > > it adds a word of memory per argument per method per class. I don't think > > the storage is an issue right now, and some day I intend to go through and > > clean up our memory usage a little bit in places much more severe than this. > > > > Other than that it's pretty straightforward. OK to commit? > > > > -- > > Daniel Jacobowitz Carnegie Mellon University > > MontaVista Software Debian GNU/Linux Developer > > > > 2002-01-15 Daniel Jacobowitz <drow@mvista.com> > > > > * gdbtypes.h (struct method_args): New. > > (struct type): Change arg_types to method_args. > > Change TYPE_ARG_TYPES to TYPE_METHOD_ARGS. Add TYPE_ARG_TYPE, > > TYPE_FN_FIELD_ARG. > > (smash_to_method_type): Update prototype to accept struct > > method_args. > > * gdbtypes.c (smash_to_method_type): Update to use TYPE_METHOD_ARGS. > > (check_stub_method): Likewise. Initialize method arguments > > to non-artificial. > > (print_arg_types): Update to accept struct method_args. Print out > > new field ``artificial'' for each argument. > > (dump_fn_fieldlists): Fix indentation of type dumps. > > (recursive_dump_type): Update to use TYPE_METHOD_ARGS. > > > > * dwarf2read.c (dwarf2_add_member_fn): Update to use struct > > method_args. Preserve TYPE_FIELD_ARTIFICIAL. > > * stabsread.c (read_type): Update to use struct method_args. > > (read_args): Likewise. Initialize artificial to 0. > > * valops.c (hand_function_call): Update to use struct method_args. > > (typecmp): Likewise. > > (find_overload_match): Update to use TYPE_FN_FIELD_ARG. > > > > * c-typeprint.c (cp_type_print_method_args): Update to accept > > struct method_args. Skip leading artificial arguments. > > (c_type_print_args): Likewise. > > > > diff -urp src-p3/gdb/c-typeprint.c src-final/gdb/c-typeprint.c > > --- src-p3/gdb/c-typeprint.c Tue Jan 15 14:38:27 2002 > > +++ src-final/gdb/c-typeprint.c Tue Jan 15 14:30:21 2002 > > @@ -41,7 +41,7 @@ > > /* Flag indicating target was compiled by HP compiler */ > > extern int hp_som_som_object_present; > > > > -static void cp_type_print_method_args (struct type ** args, char *prefix, > > +static void cp_type_print_method_args (struct method_args *args, char *prefix, > > char *varstring, int staticp, > > struct ui_file *stream); > > > > @@ -150,26 +150,36 @@ cp_type_print_derivation_info (struct ui > > /* Print the C++ method arguments ARGS to the file STREAM. */ > > > > static void > > -cp_type_print_method_args (struct type **args, char *prefix, char *varstring, > > - int staticp, struct ui_file *stream) > > +cp_type_print_method_args (struct method_args *args, char *prefix, > > + char *varstring, int staticp, > > + struct ui_file *stream) > > { > > - int i; > > + struct method_args *curarg = NULL; > > + > > + if (args != NULL) > > + { > > + /* Skip ``this'' and any leading artificial arguments. */ > > + curarg = &args[!staticp]; > > + while (curarg->artificial) > > + curarg++; > > + } > > > > fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI); > > fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI); > > fputs_filtered ("(", stream); > > - if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID) > > + if (curarg && curarg->type > > + && curarg->type->code != TYPE_CODE_VOID) > > { > > - i = !staticp; /* skip the class variable */ > > while (1) > > { > > - type_print (args[i++], "", stream, 0); > > - if (!args[i]) > > + type_print (curarg->type, "", stream, 0); > > + curarg++; > > + if (!curarg->type) > > { > > fprintf_filtered (stream, " ..."); > > break; > > } > > - else if (args[i]->code != TYPE_CODE_VOID) > > + else if (curarg->type->code != TYPE_CODE_VOID) > > { > > fprintf_filtered (stream, ", "); > > } > > @@ -336,33 +346,39 @@ static void > > c_type_print_args (struct type *type, struct ui_file *stream) > > { > > int i; > > - struct type **args; > > + struct method_args *args, *curarg; > > > > fprintf_filtered (stream, "("); > > - args = TYPE_ARG_TYPES (type); > > + args = TYPE_METHOD_ARGS (type); > > if (args != NULL) > > { > > - if (args[1] == NULL) > > + /* Always skip ``this''. */ > > + curarg = &args[1]; > > + > > + /* Skip any artificial arguments. */ > > + while (curarg->artificial) > > + curarg++; > > + > > + if (curarg->type == NULL) > > { > > fprintf_filtered (stream, "..."); > > } > > - else if ((args[1]->code == TYPE_CODE_VOID) && > > + else if ((curarg->type->code == TYPE_CODE_VOID) && > > (current_language->la_language == language_cplus)) > > { > > fprintf_filtered (stream, "void"); > > } > > else > > { > > - for (i = 1; > > - args[i] != NULL && args[i]->code != TYPE_CODE_VOID; > > - i++) > > + while (curarg->type != NULL > > + && curarg->type->code != TYPE_CODE_VOID) > > { > > - c_print_type (args[i], "", stream, -1, 0); > > - if (args[i + 1] == NULL) > > + c_print_type (curarg->type, "", stream, -1, 0); > > + if ((curarg + 1)->type == NULL) > > { > > fprintf_filtered (stream, "..."); > > } > > - else if (args[i + 1]->code != TYPE_CODE_VOID) > > + else if ((curarg + 1)->type->code != TYPE_CODE_VOID) > > { > > fprintf_filtered (stream, ","); > > wrap_here (" "); > > diff -urp src-p3/gdb/dwarf2read.c src-final/gdb/dwarf2read.c > > --- src-p3/gdb/dwarf2read.c Tue Jan 15 14:38:27 2002 > > +++ src-final/gdb/dwarf2read.c Tue Jan 15 14:30:21 2002 > > @@ -2116,21 +2116,26 @@ dwarf2_add_member_fn (struct field_info > > if (die->type && TYPE_CODE (die->type) == TYPE_CODE_FUNC) > > { > > struct type *return_type = TYPE_TARGET_TYPE (die->type); > > - struct type **arg_types; > > + struct method_args *arg_types; > > int nparams = TYPE_NFIELDS (die->type); > > int iparams; > > > > /* Copy argument types from the subroutine type. */ > > - arg_types = (struct type **) > > - TYPE_ALLOC (fnp->type, (nparams + 1) * sizeof (struct type *)); > > + arg_types = (struct method_args *) > > + TYPE_ALLOC (fnp->type, (nparams + 1) * sizeof (struct method_args)); > > for (iparams = 0; iparams < nparams; iparams++) > > - arg_types[iparams] = TYPE_FIELD_TYPE (die->type, iparams); > > + { > > + arg_types[iparams].type = TYPE_FIELD_TYPE (die->type, iparams); > > + arg_types[iparams].artificial = TYPE_FIELD_ARTIFICIAL (die->type, > > + iparams); > > + } > > > > /* Set last entry in argument type vector. */ > > if (TYPE_VARARGS (die->type)) > > - arg_types[nparams] = NULL; > > + arg_types[nparams].type = NULL; > > else > > - arg_types[nparams] = dwarf2_fundamental_type (objfile, FT_VOID); > > + arg_types[nparams].type = dwarf2_fundamental_type (objfile, FT_VOID); > > + arg_types[nparams].artificial = 0; > > > > smash_to_method_type (fnp->type, type, return_type, arg_types); > > > > diff -urp src-p3/gdb/gdbtypes.c src-final/gdb/gdbtypes.c > > --- src-p3/gdb/gdbtypes.c Tue Jan 15 14:25:54 2002 > > +++ src-final/gdb/gdbtypes.c Tue Jan 15 14:30:21 2002 > > @@ -112,7 +112,7 @@ static void add_mangled_type (struct ext > > static void cfront_mangle_name (struct type *, int, int); > > #endif > > static void print_bit_vector (B_TYPE *, int); > > -static void print_arg_types (struct type **, int); > > +static void print_arg_types (struct method_args *, int); > > static void dump_fn_fieldlists (struct type *, int); > > static void print_cplus_stuff (struct type *, int); > > static void virtual_base_list_aux (struct type *dclass); > > @@ -821,7 +821,7 @@ smash_to_member_type (struct type *type, > > > > void > > smash_to_method_type (struct type *type, struct type *domain, > > - struct type *to_type, struct type **args) > > + struct type *to_type, struct method_args *args) > > { > > struct objfile *objfile; > > > > @@ -831,7 +831,7 @@ smash_to_method_type (struct type *type, > > TYPE_OBJFILE (type) = objfile; > > TYPE_TARGET_TYPE (type) = to_type; > > TYPE_DOMAIN_TYPE (type) = domain; > > - TYPE_ARG_TYPES (type) = args; > > + TYPE_METHOD_ARGS (type) = args; > > TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */ > > TYPE_CODE (type) = TYPE_CODE_METHOD; > > } > > @@ -1535,7 +1535,7 @@ check_stub_method (struct type *type, in > > DMGL_PARAMS | DMGL_ANSI); > > char *argtypetext, *p; > > int depth = 0, argcount = 1; > > - struct type **argtypes; > > + struct method_args *argtypes; > > struct type *mtype; > > > > /* Make sure we got back a function string that we can use. */ > > @@ -1571,11 +1571,13 @@ check_stub_method (struct type *type, in > > /* We need two more slots: one for the THIS pointer, and one for the > > NULL [...] or void [end of arglist]. */ > > > > - argtypes = (struct type **) > > - TYPE_ALLOC (type, (argcount + 2) * sizeof (struct type *)); > > + argtypes = (struct method_args *) > > + TYPE_ALLOC (type, (argcount + 2) * sizeof (struct method_args)); > > p = argtypetext; > > /* FIXME: This is wrong for static member functions. */ > > - argtypes[0] = lookup_pointer_type (type); > > + argtypes[0].type = lookup_pointer_type (type); > > + /* Assume no artificial arguments. */ > > + argtypes[0].artificial = 0; > > argcount = 1; > > > > if (*p != ')') /* () means no args, skip while */ > > @@ -1588,8 +1590,9 @@ check_stub_method (struct type *type, in > > /* Avoid parsing of ellipsis, they will be handled below. */ > > if (strncmp (argtypetext, "...", p - argtypetext) != 0) > > { > > - argtypes[argcount] = > > + argtypes[argcount].type = > > safe_parse_type (argtypetext, p - argtypetext); > > + argtypes[argcount].artificial = 0; > > argcount += 1; > > } > > argtypetext = p + 1; > > @@ -1610,11 +1613,13 @@ check_stub_method (struct type *type, in > > > > if (p[-2] != '.') /* Not '...' */ > > { > > - argtypes[argcount] = builtin_type_void; /* List terminator */ > > + argtypes[argcount].type = builtin_type_void; /* List terminator */ > > + argtypes[argcount].artificial = 0; > > } > > else > > { > > - argtypes[argcount] = NULL; /* Ellist terminator */ > > + argtypes[argcount].type = NULL; /* Ellist terminator */ > > + argtypes[argcount].artificial = 0; > > } > > > > xfree (demangled_name); > > @@ -1626,7 +1631,7 @@ check_stub_method (struct type *type, in > > /* Now update the old "stub" type into a real type. */ > > mtype = TYPE_FN_FIELD_TYPE (f, signature_id); > > TYPE_DOMAIN_TYPE (mtype) = type; > > - TYPE_ARG_TYPES (mtype) = argtypes; > > + TYPE_METHOD_ARGS (mtype) = argtypes; > > TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB; > > TYPE_FN_FIELD_STUB (f, signature_id) = 0; > > } > > @@ -2584,14 +2589,15 @@ print_bit_vector (B_TYPE *bits, int nbit > > include it since we may get into a infinitely recursive situation. */ > > > > static void > > -print_arg_types (struct type **args, int spaces) > > +print_arg_types (struct method_args *args, int spaces) > > { > > if (args != NULL) > > { > > - while (*args != NULL) > > + while (args->type != NULL) > > { > > - recursive_dump_type (*args, spaces + 2); > > - if ((*args++)->code == TYPE_CODE_VOID) > > + printfi_filtered (spaces, "artificial %d\n", args->artificial); > > + recursive_dump_type (args->type, spaces + 2); > > + if ((args++)->type->code == TYPE_CODE_VOID) > > { > > break; > > } > > @@ -2640,7 +2646,7 @@ dump_fn_fieldlists (struct type *type, i > > gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout); > > printf_filtered ("\n"); > > > > - print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces); > > + print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces+8); > > printfi_filtered (spaces + 8, "fcontext "); > > gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx), > > gdb_stdout); > > @@ -2978,10 +2984,10 @@ recursive_dump_type (struct type *type, > > { > > case TYPE_CODE_METHOD: > > case TYPE_CODE_FUNC: > > - printfi_filtered (spaces, "arg_types "); > > - gdb_print_host_address (TYPE_ARG_TYPES (type), gdb_stdout); > > + printfi_filtered (spaces, "method_args "); > > + gdb_print_host_address (TYPE_METHOD_ARGS (type), gdb_stdout); > > puts_filtered ("\n"); > > - print_arg_types (TYPE_ARG_TYPES (type), spaces); > > + print_arg_types (TYPE_METHOD_ARGS (type), spaces); > > break; > > > > case TYPE_CODE_STRUCT: > > diff -urp src-p3/gdb/gdbtypes.h src-final/gdb/gdbtypes.h > > --- src-p3/gdb/gdbtypes.h Tue Jan 15 14:38:27 2002 > > +++ src-final/gdb/gdbtypes.h Tue Jan 15 14:30:21 2002 > > @@ -73,6 +73,11 @@ struct block; > > #define B_BYTES(x) ( 1 + ((x)>>3) ) > > #define B_CLRALL(a,x) memset ((a), 0, B_BYTES(x)) > > > > +struct method_args { > > + struct type *type; > > + int artificial; > > +}; > > + > > /* Different kinds of data types are distinguished by the `code' field. */ > > > > enum type_code > > @@ -463,7 +468,7 @@ struct type > > pointer after the last argument for functions with variable > > arguments. */ > > > > - struct type **arg_types; > > + struct method_args *method_args; > > > > /* CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to point to > > cplus_struct_default, a default static instance of a struct > > @@ -780,7 +785,8 @@ extern void allocate_cplus_struct_type ( > > #define TYPE_NINSTANTIATIONS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ninstantiations > > #define TYPE_DECLARED_TYPE(thistype) TYPE_CPLUS_SPECIFIC(thistype)->declared_type > > #define TYPE_TYPE_SPECIFIC(thistype) (thistype)->type_specific > > -#define TYPE_ARG_TYPES(thistype) (thistype)->type_specific.arg_types > > +#define TYPE_METHOD_ARGS(thistype) (thistype)->type_specific.method_args > > +#define TYPE_ARG_TYPE(thistype,i) TYPE_METHOD_ARGS(thistype)[i].type > > #define TYPE_CPLUS_SPECIFIC(thistype) (thistype)->type_specific.cplus_stuff > > #define TYPE_FLOATFORMAT(thistype) (thistype)->type_specific.floatformat > > #define TYPE_BASECLASS(thistype,index) (thistype)->fields[index].type > > @@ -858,7 +864,8 @@ extern void allocate_cplus_struct_type ( > > #define TYPE_FN_FIELD(thisfn, n) (thisfn)[n] > > #define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname > > #define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type > > -#define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_ARG_TYPES ((thisfn)[n].type) > > +#define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_METHOD_ARGS ((thisfn)[n].type) > > +#define TYPE_FN_FIELD_ARG(thisfn, n, i) TYPE_ARG_TYPE ((thisfn)[n].type, i) > > #define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const) > > #define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile) > > #define TYPE_FN_FIELD_PRIVATE(thisfn, n) ((thisfn)[n].is_private) > > @@ -1068,7 +1075,7 @@ extern struct type *lookup_member_type ( > > > > extern void > > smash_to_method_type (struct type *, struct type *, struct type *, > > - struct type **); > > + struct method_args *); > > > > extern void > > smash_to_member_type (struct type *, struct type *, struct type *); > > diff -urp src-p3/gdb/hp-symtab-read.c src-final/gdb/hp-symtab-read.c > > --- src-p3/gdb/hp-symtab-read.c Tue Jan 15 14:29:16 2002 > > +++ src-final/gdb/hp-symtab-read.c Tue Jan 15 14:30:21 2002 > > @@ -2555,19 +2555,20 @@ hpread_type_lookup (dnttpointer hp_type, > > struct type *retvaltype; > > int nargs; > > int i; > > - struct type **args_type; > > + struct method_args *args_type; > > class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto, > > objfile); > > functype = hpread_type_lookup (dn_bufp->dptrmem.memtype, > > objfile); > > retvaltype = TYPE_TARGET_TYPE (functype); > > nargs = TYPE_NFIELDS (functype); > > - args_type = (struct type **) xmalloc ((nargs + 1) * sizeof (struct type *)); > > + args_type = (struct method_args *) xmalloc ((nargs + 1) * sizeof (struct method_args)); > > for (i = 0; i < nargs; i++) > > { > > - args_type[i] = TYPE_FIELD_TYPE (functype, i); > > + args_type[i].type = TYPE_FIELD_TYPE (functype, i); > > + args_type[i].artificial = 0; > > } > > - args_type[nargs] = NULL; > > + args_type[nargs].type = NULL; > > ptrmemtype = alloc_type (objfile); > > smash_to_method_type (ptrmemtype, class_type, retvaltype, args_type); > > return make_pointer_type (ptrmemtype, NULL); > > diff -urp src-p3/gdb/stabsread.c src-final/gdb/stabsread.c > > --- src-p3/gdb/stabsread.c Tue Jan 15 14:29:16 2002 > > +++ src-final/gdb/stabsread.c Tue Jan 15 14:30:22 2002 > > @@ -141,7 +141,7 @@ static struct type *read_struct_type (ch > > static struct type *read_array_type (char **, struct type *, > > struct objfile *); > > > > -static struct type **read_args (char **, int, struct objfile *); > > +static struct method_args *read_args (char **, int, struct objfile *); > > > > static int > > read_cpp_abbrev (struct field_info *, char **, struct type *, > > @@ -2671,7 +2671,7 @@ again: > > { > > struct type *domain = read_type (pp, objfile); > > struct type *return_type; > > - struct type **args; > > + struct method_args *args; > > > > if (**pp != ',') > > /* Invalid member type data format. */ > > @@ -4748,21 +4748,23 @@ handle_true_range: > > } > > > > /* Read in an argument list. This is a list of types, separated by commas > > - and terminated with END. Return the list of types read in, or (struct type > > - **)-1 if there is an error. */ > > + and terminated with END. Return the list of types read in, or (struct > > + method_args *)-1 if there is an error. */ > > > > -static struct type ** > > +static struct method_args * > > read_args (char **pp, int end, struct objfile *objfile) > > { > > /* FIXME! Remove this arbitrary limit! */ > > - struct type *types[1024], **rval; /* allow for fns of 1023 parameters */ > > + struct type *types[1024]; /* allow for fns of 1023 parameters */ > > + struct method_args *rval; > > int n = 0; > > + int i; > > > > while (**pp != end) > > { > > if (**pp != ',') > > /* Invalid argument list: no ','. */ > > - return (struct type **) -1; > > + return (struct method_args *) -1; > > (*pp)++; > > STABS_CONTINUE (pp, objfile); > > types[n++] = read_type (pp, objfile); > > @@ -4771,18 +4773,22 @@ read_args (char **pp, int end, struct ob > > > > if (n == 1) > > { > > - rval = (struct type **) xmalloc (2 * sizeof (struct type *)); > > + rval = (struct method_args *) xmalloc (2 * sizeof (struct method_args)); > > } > > else if (TYPE_CODE (types[n - 1]) != TYPE_CODE_VOID) > > { > > - rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *)); > > - memset (rval + n, 0, sizeof (struct type *)); > > + rval = (struct method_args *) xmalloc ((n + 1) * sizeof (struct method_args)); > > + memset (rval + n, 0, sizeof (struct method_args)); > > } > > else > > { > > - rval = (struct type **) xmalloc (n * sizeof (struct type *)); > > + rval = (struct method_args *) xmalloc (n * sizeof (struct method_args)); > > + } > > + for (i = 0; i < n; i++) > > + { > > + rval[i].type = types[i]; > > + rval[i].artificial = 0; > > } > > - memcpy (rval, types, n * sizeof (struct type *)); > > return rval; > > } > > \f > > diff -urp src-p3/gdb/valops.c src-final/gdb/valops.c > > --- src-p3/gdb/valops.c Tue Jan 15 14:25:54 2002 > > +++ src-final/gdb/valops.c Tue Jan 15 14:30:22 2002 > > @@ -44,7 +44,7 @@ extern int hp_som_som_object_present; > > extern int overload_debug; > > /* Local functions. */ > > > > -static int typecmp (int staticp, struct type *t1[], struct value *t2[]); > > +static int typecmp (int staticp, struct method_args *t1, struct value *t2[]); > > > > static CORE_ADDR find_function_addr (struct value *, struct type **); > > static struct value *value_arg_coerce (struct value *, struct type *, int); > > @@ -1429,7 +1429,7 @@ hand_function_call (struct value *functi > > if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) > > { > > i = 0; > > - while (TYPE_CODE (TYPE_ARG_TYPES (ftype)[i]) != TYPE_CODE_VOID) > > + while (TYPE_CODE (TYPE_ARG_TYPE (ftype, i)) != TYPE_CODE_VOID) > > i++; > > n_method_args = i; > > if (nargs < i) > > @@ -1446,7 +1446,7 @@ hand_function_call (struct value *functi > > if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) > > { > > if (i < n_method_args) > > - args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPES (ftype)[i], 1); > > + args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPE (ftype, i), 1); > > else > > args[i] = value_arg_coerce (args[i], NULL, 0); > > } > > @@ -1941,7 +1941,7 @@ value_bitstring (char *ptr, int len) > > requested operation is type secure, shouldn't we? FIXME. */ > > > > static int > > -typecmp (int staticp, struct type *t1[], struct value *t2[]) > > +typecmp (int staticp, struct method_args t1[], struct value *t2[]) > > { > > int i; > > > > @@ -1951,16 +1951,17 @@ typecmp (int staticp, struct type *t1[], > > return t2[1] != 0; > > if (t1 == 0) > > return 1; > > - if (TYPE_CODE (t1[0]) == TYPE_CODE_VOID) > > + if (TYPE_CODE (t1[0].type) == TYPE_CODE_VOID) > > return 0; > > - if (t1[!staticp] == 0) > > + if (t1[!staticp].type == 0) > > return 0; > > - for (i = !staticp; t1[i] && TYPE_CODE (t1[i]) != TYPE_CODE_VOID; i++) > > + for (i = !staticp; t1[i].type && TYPE_CODE (t1[i].type) != TYPE_CODE_VOID; > > + i++) > > { > > struct type *tt1, *tt2; > > if (!t2[i]) > > return i + 1; > > - tt1 = check_typedef (t1[i]); > > + tt1 = check_typedef (t1[i].type); > > tt2 = check_typedef (VALUE_TYPE (t2[i])); > > if (TYPE_CODE (tt1) == TYPE_CODE_REF > > /* We should be doing hairy argument matching, as below. */ > > @@ -1997,10 +1998,10 @@ typecmp (int staticp, struct type *t1[], > > /* We should be doing much hairier argument matching (see section 13.2 > > of the ARM), but as a quick kludge, just check for the same type > > code. */ > > - if (TYPE_CODE (t1[i]) != TYPE_CODE (VALUE_TYPE (t2[i]))) > > + if (TYPE_CODE (t1[i].type) != TYPE_CODE (VALUE_TYPE (t2[i]))) > > return i + 1; > > } > > - if (!t1[i]) > > + if (!t1[i].type) > > return 0; > > return t2[i] ? i + 1 : 0; > > } > > @@ -2744,7 +2745,8 @@ find_overload_match (struct type **arg_t > > > > if (TYPE_FN_FIELD_ARGS(fns_ptr,ix)) > > { > > - while (TYPE_CODE(TYPE_FN_FIELD_ARGS(fns_ptr,ix)[nparms]) != TYPE_CODE_VOID) > > + while (TYPE_CODE(TYPE_FN_FIELD_ARG(fns_ptr,ix,nparms)) > > + != TYPE_CODE_VOID) > > nparms++; > > } > > } > > @@ -2758,7 +2760,7 @@ find_overload_match (struct type **arg_t > > parm_types = (struct type **) xmalloc (nparms * (sizeof (struct type *))); > > for (jj = 0; jj < nparms; jj++) > > parm_types[jj] = (method > > - ? (TYPE_FN_FIELD_ARGS (fns_ptr, ix)[jj]) > > + ? (TYPE_FN_FIELD_ARG (fns_ptr, ix, jj)) > > : TYPE_FIELD_TYPE (SYMBOL_TYPE (oload_syms[ix]), jj)); > > > > /* Compare parameter types to supplied argument types */ > > > > -- > Daniel Jacobowitz Carnegie Mellon University > MontaVista Software Debian GNU/Linux Developer > -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-05-14 14:13 ` Daniel Jacobowitz @ 2002-05-14 21:36 ` Elena Zannoni 2002-05-14 21:52 ` Daniel Jacobowitz 0 siblings, 1 reply; 15+ messages in thread From: Elena Zannoni @ 2002-05-14 21:36 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: gdb-patches, mec@shout.net Elena Zannoni Daniel Jacobowitz writes: > I hate to be a nag, but this patch would be useful for some of my > current work. Do you have a chance to look at it? > You are completely right, sorry. I wonder if MichaelC could kindly run it through his test harness. That was a big help with yesterday's patch. And if you can run the tests with the maintainers file script. How much does the size increase by adding this new struct? I have looked at it when you first posted it, and I had some questions, I have to go fish for them again. But basically, the motivation for this change is what? You need to handle the dwarf2 information for artificial arguments, right? So that needs a change in dwarf2read.c. How does that bring about the change in the type structure? Can you explain a bit? (my brain gets lazy at this time). In the meantime, I noticed that the hp-symtab-read.c changes are not mentioned in the ChangeLog (well, now it is hpread.c). Also now you have a bunch of type->code instead of TYPE_CODE(). I tried to apply the patch to the current sources, but it failed in several files. I tried to resolve the conflicts by hand but the compilation died in valops.c, gdbypes.c and c-typeprint.c. I think the rename of type to main_type needs to be taken into account as well. I get these 2 kinds of errors: /home/ezannoni/sources/src/gdb/c-typeprint.c:171: structure has no member named `code' /home/ezannoni/sources/src/gdb/gdbtypes.c:2750: structure has no member named `type_specific' I noticed this quite ugly syntax. I know you didn't introduce it, but, I wonder why it's needed: 't1[!staticp].type' and 'for (i = !staticp;....)' I think you also need to update a few comments in gdbtypes.h when introducing the new method_args field. Is there any better naming scheme for TYPE_FN_FIELD_ARGS and TYPE_FN_FIELD_ARG? I am always a bit worried when identifiers differ by just one char. I guess you can clean the patch up a bit and I'll take a look again. I include my unsuccessful diff below, in case it's useful. Elena > > On Tue, Jan 15, 2002 at 03:31:57PM -0500, Daniel Jacobowitz wrote: > > > This one's a bit larger than the others. It also has a little more impact - > > > it adds a word of memory per argument per method per class. I don't think > > > the storage is an issue right now, and some day I intend to go through and > > > clean up our memory usage a little bit in places much more severe than this. > > > > > > Other than that it's pretty straightforward. OK to commit? > > > > > > -- > > > Daniel Jacobowitz Carnegie Mellon University > > > MontaVista Software Debian GNU/Linux Developer > > > > > > 2002-01-15 Daniel Jacobowitz <drow@mvista.com> > > > > > > * gdbtypes.h (struct method_args): New. > > > (struct type): Change arg_types to method_args. > > > Change TYPE_ARG_TYPES to TYPE_METHOD_ARGS. Add TYPE_ARG_TYPE, > > > TYPE_FN_FIELD_ARG. > > > (smash_to_method_type): Update prototype to accept struct > > > method_args. > > > * gdbtypes.c (smash_to_method_type): Update to use TYPE_METHOD_ARGS. > > > (check_stub_method): Likewise. Initialize method arguments > > > to non-artificial. > > > (print_arg_types): Update to accept struct method_args. Print out > > > new field ``artificial'' for each argument. > > > (dump_fn_fieldlists): Fix indentation of type dumps. > > > (recursive_dump_type): Update to use TYPE_METHOD_ARGS. > > > > > > * dwarf2read.c (dwarf2_add_member_fn): Update to use struct > > > method_args. Preserve TYPE_FIELD_ARTIFICIAL. > > > * stabsread.c (read_type): Update to use struct method_args. > > > (read_args): Likewise. Initialize artificial to 0. > > > * valops.c (hand_function_call): Update to use struct method_args. > > > (typecmp): Likewise. > > > (find_overload_match): Update to use TYPE_FN_FIELD_ARG. > > > > > > * c-typeprint.c (cp_type_print_method_args): Update to accept > > > struct method_args. Skip leading artificial arguments. > > > (c_type_print_args): Likewise. > > > Index: c-typeprint.c =================================================================== RCS file: /cvs/uberbaum/gdb/c-typeprint.c,v retrieving revision 1.20 diff -u -p -r1.20 c-typeprint.c --- c-typeprint.c 14 May 2002 18:30:50 -0000 1.20 +++ c-typeprint.c 15 May 2002 03:56:30 -0000 @@ -41,7 +41,7 @@ /* Flag indicating target was compiled by HP compiler */ extern int hp_som_som_object_present; -static void cp_type_print_method_args (struct type ** args, char *prefix, +static void cp_type_print_method_args (struct method_args *args, char *prefix, char *varstring, int staticp, struct ui_file *stream); @@ -150,26 +150,36 @@ cp_type_print_derivation_info (struct ui /* Print the C++ method arguments ARGS to the file STREAM. */ static void -cp_type_print_method_args (struct type **args, char *prefix, char *varstring, - int staticp, struct ui_file *stream) +cp_type_print_method_args (struct method_args *args, char *prefix, + char *varstring, int staticp, + struct ui_file *stream) { - int i; + struct method_args *curarg = NULL; + + if (args != NULL) + { + /* Skip ``this'' and any leading artificial arguments. */ + curarg = &args[!staticp]; + while (curarg->artificial) + curarg++; + } fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI); fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI); fputs_filtered ("(", stream); - if (args && args[!staticp] && TYPE_CODE (args[!staticp]) != TYPE_CODE_VOID) + if (curarg && curarg->type + && curarg->type->code != TYPE_CODE_VOID) { - i = !staticp; /* skip the class variable */ while (1) { - type_print (args[i++], "", stream, 0); - if (!args[i]) + type_print (curarg->type, "", stream, 0); + curarg++; + if (!curarg->type) { fprintf_filtered (stream, " ..."); break; } - else if (TYPE_CODE (args[i]) != TYPE_CODE_VOID) + else if (curarg->type->code != TYPE_CODE_VOID) { fprintf_filtered (stream, ", "); } @@ -329,40 +339,43 @@ c_type_print_modifier (struct type *type fprintf_filtered (stream, " "); } - - - static void c_type_print_args (struct type *type, struct ui_file *stream) { int i; - struct type **args; + struct method_args *args, *curarg; fprintf_filtered (stream, "("); - args = TYPE_ARG_TYPES (type); + args = TYPE_METHOD_ARGS (type); if (args != NULL) { - if (args[1] == NULL) + /* Always skip ``this''. */ + curarg = &args[1]; + + /* Skip any artificial arguments. */ + while (curarg->artificial) + curarg++; + + if (curarg->type == NULL) { fprintf_filtered (stream, "..."); } - else if ((TYPE_CODE (args[1]) == TYPE_CODE_VOID) && + else if ((curarg->type->code == TYPE_CODE_VOID) && (current_language->la_language == language_cplus)) { fprintf_filtered (stream, "void"); } else { - for (i = 1; - args[i] != NULL && TYPE_CODE (args[i]) != TYPE_CODE_VOID; - i++) + while (curarg->type != NULL + && curarg->type->code != TYPE_CODE_VOID) { - c_print_type (args[i], "", stream, -1, 0); - if (args[i + 1] == NULL) + c_print_type (curarg->type, "", stream, -1, 0); + if ((curarg + 1)->type == NULL) { fprintf_filtered (stream, "..."); } - else if (TYPE_CODE (args[i + 1]) != TYPE_CODE_VOID) + else if ((curarg + 1)->type->code != TYPE_CODE_VOID) { fprintf_filtered (stream, ","); wrap_here (" "); Index: dwarf2read.c =================================================================== RCS file: /cvs/uberbaum/gdb/dwarf2read.c,v retrieving revision 1.56 diff -u -p -r1.56 dwarf2read.c --- dwarf2read.c 14 May 2002 18:30:50 -0000 1.56 +++ dwarf2read.c 15 May 2002 03:57:18 -0000 @@ -2228,21 +2228,26 @@ dwarf2_add_member_fn (struct field_info if (die->type && TYPE_CODE (die->type) == TYPE_CODE_FUNC) { struct type *return_type = TYPE_TARGET_TYPE (die->type); - struct type **arg_types; + struct method_args *arg_types; int nparams = TYPE_NFIELDS (die->type); int iparams; /* Copy argument types from the subroutine type. */ - arg_types = (struct type **) - TYPE_ALLOC (fnp->type, (nparams + 1) * sizeof (struct type *)); + arg_types = (struct method_args *) + TYPE_ALLOC (fnp->type, (nparams + 1) * sizeof (struct method_args)); for (iparams = 0; iparams < nparams; iparams++) - arg_types[iparams] = TYPE_FIELD_TYPE (die->type, iparams); + { + arg_types[iparams].type = TYPE_FIELD_TYPE (die->type, iparams); + arg_types[iparams].artificial = TYPE_FIELD_ARTIFICIAL (die->type, + iparams); + } /* Set last entry in argument type vector. */ if (TYPE_VARARGS (die->type)) - arg_types[nparams] = NULL; + arg_types[nparams].type = NULL; else - arg_types[nparams] = dwarf2_fundamental_type (objfile, FT_VOID); + arg_types[nparams].type = dwarf2_fundamental_type (objfile, FT_VOID); + arg_types[nparams].artificial = 0; smash_to_method_type (fnp->type, type, return_type, arg_types); Index: gdbtypes.c =================================================================== RCS file: /cvs/uberbaum/gdb/gdbtypes.c,v retrieving revision 1.51 diff -u -p -r1.51 gdbtypes.c --- gdbtypes.c 14 May 2002 18:30:50 -0000 1.51 +++ gdbtypes.c 15 May 2002 03:57:31 -0000 @@ -127,7 +127,7 @@ static void add_mangled_type (struct ext static void cfront_mangle_name (struct type *, int, int); #endif static void print_bit_vector (B_TYPE *, int); -static void print_arg_types (struct type **, int); +static void print_arg_types (struct method_args *, int); static void dump_fn_fieldlists (struct type *, int); static void print_cplus_stuff (struct type *, int); static void virtual_base_list_aux (struct type *dclass); @@ -879,7 +879,7 @@ smash_to_member_type (struct type *type, void smash_to_method_type (struct type *type, struct type *domain, - struct type *to_type, struct type **args) + struct type *to_type, struct method_args *args) { struct objfile *objfile; @@ -889,7 +889,7 @@ smash_to_method_type (struct type *type, TYPE_OBJFILE (type) = objfile; TYPE_TARGET_TYPE (type) = to_type; TYPE_DOMAIN_TYPE (type) = domain; - TYPE_ARG_TYPES (type) = args; + TYPE_METHOD_ARGS (type) = args; TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */ TYPE_CODE (type) = TYPE_CODE_METHOD; } @@ -1593,7 +1593,7 @@ check_stub_method (struct type *type, in DMGL_PARAMS | DMGL_ANSI); char *argtypetext, *p; int depth = 0, argcount = 1; - struct type **argtypes; + struct method_args *argtypes; struct type *mtype; /* Make sure we got back a function string that we can use. */ @@ -1629,8 +1629,8 @@ check_stub_method (struct type *type, in /* We need two more slots: one for the THIS pointer, and one for the NULL [...] or void [end of arglist]. */ - argtypes = (struct type **) - TYPE_ALLOC (type, (argcount + 2) * sizeof (struct type *)); + argtypes = (struct method_args *) + TYPE_ALLOC (type, (argcount + 2) * sizeof (struct method_args)); p = argtypetext; /* Add THIS pointer for non-static methods. */ @@ -1639,8 +1639,9 @@ check_stub_method (struct type *type, in argcount = 0; else { - argtypes[0] = lookup_pointer_type (type); - argcount = 1; + argtypes[0].type = lookup_pointer_type (type); + /* Assume no artificial arguments. */ + argtypes[0].artificial = 0; } if (*p != ')') /* () means no args, skip while */ @@ -1653,8 +1654,9 @@ check_stub_method (struct type *type, in /* Avoid parsing of ellipsis, they will be handled below. */ if (strncmp (argtypetext, "...", p - argtypetext) != 0) { - argtypes[argcount] = + argtypes[argcount].type = safe_parse_type (argtypetext, p - argtypetext); + argtypes[argcount].artificial = 0; argcount += 1; } argtypetext = p + 1; @@ -1675,11 +1677,13 @@ check_stub_method (struct type *type, in if (p[-2] != '.') /* Not '...' */ { - argtypes[argcount] = builtin_type_void; /* List terminator */ + argtypes[argcount].type = builtin_type_void; /* List terminator */ + argtypes[argcount].artificial = 0; } else { - argtypes[argcount] = NULL; /* Ellist terminator */ + argtypes[argcount].type = NULL; /* Ellist terminator */ + argtypes[argcount].artificial = 0; } xfree (demangled_name); @@ -1689,7 +1693,7 @@ check_stub_method (struct type *type, in /* Now update the old "stub" type into a real type. */ mtype = TYPE_FN_FIELD_TYPE (f, signature_id); TYPE_DOMAIN_TYPE (mtype) = type; - TYPE_ARG_TYPES (mtype) = argtypes; + TYPE_METHOD_ARGS (mtype) = argtypes; TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB; TYPE_FN_FIELD_STUB (f, signature_id) = 0; } @@ -2689,14 +2693,15 @@ print_bit_vector (B_TYPE *bits, int nbit include it since we may get into a infinitely recursive situation. */ static void -print_arg_types (struct type **args, int spaces) +print_arg_types (struct method_args *args, int spaces) { if (args != NULL) { - while (*args != NULL) + while (args->type != NULL) { - recursive_dump_type (*args, spaces + 2); - if (TYPE_CODE (*args++) == TYPE_CODE_VOID) + printfi_filtered (spaces, "artificial %d\n", args->artificial); + recursive_dump_type (args->type, spaces + 2); + if ((args++)->type->code == TYPE_CODE_VOID) { break; } @@ -2745,7 +2750,7 @@ dump_fn_fieldlists (struct type *type, i gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout); printf_filtered ("\n"); - print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces); + print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces+8); printfi_filtered (spaces + 8, "fcontext "); gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx), gdb_stdout); @@ -3089,10 +3094,10 @@ recursive_dump_type (struct type *type, { case TYPE_CODE_METHOD: case TYPE_CODE_FUNC: - printfi_filtered (spaces, "arg_types "); - gdb_print_host_address (TYPE_ARG_TYPES (type), gdb_stdout); + printfi_filtered (spaces, "method_args "); + gdb_print_host_address (TYPE_METHOD_ARGS (type), gdb_stdout); puts_filtered ("\n"); - print_arg_types (TYPE_ARG_TYPES (type), spaces); + print_arg_types (TYPE_METHOD_ARGS (type), spaces); break; case TYPE_CODE_STRUCT: Index: gdbtypes.h =================================================================== RCS file: /cvs/uberbaum/gdb/gdbtypes.h,v retrieving revision 1.30 diff -u -p -r1.30 gdbtypes.h --- gdbtypes.h 14 May 2002 18:30:50 -0000 1.30 +++ gdbtypes.h 15 May 2002 04:31:37 -0000 @@ -73,6 +73,11 @@ struct block; #define B_BYTES(x) ( 1 + ((x)>>3) ) #define B_CLRALL(a,x) memset ((a), 0, B_BYTES(x)) +struct method_args { + struct type *type; + int artificial; +}; + /* Different kinds of data types are distinguished by the `code' field. */ enum type_code @@ -444,7 +449,7 @@ struct main_type pointer after the last argument for functions with variable arguments. */ - struct type **arg_types; + struct method_args *method_args; /* CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to point to cplus_struct_default, a default static instance of a struct @@ -792,7 +797,8 @@ extern void allocate_cplus_struct_type ( #define TYPE_NINSTANTIATIONS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ninstantiations #define TYPE_DECLARED_TYPE(thistype) TYPE_CPLUS_SPECIFIC(thistype)->declared_type #define TYPE_TYPE_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific -#define TYPE_ARG_TYPES(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.arg_types +#define TYPE_METHOD_ARGS(thistype) (thistype)->type_specific.method_args +#define TYPE_ARG_TYPE(thistype,i) TYPE_METHOD_ARGS((thistype)[i].type) #define TYPE_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff #define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat #define TYPE_BASECLASS(thistype,index) TYPE_MAIN_TYPE(thistype)->fields[index].type @@ -870,7 +876,8 @@ extern void allocate_cplus_struct_type ( #define TYPE_FN_FIELD(thisfn, n) (thisfn)[n] #define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname #define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type -#define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_ARG_TYPES ((thisfn)[n].type) +#define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_METHOD_ARGS ((thisfn)[n].type) +#define TYPE_FN_FIELD_ARG(thisfn, n, i) TYPE_ARG_TYPE ((thisfn)[n].type, i) #define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const) #define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile) #define TYPE_FN_FIELD_PRIVATE(thisfn, n) ((thisfn)[n].is_private) @@ -1095,7 +1102,7 @@ extern struct type *lookup_member_type ( extern void smash_to_method_type (struct type *, struct type *, struct type *, - struct type **); + struct method_args *); extern void smash_to_member_type (struct type *, struct type *, struct type *); Index: hpread.c =================================================================== RCS file: /cvs/uberbaum/gdb/hpread.c,v retrieving revision 1.19 diff -u -p -r1.19 hpread.c --- hpread.c 14 May 2002 18:30:51 -0000 1.19 +++ hpread.c 15 May 2002 03:58:02 -0000 @@ -4937,19 +4937,20 @@ hpread_type_lookup (dnttpointer hp_type, struct type *retvaltype; int nargs; int i; - struct type **args_type; + struct method_args *args_type; class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto, objfile); functype = hpread_type_lookup (dn_bufp->dptrmem.memtype, objfile); retvaltype = TYPE_TARGET_TYPE (functype); nargs = TYPE_NFIELDS (functype); - args_type = (struct type **) xmalloc ((nargs + 1) * sizeof (struct type *)); + args_type = (struct method_args *) xmalloc ((nargs + 1) * sizeof (struct method_args)); for (i = 0; i < nargs; i++) { - args_type[i] = TYPE_FIELD_TYPE (functype, i); + args_type[i].type = TYPE_FIELD_TYPE (functype, i); + args_type[i].artificial = 0; } - args_type[nargs] = NULL; + args_type[nargs].type = NULL; ptrmemtype = alloc_type (objfile); smash_to_method_type (ptrmemtype, class_type, retvaltype, args_type); return make_pointer_type (ptrmemtype, NULL); Index: stabsread.c =================================================================== RCS file: /cvs/uberbaum/gdb/stabsread.c,v retrieving revision 1.34 diff -u -p -r1.34 stabsread.c --- stabsread.c 14 May 2002 18:30:51 -0000 1.34 +++ stabsread.c 15 May 2002 03:58:15 -0000 @@ -142,7 +142,7 @@ static struct type *read_struct_type (ch static struct type *read_array_type (char **, struct type *, struct objfile *); -static struct type **read_args (char **, int, struct objfile *); +static struct method_args *read_args (char **, int, struct objfile *); static int read_cpp_abbrev (struct field_info *, char **, struct type *, @@ -2780,7 +2780,7 @@ again: { struct type *domain = read_type (pp, objfile); struct type *return_type; - struct type **args; + struct method_args *args; if (**pp != ',') /* Invalid member type data format. */ @@ -4926,21 +4926,23 @@ handle_true_range: } /* Read in an argument list. This is a list of types, separated by commas - and terminated with END. Return the list of types read in, or (struct type - **)-1 if there is an error. */ + and terminated with END. Return the list of types read in, or (struct + method_args *)-1 if there is an error. */ -static struct type ** +static struct method_args * read_args (char **pp, int end, struct objfile *objfile) { /* FIXME! Remove this arbitrary limit! */ - struct type *types[1024], **rval; /* allow for fns of 1023 parameters */ + struct type *types[1024]; /* allow for fns of 1023 parameters */ + struct method_args *rval; int n = 0; + int i; while (**pp != end) { if (**pp != ',') /* Invalid argument list: no ','. */ - return (struct type **) -1; + return (struct method_args *) -1; (*pp)++; STABS_CONTINUE (pp, objfile); types[n++] = read_type (pp, objfile); @@ -4949,18 +4951,22 @@ read_args (char **pp, int end, struct ob if (n == 1) { - rval = (struct type **) xmalloc (2 * sizeof (struct type *)); + rval = (struct method_args *) xmalloc (2 * sizeof (struct method_args)); } else if (TYPE_CODE (types[n - 1]) != TYPE_CODE_VOID) { - rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *)); - memset (rval + n, 0, sizeof (struct type *)); + rval = (struct method_args *) xmalloc ((n + 1) * sizeof (struct method_args)); + memset (rval + n, 0, sizeof (struct method_args)); } else { - rval = (struct type **) xmalloc (n * sizeof (struct type *)); + rval = (struct method_args *) xmalloc (n * sizeof (struct method_args)); + } + for (i = 0; i < n; i++) + { + rval[i].type = types[i]; + rval[i].artificial = 0; } - memcpy (rval, types, n * sizeof (struct type *)); return rval; } \f Index: valops.c =================================================================== RCS file: /cvs/uberbaum/gdb/valops.c,v retrieving revision 1.59 diff -u -p -r1.59 valops.c --- valops.c 13 May 2002 14:00:36 -0000 1.59 +++ valops.c 15 May 2002 03:58:32 -0000 @@ -45,7 +45,7 @@ extern int hp_som_som_object_present; extern int overload_debug; /* Local functions. */ -static int typecmp (int staticp, struct type *t1[], struct value *t2[]); +static int typecmp (int staticp, struct method_args *t1, struct value *t2[]); static CORE_ADDR find_function_addr (struct value *, struct type **); static struct value *value_arg_coerce (struct value *, struct type *, int); @@ -1441,7 +1441,7 @@ hand_function_call (struct value *functi if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) { i = 0; - while (TYPE_CODE (TYPE_ARG_TYPES (ftype)[i]) != TYPE_CODE_VOID) + while (TYPE_CODE (TYPE_ARG_TYPE (ftype, i)) != TYPE_CODE_VOID) i++; n_method_args = i; if (nargs < i) @@ -1458,7 +1458,7 @@ hand_function_call (struct value *functi if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) { if (i < n_method_args) - args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPES (ftype)[i], 1); + args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPE (ftype, i), 1); else args[i] = value_arg_coerce (args[i], NULL, 0); } @@ -1953,7 +1953,7 @@ value_bitstring (char *ptr, int len) requested operation is type secure, shouldn't we? FIXME. */ static int -typecmp (int staticp, struct type *t1[], struct value *t2[]) +typecmp (int staticp, struct method_args t1[], struct value *t2[]) { int i; @@ -1963,19 +1963,20 @@ typecmp (int staticp, struct type *t1[], return t2[1] != 0; if (t1 == 0) return 1; - if (t1[!staticp] == 0) + if (t1[!staticp].type == 0) return 0; - if (TYPE_CODE (t1[0]) == TYPE_CODE_VOID) + if (TYPE_CODE (t1[0].type) == TYPE_CODE_VOID) return 0; /* Skip ``this'' argument if applicable. T2 will always include THIS. */ if (staticp) t2++; - for (i = !staticp; t1[i] && TYPE_CODE (t1[i]) != TYPE_CODE_VOID; i++) + for (i = !staticp; t1[i].type && TYPE_CODE (t1[i].type) != TYPE_CODE_VOID; + i++) { struct type *tt1, *tt2; if (!t2[i]) return i + 1; - tt1 = check_typedef (t1[i]); + tt1 = check_typedef (t1[i].type); tt2 = check_typedef (VALUE_TYPE (t2[i])); if (TYPE_CODE (tt1) == TYPE_CODE_REF /* We should be doing hairy argument matching, as below. */ @@ -2012,10 +2013,10 @@ typecmp (int staticp, struct type *t1[], /* We should be doing much hairier argument matching (see section 13.2 of the ARM), but as a quick kludge, just check for the same type code. */ - if (TYPE_CODE (t1[i]) != TYPE_CODE (VALUE_TYPE (t2[i]))) + if (TYPE_CODE (t1[i].type) != TYPE_CODE (VALUE_TYPE (t2[i]))) return i + 1; } - if (!t1[i]) + if (!t1[i].type) return 0; return t2[i] ? i + 1 : 0; } @@ -2758,7 +2759,8 @@ find_overload_match (struct type **arg_t if (TYPE_FN_FIELD_ARGS(fns_ptr,ix)) { - while (TYPE_CODE(TYPE_FN_FIELD_ARGS(fns_ptr,ix)[nparms]) != TYPE_CODE_VOID) + while (TYPE_CODE(TYPE_FN_FIELD_ARG(fns_ptr,ix,nparms)) + != TYPE_CODE_VOID) nparms++; } } @@ -2772,7 +2774,7 @@ find_overload_match (struct type **arg_t parm_types = (struct type **) xmalloc (nparms * (sizeof (struct type *))); for (jj = 0; jj < nparms; jj++) parm_types[jj] = (method - ? (TYPE_FN_FIELD_ARGS (fns_ptr, ix)[jj]) + ? (TYPE_FN_FIELD_ARG (fns_ptr, ix, jj)) : TYPE_FIELD_TYPE (SYMBOL_TYPE (oload_syms[ix]), jj)); /* Compare parameter types to supplied argument types. Skip THIS for ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-05-14 21:36 ` Elena Zannoni @ 2002-05-14 21:52 ` Daniel Jacobowitz 2002-05-15 11:16 ` Elena Zannoni 0 siblings, 1 reply; 15+ messages in thread From: Daniel Jacobowitz @ 2002-05-14 21:52 UTC (permalink / raw) To: Elena Zannoni; +Cc: gdb-patches On Wed, May 15, 2002 at 12:35:43AM -0400, Elena Zannoni wrote: > Daniel Jacobowitz writes: > > I hate to be a nag, but this patch would be useful for some of my > > current work. Do you have a chance to look at it? > > > > You are completely right, sorry. I wonder if MichaelC could kindly > run it through his test harness. That was a big help with yesterday's > patch. And if you can run the tests with the maintainers file script. (Don't bother, Michael, it doesn't apply any more.) I looked at this in passing and noticed it touched some of the same files I was working on. I completely forgot that my previous patches completely invalidated it :) Sorry for wasting your time. > How much does the size increase by adding this new struct? I don't have any numbers, unfortunately. I'll try to get some, unless I think of a better way to do it... > I have looked at it when you first posted it, and I had some > questions, I have to go fish for them again. But basically, the > motivation for this change is what? You need to handle the dwarf2 > information for artificial arguments, right? So that needs a change in > dwarf2read.c. How does that bring about the change in the type > structure? Can you explain a bit? (my brain gets lazy at this time). OK, let me explain this a bit. Right now the only information we save for a method type are some flags, the return type, and a list of argument types - just as an array of struct type *. I needed another bit per argument, and I couldn't find anywhere to put it. Maintaining a separate bitmap is even uglier. > In the meantime, I noticed that the hp-symtab-read.c changes are not > mentioned in the ChangeLog (well, now it is hpread.c). Also now you > have a bunch of type->code instead of TYPE_CODE(). I tried to apply > the patch to the current sources, but it failed in several files. I > tried to resolve the conflicts by hand but the compilation died in > valops.c, gdbypes.c and c-typeprint.c. I think the rename of type to > main_type needs to be taken into account as well. > I get these 2 kinds of errors: > /home/ezannoni/sources/src/gdb/c-typeprint.c:171: structure has no member named `code' > /home/ezannoni/sources/src/gdb/gdbtypes.c:2750: structure has no member named `type_specific' Yep, those are symptomatic of missing accessor macros. Those used to be members of struct type. > I noticed this quite ugly syntax. I know you didn't introduce it, but, > I wonder why it's needed: > 't1[!staticp].type' and 'for (i = !staticp;....)' Basically, it is just shorthand for "the first non-THIS argument". I don't know who introduced it; one of the past C++ maintainers, possibly Tiemann, seems to have been very fond of that syntax. I'm killing it where I run into it. > I think you also need to update a few comments in gdbtypes.h when > introducing the new method_args field. > > Is there any better naming scheme for TYPE_FN_FIELD_ARGS and > TYPE_FN_FIELD_ARG? I am always a bit worried when identifiers differ > by just one char. Before I clean this up, do you have any better ideas on where to record the new flag? Maybe a separate bitmap would be better after all. Less intrusive, certainly. By the way, I intend to use this flag from stabs also; the C++ ABI can tell us when the int used to control constructors/destructors is artificial with acceptably high accuracy, I think. That'll improve our display of them somewhat. -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-05-14 21:52 ` Daniel Jacobowitz @ 2002-05-15 11:16 ` Elena Zannoni 2002-05-15 11:51 ` Daniel Jacobowitz 0 siblings, 1 reply; 15+ messages in thread From: Elena Zannoni @ 2002-05-15 11:16 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Elena Zannoni, gdb-patches Daniel Jacobowitz writes: > On Wed, May 15, 2002 at 12:35:43AM -0400, Elena Zannoni wrote: > > Daniel Jacobowitz writes: > > > I hate to be a nag, but this patch would be useful for some of my > > > current work. Do you have a chance to look at it? > > > > > > > You are completely right, sorry. I wonder if MichaelC could kindly > > run it through his test harness. That was a big help with yesterday's > > patch. And if you can run the tests with the maintainers file script. > > (Don't bother, Michael, it doesn't apply any more.) > > I looked at this in passing and noticed it touched some of the same > files I was working on. I completely forgot that my previous patches > completely invalidated it :) Sorry for wasting your time. > No prob. > > How much does the size increase by adding this new struct? > > I don't have any numbers, unfortunately. I'll try to get some, unless > I think of a better way to do it... > > > I have looked at it when you first posted it, and I had some > > questions, I have to go fish for them again. But basically, the > > motivation for this change is what? You need to handle the dwarf2 > > information for artificial arguments, right? So that needs a change in > > dwarf2read.c. How does that bring about the change in the type > > structure? Can you explain a bit? (my brain gets lazy at this time). > > OK, let me explain this a bit. Right now the only information we save > for a method type are some flags, the return type, and a list of > argument types - just as an array of struct type *. I needed another > bit per argument, and I couldn't find anywhere to put it. Maintaining > a separate bitmap is even uglier. > How does the type structure look right now for a c++ class method? There is a TYPE struct for the class. The TYPE_SPECIFIC field points to CPLUS_STUFF which has an array of unique methods (FN_FIELDLISTS). For each of these methods there is another list (FN_FIELDS) of all the overloaded methods with the same name (which may be just 1 if not overloaded). For each of them there is an array of arguments (ARGS). (which is just a type struct). You need to add something to this array of ARGS to indicate if they are artificial. There is already an occurrence of 'artificial' but that's for methods. Yes? The thing I don't understand in your patch (or is this messy code in general) is why was type_specific.arg_types changed to type_specific.method_args. Wouldn't it be enough to change the args array inside the fn_field structure from an array of types to an array of method_args? Basically I don't think I understand why the type system seems to be storing this info in 2 places: in the cplus_struct: /* The argument list. Only valid if is_stub is clear. Contains the type of each argument, including `this', and ending with a NULL pointer after the last argument. Should not contain a `this' pointer for static member functions. */ struct type **args; in type_specific: /* ARG_TYPES is for TYPE_CODE_METHOD. Contains the type of each argument, ending with a void type after the last argument for normal member functions or a NULL pointer after the last argument for functions with variable arguments. */ struct type **arg_types; Argh!!! This occurrence of args in fn_field was *removed* in 1996 by Peter Schauer, and *replaced* by arg_types. But guess what?? The HP merge reintroduced the args, forgetting about the existance of arg_types. Grrrr. No wonder I didn't understand the layout. Ok, let's get rid of the cplus_struct args again, I would suggest, and stick with the other. This may require a bit of careful surgery. Proably uses of args have propagated all over the place. Then you would have only one place to modify for the artificial attribute. I bet your patch would become much much simpler. > > In the meantime, I noticed that the hp-symtab-read.c changes are not > > mentioned in the ChangeLog (well, now it is hpread.c). Also now you > > have a bunch of type->code instead of TYPE_CODE(). I tried to apply > > the patch to the current sources, but it failed in several files. I > > tried to resolve the conflicts by hand but the compilation died in > > valops.c, gdbypes.c and c-typeprint.c. I think the rename of type to > > main_type needs to be taken into account as well. > > > I get these 2 kinds of errors: > > /home/ezannoni/sources/src/gdb/c-typeprint.c:171: structure has no member named `code' > > /home/ezannoni/sources/src/gdb/gdbtypes.c:2750: structure has no member named `type_specific' > > Yep, those are symptomatic of missing accessor macros. Those used to > be members of struct type. > > > > I noticed this quite ugly syntax. I know you didn't introduce it, but, > > I wonder why it's needed: > > 't1[!staticp].type' and 'for (i = !staticp;....)' > > Basically, it is just shorthand for "the first non-THIS argument". I > don't know who introduced it; one of the past C++ maintainers, possibly > Tiemann, seems to have been very fond of that syntax. I'm killing it > where I run into it. > You can just submit a cleanup patch for that separately. I would consider it fairly obvious. > > I think you also need to update a few comments in gdbtypes.h when > > introducing the new method_args field. > > > > Is there any better naming scheme for TYPE_FN_FIELD_ARGS and > > TYPE_FN_FIELD_ARG? I am always a bit worried when identifiers differ > > by just one char. > > Before I clean this up, do you have any better ideas on where to record > the new flag? Maybe a separate bitmap would be better after all. Less > intrusive, certainly. By the way, I intend to use this flag from stabs > also; the C++ ABI can tell us when the int used to control > constructors/destructors is artificial with acceptably high accuracy, I > think. That'll improve our display of them somewhat. > If you get rid of the second instance of args, it would become easier. Elena ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-05-15 11:16 ` Elena Zannoni @ 2002-05-15 11:51 ` Daniel Jacobowitz 2002-05-16 15:33 ` Jim Blandy 0 siblings, 1 reply; 15+ messages in thread From: Daniel Jacobowitz @ 2002-05-15 11:51 UTC (permalink / raw) To: Elena Zannoni; +Cc: gdb-patches On Wed, May 15, 2002 at 02:15:23PM -0400, Elena Zannoni wrote: > Daniel Jacobowitz writes: > > On Wed, May 15, 2002 at 12:35:43AM -0400, Elena Zannoni wrote: > > > Daniel Jacobowitz writes: > > > > I hate to be a nag, but this patch would be useful for some of my > > > > current work. Do you have a chance to look at it? > > > > > > > > > > You are completely right, sorry. I wonder if MichaelC could kindly > > > run it through his test harness. That was a big help with yesterday's > > > patch. And if you can run the tests with the maintainers file script. > > > > (Don't bother, Michael, it doesn't apply any more.) > > > > I looked at this in passing and noticed it touched some of the same > > files I was working on. I completely forgot that my previous patches > > completely invalidated it :) Sorry for wasting your time. > > > > No prob. > > > > How much does the size increase by adding this new struct? > > > > I don't have any numbers, unfortunately. I'll try to get some, unless > > I think of a better way to do it... > > > > > I have looked at it when you first posted it, and I had some > > > questions, I have to go fish for them again. But basically, the > > > motivation for this change is what? You need to handle the dwarf2 > > > information for artificial arguments, right? So that needs a change in > > > dwarf2read.c. How does that bring about the change in the type > > > structure? Can you explain a bit? (my brain gets lazy at this time). > > > > OK, let me explain this a bit. Right now the only information we save > > for a method type are some flags, the return type, and a list of > > argument types - just as an array of struct type *. I needed another > > bit per argument, and I couldn't find anywhere to put it. Maintaining > > a separate bitmap is even uglier. > > > > How does the type structure look right now for a c++ class method? > > There is a TYPE struct for the class. > > The TYPE_SPECIFIC field points to CPLUS_STUFF which has an array of > unique methods (FN_FIELDLISTS). > > For each of these methods there is another list (FN_FIELDS) of all the > overloaded methods with the same name (which may be just 1 if not > overloaded). > > For each of them there is an array of arguments (ARGS). (which is just > a type struct). > > You need to add something to this array of ARGS to indicate if they > are artificial. > > There is already an occurrence of 'artificial' but that's for methods. > > Yes? > > The thing I don't understand in your patch (or is this messy code in > general) is why was type_specific.arg_types changed to > type_specific.method_args. Wouldn't it be enough to change the args > array inside the fn_field structure from an array of types to an array > of method_args? Basically I don't think I understand why the type > system seems to be storing this info in 2 places: > > in the cplus_struct: > /* The argument list. Only valid if is_stub is clear. Contains > the type of each argument, including `this', and ending with > a NULL pointer after the last argument. Should not contain > a `this' pointer for static member functions. */ > > struct type **args; > > in type_specific: > /* ARG_TYPES is for TYPE_CODE_METHOD. > Contains the type of each argument, ending with a void type > after the last argument for normal member functions or a NULL > pointer after the last argument for functions with variable > arguments. */ > > struct type **arg_types; > > Argh!!! > This occurrence of args in fn_field was *removed* in 1996 by Peter Schauer, > and *replaced* by arg_types. > But guess what?? The HP merge reintroduced the args, forgetting about the > existance of arg_types. > > Grrrr. No wonder I didn't understand the layout. Ok, let's get rid of > the cplus_struct args again, I would suggest, and stick with the other. > This may require a bit of careful surgery. Proably uses of args have > propagated all over the place. > > Then you would have only one place to modify for the artificial attribute. > I bet your patch would become much much simpler. Excuse the language, but... "Arg!" This merge has really begun to annoy me. It also probably explains a bit of beauty that I found in gdbtypes.h the other day, which of course I can no longer find now that I'm looking for it; there appear to be some accessor macros accessing things that don't exist. > If you get rid of the second instance of args, it would become easier. OK, you want to kill the one in cplus_struct. This should actually be very easy; the only client is hpread.c. If C++ support still worked on HP/UX someone would probably have noticed... I'll do that first and then begin again. -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-05-15 11:51 ` Daniel Jacobowitz @ 2002-05-16 15:33 ` Jim Blandy 2002-05-16 16:53 ` Elena Zannoni 0 siblings, 1 reply; 15+ messages in thread From: Jim Blandy @ 2002-05-16 15:33 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Elena Zannoni, gdb-patches Possibly clueless suggestion: Couldn't we represent a method's arguments the same way we represent a function's arguments? That is, nfields would carry the number of arguments, and fields[i] would describe the n'th field. We could use the `artificial' member of `union field_location' in `struct field' to hold the information conveyed by DW_AT_artificial. The fact that we've distinguished these has caused problems in the past. Check out the following code in hand_function_call: for (i = nargs - 1; i >= 0; i--) { /* Assume that methods are always prototyped, unless they are off the end (which we should only be allowing if there is a ``...''). FIXME. */ if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) { if (i < n_method_args) args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPES (ftype)[i], 1); else args[i] = value_arg_coerce (args[i], NULL, 0); } /* If we're off the end of the known arguments, do the standard promotions. FIXME: if we had a prototype, this should only be allowed if ... were present. */ if (i >= TYPE_NFIELDS (ftype)) args[i] = value_arg_coerce (args[i], NULL, 0); else { param_type = TYPE_FIELD_TYPE (ftype, i); args[i] = value_arg_coerce (args[i], param_type, TYPE_PROTOTYPED (ftype)); } Those two loops could be re-collapsed into one. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-05-16 15:33 ` Jim Blandy @ 2002-05-16 16:53 ` Elena Zannoni 2002-05-16 17:24 ` Andrew Cagney 2002-05-16 21:09 ` Daniel Jacobowitz 0 siblings, 2 replies; 15+ messages in thread From: Elena Zannoni @ 2002-05-16 16:53 UTC (permalink / raw) To: Jim Blandy; +Cc: Daniel Jacobowitz, Elena Zannoni, gdb-patches Jim Blandy writes: > > Possibly clueless suggestion: > I think this is where Daniel was headed, he's the one that added that 'artificial' member. Except he ran into an HP merge roadblock. Elena > Couldn't we represent a method's arguments the same way we represent a > function's arguments? That is, nfields would carry the number of > arguments, and fields[i] would describe the n'th field. We could use > the `artificial' member of `union field_location' in `struct field' to > hold the information conveyed by DW_AT_artificial. > > The fact that we've distinguished these has caused problems in the > past. Check out the following code in hand_function_call: > > for (i = nargs - 1; i >= 0; i--) > { > /* Assume that methods are always prototyped, unless they are off the > end (which we should only be allowing if there is a ``...''). > FIXME. */ > if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) > { > if (i < n_method_args) > args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPES (ftype)[i], 1); > else > args[i] = value_arg_coerce (args[i], NULL, 0); > } > > /* If we're off the end of the known arguments, do the standard > promotions. FIXME: if we had a prototype, this should only > be allowed if ... were present. */ > if (i >= TYPE_NFIELDS (ftype)) > args[i] = value_arg_coerce (args[i], NULL, 0); > > else > { > param_type = TYPE_FIELD_TYPE (ftype, i); > args[i] = value_arg_coerce (args[i], param_type, TYPE_PROTOTYPED (ftype)); > } > > Those two loops could be re-collapsed into one. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-05-16 16:53 ` Elena Zannoni @ 2002-05-16 17:24 ` Andrew Cagney 2002-05-17 10:45 ` Michael Snyder 2002-05-16 21:09 ` Daniel Jacobowitz 1 sibling, 1 reply; 15+ messages in thread From: Andrew Cagney @ 2002-05-16 17:24 UTC (permalink / raw) To: Elena Zannoni; +Cc: Jim Blandy, Daniel Jacobowitz, gdb-patches > roadblock. I guess that is the politically correct term for the carnage left behind after a 50 car pile-up :-) Andrew ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-05-16 17:24 ` Andrew Cagney @ 2002-05-17 10:45 ` Michael Snyder 2002-05-17 11:00 ` Elena Zannoni 0 siblings, 1 reply; 15+ messages in thread From: Michael Snyder @ 2002-05-17 10:45 UTC (permalink / raw) To: Andrew Cagney; +Cc: Elena Zannoni, Jim Blandy, Daniel Jacobowitz, gdb-patches Andrew Cagney wrote: > > > roadblock. > > I guess that is the politically correct term for the carnage left behind > after a 50 car pile-up :-) Only if the 50 cars are left in the middle of the road to rust for several years... ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-05-17 10:45 ` Michael Snyder @ 2002-05-17 11:00 ` Elena Zannoni 0 siblings, 0 replies; 15+ messages in thread From: Elena Zannoni @ 2002-05-17 11:00 UTC (permalink / raw) To: Michael Snyder Cc: Andrew Cagney, Elena Zannoni, Jim Blandy, Daniel Jacobowitz, gdb-patches Michael Snyder writes: > Andrew Cagney wrote: > > > > > roadblock. > > > > I guess that is the politically correct term for the carnage left behind > > after a 50 car pile-up :-) > > Only if the 50 cars are left in the middle of the road > to rust for several years... Hope Daniel's tetanus shots are up to date. Elena ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFA] [4/5] Use DWARF-2 DW_AT_artificial information 2002-05-16 16:53 ` Elena Zannoni 2002-05-16 17:24 ` Andrew Cagney @ 2002-05-16 21:09 ` Daniel Jacobowitz 1 sibling, 0 replies; 15+ messages in thread From: Daniel Jacobowitz @ 2002-05-16 21:09 UTC (permalink / raw) To: Elena Zannoni; +Cc: Jim Blandy, gdb-patches On Thu, May 16, 2002 at 07:51:38PM -0400, Elena Zannoni wrote: > Jim Blandy writes: > > > > Possibly clueless suggestion: > > > > I think this is where Daniel was headed, he's the one that added that > 'artificial' member. Except he ran into an HP merge roadblock. You're thinking too highly of me, but now that you mention it it's a really good idea... I will investigate the practicality of this. I believe it would be a memory increase from where we are now, since we'd allocate a struct field for every argument, but that's not necessarily a bad thing. The simplicity is more important. > > Elena > > > > Couldn't we represent a method's arguments the same way we represent a > > function's arguments? That is, nfields would carry the number of > > arguments, and fields[i] would describe the n'th field. We could use > > the `artificial' member of `union field_location' in `struct field' to > > hold the information conveyed by DW_AT_artificial. > > > > The fact that we've distinguished these has caused problems in the > > past. Check out the following code in hand_function_call: > > > > for (i = nargs - 1; i >= 0; i--) > > { > > /* Assume that methods are always prototyped, unless they are off the > > end (which we should only be allowing if there is a ``...''). > > FIXME. */ > > if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) > > { > > if (i < n_method_args) > > args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPES (ftype)[i], 1); > > else > > args[i] = value_arg_coerce (args[i], NULL, 0); > > } > > > > /* If we're off the end of the known arguments, do the standard > > promotions. FIXME: if we had a prototype, this should only > > be allowed if ... were present. */ > > if (i >= TYPE_NFIELDS (ftype)) > > args[i] = value_arg_coerce (args[i], NULL, 0); > > > > else > > { > > param_type = TYPE_FIELD_TYPE (ftype, i); > > args[i] = value_arg_coerce (args[i], param_type, TYPE_PROTOTYPED (ftype)); > > } > > > > Those two loops could be re-collapsed into one. > -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2002-05-17 18:00 UTC | newest] Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-05-14 22:06 [RFA] [4/5] Use DWARF-2 DW_AT_artificial information Michael Elizabeth Chastain -- strict thread matches above, loose matches on Subject: below -- 2002-01-15 12:31 Daniel Jacobowitz 2002-03-07 12:43 ` Daniel Jacobowitz 2002-03-07 12:55 ` Elena Zannoni 2002-05-14 14:13 ` Daniel Jacobowitz 2002-05-14 21:36 ` Elena Zannoni 2002-05-14 21:52 ` Daniel Jacobowitz 2002-05-15 11:16 ` Elena Zannoni 2002-05-15 11:51 ` Daniel Jacobowitz 2002-05-16 15:33 ` Jim Blandy 2002-05-16 16:53 ` Elena Zannoni 2002-05-16 17:24 ` Andrew Cagney 2002-05-17 10:45 ` Michael Snyder 2002-05-17 11:00 ` Elena Zannoni 2002-05-16 21:09 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox