forked from Imagelibrary/binutils-gdb
Fetch and store GP registers by PTRACE_{G,S}ETREGSET
If kernel supports PTRACE_GETREGSET, GDB uses PTRACE_{G,S}ETREGSET
to fetch and store GP registers.
gdb:
2015-06-01 Yao Qi <yao.qi@linaro.org>
* arm-linux-nat.c (fetch_register): Use PTRACE_GETREGSET.
(fetch_regs): Likewise.
(store_regs): Use PTRACE_SETREGSET.
(store_register): Likewise.
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
2015-06-01 Yao Qi <yao.qi@linaro.org>
|
||||||
|
|
||||||
|
* arm-linux-nat.c (fetch_register): Use PTRACE_GETREGSET.
|
||||||
|
(fetch_regs): Likewise.
|
||||||
|
(store_regs): Use PTRACE_SETREGSET.
|
||||||
|
(store_register): Likewise.
|
||||||
|
|
||||||
2015-06-01 Yao Qi <yao.qi@linaro.org>
|
2015-06-01 Yao Qi <yao.qi@linaro.org>
|
||||||
|
|
||||||
* arm-linux-nat.c (arm_linux_read_description): Check whether
|
* arm-linux-nat.c (arm_linux_read_description): Check whether
|
||||||
|
|||||||
@@ -225,7 +225,18 @@ fetch_register (struct regcache *regcache, int regno)
|
|||||||
/* Get the thread id for the ptrace call. */
|
/* Get the thread id for the ptrace call. */
|
||||||
tid = GET_THREAD_ID (inferior_ptid);
|
tid = GET_THREAD_ID (inferior_ptid);
|
||||||
|
|
||||||
ret = ptrace (PTRACE_GETREGS, tid, 0, ®s);
|
if (have_ptrace_getregset)
|
||||||
|
{
|
||||||
|
struct iovec iov;
|
||||||
|
|
||||||
|
iov.iov_base = ®s;
|
||||||
|
iov.iov_len = sizeof (regs);
|
||||||
|
|
||||||
|
ret = ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, &iov);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = ptrace (PTRACE_GETREGS, tid, 0, ®s);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
warning (_("Unable to fetch general register."));
|
warning (_("Unable to fetch general register."));
|
||||||
@@ -267,7 +278,18 @@ fetch_regs (struct regcache *regcache)
|
|||||||
/* Get the thread id for the ptrace call. */
|
/* Get the thread id for the ptrace call. */
|
||||||
tid = GET_THREAD_ID (inferior_ptid);
|
tid = GET_THREAD_ID (inferior_ptid);
|
||||||
|
|
||||||
ret = ptrace (PTRACE_GETREGS, tid, 0, ®s);
|
if (have_ptrace_getregset)
|
||||||
|
{
|
||||||
|
struct iovec iov;
|
||||||
|
|
||||||
|
iov.iov_base = ®s;
|
||||||
|
iov.iov_len = sizeof (regs);
|
||||||
|
|
||||||
|
ret = ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, &iov);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = ptrace (PTRACE_GETREGS, tid, 0, ®s);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
warning (_("Unable to fetch general registers."));
|
warning (_("Unable to fetch general registers."));
|
||||||
@@ -306,7 +328,18 @@ store_register (const struct regcache *regcache, int regno)
|
|||||||
tid = GET_THREAD_ID (inferior_ptid);
|
tid = GET_THREAD_ID (inferior_ptid);
|
||||||
|
|
||||||
/* Get the general registers from the process. */
|
/* Get the general registers from the process. */
|
||||||
ret = ptrace (PTRACE_GETREGS, tid, 0, ®s);
|
if (have_ptrace_getregset)
|
||||||
|
{
|
||||||
|
struct iovec iov;
|
||||||
|
|
||||||
|
iov.iov_base = ®s;
|
||||||
|
iov.iov_len = sizeof (regs);
|
||||||
|
|
||||||
|
ret = ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, &iov);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = ptrace (PTRACE_GETREGS, tid, 0, ®s);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
warning (_("Unable to fetch general registers."));
|
warning (_("Unable to fetch general registers."));
|
||||||
@@ -322,7 +355,18 @@ store_register (const struct regcache *regcache, int regno)
|
|||||||
regcache_raw_collect (regcache, ARM_PC_REGNUM,
|
regcache_raw_collect (regcache, ARM_PC_REGNUM,
|
||||||
(char *) ®s[ARM_PC_REGNUM]);
|
(char *) ®s[ARM_PC_REGNUM]);
|
||||||
|
|
||||||
ret = ptrace (PTRACE_SETREGS, tid, 0, ®s);
|
if (have_ptrace_getregset)
|
||||||
|
{
|
||||||
|
struct iovec iov;
|
||||||
|
|
||||||
|
iov.iov_base = ®s;
|
||||||
|
iov.iov_len = sizeof (regs);
|
||||||
|
|
||||||
|
ret = ptrace (PTRACE_SETREGSET, tid, NT_PRSTATUS, &iov);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = ptrace (PTRACE_SETREGS, tid, 0, ®s);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
warning (_("Unable to store general register."));
|
warning (_("Unable to store general register."));
|
||||||
@@ -340,7 +384,18 @@ store_regs (const struct regcache *regcache)
|
|||||||
tid = GET_THREAD_ID (inferior_ptid);
|
tid = GET_THREAD_ID (inferior_ptid);
|
||||||
|
|
||||||
/* Fetch the general registers. */
|
/* Fetch the general registers. */
|
||||||
ret = ptrace (PTRACE_GETREGS, tid, 0, ®s);
|
if (have_ptrace_getregset)
|
||||||
|
{
|
||||||
|
struct iovec iov;
|
||||||
|
|
||||||
|
iov.iov_base = ®s;
|
||||||
|
iov.iov_len = sizeof (regs);
|
||||||
|
|
||||||
|
ret = ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, &iov);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = ptrace (PTRACE_GETREGS, tid, 0, ®s);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
warning (_("Unable to fetch general registers."));
|
warning (_("Unable to fetch general registers."));
|
||||||
@@ -357,7 +412,17 @@ store_regs (const struct regcache *regcache)
|
|||||||
regcache_raw_collect (regcache, ARM_PS_REGNUM,
|
regcache_raw_collect (regcache, ARM_PS_REGNUM,
|
||||||
(char *) ®s[ARM_CPSR_GREGNUM]);
|
(char *) ®s[ARM_CPSR_GREGNUM]);
|
||||||
|
|
||||||
ret = ptrace (PTRACE_SETREGS, tid, 0, ®s);
|
if (have_ptrace_getregset)
|
||||||
|
{
|
||||||
|
struct iovec iov;
|
||||||
|
|
||||||
|
iov.iov_base = ®s;
|
||||||
|
iov.iov_len = sizeof (regs);
|
||||||
|
|
||||||
|
ret = ptrace (PTRACE_SETREGSET, tid, NT_PRSTATUS, &iov);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = ptrace (PTRACE_SETREGS, tid, 0, ®s);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user