Skip to content

Commit 77e7077

Browse files
committed
struct resumed_pending_vcont_info -> struct resume_info
The next patch will want to know what was the last resume action done on a given remote thread. This commit generalizes struct resumed_pending_vcont_info a bit so that that info can be retrieved in either RESUMED_PENDING_VCONT or RESUMED state. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <[email protected]> PR gdb/27338 * remote.c (struct resumed_pending_vcont_info): Rename to ... (struct resume_info): ... this. (resumed_pending_vcont_info::set_resumed_pending_vcont): Adjust. (resumed_pending_vcont_info): Rename to ... (resumed_pending_vcont_info::resume_info): ... this. (resumed_pending_vcont_info::set_resumed): Add 'step' and 'sig' parameters. Use them. (resumed_pending_vcont_info::m_resumed_pending_vcont_info): Rename to ... (resumed_pending_vcont_info::m_resume_info): ... this. (remote_target::remote_add_thread, remote_target::start_remote): Adjust. (remote_target::resume): Record step and siggnal for the main resumed thread. (remote_target::commit_resumed): Adjust. (remote_target::remote_stop_ns): Adjust. Change-Id: Ic1f884dd822f5bbc5c24698ec02c13dadb7773c8
1 parent 36d514f commit 77e7077

File tree

1 file changed

+56
-51
lines changed

1 file changed

+56
-51
lines changed

gdb/remote.c

+56-51
Original file line numberDiff line numberDiff line change
@@ -1084,12 +1084,10 @@ enum class resume_state
10841084
RESUMED,
10851085
};
10861086

1087-
/* Information about a thread's pending vCont-resume. Used when a thread is in
1088-
the remote_resume_state::RESUMED_PENDING_VCONT state. remote_target::resume
1089-
stores this information which is then picked up by
1090-
remote_target::commit_resume to know which is the proper action for this
1091-
thread to include in the vCont packet. */
1092-
struct resumed_pending_vcont_info
1087+
/* Information about a thread's resume state. Used when a thread is
1088+
in the resume_state::RESUMED_PENDING_VCONT or resume_state::RESUMED
1089+
states. */
1090+
struct resume_info
10931091
{
10941092
/* True if the last resume call for this thread was a step request, false
10951093
if a continue request. */
@@ -1133,45 +1131,54 @@ struct remote_thread_info : public private_thread_info
11331131
void set_resumed_pending_vcont (bool step, gdb_signal sig)
11341132
{
11351133
m_resume_state = resume_state::RESUMED_PENDING_VCONT;
1136-
m_resumed_pending_vcont_info.step = step;
1137-
m_resumed_pending_vcont_info.sig = sig;
1138-
}
1139-
1140-
/* Get the information this thread's pending vCont-resumption.
1141-
1142-
Must only be called if the thread is in the RESUMED_PENDING_VCONT resume
1143-
state. */
1144-
const struct resumed_pending_vcont_info &resumed_pending_vcont_info () const
1145-
{
1146-
gdb_assert (m_resume_state == resume_state::RESUMED_PENDING_VCONT);
1147-
1148-
return m_resumed_pending_vcont_info;
1134+
m_resume_info.step = step;
1135+
m_resume_info.sig = sig;
11491136
}
11501137

11511138
/* Put the thread in the VCONT_RESUMED state. */
1152-
void set_resumed ()
1139+
void set_resumed (bool step, gdb_signal sig)
11531140
{
11541141
m_resume_state = resume_state::RESUMED;
1142+
m_resume_info.step = step;
1143+
m_resume_info.sig = sig;
11551144
}
11561145

1157-
private:
1158-
/* Resume state for this thread. This is used to implement vCont action
1159-
coalescing (only when the target operates in non-stop mode).
1146+
/* Get the information this thread's pending vCont-resumption.
11601147
1161-
remote_target::resume moves the thread to the RESUMED_PENDING_VCONT state,
1162-
which notes that this thread must be considered in the next commit_resume
1163-
call.
1148+
Must only be called if the thread is in the RESUMED_PENDING_VCONT
1149+
or RESUMED states. */
1150+
const struct resume_info &resume_info () const
1151+
{
1152+
gdb_assert (m_resume_state == resume_state::RESUMED_PENDING_VCONT
1153+
|| m_resume_state == resume_state::RESUMED);
11641154

1165-
remote_target::commit_resume sends a vCont packet with actions for the
1166-
threads in the RESUMED_PENDING_VCONT state and moves them to the
1167-
VCONT_RESUMED state.
1155+
return m_resume_info;
1156+
}
11681157

1169-
When reporting a stop to the core for a thread, that thread is moved back
1170-
to the NOT_RESUMED state. */
1158+
private:
1159+
/* Resume state for this thread. This is used to implement vCont
1160+
action coalescing (only when the target operates in non-stop
1161+
mode), and also generally be able to retrieve the last resume
1162+
action on a given thread.
1163+
1164+
In non-stop mode, remote_target::resume moves the thread to the
1165+
RESUMED_PENDING_VCONT state, which notes that this thread must be
1166+
considered in the next commit_resume call. In all-stop,
1167+
remote_target::resume resumes the thread immediately and moves it
1168+
to the RESUMED state.
1169+
1170+
In non-stop mode, remote_target::commit_resume sends a vCont
1171+
packet with actions for the threads in the RESUMED_PENDING_VCONT
1172+
state and moves them to the VCONT_RESUMED state.
1173+
remote_target::commit_resume is a no-op in all-stop mode.
1174+
1175+
When reporting a stop to the core for a thread, that thread is
1176+
moved back to the NOT_RESUMED state. */
11711177
enum resume_state m_resume_state = resume_state::NOT_RESUMED;
11721178

1173-
/* Extra info used if the thread is in the RESUMED_PENDING_VCONT state. */
1174-
struct resumed_pending_vcont_info m_resumed_pending_vcont_info;
1179+
/* Extra info used if the thread is in the RESUMED_PENDING_VCONT or
1180+
RESUMED state. */
1181+
struct resume_info m_resume_info;
11751182
};
11761183

