gdbserver: Eliminate prepare_to_access_memory

Given:

 - The prepare_to_access_memory machinery was added for non-stop mode.

 - Only Linux supports non-stop.

 - Linux no longer needs the prepare_to_access_memory machinery.  In
   fact, after the previous patch,
   linux_process_target::prepare_to_access_memory became a nop.

Thus, prepare_to_access_memory can go away, simplifying core GDBserver
code.

Change-Id: I93ac8bfe66bd61c3d1c4a0e7d419335163120ecf
This commit is contained in:
Pedro Alves
2022-03-29 13:32:48 +01:00
parent 421490af33
commit 8e347faf8f
5 changed files with 24 additions and 235 deletions

View File

@@ -39,88 +39,6 @@ set_desired_thread ()
return (current_thread != NULL);
}
/* The thread that was current before prepare_to_access_memory was
called. done_accessing_memory uses this to restore the previous
selected thread. */
static ptid_t prev_general_thread;
/* See target.h. */
int
prepare_to_access_memory (void)
{
client_state &cs = get_client_state ();
/* The first thread found. */
struct thread_info *first = NULL;
/* The first stopped thread found. */
struct thread_info *stopped = NULL;
/* The current general thread, if found. */
struct thread_info *current = NULL;
/* Save the general thread value, since prepare_to_access_memory could change
it. */
prev_general_thread = cs.general_thread;
int res = the_target->prepare_to_access_memory ();
if (res != 0)
return res;
for_each_thread (prev_general_thread.pid (), [&] (thread_info *thread)
{
if (mythread_alive (thread->id))
{
if (stopped == NULL && the_target->supports_thread_stopped ()
&& target_thread_stopped (thread))
stopped = thread;
if (first == NULL)
first = thread;
if (current == NULL && prev_general_thread == thread->id)
current = thread;
}
});
/* The thread we end up choosing. */
struct thread_info *thread;
/* Prefer a stopped thread. If none is found, try the current
thread. Otherwise, take the first thread in the process. If
none is found, undo the effects of
target->prepare_to_access_memory() and return error. */
if (stopped != NULL)
thread = stopped;
else if (current != NULL)
thread = current;
else if (first != NULL)
thread = first;
else
{
done_accessing_memory ();
return 1;
}
switch_to_thread (thread);
cs.general_thread = ptid_of (thread);
return 0;
}
/* See target.h. */
void
done_accessing_memory (void)
{
client_state &cs = get_client_state ();
the_target->done_accessing_memory ();
/* Restore the previous selected thread. */
cs.general_thread = prev_general_thread;
switch_to_thread (the_target, cs.general_thread);
}
int
read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
{
@@ -373,18 +291,6 @@ process_stratum_target::post_create_inferior ()
/* Nop. */
}
int
process_stratum_target::prepare_to_access_memory ()
{
return 0;
}
void
process_stratum_target::done_accessing_memory ()
{
/* Nop. */
}
void
process_stratum_target::look_up_symbols ()
{