Re: [patch] gdb/testsuite: fixes for gdb.xml/tdesc-regs.exp

Andrew Burgess
2020-06-18T09:43:40Z

* Sandra Loosemore <sandra@codesourcery.com> [2020-06-16 15:08:59 -0600]:

> On 6/16/20 2:47 PM, Andrew Burgess wrote:
>
> > I'd be interested to know more about which targets don't place any
> > registers in the 'general' group. This group is used in
> > default_print_registers_info to implement 'info registers', so I'd
> > like to see what this particular target has done instead.
>
> nios2, for one. From the original test log for nios2-linux-gnu:

OK, but...

Please bear with me, I don't have a nios2 tool chain to hand, but...

In nios2-tdep.c, there is no call to set_gdbarch_print_registers_info,
which means (from gdbarch.c) that nios2 will use
default_print_registers_info.

Now if we look in infcmd.c at both default_print_registers_info and
registers_info, then we see that if a user says:

(gdb) info registers

then they will be asking which registers are in the general_reggroup.

Now, nios can optionally use a remote target-description (from
nios2_gdbarch_init), so, lets for now assume no target description. I
see no call to set_gdbarch_register_reggroup_p for nios2, which means
we are going to be using default_register_reggroup_p, which if we
inspect (in reggroups.c) we'll see does place some registers into the
general group.

Now, does this matter? The reggroup name is never printed anywhere, we
just see a set of random registers?

But it is annoying that the user is not easily able to say:

(gdb) info registers general

and get the same output.

If we look at how other targets deal with this most of them manually
add at least some sub-set of the default register groups to their
architectures set of register groups as part of their _gdbarch_init
routine.

My gut instinct here is that this is what nios2 should be doing (and
maybe arm too).

It does seem odd that there's no central "add-the-default-reggroups"
type routine that targets can or should call.

Thanks,
Andrew

>
> maintenance print reggroups
> Group Type
> foo user
> (gdb) FAIL: gdb.xml/tdesc-regs.exp: maintenance print reggroups
>
> I don't have a mainline build for ARM handy but the failure reproduces on
> GDB 9 branch for arm-none-eabi.
>
> This is Abid's original summary of his investigation in 2018:
>
> There are 2 reggroups maintained in the code. One is the
> default_groups which is populated in _initialize_reggroup. This group
> has 'general' group. So if you do 'maint print reggroups without
> loading anything in gdb, you will see 'general' group.
>
> The other group is stored in reggroups_data. This is populated when we
> load a target description xml file. So it only has group defined in
> xml file. But if has a valid group, then 'maint print reggroups' will
> not use default_groups. So that command will not print 'general' group
> if xml files did not have any.
>
> For x86, we have slightly different behavior. Its tdep code calls
> i386_add_reggroups which add 'general' group to reggroups_data as
> well.
>
> So this testcase assumes that 'general' group is always present. This
> asumption is true on x86 only not in general. So I have removed it
> from the match pattern.
>
> -Sandra