summaryrefslogtreecommitdiffstats
path: root/tests/backtrace.c
diff options
context:
space:
mode:
authorH.J. Lu <[email protected]>2015-03-12 12:14:43 -0700
committerMark Wielaard <[email protected]>2015-03-13 16:06:23 +0100
commitbe7ea70f3fc2be7a39dc210a70e92109b5d9ef5d (patch)
tree9bdd2807d52d96f943a664dc162e358bad56eeb6 /tests/backtrace.c
parentcbf25bb674320ad595707d2592799381979d85f3 (diff)
tests: Use PTRACE_GETREGS/PTRACE_SETREGS to update rip
Use PTRACE_POKEUSER to update rip is unsupported for x32. We should use PTRACE_GETREGS/PTRACE_SETREGS to update rip. Signed-off-by: H.J. Lu <[email protected]>
Diffstat (limited to 'tests/backtrace.c')
-rw-r--r--tests/backtrace.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/backtrace.c b/tests/backtrace.c
index e109654f..8b19b947 100644
--- a/tests/backtrace.c
+++ b/tests/backtrace.c
@@ -260,9 +260,13 @@ prepare_thread (pid_t pid2 __attribute__ ((unused)),
abort ();
#else /* x86_64 */
long l;
+ struct user_regs_struct user_regs;
errno = 0;
- l = ptrace (PTRACE_POKEUSER, pid2,
- (void *) (intptr_t) offsetof (struct user_regs_struct, rip), jmp);
+ l = ptrace (PTRACE_GETREGS, pid2, 0, (intptr_t) &user_regs);
+ assert_perror (errno);
+ assert (l == 0);
+ user_regs.rip = (intptr_t) jmp;
+ l = ptrace (PTRACE_SETREGS, pid2, 0, (intptr_t) &user_regs);
assert_perror (errno);
assert (l == 0);
l = ptrace (PTRACE_CONT, pid2, NULL, (void *) (intptr_t) SIGUSR2);
@@ -375,7 +379,7 @@ exec_dump (const char *exec)
#ifndef __x86_64__
is_x86_64_native = false;
#else /* __x86_64__ */
- is_x86_64_native = ehdr->e_ident[EI_CLASS] == ELFCLASS64;
+ is_x86_64_native = ehdr->e_machine == EM_X86_64;
#endif /* __x86_64__ */
void (*jmp) (void) = 0;
if (is_x86_64_native)