diff options
author | Doug Evans <dje@google.com> | 2014-02-19 16:38:44 -0800 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2014-02-19 16:38:44 -0800 |
commit | f7667f0de68675a72743c73333c83a5fc6e5e69e (patch) | |
tree | 3bb438477d258ea00632081f632944136cc716e7 /gdb/gdbserver | |
parent | b3312d801920bf1705263f533cdf16330bddedbe (diff) | |
download | gdb-f7667f0de68675a72743c73333c83a5fc6e5e69e.zip gdb-f7667f0de68675a72743c73333c83a5fc6e5e69e.tar.gz gdb-f7667f0de68675a72743c73333c83a5fc6e5e69e.tar.bz2 |
Add backlink from lwp_info to thread_info.
* gdbthread.h (add_thread): Change result type to struct thread_info *.
* inferiors.c (add_thread): Change result type to struct thread_info *.
All callers updated.
(add_lwp): Call add_thread here instead of in callers.
All callers updated.
* linux-low.h (get_lwp_thread): Rewrite.
(struct lwp_info): New member "thread".
This speeds up gdbserver attach in non-stop mode because now get_lwp_thread
doesn't do a linear search for the corresponding thread_info object.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/gdbserver/gdbthread.h | 2 | ||||
-rw-r--r-- | gdb/gdbserver/inferiors.c | 4 | ||||
-rw-r--r-- | gdb/gdbserver/linux-low.c | 4 | ||||
-rw-r--r-- | gdb/gdbserver/linux-low.h | 9 |
5 files changed, 21 insertions, 8 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 1671772..4105224 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,15 @@ 2014-02-19 Doug Evans <dje@google.com> + * gdbthread.h (add_thread): Change result type to struct thread_info *. + * inferiors.c (add_thread): Change result type to struct thread_info *. + All callers updated. + (add_lwp): Call add_thread here instead of in callers. + All callers updated. + * linux-low.h (get_lwp_thread): Rewrite. + (struct lwp_info): New member "thread". + +2014-02-19 Doug Evans <dje@google.com> + * linux-low.c (add_lwp): Change result to struct lwp_info *. All callers updated. diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h index 0eac5a4..9785d67 100644 --- a/gdb/gdbserver/gdbthread.h +++ b/gdb/gdbserver/gdbthread.h @@ -74,7 +74,7 @@ struct thread_info extern struct inferior_list all_threads; void remove_thread (struct thread_info *thread); -void add_thread (ptid_t ptid, void *target_data); +struct thread_info *add_thread (ptid_t ptid, void *target_data); struct thread_info *get_first_thread (void); diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c index fd7c922..f83ee22 100644 --- a/gdb/gdbserver/inferiors.c +++ b/gdb/gdbserver/inferiors.c @@ -104,7 +104,7 @@ remove_inferior (struct inferior_list *list, list->tail = *cur; } -void +struct thread_info * add_thread (ptid_t thread_id, void *target_data) { struct thread_info *new_thread = xmalloc (sizeof (*new_thread)); @@ -121,6 +121,8 @@ add_thread (ptid_t thread_id, void *target_data) current_inferior = new_thread; new_thread->target_data = target_data; + + return new_thread; } ptid_t diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 910d96d..d4c113a 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -409,7 +409,6 @@ handle_extended_wait (struct lwp_info *event_child, int wstat) ptid = ptid_build (pid_of (event_child), new_pid, 0); new_lwp = add_lwp (ptid); - add_thread (ptid, new_lwp); /* Either we're going to immediately resume the new thread or leave it stopped. linux_resume_one_lwp is a nop if it @@ -539,6 +538,7 @@ add_lwp (ptid_t ptid) lwp->arch_private = the_low_target.new_thread (); add_inferior_to_list (&all_lwps, &lwp->entry); + lwp->thread = add_thread (ptid, lwp); return lwp; } @@ -632,7 +632,6 @@ linux_create_inferior (char *program, char **allargs) ptid = ptid_build (pid, pid, 0); new_lwp = add_lwp (ptid); - add_thread (ptid, new_lwp); new_lwp->must_set_ptrace_flags = 1; return pid; @@ -683,7 +682,6 @@ linux_attach_lwp_1 (unsigned long lwpid, int initial) } new_lwp = add_lwp (ptid); - add_thread (ptid, new_lwp); /* We need to wait for SIGSTOP before being able to make the next ptrace call on this LWP. */ diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h index 3b7ec21..b3e75db 100644 --- a/gdb/gdbserver/linux-low.h +++ b/gdb/gdbserver/linux-low.h @@ -229,14 +229,17 @@ extern struct linux_target_ops the_low_target; #define get_lwp(inf) ((struct lwp_info *)(inf)) #define get_thread_lwp(thr) (get_lwp (inferior_target_data (thr))) -#define get_lwp_thread(proc) ((struct thread_info *) \ - find_inferior_id (&all_threads, \ - get_lwp (proc)->entry.id)) +#define get_lwp_thread(lwp) ((lwp)->thread) struct lwp_info { struct inferior_list_entry entry; + /* Backlink to the thread_info object. + It is the "main" representation of the thread, we just contain + linux-specific subordinate data. */ + struct thread_info *thread; + /* If this flag is set, the next SIGSTOP will be ignored (the process will be immediately resumed). This means that either we sent the SIGSTOP to it ourselves and got some other pending event |