mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-18 09:05:10 +00:00
parasite-syscall: use the ptrace requests PTRACE_(GET|SET)REGSET to retrieve and set CPU registers
This patch introduces the routines ptrace_get_gpregs() and ptrace_set_gpregs() that wrap the ptrace interface to get and set CPU registers respectively. The motivation is to make the CRIU code be compatible with architectures that don't support the PTRACE_GETREGS and PTRACE_SETREGS ptrace calls --- the requests PTRACE_GETREGSET and PTRACE_SETREGSET are implemented instead. Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
c2a366d44d
commit
03a9c6b0b7
2 changed files with 16 additions and 2 deletions
|
|
@ -27,6 +27,11 @@ struct ptrace_peeksiginfo_args {
|
|||
#define PTRACE_PEEKSIGINFO_SHARED (1 << 0)
|
||||
#endif
|
||||
|
||||
#ifndef PTRACE_GETREGSET
|
||||
# define PTRACE_GETREGSET 0x4204
|
||||
# define PTRACE_SETREGSET 0x4205
|
||||
#endif
|
||||
|
||||
#define PTRACE_GETSIGMASK 0x420a
|
||||
#define PTRACE_SETSIGMASK 0x420b
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <elf.h>
|
||||
|
||||
#include "asm/parasite-syscall.h"
|
||||
#include "asm/dump.h"
|
||||
|
|
@ -67,12 +68,20 @@ static struct vma_area *get_vma_by_ip(struct list_head *vma_area_list, unsigned
|
|||
|
||||
static inline int ptrace_get_regs(int pid, user_regs_struct_t *regs)
|
||||
{
|
||||
return ptrace(PTRACE_GETREGS, pid, NULL, regs);
|
||||
struct iovec iov;
|
||||
|
||||
iov.iov_base = regs;
|
||||
iov.iov_len = sizeof(user_regs_struct_t);
|
||||
return ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &iov);
|
||||
}
|
||||
|
||||
static inline int ptrace_set_regs(int pid, user_regs_struct_t *regs)
|
||||
{
|
||||
return ptrace(PTRACE_SETREGS, pid, NULL, regs);
|
||||
struct iovec iov;
|
||||
|
||||
iov.iov_base = regs;
|
||||
iov.iov_len = sizeof(user_regs_struct_t);
|
||||
return ptrace(PTRACE_SETREGSET, pid, NT_PRSTATUS, &iov);
|
||||
}
|
||||
|
||||
static int get_thread_ctx(int pid, struct thread_ctx *ctx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue