Use std::forward_list for displaced_step_inferior_states
Use std::forward_list instead of manually implemented list. This simplifies a bit the code, especially around removal. Regtested on the buildbot. There are some failures as always, but I think they are unrelated. gdb/ChangeLog: * infrun.c (displaced_step_inferior_states): Change type to std::forward_list. (get_displaced_stepping_state): Adjust. (displaced_step_in_progress_any_inferior): Adjust. (add_displaced_stepping_state): Adjust. (remove_displaced_stepping_state): Adjust.
This commit is contained in:
parent
32641fa925
commit
39a36629f6
2 changed files with 44 additions and 45 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2018-11-19 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
|
|
||||||
|
* infrun.c (displaced_step_inferior_states): Change type to
|
||||||
|
std::forward_list.
|
||||||
|
(get_displaced_stepping_state): Adjust.
|
||||||
|
(displaced_step_in_progress_any_inferior): Adjust.
|
||||||
|
(add_displaced_stepping_state): Adjust.
|
||||||
|
(remove_displaced_stepping_state): Adjust.
|
||||||
|
|
||||||
2018-11-18 Tom Tromey <tom@tromey.com>
|
2018-11-18 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
PR build/23814:
|
PR build/23814:
|
||||||
|
|
66
gdb/infrun.c
66
gdb/infrun.c
|
@ -1516,39 +1516,36 @@ struct displaced_step_inferior_state
|
||||||
|
|
||||||
/* The list of states of processes involved in displaced stepping
|
/* The list of states of processes involved in displaced stepping
|
||||||
presently. */
|
presently. */
|
||||||
static struct displaced_step_inferior_state *displaced_step_inferior_states;
|
static std::forward_list<displaced_step_inferior_state *>
|
||||||
|
displaced_step_inferior_states;
|
||||||
|
|
||||||
/* Get the displaced stepping state of process PID. */
|
/* Get the displaced stepping state of process PID. */
|
||||||
|
|
||||||
static struct displaced_step_inferior_state *
|
static displaced_step_inferior_state *
|
||||||
get_displaced_stepping_state (inferior *inf)
|
get_displaced_stepping_state (inferior *inf)
|
||||||
{
|
{
|
||||||
struct displaced_step_inferior_state *state;
|
for (auto *state : displaced_step_inferior_states)
|
||||||
|
{
|
||||||
for (state = displaced_step_inferior_states;
|
|
||||||
state != NULL;
|
|
||||||
state = state->next)
|
|
||||||
if (state->inf == inf)
|
if (state->inf == inf)
|
||||||
return state;
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns true if any inferior has a thread doing a displaced
|
/* Returns true if any inferior has a thread doing a displaced
|
||||||
step. */
|
step. */
|
||||||
|
|
||||||
static int
|
static bool
|
||||||
displaced_step_in_progress_any_inferior (void)
|
displaced_step_in_progress_any_inferior ()
|
||||||
|
{
|
||||||
|
for (auto *state : displaced_step_inferior_states)
|
||||||
{
|
{
|
||||||
struct displaced_step_inferior_state *state;
|
|
||||||
|
|
||||||
for (state = displaced_step_inferior_states;
|
|
||||||
state != NULL;
|
|
||||||
state = state->next)
|
|
||||||
if (state->step_thread != nullptr)
|
if (state->step_thread != nullptr)
|
||||||
return 1;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return true if thread represented by PTID is doing a displaced
|
/* Return true if thread represented by PTID is doing a displaced
|
||||||
|
@ -1584,21 +1581,19 @@ displaced_step_in_progress (inferior *inf)
|
||||||
stepping state list, or return a pointer to an already existing
|
stepping state list, or return a pointer to an already existing
|
||||||
entry, if it already exists. Never returns NULL. */
|
entry, if it already exists. Never returns NULL. */
|
||||||
|
|
||||||
static struct displaced_step_inferior_state *
|
static displaced_step_inferior_state *
|
||||||
add_displaced_stepping_state (inferior *inf)
|
add_displaced_stepping_state (inferior *inf)
|
||||||
{
|
{
|
||||||
struct displaced_step_inferior_state *state;
|
displaced_step_inferior_state *state
|
||||||
|
= get_displaced_stepping_state (inf);
|
||||||
|
|
||||||
for (state = displaced_step_inferior_states;
|
if (state != nullptr)
|
||||||
state != NULL;
|
|
||||||
state = state->next)
|
|
||||||
if (state->inf == inf)
|
|
||||||
return state;
|
return state;
|
||||||
|
|
||||||
state = XCNEW (struct displaced_step_inferior_state);
|
state = XCNEW (struct displaced_step_inferior_state);
|
||||||
state->inf = inf;
|
state->inf = inf;
|
||||||
state->next = displaced_step_inferior_states;
|
|
||||||
displaced_step_inferior_states = state;
|
displaced_step_inferior_states.push_front (state);
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -1627,24 +1622,19 @@ get_displaced_step_closure_by_addr (CORE_ADDR addr)
|
||||||
static void
|
static void
|
||||||
remove_displaced_stepping_state (inferior *inf)
|
remove_displaced_stepping_state (inferior *inf)
|
||||||
{
|
{
|
||||||
struct displaced_step_inferior_state *it, **prev_next_p;
|
|
||||||
|
|
||||||
gdb_assert (inf != nullptr);
|
gdb_assert (inf != nullptr);
|
||||||
|
|
||||||
it = displaced_step_inferior_states;
|
displaced_step_inferior_states.remove_if
|
||||||
prev_next_p = &displaced_step_inferior_states;
|
([inf] (displaced_step_inferior_state *state)
|
||||||
while (it)
|
|
||||||
{
|
{
|
||||||
if (it->inf == inf)
|
if (state->inf == inf)
|
||||||
{
|
{
|
||||||
*prev_next_p = it->next;
|
xfree (state);
|
||||||
xfree (it);
|
return true;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
prev_next_p = &it->next;
|
|
||||||
it = *prev_next_p;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue