Re: [PATCH] Disallow pseudo-registers in agent expression.

Jim Blandy
2008-02-05T15:34:45Z

Andrzej, is this idea something that you would be interested in
implementing? It'd be great to get this working.

On Jan 28, 2008 5:28 PM, Jim Blandy <jimb@red-bean.com> wrote:
> On Jan 28, 2008 3:51 PM, andrzej zaborowski <balrogg@gmail.com> wrote:
> > On 27/01/2008, Jim Blandy <jimb@red-bean.com> wrote:
> > > On some targets, all the user-visible registers are pseudo-registers.
> > > What we need is a gdbarch method (optional) that the tracepoint code
> > > could call, passing it a struct agent_expr and a pseudo-register
> > > number, to have the architecture code append the appropriate bytecodes
> > > to access that register.
> >
> > That's ofcourse doable but sounds tough and bug-prone. The mapping of
> > numbers to raw registers is to some extent obvious and unlikely to
> > change, while the pseudo-registers may change with gdb version so the
> > target has more gdb version dependence.
>
> I'm not sure I expressed myself well. I was imagining something like this:
>
> *** ax-gdb.c 07 Jan 2008 08:31:13 -0800 1.40
> --- ax-gdb.c 28 Jan 2008 17:21:28 -0800
> ***************
> *** 1607,1615 ****
> if (reg == -1)
> internal_error (__FILE__, __LINE__,
> _("Register $%s not available"), name);
> ! value->kind = axs_lvalue_register;
> ! value->u.reg = reg;
> ! value->type = register_type (current_gdbarch, reg);
> }
> break;
>
> --- 1607,1627 ----
> if (reg == -1)
> internal_error (__FILE__, __LINE__,
> _("Register $%s not available"), name);
> ! if (reg < gdbarch_num_regs (current_gdbarch))
> ! {
> ! value->kind = axs_lvalue_register;
> ! value->u.reg = reg;
> ! value->type = register_type (current_gdbarch, reg);
> ! }
> ! else
> ! {
> ! /* It's a pseudo-register reference; ask the architecture
> ! to generate appropriate bytecode for it. */
> ! if (! gdbarch_gen_pseudo_reg_ax (current_gdbarch, ax, value, reg))
> ! error (_("Couldn't generate agent expression"
> ! " to refer to register '%s'"),
> ! gdbarch_register_name (current_gdbarch, reg));
> ! }
> }
> break;
>
> This seems pretty reasonable to me: only the architecture knows how
> pseudo-register values are computed from the raw register values --- a
> pseudo-register might be two raw registers spliced together, for
> example --- so only the architecture knows the right agent bytecode to
> generate.
>