This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] [3/5] Use DWARF-2 DW_AT_artificial information
- From: Elena Zannoni <ezannoni at redhat dot com>
- To: Daniel Jacobowitz <drow at mvista dot com>
- Cc: jimb at redhat dot com, gdb-patches at sources dot redhat dot com
- Date: Wed, 16 Jan 2002 17:59:11 -0500
- Subject: Re: [RFA] [3/5] Use DWARF-2 DW_AT_artificial information
- References: <20020115153005.A28550@nevyn.them.org>
Daniel Jacobowitz writes:
> This one's pretty simple. This handles artificial methods (which turned out
> to be much easier than artificial arguments). It's independent of the
> others.
>
> OK to commit?
>
See below for some minor things.
Again, I am not sure I can approve outside of the symbol readers yet.
JimB, do yo have any comments?
Dwarf2read.c part is ok.
Elena
> --
> Daniel Jacobowitz Carnegie Mellon University
> MontaVista Software Debian GNU/Linux Developer
>
> 2002-01-15 Daniel Jacobowitz <drow@mvista.com>
>
> * gdbtypes.h (struct cplus_struct_type): Add is_artificial to
> member function fields. Add accessor macro
> TYPE_FN_FIELD_ARTIFICIAL.
> * dwarf2read.c (dwarf2_add_member_fn): Check for artificial methods.
> * c-typeprint.c (c_type_print_base): Skip artificial member
> functions.
>
> diff -urp src-p2/gdb/c-typeprint.c src-p3/gdb/c-typeprint.c
> --- src-p2/gdb/c-typeprint.c Tue Jan 15 14:25:54 2002
> +++ src-p3/gdb/c-typeprint.c Tue Jan 15 14:38:27 2002
> @@ -636,9 +636,9 @@ void
> c_type_print_base (struct type *type, struct ui_file *stream, int show,
> int level)
> {
> - register int i;
> - register int len;
> - register int lastval;
> + int i;
> + int len, reallen;
> + int lastval;
> char *mangled_name;
> char *demangled_name;
> char *demangled_no_static;
> @@ -903,7 +903,17 @@ c_type_print_base (struct type *type, st
>
> /* If there are both fields and methods, put a space between. */
> len = TYPE_NFN_FIELDS (type);
> - if (len && section_type != s_none)
> + reallen = 0;
> + for (i = 0; i < len; i++)
> + {
> + struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
> + int len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
> + int j;
> + for (j = 0; j < len2; j++)
> + if (!TYPE_FN_FIELD_ARTIFICIAL (f, j))
> + reallen++;
> + }
> + if (reallen && section_type != s_none)
> fprintf_filtered (stream, "\n");
>
Very minor nit picking:
Could you please add a comment on what's going on here, something like
'compute the number of non-artificial methods'. Also, the comment about
'put a space in between' should say 'put an extra line in between' or
something like that. Can you call the variable 'real_len'?
> /* C++: print out the methods */
> @@ -922,6 +932,9 @@ c_type_print_base (struct type *type, st
> || is_destructor_name (physname)
> || method_name[0] == '~';
>
> + /* Do not print out artificial methods. */
> + if (TYPE_FN_FIELD_ARTIFICIAL (f, j))
> + continue;
>
> QUIT;
> if (TYPE_FN_FIELD_PROTECTED (f, j))
> diff -urp src-p2/gdb/dwarf2read.c src-p3/gdb/dwarf2read.c
> --- src-p2/gdb/dwarf2read.c Tue Jan 15 14:29:15 2002
> +++ src-p3/gdb/dwarf2read.c Tue Jan 15 14:38:27 2002
> @@ -2168,6 +2168,11 @@ dwarf2_add_member_fn (struct field_info
> }
> }
>
> + /* Check for artificial methods. */
> + attr = dwarf_attr (die, DW_AT_artificial);
> + if (attr && DW_UNSND (attr) != 0)
> + fnp->is_artificial = 1;
> +
> /* Get index in virtual function table if it is a virtual member function. */
> attr = dwarf_attr (die, DW_AT_vtable_elem_location);
> if (attr)
> diff -urp src-p2/gdb/gdbtypes.h src-p3/gdb/gdbtypes.h
> --- src-p2/gdb/gdbtypes.h Tue Jan 15 14:29:15 2002
> +++ src-p3/gdb/gdbtypes.h Tue Jan 15 14:38:27 2002
> @@ -619,6 +619,7 @@ struct cplus_struct_type
> unsigned int is_final:1;
> unsigned int is_synchronized:1;
> unsigned int is_native:1;
> + unsigned int is_artificial:1;
>
> /* A stub method only has some fields valid (but they are enough
> to reconstruct the rest of the fields). */
> @@ -628,7 +629,7 @@ struct cplus_struct_type
> unsigned int is_inlined:1;
>
> /* Unused. */
> - unsigned int dummy:4;
> + unsigned int dummy:3;
>
> /* Index into that baseclass's virtual function table,
> minus 2; else if static: VOFFSET_STATIC; else: 0. */
> @@ -867,6 +868,7 @@ extern void allocate_cplus_struct_type (
> #define TYPE_FN_FIELD_FINAL(thisfn, n) ((thisfn)[n].is_final)
> #define TYPE_FN_FIELD_SYNCHRONIZED(thisfn, n) ((thisfn)[n].is_synchronized)
> #define TYPE_FN_FIELD_NATIVE(thisfn, n) ((thisfn)[n].is_native)
> +#define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n) ((thisfn)[n].is_artificial)
> #define TYPE_FN_FIELD_ABSTRACT(thisfn, n) ((thisfn)[n].is_abstract)
> #define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub)
> #define TYPE_FN_FIELD_INLINED(thisfn, n) ((thisfn)[n].is_inlined)