From 117de6a92498c0dd715fa0fdec577697433f3c5e Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 6 Feb 2009 22:21:26 +0000 Subject: * linux-nat.c (linux_nat_wait): Adjust. (linux_nat_pid_to_str): Adjust. Remove call to thread_db_init. * linux-nat.h (thread_db_init): Delete declaration. * linux-thread-db.c (target_beneath): Delete. (thread_db_init): Delete. (thread_db_detach): Use find_target_beneath. (thread_db_wait): Adjust interface. Use find_target_beneath. (thread_db_mourn_inferior): Use find_target_beneath. (thread_db_can_async_p, thread_db_is_async_p, thread_db_async) (thread_db_async_mask): Delete. (thread_db_pid_to_str): Adjust interface. Use find_target_beneath. (thread_db_get_thread_local_address): Adjust interface. Use find_target_beneath. (init_thread_db_ops): Delete references to delete functions. * target.c (update_current_target): Don't inherit or default to_wait. Don't inherit to_pid_to_str and to_get_thread_local_address. (target_translate_tls_address): Look for a pushed target that implements to_get_thread_local_address, and use it instead of checking for target_get_thread_local_address_p. (target_wait, target_pid_to_str): Reimplement as functions. (dummy_pid_to_str): New. (init_dummy_target): Register it. (debug_to_wait): Delete. * target.h (struct target_ops): Make to_wait, to_pid_to_str and to_get_thread_local_address accept a pointer to struct target_ops. (target_wait): Delete macro, and declare as function. (target_pid_to_str): Likewise. (target_get_thread_local_address) (target_get_thread_local_address_p): Delete. (noprocess): Add NORETURN and ATTR_NORETURN tags. * inf-ptrace.c (inf_ptrace_wait): Adjust. (inf_ptrace_pid_to_str): New. (inf_ptrace_target): Use inf_ptrace_pid_to_str. * aix-thread.c (aix_thread_wait, aix_thread_pid_to_str): Adjust. * bsd-kvm.c (bsd_kvm_pid_to_str): Adjust. * bsd-uthread.c (bsd_uthread_wait, bsd_uthread_pid_to_str): Adjust. * corelow.c (core_pid_to_str): Adjust. * darwin-nat.c (darwin_wait, darwin_pid_to_str): Adjust. * dec-thread.c (dec_thread_wait, dec_thread_pid_to_str): Adjust. * gnu-nat.c (gnu_wait, gnu_pid_to_str): Adjust. * go32-nat.c (go32_wait, go32_pid_to_str): Adjust. * hpux-thread.c (hpux_thread_wait): Adjust. * inf-ttrace.c (inf_ttrace_wait, inf_ttrace_pid_to_str): Adjust. * monitor.c (monitor_wait, monitor_pid_to_str): Adjust. * nto-procfs.c (procfs_wait, procfs_pid_to_str): Adjust. * procfs.c (procfs_pid_to_str): Adjust. * remote-m32r-sdi.c (m32r_wait, m32r_pid_to_str): Adjust. * remote-mips.c (mips_wait): Adjust. * remote-sim.c (gdbsim_wait, gdbsim_pid_to_str): Adjust. * remote.c (remote_wait, remote_pid_to_str) (remote_get_thread_local_address): Adjust. * rs6000-nat.c (rs6000_wait): Adjust. * sol-thread.c (procfs_pid_to_str): Adjust declaration. (sol_thread_wait, solaris_pid_to_str): Adjust. * spu-linux-nat.c (spu_child_wait): Adjust. * windows-nat.c (windows_wait, windows_pid_to_str): Adjust. --- gdb/linux-thread-db.c | 66 ++++++++++++++++----------------------------------- 1 file changed, 20 insertions(+), 46 deletions(-) (limited to 'gdb/linux-thread-db.c') diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index eced854..d3371d0 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -80,9 +80,6 @@ /* This module's target vector. */ static struct target_ops thread_db_ops; -/* The target vector that we call for things this module can't handle. */ -static struct target_ops *target_beneath; - /* Non-zero if we're using this module's target vector. */ static int using_thread_db; @@ -379,12 +376,6 @@ thread_db_attach_lwp (ptid_t ptid) return 1; } -void -thread_db_init (struct target_ops *target) -{ - target_beneath = target; -} - static void * verbose_dlsym (void *handle, const char *name) { @@ -782,6 +773,8 @@ detach_thread (ptid_t ptid) static void thread_db_detach (struct target_ops *ops, char *args, int from_tty) { + struct target_ops *target_beneath = find_target_beneath (ops); + disable_thread_event_reporting (); /* Forget about the child's process ID. We shouldn't need it @@ -885,9 +878,12 @@ check_event (ptid_t ptid) } static ptid_t -thread_db_wait (ptid_t ptid, struct target_waitstatus *ourstatus) +thread_db_wait (struct target_ops *ops, + ptid_t ptid, struct target_waitstatus *ourstatus) { - ptid = target_beneath->to_wait (ptid, ourstatus); + struct target_ops *beneath = find_target_beneath (ops); + + ptid = beneath->to_wait (beneath, ptid, ourstatus); if (ourstatus->kind == TARGET_WAITKIND_IGNORE) return ptid; @@ -934,6 +930,8 @@ thread_db_wait (ptid_t ptid, struct target_waitstatus *ourstatus) static void thread_db_mourn_inferior (struct target_ops *ops) { + struct target_ops *target_beneath = find_target_beneath (ops); + /* Forget about the child's process ID. We shouldn't need it anymore. */ proc_handle.pid = 0; @@ -950,31 +948,6 @@ thread_db_mourn_inferior (struct target_ops *ops) } static int -thread_db_can_async_p (void) -{ - return target_beneath->to_can_async_p (); -} - -static int -thread_db_is_async_p (void) -{ - return target_beneath->to_is_async_p (); -} - -static void -thread_db_async (void (*callback) (enum inferior_event_type event_type, - void *context), void *context) -{ - return target_beneath->to_async (callback, context); -} - -static int -thread_db_async_mask (int mask) -{ - return target_beneath->to_async_mask (mask); -} - -static int find_new_threads_callback (const td_thrhandle_t *th_p, void *data) { td_thrinfo_t ti; @@ -1045,9 +1018,10 @@ thread_db_find_new_threads (void) } static char * -thread_db_pid_to_str (ptid_t ptid) +thread_db_pid_to_str (struct target_ops *ops, ptid_t ptid) { struct thread_info *thread_info = find_thread_pid (ptid); + struct target_ops *beneath; if (thread_info != NULL && thread_info->private != NULL) { @@ -1062,8 +1036,9 @@ thread_db_pid_to_str (ptid_t ptid) return buf; } - if (target_beneath->to_pid_to_str (ptid)) - return target_beneath->to_pid_to_str (ptid); + beneath = find_target_beneath (ops); + if (beneath->to_pid_to_str (beneath, ptid)) + return beneath->to_pid_to_str (beneath, ptid); return normal_pid_to_str (ptid); } @@ -1087,11 +1062,13 @@ thread_db_extra_thread_info (struct thread_info *info) is stored at OFFSET within the thread local storage for thread PTID. */ static CORE_ADDR -thread_db_get_thread_local_address (ptid_t ptid, +thread_db_get_thread_local_address (struct target_ops *ops, + ptid_t ptid, CORE_ADDR lm, CORE_ADDR offset) { struct thread_info *thread_info; + struct target_ops *beneath; /* If we have not discovered any threads yet, check now. */ if (!have_threads ()) @@ -1141,8 +1118,9 @@ thread_db_get_thread_local_address (ptid_t ptid, : (CORE_ADDR) (uintptr_t) address); } - if (target_beneath->to_get_thread_local_address) - return target_beneath->to_get_thread_local_address (ptid, lm, offset); + beneath = find_target_beneath (ops); + if (beneath->to_get_thread_local_address) + return beneath->to_get_thread_local_address (beneath, ptid, lm, offset); else throw_error (TLS_GENERIC_ERROR, _("TLS not supported on this target")); @@ -1193,10 +1171,6 @@ init_thread_db_ops (void) thread_db_ops.to_get_thread_local_address = thread_db_get_thread_local_address; thread_db_ops.to_extra_thread_info = thread_db_extra_thread_info; - thread_db_ops.to_can_async_p = thread_db_can_async_p; - thread_db_ops.to_is_async_p = thread_db_is_async_p; - thread_db_ops.to_async = thread_db_async; - thread_db_ops.to_async_mask = thread_db_async_mask; thread_db_ops.to_get_ada_task_ptid = thread_db_get_ada_task_ptid; thread_db_ops.to_magic = OPS_MAGIC; } -- cgit v1.1