/* libthread_db assisted debugging support, generic parts.
- Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008
+ Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GDB.
/* 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;
return 1;
}
-void
-thread_db_init (struct target_ops *target)
-{
- target_beneath = target;
-}
-
static void *
verbose_dlsym (void *handle, const char *name)
{
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
}
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;
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;
using_thread_db = 0;
}
-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)
{
}
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)
{
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);
}
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 ())
: (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"));
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;
}