* RFA: use init_type() in dwarf2read.c
@ 2001-12-08 22:47 Fred Fish
2001-12-09 11:06 ` Elena Zannoni
0 siblings, 1 reply; 2+ messages in thread
From: Fred Fish @ 2001-12-08 22:47 UTC (permalink / raw)
To: gdb-patches; +Cc: fnf
The dwarf2read.c file sometimes handcrafts new types and sometimes
calls init_type(). This patch eliminates one of the unnecessary
handcraftings.
-Fred
2001-12-08 Fred Fish <fnf@redhat.com>
* dwarf2read.c (read_typedef): Replace hand crafted type
initialization with a call to the init_type() function, which
is how the rest of gdb creates types.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.38
diff -u -p -r1.38 dwarf2read.c
--- dwarf2read.c 2001/12/07 22:11:51 1.38
+++ dwarf2read.c 2001/12/09 01:28:00
@@ -2886,26 +2882,15 @@ static void
read_typedef (struct die_info *die, struct objfile *objfile,
const struct comp_unit_head *cu_header)
{
- struct type *type;
+ struct attribute *attr;
+ char *name;
if (!die->type)
{
- struct attribute *attr;
- struct type *xtype;
-
- xtype = die_type (die, objfile, cu_header);
-
- type = alloc_type (objfile);
- TYPE_CODE (type) = TYPE_CODE_TYPEDEF;
- TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB;
- TYPE_TARGET_TYPE (type) = xtype;
attr = dwarf_attr (die, DW_AT_name);
- if (attr && DW_STRING (attr))
- TYPE_NAME (type) = obsavestring (DW_STRING (attr),
- strlen (DW_STRING (attr)),
- &objfile->type_obstack);
-
- die->type = type;
+ name = (attr && DW_STRING (attr)) ? DW_STRING (attr) : NULL;
+ die->type = init_type (TYPE_CODE_TYPEDEF, 0, TYPE_FLAG_TARGET_STUB, name, objfile);
+ TYPE_TARGET_TYPE (die->type) = die_type (die, objfile, cu_header);
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: RFA: use init_type() in dwarf2read.c
2001-12-08 22:47 RFA: use init_type() in dwarf2read.c Fred Fish
@ 2001-12-09 11:06 ` Elena Zannoni
0 siblings, 0 replies; 2+ messages in thread
From: Elena Zannoni @ 2001-12-09 11:06 UTC (permalink / raw)
To: fnf; +Cc: gdb-patches
Fred Fish writes:
> The dwarf2read.c file sometimes handcrafts new types and sometimes
> calls init_type(). This patch eliminates one of the unnecessary
> handcraftings.
>
> -Fred
>
Fred, this is OK, but could you please not use the conditional
expression? You can initialize name to NULL at the top, and then just
use an 'if(attr && DW_STRING (attr))'.
Thanks
Elena
>
> 2001-12-08 Fred Fish <fnf@redhat.com>
>
> * dwarf2read.c (read_typedef): Replace hand crafted type
> initialization with a call to the init_type() function, which
> is how the rest of gdb creates types.
>
> Index: dwarf2read.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> retrieving revision 1.38
> diff -u -p -r1.38 dwarf2read.c
> --- dwarf2read.c 2001/12/07 22:11:51 1.38
> +++ dwarf2read.c 2001/12/09 01:28:00
> @@ -2886,26 +2882,15 @@ static void
> read_typedef (struct die_info *die, struct objfile *objfile,
> const struct comp_unit_head *cu_header)
> {
> - struct type *type;
> + struct attribute *attr;
> + char *name;
>
> if (!die->type)
> {
> - struct attribute *attr;
> - struct type *xtype;
> -
> - xtype = die_type (die, objfile, cu_header);
> -
> - type = alloc_type (objfile);
> - TYPE_CODE (type) = TYPE_CODE_TYPEDEF;
> - TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB;
> - TYPE_TARGET_TYPE (type) = xtype;
> attr = dwarf_attr (die, DW_AT_name);
> - if (attr && DW_STRING (attr))
> - TYPE_NAME (type) = obsavestring (DW_STRING (attr),
> - strlen (DW_STRING (attr)),
> - &objfile->type_obstack);
> -
> - die->type = type;
> + name = (attr && DW_STRING (attr)) ? DW_STRING (attr) : NULL;
> + die->type = init_type (TYPE_CODE_TYPEDEF, 0, TYPE_FLAG_TARGET_STUB, name, objfile);
> + TYPE_TARGET_TYPE (die->type) = die_type (die, objfile, cu_header);
> }
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-12-09 19:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-08 22:47 RFA: use init_type() in dwarf2read.c Fred Fish
2001-12-09 11:06 ` Elena Zannoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox