diff options
author | Pedro Alves <palves@redhat.com> | 2009-10-20 11:09:01 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2009-10-20 11:09:01 +0000 |
commit | c069425482903a72eadc818c9c3c685df6170238 (patch) | |
tree | 7a275c1bb27f5ec91032741c0e0e157255a0a9c4 /gdb/linux-nat.c | |
parent | dbde1c12721304ec89ee0326187ecedebd9da4ed (diff) | |
download | gdb-c069425482903a72eadc818c9c3c685df6170238.zip gdb-c069425482903a72eadc818c9c3c685df6170238.tar.gz gdb-c069425482903a72eadc818c9c3c685df6170238.tar.bz2 |
* linux-nat.c (linux_nat_thread_address_space): New.
(linux_nat_add_target): Install it.
* progspace.c (address_space_num): New.
* progspace.h (address_space_num): Declare.
* target.c (target_thread_address_space): Really query the target.
* target.h (struct target_ops) <to_thread_address_space>: New
field.
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r-- | gdb/linux-nat.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 724cdee..c0c0240 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -5311,6 +5311,39 @@ linux_nat_close (int quitting) linux_ops->to_close (quitting); } +/* When requests are passed down from the linux-nat layer to the + single threaded inf-ptrace layer, ptids of (lwpid,0,0) form are + used. The address space pointer is stored in the inferior object, + but the common code that is passed such ptid can't tell whether + lwpid is a "main" process id or not (it assumes so). We reverse + look up the "main" process id from the lwp here. */ + +struct address_space * +linux_nat_thread_address_space (struct target_ops *t, ptid_t ptid) +{ + struct lwp_info *lwp; + struct inferior *inf; + int pid; + + pid = GET_LWP (ptid); + if (GET_LWP (ptid) == 0) + { + /* An (lwpid,0,0) ptid. Look up the lwp object to get at the + tgid. */ + lwp = find_lwp_pid (ptid); + pid = GET_PID (lwp->ptid); + } + else + { + /* A (pid,lwpid,0) ptid. */ + pid = GET_PID (ptid); + } + + inf = find_inferior_pid (pid); + gdb_assert (inf != NULL); + return inf->aspace; +} + void linux_nat_add_target (struct target_ops *t) { @@ -5333,6 +5366,7 @@ linux_nat_add_target (struct target_ops *t) t->to_thread_alive = linux_nat_thread_alive; t->to_pid_to_str = linux_nat_pid_to_str; t->to_has_thread_control = tc_schedlock; + t->to_thread_address_space = linux_nat_thread_address_space; t->to_can_async_p = linux_nat_can_async_p; t->to_is_async_p = linux_nat_is_async_p; |