Re: [PATCH v2] Enable tracing of pseudo-registers on ARM

Antoine Tremblay
2016-02-19T16:33:17Z

Antoine Tremblay writes:

> In this v2:
> Use user_reg_map_name_to_regnum.

Oops this is actually wrong.

I forgot that the reason I had it as :

+ /* Single precision pseudo registers. s0-s31. */
+ if (reg >= num_regs && reg < num_regs + 32)
+ {
+ rawnum = (reg - num_regs) / 2 + 26;
+ }
+ /* Quadruple precision pseudo regisers. q0-q15. */
+ else if (reg >= num_regs + 32 && reg < num_regs + 32 + 16)
+ {
+ rawnum = (reg - num_regs - 32) * 2 + 26;
+ }

In order to map from the GDB internal regnum to a real regnum to be used
by GDBServer in gdbserver/ax.c as :

case gdb_agent_op_reg:
/* Flush the cached stack top. */
stack[sp++] = top;
arg = aexpr->bytes[pc++];
arg = (arg << 8) + aexpr->bytes[pc++];
{
int regnum = arg;
struct regcache *regcache = ctx->regcache;

switch (register_size (regcache->tdesc, regnum))

Here regnum is expected to be the real register number.

As example if I get arm_pseudo_register_to_register with register 109

This is actually register 35, but user_reg_map_name_to_regnum will still
map it as a GDB internal register number 67.

It's 32 regs off because user_reg_map_name_to_regnum iterates over all
regs as num_regs + pseudo_regs, and in this case num_regs is 91 since in
arm.h the regnum enums gives a GDB internal register number so that all
registers numbers are unique independantly from the arch in use.

Maybe there's a better way to map these internal gdb registers to actual
register numbers ? Yao?