[PATCH 1/3] change gdbserver to use hashtab: list->table

Doug Evans
2014-01-25T01:12:15Z

Hi.

I did some profiling of gdbserver's attach/detach speed and was
able to obtain a significant speedup by changing gdbserver to use
a hashtable to maintain its tables of inferiors and threads.

[In one perf experiment of attach/detach repeated 20 times on a
program with 1000 threads, the time as measured by gprof went from
45sec to 5sec.]

I created a testcase for our perf testsuite but the results there
don't show the speed as impressively because it can only measure gdb
not gdbserver. I may submit it separately anyway.

The patch is in 3 parts:

1) rename "list" to "table" throughout,
rename member "entry" in some structs to "head" (for consistency)

2) misc. prepatory cleanup, in particular while there are routines
to traverse the lists, some code traverses the list itself.
These need to be rewritten to always use the provided traversal
routines.

3) Add hashtable support.

2014-01-24 Doug Evans <dje@google.com>

* inferiors.h (struct inferior_table): Renamed from struct
inferior_list. All uses updated.
(struct inferior_table_entry): Renamed from struct
inferior_list_entry. All uses updated.
(add_inferior_to_table): Renamed from add_inferior_to_list.
* inferiors.c (*): Update.
(add_inferior_to_table): Renamed from add_inferior_to_list.
All callers updated.
* dll.c (*): Update.
* dll.h (*): Update.
(struct dll_info): Member "entry" renamed to "head".
* gdbthread.h (*): Update.
(struct thread_info): Member "entry" renamed to "head".
* linux-aarch64-low.c (*): Update.
* linux-arm-low.c (*): Update.
* linux-low.c (*): Update.
* linux-low.h (*): Update.
* linux-mips-low.c (*): Update.
* linux-x86-low.c (*): Update.
* regcache.c (*): Update.
* regcache.h (*): Update.
* server.c (*): Update.
* thread-db.c (*): Update.
* tracepoint.c (*): Update.
* win32-low.c (*): Update.

diff --git a/gdb/gdbserver/dll.c b/gdb/gdbserver/dll.c
index be0e01f..612a91f 100644
--- a/gdb/gdbserver/dll.c
+++ b/gdb/gdbserver/dll.c
@@ -23,11 +23,11 @@
/* An "unspecified" CORE_ADDR, for match_dll. */
#define UNSPECIFIED_CORE_ADDR (~(CORE_ADDR) 0)

-struct inferior_list all_dlls;
+struct inferior_table all_dlls;
int dlls_changed;

static void
-free_one_dll (struct inferior_list_entry *inf)
+free_one_dll (struct inferior_table_entry *inf)
{
struct dll_info *dll = get_dll (inf);
if (dll->name != NULL)
@@ -39,7 +39,7 @@ free_one_dll (struct inferior_list_entry *inf)
the key is ignored; so is an all-ones base address. */

static int
-match_dll (struct inferior_list_entry *inf, void *arg)
+match_dll (struct inferior_table_entry *inf, void *arg)
{
struct dll_info *iter = (void *) inf;
struct dll_info *key = arg;
@@ -63,12 +63,12 @@ loaded_dll (const char *name, CORE_ADDR base_addr)
struct dll_info *new_dll = xmalloc (sizeof (*new_dll));
memset (new_dll, 0, sizeof (*new_dll));

- new_dll->entry.id = minus_one_ptid;
+ new_dll->head.id = minus_one_ptid;

new_dll->name = xstrdup (name);
new_dll->base_addr = base_addr;

- add_inferior_to_list (&all_dlls, &new_dll->entry);
+ add_inferior_to_table (&all_dlls, &new_dll->head);
dlls_changed = 1;
}

@@ -100,8 +100,8 @@ unloaded_dll (const char *name, CORE_ADDR base_addr)
{
/* DLL has been found so remove the entry and free associated
resources. */
- remove_inferior (&all_dlls, &dll->entry);
- free_one_dll (&dll->entry);
+ remove_inferior (&all_dlls, &dll->head);
+ free_one_dll (&dll->head);
dlls_changed = 1;
}
}
diff --git a/gdb/gdbserver/dll.h b/gdb/gdbserver/dll.h
index 879f5ba..bd6d7c5 100644
--- a/gdb/gdbserver/dll.h
+++ b/gdb/gdbserver/dll.h
@@ -20,12 +20,12 @@

struct dll_info
{
- struct inferior_list_entry entry;
+ struct inferior_table_entry head;
char *name;
CORE_ADDR base_addr;
};

-extern struct inferior_list all_dlls;
+extern struct inferior_table all_dlls;
extern int dlls_changed;

extern void clear_dlls (void);
diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h
index a1d9ca8..b050369 100644
--- a/gdb/gdbserver/gdbthread.h
+++ b/gdb/gdbserver/gdbthread.h
@@ -26,7 +26,7 @@ struct btrace_target_info;

struct thread_info
{
- struct inferior_list_entry entry;
+ struct inferior_table_entry head;
void *target_data;
void *regcache_data;

@@ -68,7 +68,7 @@ struct thread_info
struct btrace_target_info *btrace;
};

-extern struct inferior_list all_threads;
+extern struct inferior_table all_threads;

