This is the mail archive of the gdb-patches@sourceware.org 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: [RFC] Add support for PPC Altivec registers in gcore


Carlos Eduardo Seo wrote:

> The attached patch makes gcore dump the contents of PPC Altivec registers.
> 
> However, I'm not happy with declaring a bunch of PPC-specific stuff in
> gregset.h. But since FPXREGSET was there, I put everything in that file
> as well.
> 
> I'm open to comments about how to make this better, so please give me
> some thoughts.

> +  if (core_regset_p
> +      && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-ppc-vmx",
> +						     sizeof (vrregs))) != NULL
> +      && regset->collect_regset != NULL)
> +    regset->collect_regset (regset, regcache, -1,
> +			    &vrregs, sizeof (vrregs));
> +  else
> +    fill_vrregset (regcache, &vrregs);

First of all, you certainly do not need the global fill_vrregset fallback.
In fact, the existing uses of the global "fill_..." functions should be
removed and targets switched over to use the collect_regset method.

For *new* support like this, you should simply require the collect_regset
method to be used, and not provide any fallback.

Also, the current patch as it stands will cause build failures on any
native Linux target but PowerPC, as that function is not defined.


> Index: src/gdb/gregset.h

> +/* For PPC Altivec support  */
> +
> +#define SIZEOF_VRREGS 33*16+4
> +
> +typedef char gdb_vrregset_t[SIZEOF_VRREGS];

Now, the only reason this currently needs to be in common code is
that common code allocates a local variable on the stack, and needs
to know the size required for it.  Everything else is actually not
necessary in common code.

So maybe be should add a new gdbarch variable that points to a 
list of supported register notes, each specified via name and size:

  { { ".reg", sizeof gdb_gregset_t },
    { ".reg2", sizeof gdb_fpregset_t },
    { ".reg-ppx-vmx", sizeof gdb_vrregset_t },
    { NULL } }

Common linux-nat code would walk through the list, instead of 
having to handle each note separately.  (Note that corelow.c
could also walk that list instead of hard-coding note names.)

Probably at least for now the "main" .reg / .reg2 will have to
remain special-cased due to the fill_ fallbacks.  But the 
"special" note types, .reg-xfp for Intel and .reg-ppc-vmx for
PPC, could certainly be switched to the new method.


Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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