This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Convert have_ptrace_getregset to a tri-state boolean


*** TEST RESULTS FOR COMMIT 0bdb2f78497a1b3be65d1428cc02f7d4e1d3a888 ***

Author: Yao Qi <yao.qi@linaro.org>
Branch: master
Commit: 0bdb2f78497a1b3be65d1428cc02f7d4e1d3a888

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]