There's a more general problem here (JeffJ pointed it out to me). At
present "gcore" obtains the registers being saved using regcache
collect. Unfortunatly, there's a missing target_fetch_registers(-1)
call, and, as a consequence, the registers written out can be invalid
:-( There are several issues here: should "gcore" use regcache collect
directly (bypassing the register fetch mechanism); if not, should this
regset methods be parameterized with the function that should be used
when collecting the registers (see regcache_cooked_read_ftype)?
I've run into this problem also. There's a target_fetch_registers in
linux-proc.c with a FIXME; that's in the threaded case. In the
non-threaded case the call is missing. Personally, I believe that the
call shouldn't be necessary, and that fill_gregset should use the
collect mechanism (which implicitly calls fetch). But I'm not sure if
that will work.
That's exactly what I'm aiming at :-). The "mapping" needs to be a
>function though, since in some cases it might need to do some
>arithmetic on the buffer contents in order to convert them to the
>format used by GDB's register cache.
Yes. Functions will work better.
OK. I'd like to add a function in common code which does the mapping
based on a table though, since for many cases that's enough - cuts down
on duplication. What do you think?
void
mipsnbsd_supply_reg (char *regs, int regno)
{
int i;
for (i = 0; i <= PC_REGNUM; i++)
{
if (regno == i || regno == -1)
{
if (CANNOT_FETCH_REGISTER (i))
supply_register (i, NULL);
else
supply_register (i, regs + (i * MIPS_REGSIZE));
}
}
}
Yes.
Need to figure out how to relate these regsets back to ptrace/proc
requests in some sort of generic way. Doing the same for remote would
hopefully then fall out.
I'm not sure that it's possible to relate them back in any generic way;
ptrace is just too quirky. The closest I can picture is the way I did
it in gdbserver, which is really more of a common-code thing than a
generic-interface thing:
struct regset_info target_regsets[] = {
{ PTRACE_GETREGS, PTRACE_SETREGS, sizeof (elf_gregset_t),
GENERAL_REGS,
i386_fill_gregset, i386_store_gregset },
{ PTRACE_GETFPREGS, PTRACE_SETFPREGS, sizeof (elf_fpregset_t),
FP_REGS,
i386_fill_fpregset, i386_store_fpregset },
{ 0, 0, -1, -1, NULL, NULL }
};