This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] [1/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: gdb-patches at sources dot redhat dot com
- Date: Wed, 16 Jan 2002 17:46:35 -0500
- Subject: Re: [RFA] [1/5] Use DWARF-2 DW_AT_artificial information
- References: <20020115152720.A28147@nevyn.them.org>
Daniel Jacobowitz writes:
> There are two things which gcc 3.x's DWARF-2 support marks as artificial:
> - arguments (to constructors only?)
> - methods provided by the compiler (any of operator=, copy constructor,
> default constructor, virtual thunks).
>
> In particular we do not want to print virtual thunks, and I don't see any
> reason to preserve printing operator= et al. if we don't have to (and if the
> user didn't provide them himself).
>
> This patch is the first in a series of five to add support for both of these
> things. It lays the groundwork for identifying artificial method arguments.
> The only interesting bit is removing an obsolete use of TYPE_FIELD_BITPOS -
> at one point, TYPE_FIELD_BITPOS on a function's argument was an index into
> the list of arguments. We never used this anywhere and only the HP readers
> set it. I delete it so that I can re-use that space.
>
Have you tested on hpux? It doesn't seem like it should have an effect,
but....
> I have tested the patches all together, but not individually; I'll commit
> them separately when approved, but I'm going to wait until they've all been
> approved. They should work on their own, though.
>
I think this is a bit dangerous assumption, do they compile on their own?
> OK to commit this one?
Looks ok to me. This is a fairly self-contained patch. I would think
you can check this in, for start, while I look at the rest of the
series. It should have no visible effect on GDB's behavior, right?
Elena
>
> --
> Daniel Jacobowitz Carnegie Mellon University
> MontaVista Software Debian GNU/Linux Developer
>
> 2002-01-15 Daniel Jacobowitz <drow@mvista.com>
>
> * gdbtypes.h (struct type): Fix whitespace. Remove obsolete
> comment. Add ``artificial'' to ``union field_location''.
>
> * dwarf2read.c: Remove ad-hoc TYPE_FIELD_ARTIFICIAL.
>
> * buildsym.c (finish_block): Initialize TYPE_FIELD_ARTIFICIAL to 0.
> * mdebugread.c (parse_symbol): Likewise.
> * stabsread.c (define_symbol): Likewise.
> * hp-symtab-read.c (hpread_function_type): Likewise, instead of
> initializing TYPE_FIELD_BITPOS to n (obsolete).
> (hpread_doc_function_type): Likewise.
> * hpread.c (hpread_function_type): Likewise.
>
> Index: buildsym.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/buildsym.c,v
> retrieving revision 1.12
> diff -u -p -r1.12 buildsym.c
> --- buildsym.c 2001/10/12 23:51:28 1.12
> +++ buildsym.c 2002/01/15 19:02:05
> @@ -322,6 +322,7 @@ finish_block (struct symbol *symbol, str
> case LOC_BASEREG_ARG:
> case LOC_LOCAL_ARG:
> TYPE_FIELD_TYPE (ftype, iparams) = SYMBOL_TYPE (sym);
> + TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
> iparams++;
> break;
> case LOC_UNDEF:
> Index: dwarf2read.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> retrieving revision 1.44
> diff -u -p -r1.44 dwarf2read.c
> --- dwarf2read.c 2002/01/11 16:56:04 1.44
> +++ dwarf2read.c 2002/01/15 19:02:05
> @@ -474,13 +474,6 @@ struct field_info
> int nfnfields;
> };
>
> -/* Dwarf2 has no clean way to discern C++ static and non-static member
> - functions. G++ helps GDB by marking the first parameter for non-static
> - member functions (which is the this pointer) as artificial.
> - We pass this information between dwarf2_add_member_fn and
> - read_subroutine_type via TYPE_FIELD_ARTIFICIAL. */
> -#define TYPE_FIELD_ARTIFICIAL TYPE_FIELD_BITPOS
> -
> /* Various complaints about symbol reading that don't abort the process */
>
> static struct complaint dwarf2_const_ignored =
> Index: gdbtypes.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbtypes.h,v
> retrieving revision 1.21
> diff -u -p -r1.21 gdbtypes.h
> --- gdbtypes.h 2001/12/10 06:17:01 1.21
> +++ gdbtypes.h 2002/01/15 19:02:06
> @@ -383,17 +388,12 @@ struct type
>
> struct field
> {
> -
> -
> -
> union field_location
> {
> /* Position of this field, counting in bits from start of
> containing structure.
> For BITS_BIG_ENDIAN=1 targets, it is the bit offset to the MSB.
> For BITS_BIG_ENDIAN=0 targets, it is the bit offset to the LSB.
> - For a function type, this is the position in the argument list
> - of this argument.
> For a range bound or enum value, this is the value itself. */
>
> int bitpos;
> @@ -404,6 +404,11 @@ struct type
>
> CORE_ADDR physaddr;
> char *physname;
> +
> + /* For a function type, this is 1 if the argument is marked
> + artificial. Artificial arguments should not be shown to the
> + user. */
> + int artificial;
> }
> loc;
>
> @@ -796,6 +803,7 @@ extern void allocate_cplus_struct_type (
> #define FIELD_TYPE(thisfld) ((thisfld).type)
> #define FIELD_NAME(thisfld) ((thisfld).name)
> #define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos)
> +#define FIELD_ARTIFICIAL(thisfld) ((thisfld).loc.artificial)
> #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
> #define FIELD_PHYSNAME(thisfld) ((thisfld).loc.physname)
> #define FIELD_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
> @@ -807,6 +815,7 @@ extern void allocate_cplus_struct_type (
> #define TYPE_FIELD_TYPE(thistype, n) FIELD_TYPE(TYPE_FIELD(thistype, n))
> #define TYPE_FIELD_NAME(thistype, n) FIELD_NAME(TYPE_FIELD(thistype, n))
> #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS(TYPE_FIELD(thistype,n))
> +#define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n))
> #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE(TYPE_FIELD(thistype,n))
> #define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE(TYPE_FIELD(thistype,n))!=0)
> #define TYPE_TEMPLATE_ARG(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->template_args[n]
> Index: hp-symtab-read.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/hp-symtab-read.c,v
> retrieving revision 1.8
> diff -u -p -r1.8 hp-symtab-read.c
> --- hp-symtab-read.c 2001/12/07 22:11:51 1.8
> +++ hp-symtab-read.c 2002/01/15 19:02:06
> @@ -965,7 +965,7 @@ hpread_read_function_type (dnttpointer h
> struct symbol *xsym = syms->symbol[j];
> TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
> TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym);
> - TYPE_FIELD_BITPOS (type, n) = n;
> + TYPE_FIELD_ARTIFICIAL (type, n) = 0;
> TYPE_FIELD_BITSIZE (type, n) = 0;
> }
> }
> @@ -1138,7 +1138,7 @@ hpread_read_doc_function_type (dnttpoint
> struct symbol *xsym = syms->symbol[j];
> TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
> TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym);
> - TYPE_FIELD_BITPOS (type, n) = n;
> + TYPE_FIELD_ARTIFICIAL (type, n) = 0;
> TYPE_FIELD_BITSIZE (type, n) = 0;
> }
> }
> Index: hpread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/hpread.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 hpread.c
> --- hpread.c 2001/12/02 22:38:23 1.11
> +++ hpread.c 2002/01/15 19:02:06
> @@ -1371,7 +1371,7 @@ hpread_read_function_type (dnttpointer h
> struct symbol *xsym = syms->symbol[j];
> TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
> TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym);
> - TYPE_FIELD_BITPOS (type, n) = n;
> + TYPE_FIELD_ARTIFICIAL (type, n) = 0;
> TYPE_FIELD_BITSIZE (type, n) = 0;
> }
> if (syms == osyms)
> Index: mdebugread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mdebugread.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 mdebugread.c
> --- mdebugread.c 2001/12/09 21:45:26 1.20
> +++ mdebugread.c 2002/01/15 19:02:06
> @@ -1282,6 +1282,7 @@ parse_symbol (SYMR *sh, union aux_ext *a
> case LOC_REGPARM:
> case LOC_REGPARM_ADDR:
> TYPE_FIELD_TYPE (ftype, iparams) = SYMBOL_TYPE (sym);
> + TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
> iparams++;
> break;
> default:
> Index: stabsread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/stabsread.c,v
> retrieving revision 1.22
> diff -u -p -r1.22 stabsread.c
> --- stabsread.c 2002/01/15 16:47:17 1.22
> +++ stabsread.c 2002/01/15 19:02:07
> @@ -1628,7 +1628,8 @@ define_symbol (CORE_ADDR valu, char *str
> FIXME: Do we need a new builtin_type_promoted_int_arg ? */
> if (TYPE_CODE (ptype) == TYPE_CODE_VOID)
> ptype = builtin_type_int;
> - TYPE_FIELD_TYPE (ftype, nparams++) = ptype;
> + TYPE_FIELD_TYPE (ftype, nparams) = ptype;
> + TYPE_FIELD_ARTIFICIAL (ftype, nparams++) = 0;
> }
> TYPE_NFIELDS (ftype) = nparams;
> TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;