11771184
remote_state::remote_state ()
@@ -2548,7 +2555,7 @@ remote_target::remote_add_thread (ptid_t ptid, bool running, bool executing)
25482555

25492556
/* We start by assuming threads are resumed. That state then gets updated
25502557
when we process a matching stop reply. */
2551-
get_remote_thread_info (thread)->set_resumed ();
2558+
get_remote_thread_info (thread)->set_resumed (false, GDB_SIGNAL_0);
25522559

25532560
set_executing (this, ptid, executing);
25542561
set_running (this, ptid, running);
@@ -4835,7 +4842,7 @@ remote_target::start_remote (int from_tty, int extended_p)
48354842
non-threaded target as single-threaded; add a main
48364843
thread. */
48374844
thread_info *tp = add_current_inferior_and_thread (wait_status);
4838-
get_remote_thread_info (tp)->set_resumed ();
4845+
get_remote_thread_info (tp)->set_resumed (false, GDB_SIGNAL_0);
48394846
}
48404847
else
48414848
{
@@ -6426,6 +6433,13 @@ remote_target::resume (ptid_t ptid, int step, enum gdb_signal siggnal)
64266433
{
64276434
struct remote_state *rs = get_remote_state ();
64286435

6436+
remote_thread_info *remote_thr;
6437+
6438+
if (minus_one_ptid == ptid || ptid.is_pid ())
6439+
remote_thr = get_remote_thread_info (this, inferior_ptid);
6440+
else
6441+
remote_thr = get_remote_thread_info (this, ptid);
6442+
64296443
/* When connected in non-stop mode, the core resumes threads
64306444
individually. Resuming remote threads directly in target_resume
64316445
would thus result in sending one packet per thread. Instead, to
@@ -6435,13 +6449,6 @@ remote_target::resume (ptid_t ptid, int step, enum gdb_signal siggnal)
64356449
able to do vCont action coalescing. */
64366450
if (target_is_non_stop_p () && ::execution_direction != EXEC_REVERSE)
64376451
{
6438-
remote_thread_info *remote_thr;
6439-
6440-
if (minus_one_ptid == ptid || ptid.is_pid ())
6441-
remote_thr = get_remote_thread_info (this, inferior_ptid);
6442-
else
6443-
remote_thr = get_remote_thread_info (this, ptid);
6444-
64456452
/* We don't expect the core to ask to resume an already resumed (from
64466453
its point of view) thread. */
64476454
gdb_assert (remote_thr->get_resume_state () == resume_state::NOT_RESUMED);
@@ -6467,7 +6474,8 @@ remote_target::resume (ptid_t ptid, int step, enum gdb_signal siggnal)
64676474

64686475
/* Update resumed state tracked by the remote target. */
64696476
for (thread_info *tp : all_non_exited_threads (this, ptid))
6470-
get_remote_thread_info (tp)->set_resumed ();
6477+
get_remote_thread_info (tp)->set_resumed (false, GDB_SIGNAL_0);
6478+
remote_thr->set_resumed (step, siggnal);
64716479

64726480
/* We are about to start executing the inferior, let's register it
64736481
with the event loop. NOTE: this is the one place where all the
@@ -6777,16 +6785,15 @@ remote_target::commit_resumed ()
67776785
for (const auto &stop_reply : rs->stop_reply_queue)
67786786
gdb_assert (stop_reply->ptid != tp->ptid);
67796787

6780-
const resumed_pending_vcont_info &info
6781-
= remote_thr->resumed_pending_vcont_info ();
6788+
const resume_info &info = remote_thr->resume_info ();
67826789

67836790
/* Check if we need to send a specific action for this thread. If not,
67846791
it will be included in a wildcard resume instead. */
67856792
if (info.step || info.sig != GDB_SIGNAL_0
67866793
|| !get_remote_inferior (tp->inf)->may_wildcard_vcont)
67876794
vcont_builder.push_action (tp->ptid, info.step, info.sig);
67886795

6789-
remote_thr->set_resumed ();
6796+
remote_thr->set_resumed (info.step, info.sig);
67906797
}
67916798

67926799
/* Now check whether we can send any process-wide wildcard. This is
@@ -6874,8 +6881,7 @@ remote_target::remote_stop_ns (ptid_t ptid)
68746881
if (remote_thr->get_resume_state ()
68756882
== resume_state::RESUMED_PENDING_VCONT)
68766883
{
6877-
const resumed_pending_vcont_info &info
6878-
= remote_thr->resumed_pending_vcont_info ();
6884+
const resume_info &info = remote_thr->resume_info ();
68796885
if (info.sig != GDB_SIGNAL_0)
68806886
{
68816887
/* This signal must be forwarded to the inferior. We
@@ -6904,8 +6910,7 @@ remote_target::remote_stop_ns (ptid_t ptid)
69046910
/* Check that the thread wasn't resumed with a signal.
69056911
Generating a phony stop would result in losing the
69066912
signal. */
6907-
const resumed_pending_vcont_info &info
6908-
= remote_thr->resumed_pending_vcont_info ();
6913+
const resume_info &info = remote_thr->resume_info ();
69096914
gdb_assert (info.sig == GDB_SIGNAL_0);
69106915

69116916
stop_reply *sr = new stop_reply ();
@@ -6926,7 +6931,7 @@ remote_target::remote_stop_ns (ptid_t ptid)
69266931
queue, we'll end up reporting a stop event to the core
69276932
for that thread while it is running on the remote
69286933
target... that would be bad. */
6929-
remote_thr->set_resumed ();
6934+
remote_thr->set_resumed (false, GDB_SIGNAL_0);
69306935
}
69316936
}
69326937

0 commit comments

Comments
 (0)