From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH v3 4/7] gdb/remote.c: move some things up
Date: Wed, 1 Dec 2021 09:44:57 -0500 [thread overview]
Message-ID: <20211201144500.627736-5-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20211201144500.627736-1-simon.marchi@polymtl.ca>
From: Simon Marchi <simon.marchi@efficios.com>
Move the stop_reply and a few functions up. Some code above them in the
file will need to use them in a following patch. No behavior changes
expected here.
Change-Id: I3ca57d0e3ec253f56e1ba401289d9d167de14ad2
---
gdb/remote.c | 144 +++++++++++++++++++++++++--------------------------
1 file changed, 71 insertions(+), 73 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index f53e31e126e3..9b569b827413 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -996,6 +996,36 @@ class extended_remote_target final : public remote_target
bool supports_disable_randomization () override;
};
+struct stop_reply : public notif_event
+{
+ ~stop_reply ();
+
+ /* The identifier of the thread about this event */
+ ptid_t ptid;
+
+ /* The remote state this event is associated with. When the remote
+ connection, represented by a remote_state object, is closed,
+ all the associated stop_reply events should be released. */
+ struct remote_state *rs;
+
+ struct target_waitstatus ws;
+
+ /* The architecture associated with the expedited registers. */
+ gdbarch *arch;
+
+ /* Expedited registers. This makes remote debugging a bit more
+ efficient for those targets that provide critical registers as
+ part of their normal status mechanism (as another roundtrip to
+ fetch them is avoided). */
+ std::vector<cached_reg_t> regcache;
+
+ enum target_stop_reason stop_reason;
+
+ CORE_ADDR watch_data_address;
+
+ int core;
+};
+
/* See remote.h. */
bool
@@ -5815,6 +5845,47 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p)
rs->wait_forever_enabled_p = 1;
}
+/* Determine if THREAD_PTID is a pending fork parent thread. ARG contains
+ the pid of the process that owns the threads we want to check, or
+ -1 if we want to check all threads. */
+
+static int
+is_pending_fork_parent (const target_waitstatus &ws, int event_pid,
+ ptid_t thread_ptid)
+{
+ if (ws.kind () == TARGET_WAITKIND_FORKED
+ || ws.kind () == TARGET_WAITKIND_VFORKED)
+ {
+ if (event_pid == -1 || event_pid == thread_ptid.pid ())
+ return 1;
+ }
+
+ return 0;
+}
+
+/* Return the thread's pending status used to determine whether the
+ thread is a fork parent stopped at a fork event. */
+
+static const target_waitstatus &
+thread_pending_fork_status (struct thread_info *thread)
+{
+ if (thread->has_pending_waitstatus ())
+ return thread->pending_waitstatus ();
+ else
+ return thread->pending_follow;
+}
+
+/* Determine if THREAD is a pending fork parent thread. */
+
+static int
+is_pending_fork_parent_thread (struct thread_info *thread)
+{
+ const target_waitstatus &ws = thread_pending_fork_status (thread);
+ int pid = -1;
+
+ return is_pending_fork_parent (ws, pid, thread->ptid);
+}
+
/* Detach the specified process. */
void
@@ -6507,8 +6578,6 @@ remote_target::resume (ptid_t ptid, int step, enum gdb_signal siggnal)
rs->waiting_for_stop_reply = 1;
}
-static int is_pending_fork_parent_thread (struct thread_info *thread);
-
/* Private per-inferior info for target remote processes. */
struct remote_inferior : public private_inferior
@@ -6528,36 +6597,6 @@ get_remote_inferior (inferior *inf)
return static_cast<remote_inferior *> (inf->priv.get ());
}
-struct stop_reply : public notif_event
-{
- ~stop_reply ();
-
- /* The identifier of the thread about this event */
- ptid_t ptid;
-
- /* The remote state this event is associated with. When the remote
- connection, represented by a remote_state object, is closed,
- all the associated stop_reply events should be released. */
- struct remote_state *rs;
-
- struct target_waitstatus ws;
-
- /* The architecture associated with the expedited registers. */
- gdbarch *arch;
-
- /* Expedited registers. This makes remote debugging a bit more
- efficient for those targets that provide critical registers as
- part of their normal status mechanism (as another roundtrip to
- fetch them is avoided). */
- std::vector<cached_reg_t> regcache;
-
- enum target_stop_reason stop_reason;
-
- CORE_ADDR watch_data_address;
-
- int core;
-};
-
/* Class used to track the construction of a vCont packet in the
outgoing packet buffer. This is used to send multiple vCont
packets if we have more actions than would fit a single packet. */
@@ -7224,47 +7263,6 @@ struct notif_client notif_client_stop =
REMOTE_NOTIF_STOP,
};
-/* Determine if THREAD_PTID is a pending fork parent thread. ARG contains
- the pid of the process that owns the threads we want to check, or
- -1 if we want to check all threads. */
-
-static int
-is_pending_fork_parent (const target_waitstatus &ws, int event_pid,
- ptid_t thread_ptid)
-{
- if (ws.kind () == TARGET_WAITKIND_FORKED
- || ws.kind () == TARGET_WAITKIND_VFORKED)
- {
- if (event_pid == -1 || event_pid == thread_ptid.pid ())
- return 1;
- }
-
- return 0;
-}
-
-/* Return the thread's pending status used to determine whether the
- thread is a fork parent stopped at a fork event. */
-
-static const target_waitstatus &
-thread_pending_fork_status (struct thread_info *thread)
-{
- if (thread->has_pending_waitstatus ())
- return thread->pending_waitstatus ();
- else
- return thread->pending_follow;
-}
-
-/* Determine if THREAD is a pending fork parent thread. */
-
-static int
-is_pending_fork_parent_thread (struct thread_info *thread)
-{
- const target_waitstatus &ws = thread_pending_fork_status (thread);
- int pid = -1;
-
- return is_pending_fork_parent (ws, pid, thread->ptid);
-}
-
/* If CONTEXT contains any fork child threads that have not been
reported yet, remove them from the CONTEXT list. If such a
thread exists it is because we are stopped at a fork catchpoint
--
2.33.1
next prev parent reply other threads:[~2021-12-01 14:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 14:44 [PATCH v3 0/7] Fix handling of pending fork events Simon Marchi
2021-12-01 14:44 ` [PATCH v3 1/7] gdbserver: hide fork child threads from GDB Simon Marchi
2021-12-03 23:30 ` Pedro Alves
2021-12-01 14:44 ` [PATCH v3 2/7] gdb/linux-nat: factor ptrace-detach code to new detach_one_pid function Simon Marchi
2021-12-03 23:30 ` Pedro Alves
2021-12-01 14:44 ` [PATCH v3 3/7] gdbserver: suppress "Detaching from process" message Simon Marchi
2021-12-03 23:42 ` Pedro Alves
2021-12-04 2:57 ` Simon Marchi
2021-12-01 14:44 ` Simon Marchi [this message]
2021-12-03 23:42 ` [PATCH v3 4/7] gdb/remote.c: move some things up Pedro Alves
2021-12-01 14:44 ` [PATCH v3 5/7] gdb/remote.c: refactor pending fork status functions Simon Marchi
2021-12-03 23:43 ` Pedro Alves
2021-12-04 3:03 ` Simon Marchi
2021-12-01 14:44 ` [PATCH v3 6/7] gdb: move clearing of tp->pending_follow to follow_fork_inferior Simon Marchi
2021-12-03 23:43 ` Pedro Alves
2021-12-01 14:45 ` [PATCH v3 7/7] gdb, gdbserver: detach fork child when detaching from fork parent Simon Marchi
2021-12-03 23:44 ` Pedro Alves
2021-12-04 3:36 ` Simon Marchi
2021-12-07 23:25 ` Pedro Alves
2021-12-08 19:54 ` Simon Marchi
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=20211201144500.627736-5-simon.marchi@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
/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).