Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/sys Apply fix in rev 1.2 for core_dump_procin...



details:   https://anonhg.NetBSD.org/src/rev/166461f8a233
branches:  trunk
changeset: 977116:166461f8a233
user:      rin <rin%NetBSD.org@localhost>
date:      Thu Oct 15 22:59:50 2020 +0000

description:
Apply fix in rev 1.2 for core_dump_procinfo to aarch64 and arm:

http://cvsweb.netbsd.org/bsdweb.cgi/src/tests/lib/libc/sys/t_ptrace_core_wait.h#rev1.2

> For powerpc, program counter is not automatically incremented by trap
> instruction. We cannot increment PC in the trap handler, which breaks
> applications depending on this behavior, e.g., GDB.

This statement is true for aarch64 and arm.

Also, use PTRACE_BREAKPOINT_SIZE instead of hard-coded 4 to address
instruction next to PC.

OK ryo

diffstat:

 tests/lib/libc/sys/t_ptrace_core_wait.h |  26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diffs (46 lines):

diff -r 876d6462b50e -r 166461f8a233 tests/lib/libc/sys/t_ptrace_core_wait.h
--- a/tests/lib/libc/sys/t_ptrace_core_wait.h   Thu Oct 15 22:52:08 2020 +0000
+++ b/tests/lib/libc/sys/t_ptrace_core_wait.h   Thu Oct 15 22:59:50 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_core_wait.h,v 1.2 2020/06/24 04:47:10 rin Exp $       */
+/*     $NetBSD: t_ptrace_core_wait.h,v 1.3 2020/10/15 22:59:50 rin Exp $       */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -207,21 +207,27 @@
 
        DPRINTF("Before resuming the child process where it left off and "
            "without signal to be sent\n");
-#ifndef __powerpc__
-       SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-#else
+
+#if defined(__aarch64__) || defined(__arm__) || defined(__powerpc__)
        /*
-        * For powerpc, program counter is not automatically incremented by
-        * a trap instruction. We cannot increment PC in the trap handler,
+        * For these archs, program counter is not automatically incremented
+        * by a trap instruction. We cannot increment PC in the trap handler,
         * which breaks applications depending on this behavior, e.g., GDB.
-        * Therefore, we need to pass (PC + 4) instead of (void *)1 (== PC)
-        * to PT_CONTINUE here.
+        * Therefore, we need to pass PC++ instead of (void *)1 (== PC) to
+        * PT_CONTINUE here.
         */
        struct reg r;
 
        SYSCALL_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
-       SYSCALL_REQUIRE(
-           ptrace(PT_CONTINUE, child, (void *)(r.pc + 4), 0) != -1);
+       SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child,
+#  if defined(__aarch64__) || defined(__arm__)
+           (void *)(r.r_pc + PTRACE_BREAKPOINT_SIZE),
+#  elif defined(__powerpc__)
+           (void *)(r.pc + PTRACE_BREAKPOINT_SIZE),
+#  endif
+           0) != -1);
+#else
+       SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
 #endif
 
        DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);



Home | Main Index | Thread Index | Old Index