From: John Baldwin <jhb@FreeBSD.org>
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 [thread overview]
Message-ID: <20220121201631.63530-11-jhb@FreeBSD.org> (raw)
In-Reply-To: <20220121201631.63530-1-jhb@FreeBSD.org>
---
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<lwpid_t[]> 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
next prev parent reply other threads:[~2022-01-21 20:16 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-21 20:16 [PATCH v5 00/15] FreeBSD target async mode and related refactoring John Baldwin
2022-01-21 20:16 ` [PATCH v5 01/15] gdbsupport: Add an event-pipe class John Baldwin
2022-01-21 20:16 ` [PATCH v5 02/15] gdb linux-nat: Convert linux_nat_event_pipe to the event_pipe class John Baldwin
2022-01-21 20:16 ` [PATCH v5 03/15] gdbserver linux-low: Convert linux_event_pipe " John Baldwin
2022-01-21 20:16 ` [PATCH v5 04/15] Enable async mode on supported targets in target_resume John Baldwin
2022-02-20 10:47 ` Joel Brobecker
2022-01-21 20:16 ` [PATCH v5 05/15] Don't enable async mode at the end of target ::resume methods John Baldwin
2022-02-20 10:49 ` Joel Brobecker
2022-01-21 20:16 ` [PATCH v5 06/15] do_target_wait_1: Clear TARGET_WNOHANG if the target isn't async John Baldwin
2022-02-22 22:38 ` Simon Marchi
2022-02-23 0:07 ` John Baldwin
2022-02-23 1:40 ` Simon Marchi
2022-02-23 15:51 ` Simon Marchi
2022-02-23 16:12 ` John Baldwin
2022-02-24 2:46 ` Simon Marchi
2022-02-24 19:02 ` John Baldwin
2022-02-24 19:16 ` Simon Marchi
2022-01-21 20:16 ` [PATCH v5 07/15] inf-ptrace: Return an IGNORE event if waitpid() fails John Baldwin
2022-02-20 11:38 ` Joel Brobecker
2022-01-21 20:16 ` [PATCH v5 08/15] inf-ptrace: Support async targets in inf_ptrace_target::wait John Baldwin
2022-01-21 20:16 ` [PATCH v5 09/15] fbsd-nat: Implement async target support John Baldwin
2022-01-21 20:16 ` John Baldwin [this message]
2022-01-21 20:16 ` [PATCH v5 11/15] fbsd-nat: Various cleanups to the ::resume entry debug message John Baldwin
2022-01-21 20:16 ` [PATCH v5 12/15] fbsd-nat: Return nullptr rather than failing ::thread_name John Baldwin
2022-01-21 20:16 ` [PATCH v5 13/15] Enable async mode in the target in attach_cmd John Baldwin
2022-01-21 20:16 ` [PATCH v5 14/15] inf-ptrace: Add an event_pipe to be used for async mode in subclasses John Baldwin
2022-01-21 20:16 ` [PATCH v5 15/15] NEWS: Note that the FreeBSD async target supports async mode John Baldwin
2022-01-22 6:28 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220121201631.63530-11-jhb@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).