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 Fix core_dump_procinfo tests for powerpc,...



details:   https://anonhg.NetBSD.org/src/rev/77adf2dd5eae
branches:  trunk
changeset: 935069:77adf2dd5eae
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Jun 24 04:47:10 2020 +0000

description:
Fix core_dump_procinfo tests for powerpc, for which child process was
stalled indefinitely in trap instruction even after PT_CONTINUE.

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.

Therefore, we need to pass (PC + 4) instead of (void *)1 (== PC) to
PT_CONTINUE when child process traps itself.

diffstat:

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

diffs (32 lines):

diff -r b038507e77bf -r 77adf2dd5eae tests/lib/libc/sys/t_ptrace_core_wait.h
--- a/tests/lib/libc/sys/t_ptrace_core_wait.h   Wed Jun 24 03:38:54 2020 +0000
+++ b/tests/lib/libc/sys/t_ptrace_core_wait.h   Wed Jun 24 04:47:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_core_wait.h,v 1.1 2020/05/05 01:24:29 kamil Exp $     */
+/*     $NetBSD: t_ptrace_core_wait.h,v 1.2 2020/06/24 04:47:10 rin Exp $       */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -207,7 +207,22 @@
 
        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
+       /*
+        * For powerpc, 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.
+        */
+       struct reg r;
+
+       SYSCALL_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
+       SYSCALL_REQUIRE(
+           ptrace(PT_CONTINUE, child, (void *)(r.pc + 4), 0) != -1);
+#endif
 
        DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
        TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);



Home | Main Index | Thread Index | Old Index