S390: Enable re-attaching with native-extended-gdbserver
On s390x, when running attach.exp with native-extended-gdbserver,
gdbserver crashes in find_regno like this:
.../regcache.c:252: A problem internal to GDBserver has been detected.
Unknown register tdb0 requested
On the GDB side it looks like this:
(gdb) attach 31568
Attaching to process 31568
Remote connection closed
The test case attempts to attach to a new process via the already running
gdbserver. Thus s390_arch_setup is called a second time, and that's where
the problem occurs. In order to determine the word width (32 or 64 bits),
s390_arch_setup reads the pswm register through the regcache. For that it
uses a temporary tdesc which is supposed to work for all s390 targets,
since the actual tdesc has not been determined yet. But in this second
round this doesn't work, because s390_regsets has been updated already and
now contains regsets not described by the temporary tdesc, such as the one
containing tdb0.
This is fixed by rearranging the logic in s390_arch_setup.
gdb/gdbserver/ChangeLog:
* linux-s390-low.c (s390_get_hwcap): Replace tdesc parameter by
the word size. Add comment.
(s390_get_wordsize): New function.
(s390_arch_setup): No longer select a temporary tdesc to fetch the
pswm with it. Instead, use s390_get_wordsize to determine the
word size first and derive the correct tdesc from that directly.