diff options
author | Yao Qi <yao.qi@linaro.org> | 2015-06-23 14:03:11 +0100 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2015-06-23 14:03:11 +0100 |
commit | 0bdb2f78497a1b3be65d1428cc02f7d4e1d3a888 (patch) | |
tree | 59ef29eda0d1965b4313c735b9e75bd81919f70b /gdb/i386-linux-nat.c | |
parent | c217058957a45a93481da35e1531ed120750d739 (diff) | |
download | gdb-0bdb2f78497a1b3be65d1428cc02f7d4e1d3a888.zip gdb-0bdb2f78497a1b3be65d1428cc02f7d4e1d3a888.tar.gz gdb-0bdb2f78497a1b3be65d1428cc02f7d4e1d3a888.tar.bz2 |
Convert have_ptrace_getregset to a tri-state boolean
have_ptrace_getregset is a tri-state variable (-1, 0, 1), and we have
some conditions like "if (have_ptrace_getregset)", which is not correct.
I'll explain why it is not correct in the following example. This fix
to this problem to replace the test (have_ptrace_getregset) to test
(have_ptrace_getregset == 1) or (have_ptrace_getregset == -1) etc.
However Doug thinks it hinders readability
https://sourceware.org/ml/gdb-patches/2015-05/msg00692.html so I decide
to add a new enum tribool and change have_ptrace_getregset to it, in
order to make these tests more readable.
have_ptrace_getregset is initialised to -1, and is adjusted to 0 or 1 in
$ARCH_linux_read_description according to the capability of the kernel.
However, it is possible that have_ptrace_getregset is used before it is
set to 0 or 1, which means it is still -1. This is shown below.
(gdb) run
Starting program: gdb/testsuite/gdb.base/break
Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128
128 {
top?p have_ptrace_getregset
$1 = TRIBOOL_UNKNOWN
top?c
Continuing.
Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128
128 {
top?c
Continuing.
Breakpoint 1, x86_linux_read_description (ops=0xceaa80) at git/gdb/x86-linux-nat.c:117
117 {
PTRACE_GETREGSET command is used even GDB doesn't know whether
PTRACE_GETREGSET is supported or not. It is wrong, but works on x86.
However it doesn't work on arm-linux if the kernel doesn't support
PTRACE_GETREGSET at all. We'll get:
(gdb) run
Starting program: gdb/testsuite/gdb.base/break
warning: Unable to fetch general register.
PC register is not available
gdb:
2015-06-23 Yao Qi <yao.qi@linaro.org>
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers):
Check whether have_ptrace_getregset is TRIBOOL_TRUE explicitly.
(amd64_linux_store_inferior_registers): Likewise.
* arm-linux-nat.c (fetch_fpregister): Likewise.
(fetch_fpregs, store_fpregister): Likewise.
(store_fpregister, store_fpregs): Likewise.
(fetch_register, fetch_regs): Likewise.
(store_register, store_regs): Likewise.
(fetch_vfp_regs, store_vfp_regs): Likewise.
(arm_linux_read_description): Check have_ptrace_getregset is
TRIBOOL_UNKNOWN. Set have_ptrace_getregset to TRIBOOL_TRUE
or TRIBOOL_FALSE.
* i386-linux-nat.c (fetch_xstateregs): Check
have_ptrace_getregset is not TRIBOOL_TRUE.
(store_xstateregs): Likewise.
* linux-nat.c (have_ptrace_getregset): Change its type to
enum tribool.
* linux-nat.h (tribool): New enum.
* x86-linux-nat.c (x86_linux_read_description): Use enum tribool.
Check whether have_ptrace_getregset is TRIBOOL_TRUE.
Diffstat (limited to 'gdb/i386-linux-nat.c')
-rw-r--r-- | gdb/i386-linux-nat.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c index 4401a2f..349ce68 100644 --- a/gdb/i386-linux-nat.c +++ b/gdb/i386-linux-nat.c @@ -327,7 +327,7 @@ fetch_xstateregs (struct regcache *regcache, int tid) char xstateregs[X86_XSTATE_MAX_SIZE]; struct iovec iov; - if (!have_ptrace_getregset) + if (have_ptrace_getregset != TRIBOOL_TRUE) return 0; iov.iov_base = xstateregs; @@ -350,7 +350,7 @@ store_xstateregs (const struct regcache *regcache, int tid, int regno) char xstateregs[X86_XSTATE_MAX_SIZE]; struct iovec iov; - if (!have_ptrace_getregset) + if (have_ptrace_getregset != TRIBOOL_TRUE) return 0; iov.iov_base = xstateregs; |