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: powerpc-linux biarch corefile support


Alan Modra wrote:

> Yes, it is for zero extending, and also for initializing unused
> fields.  Random values in unused fields (eg. orig_gpr3) look odd in
> core dumps.  I could cure that particular problem by clearing the
> buffer in linux-nat.c:linux_nat_do_thread_registers, but that doesn't
> help ps_lgetregs.  I'm sure we'll need to clear the high word of regs
> for libthread_db when the inferior is 32-bit and gdb is 64-bit.  So
> that would seem to mean we need the rather messy business of clearing
> individual registers, except that fill_gregset and fill_fpregset
> are always called with regno == -1 and are not used in the powerpc
> linux store_inferior_registers.  (That code needs cleaning up to use
> ppc_collect_gregset et al too.  Maybe for my next gdb patch..)
> ie. fill_gregset and fill_fpregset are always storing into an
> uninitialised buffer.  How about we just clear the buffers in
> fill_gregset and fill_fpregset?

I'm not sure I'm happy with this, it will cause problems if at some
time in the future fill_gregset is indeed called with regno != -1.

Why don't we push the task of clearing individual registers down
to ppc_supply_reg and ppc_collect_reg in rs6000-nat.c?  Have their
callers always provide them with an "offset" value pointing to the
start of the full field in REGS, and provide an extra "size" value
denoting the length of the field in REGS.

The helper functions can compare that size with GDB's notion of
the register_size, and if it is bigger (it cannot be smaller),
supply only the right part of the field, and zero out the left
part of the field when collecting.

The callers of ppc_supply_reg and ppc_collect_reg should be able
to provide that new size value using offsets->gpr_size or fixed
values.

Note that this should make ppc64_32_linux_reg_offsets unnecessary,
you'll need to always use ppc64_linux_reg_offsets on a 64-bit host.


Mark, would this be OK with you as well?


Another minor issue:

> +const struct regset *
> +ppc_linux_gregset (struct gdbarch *gdbarch)
> +{
> +  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> +  if (tdep->wordsize == 8)
> +    return &ppc64_linux_gregset;
> +  if (sizeof (long) == 8)
> +    return &ppc64_32_linux_gregset;
> +  return &ppc32_linux_gregset;
>  }

While you'll indeed have to check sizeof (long), you should not do
so in ppc-linux-tdep.c (which is built on many different hosts when
building a cross-debugger), but rather in ppc-linux-nat.c (which is
only built on the native system).  Pass the value in as argument
similar to what the old code did ...


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]