From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [66.216.25.90]) by sourceware.org (Postfix) with ESMTPS id 215B23858405 for ; Fri, 21 Jan 2022 20:16:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 215B23858405 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from ralph.baldwin.cx (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 7FEAE1A84E21 for ; Fri, 21 Jan 2022 15:16:43 -0500 (EST) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v5 10/15] fbsd-nat: Include ptrace operation in error messages. Date: Fri, 21 Jan 2022 12:16:26 -0800 Message-Id: <20220121201631.63530-11-jhb@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220121201631.63530-1-jhb@FreeBSD.org> References: <20220121201631.63530-1-jhb@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Fri, 21 Jan 2022 15:16:43 -0500 (EST) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_STATUS, KHOP_HELO_FCRDNS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jan 2022 20:16:45 -0000 --- gdb/fbsd-nat.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 1ed7092fece..89596f6f822 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -822,7 +822,7 @@ fbsd_nat_target::thread_name (struct thread_info *thr) if (!fbsd_fetch_kinfo_proc (pid, &kp)) perror_with_name (_("Failed to fetch process information")); if (ptrace (PT_LWPINFO, lwp, (caddr_t) &pl, sizeof pl) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_LWPINFO)")); if (strcmp (kp.ki_comm, pl.pl_tdname) == 0) return NULL; xsnprintf (buf, sizeof buf, "%s", pl.pl_tdname); @@ -851,22 +851,22 @@ fbsd_enable_proc_events (pid_t pid) if (ptrace (PT_GET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events, sizeof (events)) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_GET_EVENT_MASK)")); events |= PTRACE_FORK | PTRACE_LWP; #ifdef PTRACE_VFORK events |= PTRACE_VFORK; #endif if (ptrace (PT_SET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events, sizeof (events)) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_SET_EVENT_MASK)")); #else #ifdef TDP_RFPPWAIT if (ptrace (PT_FOLLOW_FORK, pid, (PTRACE_TYPE_ARG3)0, 1) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_FOLLOW_FORK)")); #endif #ifdef PT_LWP_EVENTS if (ptrace (PT_LWP_EVENTS, pid, (PTRACE_TYPE_ARG3)0, 1) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_LWP_EVENTS)")); #endif #endif } @@ -885,13 +885,13 @@ fbsd_add_threads (fbsd_nat_target *target, pid_t pid) gdb_assert (!in_thread_list (target, ptid_t (pid))); nlwps = ptrace (PT_GETNUMLWPS, pid, NULL, 0); if (nlwps == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_GETNUMLWPS)")); gdb::unique_xmalloc_ptr lwps (XCNEWVEC (lwpid_t, nlwps)); nlwps = ptrace (PT_GETLWPLIST, pid, (caddr_t) lwps.get (), nlwps); if (nlwps == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_GETLWPLIST)")); for (i = 0; i < nlwps; i++) { @@ -905,7 +905,7 @@ fbsd_add_threads (fbsd_nat_target *target, pid_t pid) /* Don't add exited threads. Note that this is only called when attaching to a multi-threaded process. */ if (ptrace (PT_LWPINFO, lwps[i], (caddr_t) &pl, sizeof pl) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_LWPINFO)")); if (pl.pl_flags & PL_FLAG_EXITED) continue; #endif @@ -1180,7 +1180,9 @@ fbsd_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo) request = PT_SUSPEND; if (ptrace (request, tp->ptid.lwp (), NULL, 0) == -1) - perror_with_name (("ptrace")); + perror_with_name (request == PT_RESUME ? + ("ptrace (PT_RESUME)") : + ("ptrace (PT_SUSPEND)")); } } else @@ -1189,7 +1191,7 @@ fbsd_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo) until the process is continued however). */ for (thread_info *tp : all_non_exited_threads (this, ptid)) if (ptrace (PT_RESUME, tp->ptid.lwp (), NULL, 0) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_RESUME)")); ptid = inferior_ptid; } @@ -1219,7 +1221,7 @@ fbsd_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo) if (step) { if (ptrace (PT_SETSTEP, get_ptrace_pid (ptid), NULL, 0) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_SETSTEP)")); step = 0; } ptid = ptid_t (ptid.pid ()); @@ -1307,7 +1309,7 @@ fbsd_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus, pid = wptid.pid (); if (ptrace (PT_LWPINFO, pid, (caddr_t) &pl, sizeof pl) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_LWPINFO)")); wptid = ptid_t (pid, pl.pl_lwpid); @@ -1339,7 +1341,7 @@ fbsd_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus, delete_thread (thr); } if (ptrace (PT_CONTINUE, pid, (caddr_t) 1, 0) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_CONTINUE)")); continue; } #endif @@ -1402,7 +1404,7 @@ fbsd_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus, gdb_assert (pid == child); if (ptrace (PT_LWPINFO, child, (caddr_t)&pl, sizeof pl) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_LWPINFO)")); gdb_assert (pl.pl_flags & PL_FLAG_CHILD); child_ptid = ptid_t (child, pl.pl_lwpid); @@ -1491,7 +1493,7 @@ fbsd_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus, and once system call stops are enabled on a process it stops for all system call entries and exits. */ if (ptrace (PT_CONTINUE, pid, (caddr_t) 1, 0) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_CONTINUE)")); continue; } } @@ -1638,7 +1640,7 @@ fbsd_nat_target::follow_fork (inferior *child_inf, ptid_t child_ptid, infrun.c. */ if (ptrace (PT_DETACH, child_pid, (PTRACE_TYPE_ARG3)1, 0) == -1) - perror_with_name (("ptrace")); + perror_with_name (("ptrace (PT_DETACH)")); #ifndef PTRACE_VFORK if (fork_kind () == TARGET_WAITKIND_VFORKED) -- 2.34.1