void remove_thread (struct thread_info *thread);
void add_thread (ptid_t ptid, void *target_data);
@@ -76,6 +76,6 @@ void add_thread (ptid_t ptid, void *target_data);
struct thread_info *find_thread_ptid (ptid_t ptid);

/* Get current thread ID (Linux task ID). */
-#define current_ptid ((struct inferior_list_entry *) current_inferior)->id
+#define current_ptid ((struct inferior_table_entry *) current_inferior)->id

#endif /* GDB_THREAD_H */
diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
index 0033958..f7242f9 100644
--- a/gdb/gdbserver/inferiors.c
+++ b/gdb/gdbserver/inferiors.c
@@ -24,16 +24,16 @@
#include "gdbthread.h"
#include "dll.h"

-struct inferior_list all_processes;
-struct inferior_list all_threads;
+struct inferior_table all_processes;
+struct inferior_table all_threads;

struct thread_info *current_inferior;

#define get_thread(inf) ((struct thread_info *)(inf))

void
-add_inferior_to_list (struct inferior_list *list,
- struct inferior_list_entry *new_inferior)
+add_inferior_to_table (struct inferior_table *list,
+ struct inferior_table_entry *new_inferior)
{
new_inferior->next = NULL;
if (list->tail != NULL)
@@ -46,10 +46,10 @@ add_inferior_to_list (struct inferior_list *list,
/* Invoke ACTION for each inferior in LIST. */

void
-for_each_inferior (struct inferior_list *list,
- void (*action) (struct inferior_list_entry *))
+for_each_inferior (struct inferior_table *list,
+ void (*action) (struct inferior_table_entry *))
{
- struct inferior_list_entry *cur = list->head, *next;
+ struct inferior_table_entry *cur = list->head, *next;

while (cur != NULL)
{
@@ -60,10 +60,10 @@ for_each_inferior (struct inferior_list *list,
}

void
-remove_inferior (struct inferior_list *list,
- struct inferior_list_entry *entry)
+remove_inferior (struct inferior_table *list,
+ struct inferior_table_entry *entry)
{
- struct inferior_list_entry **cur;
+ struct inferior_table_entry **cur;

if (list->head == entry)
{
@@ -93,11 +93,11 @@ add_thread (ptid_t thread_id, void *target_data)

memset (new_thread, 0, sizeof (*new_thread));

- new_thread->entry.id = thread_id;
+ new_thread->head.id = thread_id;
new_thread->last_resume_kind = resume_continue;
new_thread->last_status.kind = TARGET_WAITKIND_IGNORE;

- add_inferior_to_list (&all_threads, & new_thread->entry);
+ add_inferior_to_table (&all_threads, & new_thread->head);

if (current_inferior == NULL)
current_inferior = new_thread;
@@ -108,18 +108,18 @@ add_thread (ptid_t thread_id, void *target_data)
ptid_t
thread_to_gdb_id (struct thread_info *thread)
{
- return thread->entry.id;
+ return thread->head.id;
}

struct thread_info *
find_thread_ptid (ptid_t ptid)
{
- struct inferior_list_entry *inf = all_threads.head;
+ struct inferior_table_entry *inf = all_threads.head;

while (inf != NULL)
{
struct thread_info *thread = get_thread (inf);
- if (ptid_equal (thread->entry.id, ptid))
+ if (ptid_equal (thread->head.id, ptid))
return thread;
inf = inf->next;
}
@@ -132,11 +132,11 @@ gdb_id_to_thread_id (ptid_t gdb_id)
{
struct thread_info *thread = find_thread_ptid (gdb_id);

- return thread ? thread->entry.id : null_ptid;
+ return thread ? thread->head.id : null_ptid;
}

static void
-free_one_thread (struct inferior_list_entry *inf)
+free_one_thread (struct inferior_table_entry *inf)
{
struct thread_info *thread = get_thread (inf);
free_register_cache (inferior_regcache_data (thread));
@@ -149,22 +149,22 @@ remove_thread (struct thread_info *thread)
if (thread->btrace != NULL)
target_disable_btrace (thread->btrace);

- remove_inferior (&all_threads, (struct inferior_list_entry *) thread);
- free_one_thread (&thread->entry);
+ remove_inferior (&all_threads, (struct inferior_table_entry *) thread);
+ free_one_thread (&thread->head);
}

-/* Find the first inferior_list_entry E in LIST for which FUNC (E, ARG)
+/* Find the first inferior_table_entry E in LIST for which FUNC (E, ARG)
returns non-zero. If no entry is found then return NULL. */

-struct inferior_list_entry *
-find_inferior (struct inferior_list *list,
- int (*func) (struct inferior_list_entry *, void *), void *arg)
+struct inferior_table_entry *
+find_inferior (struct inferior_table *list,
+ int (*func) (struct inferior_table_entry *, void *), void *arg)
{
- struct inferior_list_entry *inf = list->head;
+ struct inferior_table_entry *inf = list->head;

while (inf != NULL)
{
- struct inferior_list_entry *next;
+ struct inferior_table_entry *next;

next = inf->next;
if ((*func) (inf, arg))
@@ -175,10 +175,10 @@ find_inferior (struct inferior_list *list,
return NULL;
}

-struct inferior_list_entry *
-find_inferior_id (struct inferior_list *list, ptid_t id)
+struct inferior_table_entry *
+find_inferior_id (struct inferior_table *list, ptid_t id)
{
- struct inferior_list_entry *inf = list->head;
+ struct inferior_table_entry *inf = list->head;

while (inf != NULL)
{
@@ -238,7 +238,7 @@ add_process (int pid, int attached)
process->head.id = pid_to_ptid (pid);
process->attached = attached;

- add_inferior_to_list (&all_processes, &process->head);
+ add_inferior_to_table (&all_processes, &process->head);

return process;
}
@@ -267,7 +267,7 @@ find_process_pid (int pid)
i.e. not attached to. */

static int
-started_inferior_callback (struct inferior_list_entry *entry, void *args)
+started_inferior_callback (struct inferior_table_entry *entry, void *args)
{
struct process_info *process = (struct process_info *) entry;

@@ -287,7 +287,7 @@ have_started_inferiors_p (void)
/* Return non-zero if INF, a struct process_info, was attached to. */

static int
-attached_inferior_callback (struct inferior_list_entry *entry, void *args)
+attached_inferior_callback (struct inferior_table_entry *entry, void *args)
{
struct process_info *process = (struct process_info *) entry;

@@ -306,7 +306,7 @@ have_attached_inferiors_p (void)
struct process_info *
get_thread_process (struct thread_info *thread)
{
- int pid = ptid_get_pid (thread->entry.id);
+ int pid = ptid_get_pid (thread->head.id);
return find_process_pid (pid);
}

diff --git a/gdb/gdbserver/inferiors.h b/gdb/gdbserver/inferiors.h
index 5f99fbc..18be8f8 100644
--- a/gdb/gdbserver/inferiors.h
+++ b/gdb/gdbserver/inferiors.h
@@ -21,15 +21,15 @@

/* Generic information for tracking a list of ``inferiors'' - threads,
processes, etc. */
-struct inferior_list
+struct inferior_table
{
- struct inferior_list_entry *head;
- struct inferior_list_entry *tail;
+ struct inferior_table_entry *head;
+ struct inferior_table_entry *tail;
};
-struct inferior_list_entry
+struct inferior_table_entry
{
ptid_t id;
- struct inferior_list_entry *next;
+ struct inferior_table_entry *next;
};

struct thread_info;
@@ -42,7 +42,7 @@ struct process_info_private;

struct process_info
{
- struct inferior_list_entry head;
+ struct inferior_table_entry head;

/* Nonzero if this child process was attached rather than
spawned. */
@@ -77,16 +77,16 @@ struct process_info
struct process_info *current_process (void);
struct process_info *get_thread_process (struct thread_info *);

-extern struct inferior_list all_processes;
+extern struct inferior_table all_processes;

-void add_inferior_to_list (struct inferior_list *list,
- struct inferior_list_entry *new_inferior);
-void for_each_inferior (struct inferior_list *list,
- void (*action) (struct inferior_list_entry *));
+void add_inferior_to_table (struct inferior_table *table,
+ struct inferior_table_entry *new_inferior);
+void for_each_inferior (struct inferior_table *table,
+ void (*action) (struct inferior_table_entry *));

extern struct thread_info *current_inferior;
-void remove_inferior (struct inferior_list *list,
- struct inferior_list_entry *entry);
+void remove_inferior (struct inferior_table *table,
+ struct inferior_table_entry *entry);

struct process_info *add_process (int pid, int attached);
void remove_process (struct process_info *process);
@@ -98,13 +98,13 @@ ptid_t thread_to_gdb_id (struct thread_info *);
ptid_t gdb_id_to_thread_id (ptid_t);

void clear_inferiors (void);
-struct inferior_list_entry *find_inferior
- (struct inferior_list *,
- int (*func) (struct inferior_list_entry *,
+struct inferior_table_entry *find_inferior
+ (struct inferior_table *,
+ int (*func) (struct inferior_table_entry *,
void *),
void *arg);
-struct inferior_list_entry *find_inferior_id (struct inferior_list *list,
- ptid_t id);
+struct inferior_table_entry *find_inferior_id (struct inferior_table *table,
+ ptid_t id);
void *inferior_target_data (struct thread_info *);
void set_inferior_target_data (struct thread_info *, void *);
void *inferior_regcache_data (struct thread_info *);
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index e7d3e4f..a4be8f9 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -636,7 +636,7 @@ struct aarch64_dr_update_callback_param
carried out until the moment the thread is resumed. */

static int
-debug_reg_change_callback (struct inferior_list_entry *entry, void *ptr)
+debug_reg_change_callback (struct inferior_table_entry *entry, void *ptr)
{
struct lwp_info *lwp = (struct lwp_info *) entry;
struct aarch64_dr_update_callback_param *param_p
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index fb6ff68..9fd7801 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -534,7 +534,7 @@ struct update_registers_data
};

static int
-update_registers_callback (struct inferior_list_entry *entry, void *arg)
+update_registers_callback (struct inferior_table_entry *entry, void *arg)
{
struct lwp_info *lwp = (struct lwp_info *) entry;
struct update_registers_data *data = (struct update_registers_data *) arg;
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index bac6134..f0c2dfc 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -147,7 +147,7 @@ typedef struct
``all_processes'' is keyed by the "overall process ID", which
GNU/Linux calls tgid, "thread group ID". */

-struct inferior_list all_lwps;
+struct inferior_table all_lwps;

/* A list of all unknown processes which receive stop signals. Some
other process will presumably claim each of these as forked
@@ -287,7 +287,7 @@ static int linux_event_pipe[2] = { -1, -1 };
#define target_is_async_p() (linux_event_pipe[0] != -1)

static void send_sigstop (struct lwp_info *lwp);
-static void wait_for_sigstop (struct inferior_list_entry *entry);
+static void wait_for_sigstop (struct inferior_table_entry *entry);

/* Return non-zero if HEADER is a 64-bit ELF file. */

@@ -538,7 +538,7 @@ add_lwp (ptid_t ptid)
if (the_low_target.new_thread != NULL)
lwp->arch_private = the_low_target.new_thread ();

- add_inferior_to_list (&all_lwps, &lwp->head);
+ add_inferior_to_table (&all_lwps, &lwp->head);

return lwp;
}
@@ -849,7 +849,7 @@ struct counter
};

static int
-second_thread_of_pid_p (struct inferior_list_entry *entry, void *args)
+second_thread_of_pid_p (struct inferior_table_entry *entry, void *args)
{
struct counter *counter = args;

@@ -865,7 +865,7 @@ second_thread_of_pid_p (struct inferior_list_entry *entry, void *args)
static int
last_thread_of_process_p (struct thread_info *thread)
{
- ptid_t ptid = ((struct inferior_list_entry *)thread)->id;
+ ptid_t ptid = ((struct inferior_table_entry *)thread)->id;
int pid = ptid_get_pid (ptid);
struct counter counter = { pid , 0 };

@@ -913,7 +913,7 @@ linux_kill_one_lwp (struct lwp_info *lwp)
except the leader. */

static int
-kill_one_lwp_callback (struct inferior_list_entry *entry, void *args)
+kill_one_lwp_callback (struct inferior_table_entry *entry, void *args)
{
struct thread_info *thread = (struct thread_info *) entry;
struct lwp_info *lwp = get_thread_lwp (thread);
@@ -1079,7 +1079,7 @@ get_detach_signal (struct thread_info *thread)
}

static int
-linux_detach_one_lwp (struct inferior_list_entry *entry, void *args)
+linux_detach_one_lwp (struct inferior_table_entry *entry, void *args)
{
struct thread_info *thread = (struct thread_info *) entry;
struct lwp_info *lwp = get_thread_lwp (thread);
@@ -1154,7 +1154,7 @@ linux_detach (int pid)
/* Remove all LWPs that belong to process PROC from the lwp list. */

static int
-delete_lwp_callback (struct inferior_list_entry *entry, void *proc)
+delete_lwp_callback (struct inferior_table_entry *entry, void *proc)
{
struct lwp_info *lwp = (struct lwp_info *) entry;
struct process_info *process = proc;
@@ -1214,7 +1214,7 @@ linux_thread_alive (ptid_t ptid)

/* Return 1 if this lwp has an interesting status pending. */
static int
-status_pending_p_callback (struct inferior_list_entry *entry, void *arg)
+status_pending_p_callback (struct inferior_table_entry *entry, void *arg)
{
struct lwp_info *lwp = (struct lwp_info *) entry;
ptid_t ptid = * (ptid_t *) arg;
@@ -1238,7 +1238,7 @@ status_pending_p_callback (struct inferior_list_entry *entry, void *arg)
}

static int
-same_lwp (struct inferior_list_entry *entry, void *data)
+same_lwp (struct inferior_table_entry *entry, void *data)
{
ptid_t ptid = *(ptid_t *) data;
int lwp;
@@ -1948,7 +1948,7 @@ linux_wait_for_event (ptid_t ptid, int *wstat, int options)
/* Count the LWP's that have had events. */

static int
-count_events_callback (struct inferior_list_entry *entry, void *data)
+count_events_callback (struct inferior_table_entry *entry, void *data)
{
struct lwp_info *lp = (struct lwp_info *) entry;
struct thread_info *thread = get_lwp_thread (lp);
@@ -1972,7 +1972,7 @@ count_events_callback (struct inferior_list_entry *entry, void *data)
/* Select the LWP (if any) that is currently being single-stepped. */

static int
-select_singlestep_lwp_callback (struct inferior_list_entry *entry, void *data)
+select_singlestep_lwp_callback (struct inferior_table_entry *entry, void *data)
{
struct lwp_info *lp = (struct lwp_info *) entry;
struct thread_info *thread = get_lwp_thread (lp);
@@ -1989,7 +1989,7 @@ select_singlestep_lwp_callback (struct inferior_list_entry *entry, void *data)
reported to GDB. */

static int
-select_event_lwp_callback (struct inferior_list_entry *entry, void *data)
+select_event_lwp_callback (struct inferior_table_entry *entry, void *data)
{
struct lwp_info *lp = (struct lwp_info *) entry;
struct thread_info *thread = get_lwp_thread (lp);
@@ -2011,7 +2011,7 @@ select_event_lwp_callback (struct inferior_list_entry *entry, void *data)
}

static int
-cancel_breakpoints_callback (struct inferior_list_entry *entry, void *data)
+cancel_breakpoints_callback (struct inferior_table_entry *entry, void *data)
{
struct lwp_info *lp = (struct lwp_info *) entry;
struct thread_info *thread = get_lwp_thread (lp);
@@ -2102,7 +2102,7 @@ select_event_lwp (struct lwp_info **orig_lp)
/* Decrement the suspend count of an LWP. */

static int
-unsuspend_one_lwp (struct inferior_list_entry *entry, void *except)
+unsuspend_one_lwp (struct inferior_table_entry *entry, void *except)
{
struct lwp_info *lwp = (struct lwp_info *) entry;

@@ -2125,10 +2125,10 @@ unsuspend_all_lwps (struct lwp_info *except)
find_inferior (&all_lwps, unsuspend_one_lwp, except);
}

-static void move_out_of_jump_pad_callback (struct inferior_list_entry *entry);
-static int stuck_in_jump_pad_callback (struct inferior_list_entry *entry,
+static void move_out_of_jump_pad_callback (struct inferior_table_entry *entry);
+static int stuck_in_jump_pad_callback (struct inferior_table_entry *entry,
void *data);
-static int lwp_running (struct inferior_list_entry *entry, void *data);
+static int lwp_running (struct inferior_table_entry *entry, void *data);
static ptid_t linux_wait_1 (ptid_t ptid,
struct target_waitstatus *ourstatus,
int target_options);
@@ -2857,7 +2857,7 @@ send_sigstop (struct lwp_info *lwp)
}

static int
-send_sigstop_callback (struct inferior_list_entry *entry, void *except)
+send_sigstop_callback (struct inferior_table_entry *entry, void *except)
{
struct lwp_info *lwp = (struct lwp_info *) entry;

@@ -2875,7 +2875,7 @@ send_sigstop_callback (struct inferior_list_entry *entry, void *except)
/* Increment the suspend count of an LWP, and stop it, if not stopped
yet. */
static int
-suspend_and_send_sigstop_callback (struct inferior_list_entry *entry,
+suspend_and_send_sigstop_callback (struct inferior_table_entry *entry,
void *except)
{
struct lwp_info *lwp = (struct lwp_info *) entry;
@@ -2907,7 +2907,7 @@ mark_lwp_dead (struct lwp_info *lwp, int wstat)
}

static void
-wait_for_sigstop (struct inferior_list_entry *entry)
+wait_for_sigstop (struct inferior_table_entry *entry)
{
struct lwp_info *lwp = (struct lwp_info *) entry;
struct thread_info *saved_inferior;
@@ -2926,7 +2926,7 @@ wait_for_sigstop (struct inferior_list_entry *entry)

saved_inferior = current_inferior;
if (saved_inferior != NULL)
- saved_tid = ((struct inferior_list_entry *) saved_inferior)->id;
+ saved_tid = ((struct inferior_table_entry *) saved_inferior)->id;
else
saved_tid = null_ptid; /* avoid bogus unused warning */

@@ -3003,7 +3003,7 @@ wait_for_sigstop (struct inferior_list_entry *entry)
because she wants to debug it. */

static int
-stuck_in_jump_pad_callback (struct inferior_list_entry *entry, void *data)
+stuck_in_jump_pad_callback (struct inferior_table_entry *entry, void *data)
{
struct lwp_info *lwp = (struct lwp_info *) entry;
struct thread_info *thread = get_lwp_thread (lwp);
@@ -3021,7 +3021,7 @@ stuck_in_jump_pad_callback (struct inferior_list_entry *entry, void *data)
}

static void
-move_out_of_jump_pad_callback (struct inferior_list_entry *entry)
+move_out_of_jump_pad_callback (struct inferior_table_entry *entry)
{
struct lwp_info *lwp = (struct lwp_info *) entry;
struct thread_info *thread = get_lwp_thread (lwp);
@@ -3060,7 +3060,7 @@ move_out_of_jump_pad_callback (struct inferior_list_entry *entry)
}

static int
-lwp_running (struct inferior_list_entry *entry, void *data)
+lwp_running (struct inferior_table_entry *entry, void *data)
{
struct lwp_info *lwp = (struct lwp_info *) entry;

@@ -3329,7 +3329,7 @@ struct thread_resume_array
suspension). */

static int
-linux_set_resume_request (struct inferior_list_entry *entry, void *arg)
+linux_set_resume_request (struct inferior_table_entry *entry, void *arg)
{
struct lwp_info *lwp;
struct thread_info *thread;
@@ -3400,7 +3400,7 @@ linux_set_resume_request (struct inferior_list_entry *entry, void *arg)
Set *FLAG_P if this lwp has an interesting status pending. */

static int
-resume_status_pending_p (struct inferior_list_entry *entry, void *flag_p)
+resume_status_pending_p (struct inferior_table_entry *entry, void *flag_p)
{
struct lwp_info *lwp = (struct lwp_info *) entry;

@@ -3421,7 +3421,7 @@ resume_status_pending_p (struct inferior_list_entry *entry, void *flag_p)
inferior's regcache. */

static int
-need_step_over_p (struct inferior_list_entry *entry, void *dummy)
+need_step_over_p (struct inferior_table_entry *entry, void *dummy)
{
struct lwp_info *lwp = (struct lwp_info *) entry;
struct thread_info *thread;
@@ -3659,7 +3659,7 @@ finish_step_over (struct lwp_info *lwp)
they should be re-issued if necessary. */

static int
-linux_resume_one_thread (struct inferior_list_entry *entry, void *arg)
+linux_resume_one_thread (struct inferior_table_entry *entry, void *arg)
{
struct lwp_info *lwp;
struct thread_info *thread;
@@ -3844,7 +3844,7 @@ linux_resume (struct thread_resume *resume_info, size_t n)
on that particular thread, and leave all others stopped. */

static int
-proceed_one_lwp (struct inferior_list_entry *entry, void *except)
+proceed_one_lwp (struct inferior_table_entry *entry, void *except)
{
struct lwp_info *lwp = (struct lwp_info *) entry;
struct thread_info *thread;
@@ -3919,7 +3919,7 @@ proceed_one_lwp (struct inferior_list_entry *entry, void *except)
}

static int
-unsuspend_and_proceed_one_lwp (struct inferior_list_entry *entry, void *except)
+unsuspend_and_proceed_one_lwp (struct inferior_table_entry *entry, void *except)
{
struct lwp_info *lwp = (struct lwp_info *) entry;

diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h
index f2477d9..6c39c71 100644
--- a/gdb/gdbserver/linux-low.h
+++ b/gdb/gdbserver/linux-low.h
@@ -235,7 +235,7 @@ extern struct linux_target_ops the_low_target;

struct lwp_info
{
- struct inferior_list_entry head;
+ struct inferior_table_entry head;

/* If this flag is set, the next SIGSTOP will be ignored (the
process will be immediately resumed). This means that either we
@@ -337,7 +337,7 @@ struct lwp_info
struct arch_lwp_info *arch_private;
};

-extern struct inferior_list all_lwps;
+extern struct inferior_table all_lwps;

int linux_pid_exe_is_elf_64_file (int pid, unsigned int *machine);

diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c
index 70917fd..e8a3e74 100644
--- a/gdb/gdbserver/linux-mips-low.c
+++ b/gdb/gdbserver/linux-mips-low.c
@@ -295,7 +295,7 @@ mips_breakpoint_at (CORE_ADDR where)
if the lwp's process id is *PID_P. */

static int
-update_watch_registers_callback (struct inferior_list_entry *entry,
+update_watch_registers_callback (struct inferior_table_entry *entry,
void *pid_p)
{
struct lwp_info *lwp = (struct lwp_info *) entry;
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 1e590e8..7e5f165 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -535,7 +535,7 @@ x86_linux_dr_set (ptid_t ptid, int regnum, unsigned long value)
}

static int
-update_debug_registers_callback (struct inferior_list_entry *entry,
+update_debug_registers_callback (struct inferior_table_entry *entry,
void *pid_p)
{
struct lwp_info *lwp = (struct lwp_info *) entry;
@@ -1403,7 +1403,7 @@ x86_linux_read_description (void)
given PID is found. */

static int
-same_process_callback (struct inferior_list_entry *entry, void *data)
+same_process_callback (struct inferior_table_entry *entry, void *data)
{
int pid = *(int *) data;

@@ -1414,7 +1414,7 @@ same_process_callback (struct inferior_list_entry *entry, void *data)
each process. */

static void
-x86_arch_setup_process_callback (struct inferior_list_entry *entry)
+x86_arch_setup_process_callback (struct inferior_table_entry *entry)
{
int pid = ptid_get_pid (entry->id);

diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c
index ee4e2a8..a36471b 100644
--- a/gdb/gdbserver/regcache.c
+++ b/gdb/gdbserver/regcache.c
@@ -87,7 +87,7 @@ regcache_invalidate_thread (struct thread_info *thread)
}

static int
-regcache_invalidate_one (struct inferior_list_entry *entry,
+regcache_invalidate_one (struct inferior_table_entry *entry,
void *pid_p)
{
struct thread_info *thread = (struct thread_info *) entry;
@@ -104,7 +104,7 @@ void
regcache_invalidate (void)
{
/* Only update the threads of the current process. */
- int pid = ptid_get_pid (current_inferior->entry.id);
+ int pid = ptid_get_pid (current_inferior->head.id);

find_inferior (&all_threads, regcache_invalidate_one, &pid);
}
@@ -285,7 +285,7 @@ free_register_cache_thread (struct thread_info *thread)
}

static void
-free_register_cache_thread_one (struct inferior_list_entry *entry)
+free_register_cache_thread_one (struct inferior_table_entry *entry)
{
struct thread_info *thread = (struct thread_info *) entry;

diff --git a/gdb/gdbserver/regcache.h b/gdb/gdbserver/regcache.h
index 6d18d1e..b795dad 100644
--- a/gdb/gdbserver/regcache.h
+++ b/gdb/gdbserver/regcache.h
@@ -19,7 +19,7 @@
#ifndef REGCACHE_H
#define REGCACHE_H

-struct inferior_list_entry;
+struct inferior_table_entry;
struct thread_info;
struct target_desc;

diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 88354be..a7ba458 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -405,7 +405,7 @@ handle_btrace_enable (struct thread_info *thread)
if (thread->btrace != NULL)
return "E.Btrace already enabled.";

- thread->btrace = target_enable_btrace (thread->entry.id);
+ thread->btrace = target_enable_btrace (thread->head.id);
if (thread->btrace == NULL)
return "E.Could not enable btrace.";

@@ -1144,7 +1144,7 @@ handle_qxfer_libraries (const char *annex,
{
unsigned int total_len;
char *document, *p;
- struct inferior_list_entry *dll_ptr;
+ struct inferior_table_entry *dll_ptr;

if (writebuf != NULL)
return -2;
@@ -1289,7 +1289,7 @@ handle_qxfer_statictrace (const char *annex,
static void
handle_qxfer_threads_proper (struct buffer *buffer)
{
- struct inferior_list_entry *thread;
+ struct inferior_table_entry *thread;

buffer_grow_str (buffer, "<threads>\n");

@@ -1688,7 +1688,7 @@ crc32 (CORE_ADDR base, int len, unsigned int crc)
void
handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
{
- static struct inferior_list_entry *thread_ptr;
+ static struct inferior_table_entry *thread_ptr;

/* Reply the current thread id. */
if (strcmp ("qC", own_buf) == 0 && !disable_packet_qC)
@@ -2129,7 +2129,7 @@ visit_actioned_threads (const struct thread_resume *actions,
int (*callback) (const struct thread_resume *,
struct thread_info *))
{
- struct inferior_list_entry *entry;
+ struct inferior_table_entry *entry;

for (entry = all_threads.head; entry != NULL; entry = entry->next)
{
@@ -2168,7 +2168,7 @@ handle_pending_status (const struct thread_resume *resumption,
thread->status_pending_p = 0;

last_status = thread->last_status;
- last_ptid = thread->entry.id;
+ last_ptid = thread->head.id;
prepare_resume_reply (own_buf, last_ptid, &last_status);
return 1;
}
@@ -2603,7 +2603,7 @@ myresume (char *own_buf, int step, int sig)
stopped thread. */

static int
-queue_stop_reply_callback (struct inferior_list_entry *entry, void *arg)
+queue_stop_reply_callback (struct inferior_table_entry *entry, void *arg)
{
struct thread_info *thread = (struct thread_info *) entry;

@@ -2652,7 +2652,7 @@ queue_stop_reply_callback (struct inferior_list_entry *entry, void *arg)
it. */

static void
-gdb_wants_thread_stopped (struct inferior_list_entry *entry)
+gdb_wants_thread_stopped (struct inferior_table_entry *entry)
{
struct thread_info *thread = (struct thread_info *) entry;

@@ -2678,7 +2678,7 @@ gdb_wants_all_threads_stopped (void)
/* Clear the gdb_detached flag of every process. */

static void
-gdb_reattached_process (struct inferior_list_entry *entry)
+gdb_reattached_process (struct inferior_table_entry *entry)
{
struct process_info *process = (struct process_info *) entry;

@@ -2689,7 +2689,7 @@ gdb_reattached_process (struct inferior_list_entry *entry)
flag. */

static void
-clear_pending_status_callback (struct inferior_list_entry *entry)
+clear_pending_status_callback (struct inferior_table_entry *entry)
{
struct thread_info *thread = (struct thread_info *) entry;

@@ -2700,7 +2700,7 @@ clear_pending_status_callback (struct inferior_list_entry *entry)
interesting event, mark it as having a pending event. */

static void
-set_pending_status_callback (struct inferior_list_entry *entry)
+set_pending_status_callback (struct inferior_table_entry *entry)
{
struct thread_info *thread = (struct thread_info *) entry;

@@ -2720,7 +2720,7 @@ set_pending_status_callback (struct inferior_list_entry *entry)
pending status to report to GDB. */

static int
-find_status_pending_thread_callback (struct inferior_list_entry *entry, void *data)
+find_status_pending_thread_callback (struct inferior_table_entry *entry, void *data)
{
struct thread_info *thread = (struct thread_info *) entry;

@@ -2750,7 +2750,7 @@ handle_status (char *own_buf)
}
else
{
- struct inferior_list_entry *thread = NULL;
+ struct inferior_table_entry *thread = NULL;

pause_all (0);
stabilize_threads ();
@@ -2796,7 +2796,7 @@ handle_status (char *own_buf)
set_desired_inferior (1);

gdb_assert (tp->last_status.kind != TARGET_WAITKIND_IGNORE);
- prepare_resume_reply (own_buf, tp->entry.id, &tp->last_status);
+ prepare_resume_reply (own_buf, tp->head.id, &tp->last_status);
}
else
strcpy (own_buf, "W00");
@@ -2865,7 +2865,7 @@ gdbserver_show_disableable (FILE *stream)
}

static int
-first_thread_of (struct inferior_list_entry *entry, void *args)
+first_thread_of (struct inferior_table_entry *entry, void *args)
{
int pid = * (int *) args;

@@ -2876,7 +2876,7 @@ first_thread_of (struct inferior_list_entry *entry, void *args)
}

static void
-kill_inferior_callback (struct inferior_list_entry *entry)
+kill_inferior_callback (struct inferior_table_entry *entry)
{
struct process_info *process = (struct process_info *) entry;
int pid = ptid_get_pid (process->head.id);
@@ -2891,7 +2891,7 @@ kill_inferior_callback (struct inferior_list_entry *entry)
as this is only called when gdbserver is about to exit. */

static void
-detach_or_kill_inferior_callback (struct inferior_list_entry *entry)
+detach_or_kill_inferior_callback (struct inferior_table_entry *entry)
{
struct process_info *process = (struct process_info *) entry;
int pid = ptid_get_pid (process->head.id);
@@ -2908,7 +2908,7 @@ detach_or_kill_inferior_callback (struct inferior_list_entry *entry)
the pids of started inferiors. */

static void
-print_started_pid (struct inferior_list_entry *entry)
+print_started_pid (struct inferior_table_entry *entry)
{
struct process_info *process = (struct process_info *) entry;

@@ -2923,7 +2923,7 @@ print_started_pid (struct inferior_list_entry *entry)
the pids of attached inferiors. */

static void
-print_attached_pid (struct inferior_list_entry *entry)
+print_attached_pid (struct inferior_table_entry *entry)
{
struct process_info *process = (struct process_info *) entry;

@@ -3516,7 +3516,7 @@ process_serial_event (void)
break;
}

- thread_id = ((struct inferior_list_entry *)thread)->id;
+ thread_id = ((struct inferior_table_entry *)thread)->id;
}
else
{
diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c
index df06b9d..9ea6894 100644
--- a/gdb/gdbserver/thread-db.c
+++ b/gdb/gdbserver/thread-db.c
@@ -827,7 +827,7 @@ thread_db_init (int use_events)
}

static int
-any_thread_of (struct inferior_list_entry *entry, void *args)
+any_thread_of (struct inferior_table_entry *entry, void *args)
{
int *pid_p = args;

diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 3706577..3e2b74d 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -3952,7 +3952,7 @@ gdb_agent_about_to_close (int pid)
if (!maybe_write_ipa_not_loaded (buf))
{
struct thread_info *save_inferior;
- struct inferior_list_entry *inf = all_threads.head;
+ struct inferior_table_entry *inf = all_threads.head;

save_inferior = current_inferior;

@@ -4394,7 +4394,7 @@ tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc)
wstep_link = &tinfo->while_stepping;

trace_debug ("Thread %s finished a single-step for tracepoint %d at 0x%s",
- target_pid_to_str (tinfo->entry.id),
+ target_pid_to_str (tinfo->head.id),
wstep->tp_number, paddress (wstep->tp_address));

ctx.base.type = trap_tracepoint;
@@ -4407,7 +4407,7 @@ tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc)
{
trace_debug ("NO TRACEPOINT %d at 0x%s FOR THREAD %s!",
wstep->tp_number, paddress (wstep->tp_address),
- target_pid_to_str (tinfo->entry.id));
+ target_pid_to_str (tinfo->head.id));

/* Unlink. */
*wstep_link = wstep->next;
@@ -4427,7 +4427,7 @@ tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc)
{
/* The requested numbers of steps have occurred. */
trace_debug ("Thread %s done stepping for tracepoint %d at 0x%s",
- target_pid_to_str (tinfo->entry.id),
+ target_pid_to_str (tinfo->head.id),
wstep->tp_number, paddress (wstep->tp_address));

/* Unlink the wstep. */
@@ -4574,7 +4574,7 @@ tracepoint_was_hit (struct thread_info *tinfo, CORE_ADDR stop_pc)
&& tpoint->type != static_tracepoint)
{
trace_debug ("Thread %s at address of tracepoint %d at 0x%s",
- target_pid_to_str (tinfo->entry.id),
+ target_pid_to_str (tinfo->head.id),
tpoint->number, paddress (tpoint->address));

/* Test the condition if present, and collect if true. */
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 92b001f..0a93759 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -114,7 +114,7 @@ static void win32_ensure_ntdll_loaded (void);
static ptid_t
current_inferior_ptid (void)
{
- return ((struct inferior_list_entry*) current_inferior)->id;
+ return ((struct inferior_table_entry*) current_inferior)->id;
}

/* The current debug event from WaitForDebugEvent. */
@@ -215,7 +215,7 @@ child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb)

/* Delete a thread from the list of threads. */
static void
-delete_thread_info (struct inferior_list_entry *thread)
+delete_thread_info (struct inferior_table_entry *thread)
{
win32_thread_info *th = inferior_target_data ((struct thread_info *) thread);

@@ -228,7 +228,7 @@ delete_thread_info (struct inferior_list_entry *thread)
static void
child_delete_thread (DWORD pid, DWORD tid)
{
- struct inferior_list_entry *thread;
+ struct inferior_table_entry *thread;
ptid_t ptid;

/* If the last thread is exiting, just return. */
@@ -383,7 +383,7 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached)
/* Resume all artificially suspended threads if we are continuing
execution. */
static int
-continue_one_thread (struct inferior_list_entry *this_thread, void *id_ptr)
+continue_one_thread (struct inferior_table_entry *this_thread, void *id_ptr)
{
struct thread_info *thread = (struct thread_info *) this_thread;
int thread_id = * (int *) id_ptr;
@@ -1158,7 +1158,7 @@ failed:
static void
win32_ensure_ntdll_loaded (void)
{
- struct inferior_list_entry *dll_e;
+ struct inferior_table_entry *dll_e;
size_t i;
HMODULE dh_buf[1];
HMODULE *DllHandle = dh_buf;
@@ -1463,7 +1463,7 @@ handle_exception (struct target_waitstatus *ourstatus)

static void
-suspend_one_thread (struct inferior_list_entry *entry)
+suspend_one_thread (struct inferior_table_entry *entry)
{
struct thread_info *thread = (struct thread_info *) entry;
win32_thread_info *th = inferior_target_data (thread);