This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.)


  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]