This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [2/10] Remove &builtin_type_ from tdep code (amd64/s390/sparc64)
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: vladimir at codesourcery dot com (Vladimir Prus)
- Cc: drow at false dot org (Daniel Jacobowitz), gdb-patches at sourceware dot org
- Date: Wed, 13 Jun 2007 15:06:11 +0200 (CEST)
- Subject: Re: [2/10] Remove &builtin_type_ from tdep code (amd64/s390/sparc64)
Vladimir Prus wrote:
> I suppose I can change m68k_register_type to directly return
> the type, but I'm not sure why
>
> return builtin_type_double;
>
> is better than:
>
> return *x;
>
> where x = &builtin_type_double;
builtin_type_double is currently a global variable that is
gdbarch-swapped, i.e. whenever current_gdbarch switches, the
value of that global variable is re-set.
This is awkward and makes is hard to use any other gdbarch
(that is not currently installed as current_gdbarch) reliably,
which is what my patch set is intended to fix.
To that purpose, the builtin_type_double global variable will
go away, and is (temporarily) replaced by a macro
#define builtin_type_double
builtin_type (current_gdbarch)->builtin_double
However, this macro is not fully equivalent; in particular it
is no longer possible to use &builtin_type_double.
Longer term, that compatibility macro will go away as well,
and your
return builtin_type_double;
should be replaced by
return builtin_type (gdbarch)->builtin_double;
using the "gdbarch" you get as input to ..._register_type
instead of the global current_gdbarch. (If you prefer,
you can certainly use that form right away.)
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com