This is the mail archive of the gdb-patches@sources.redhat.com 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]

Pass gdbarch, not regset, to supply regset et.al.?


Mark,

I'm wondering if it would be easier to explicitly pass the gdbarch instead of the regset to the regset function?

At present the lookup regset code does this:

          tdep->gregset = XMALLOC (struct regset);
          tdep->gregset->descr = tdep;
          tdep->gregset->supply_regset = i386_supply_gregset;

so that the architecture is tunneled through to the regset function.

  const struct gdbarch_tdep *tdep = regset->descr;
  ...
  for (i = 0; i < tdep->gregset_num_regs; i++)

I'm wondering if it would be easier to just pass the architecture?

At the same time, I'm wondering if i386_regset_from_core_section should be abstracted a little so that, like reggroups it was set up:

set_regset_supply_core_section (arch, ".reg", size, i386_supply_regset);
set_regset_supply_core_section (arch, ".reg2", i386_supply_fpregset);
...
f = regset_supply_from_core_section (core_arch, ".name", length);
f (core_arch, current_regcache, regnum, contents, length);
... or even the short cut ...
regset_supply_core_section (core_arch, ".name", current_regcache, regnum, contents, length);


Thoughts?

I just came across this bit of PPC64 GNU/Linux code

void
ppc_linux_supply_gregset (char *buf)
{
int regi;
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);


  for (regi = 0; regi < 32; regi++)
    supply_register (regi, buf + 4 * regi);

(yes, that's a "4" not "8") and was studying the new mechanism.


Andrew


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