diff options
author | Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com> | 2018-05-22 11:09:05 -0300 |
---|---|---|
committer | Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com> | 2018-05-22 11:52:02 -0300 |
commit | 2e077f5e67aeff78e096a250bd225cd4658a35dc (patch) | |
tree | c1930a2baaa879e8989c9a0d80548d640ef0b7b0 /gdb/gdbserver/linux-ppc-low.c | |
parent | bd64614eb737096f40b976fb505ddd42e7f1614c (diff) | |
download | gdb-2e077f5e67aeff78e096a250bd225cd4658a35dc.zip gdb-2e077f5e67aeff78e096a250bd225cd4658a35dc.tar.gz gdb-2e077f5e67aeff78e096a250bd225cd4658a35dc.tar.bz2 |
[PowerPC] Consolidate wordsize getter between native and gdbserver
This patch moves the native target wordsize getter for ppc linux to
nat/ so that it can be used to simplify ppc_arch_setup in
gdbserver. The ptrace call used to get MSR for this is ultimately the
same as before, but it is no longer necessary to create a temporary
regcache to call fetch_inferior_registers.
gdb/ChangeLog:
2018-05-22 Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com>
* configure.nat <linux powerpc>: Add ppc-linux.o to NATDEPFILES.
* ppc-linux-nat.c (ppc_linux_target_wordsize): Move to
nat/ppc-linux.c.
(ppc_linux_nat_target::auxv_parse): Get thread id tid. Call
ppc_linux_target_wordsize with tid.
(ppc_linux_nat_target::read_description): Call ppc_linux_target
wordsize with tid.
* nat/ppc-linux.c: Include nat/gdb_ptrace.h.
(ppc64_64bit_inferior_p): Add static and inline specifiers.
(ppc_linux_target_wordsize): Move here from ppc-linux-nat.c. Add
tid parameter. Remove static specifier.
* nat/ppc-linux.h (ppc64_64bit_inferior_p): Remove declaration.
(ppc_linux_target_wordsize): New declaration.
gdb/gdbserver/ChangeLog:
2018-05-22 Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com>
* linux-ppc-low.c (ppc_arch_setup): Remove code for getting the
wordsize of the inferior. Call ppc_linux_target_wordsize.
Diffstat (limited to 'gdb/gdbserver/linux-ppc-low.c')
-rw-r--r-- | gdb/gdbserver/linux-ppc-low.c | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c index 5361baf..30fcd41 100644 --- a/gdb/gdbserver/linux-ppc-low.c +++ b/gdb/gdbserver/linux-ppc-low.c @@ -620,36 +620,16 @@ ppc_arch_setup (void) { const struct target_desc *tdesc; struct ppc_linux_features features = ppc_linux_no_features; + int tid = lwpid_of (current_thread); - features.wordsize = 4; - -#ifdef __powerpc64__ - long msr; - struct regcache *regcache; - - /* On a 64-bit host, assume 64-bit inferior process with no - AltiVec registers. Reset ppc_hwcap to ensure that the - collect_register call below does not fail. */ - tdesc = tdesc_powerpc_64l; - current_process ()->tdesc = tdesc; - ppc_hwcap = 0; - - regcache = new_register_cache (tdesc); - fetch_inferior_registers (regcache, find_regno (tdesc, "msr")); - collect_register_by_name (regcache, "msr", &msr); - free_register_cache (regcache); - if (ppc64_64bit_inferior_p (msr)) - { - features.wordsize = 8; - } -#endif + features.wordsize = ppc_linux_target_wordsize (tid); if (features.wordsize == 4) - { - /* OK, we have a 32-bit inferior. */ tdesc = tdesc_powerpc_32l; - current_process ()->tdesc = tdesc; - } + else + tdesc = tdesc_powerpc_64l; + + current_process ()->tdesc = tdesc; /* The value of current_process ()->tdesc needs to be set for this call. */ |