#include "gdb_thread_db.h"
#include "bfd.h"
+#include "exceptions.h"
#include "gdbthread.h"
#include "inferior.h"
#include "symfile.h"
if (library == NULL)
/* Paranoid - don't let a NULL path slip through. */
library = LIBTHREAD_DB_SO;
- printf_unfiltered ("Using host libthread_db library \"%s\".\n",
+ printf_unfiltered (_("Using host libthread_db library \"%s\".\n"),
library);
dejavu = 1;
}
break;
case TD_OK:
- printf_unfiltered ("[Thread debugging using libthread_db enabled]\n");
+ printf_unfiltered (_("[Thread debugging using libthread_db enabled]\n"));
/* The thread library was detected. Activate the thread_db target. */
push_target (&thread_db_ops);
memset (tp->private, 0, sizeof (struct private_thread_info));
if (verbose)
- printf_unfiltered ("[New %s]\n", target_pid_to_str (ptid));
+ printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid));
if (ti_p->ti_state == TD_THR_UNKNOWN || ti_p->ti_state == TD_THR_ZOMBIE)
return; /* A zombie thread -- do not attach. */
struct thread_info *thread_info;
if (verbose)
- printf_unfiltered ("[%s exited]\n", target_pid_to_str (ptid));
+ printf_unfiltered (_("[%s exited]\n"), target_pid_to_str (ptid));
/* Don't delete the thread now, because it still reports as active
until it has executed a few instructions after the event
return normal_pid_to_str (ptid);
}
-/* Get the address of the thread local variable in OBJFILE which is
- stored at OFFSET within the thread local storage for thread PTID. */
+/* Get the address of the thread local variable in load module LM which
+ is stored at OFFSET within the thread local storage for thread PTID. */
static CORE_ADDR
-thread_db_get_thread_local_address (ptid_t ptid, struct objfile *objfile,
+thread_db_get_thread_local_address (ptid_t ptid,
+ CORE_ADDR lm,
CORE_ADDR offset)
{
if (is_thread (ptid))
{
- int objfile_is_library = (objfile->flags & OBJF_SHARED);
td_err_e err;
void *address;
- CORE_ADDR lm;
struct thread_info *thread_info;
/* glibc doesn't provide the needed interface. */
if (!td_thr_tls_get_addr_p)
- error (_("Cannot find thread-local variables in this thread library."));
+ throw_error (TLS_NO_LIBRARY_SUPPORT_ERROR,
+ _("No TLS library support"));
- /* Get the address of the link map for this objfile. */
- lm = svr4_fetch_objfile_link_map (objfile);
-
- /* Whoops, we couldn't find one. Bail out. */
- if (!lm)
- {
- if (objfile_is_library)
- error (_("Cannot find shared library `%s' link_map in dynamic"
- " linker's module list"), objfile->name);
- else
- error (_("Cannot find executable file `%s' link_map in dynamic"
- " linker's module list"), objfile->name);
- }
+ /* Caller should have verified that lm != 0. */
+ gdb_assert (lm != 0);
/* Get info about the thread. */
thread_info = find_thread_pid (ptid);
#ifdef THREAD_DB_HAS_TD_NOTALLOC
/* The memory hasn't been allocated, yet. */
if (err == TD_NOTALLOC)
- {
/* Now, if libthread_db provided the initialization image's
address, we *could* try to build a non-lvalue value from
the initialization image. */
- if (objfile_is_library)
- error (_("The inferior has not yet allocated storage for"
- " thread-local variables in\n"
- "the shared library `%s'\n"
- "for the thread %ld"),
- objfile->name, (long) GET_THREAD (ptid));
- else
- error (_("The inferior has not yet allocated storage for"
- " thread-local variables in\n"
- "the executable `%s'\n"
- "for the thread %ld"),
- objfile->name, (long) GET_THREAD (ptid));
- }
+ throw_error (TLS_NOT_ALLOCATED_YET_ERROR,
+ _("TLS not allocated yet"));
#endif
/* Something else went wrong. */
if (err != TD_OK)
- {
- if (objfile_is_library)
- error (_("Cannot find thread-local storage for thread %ld, "
- "shared library %s:\n%s"),
- (long) GET_THREAD (ptid),
- objfile->name, thread_db_err_str (err));
- else
- error (_("Cannot find thread-local storage for thread %ld, "
- "executable file %s:\n%s"),
- (long) GET_THREAD (ptid),
- objfile->name, thread_db_err_str (err));
- }
+ throw_error (TLS_GENERIC_ERROR,
+ (("%s")), thread_db_err_str (err));
/* Cast assuming host == target. Joy. */
return (CORE_ADDR) address;
}
if (target_beneath->to_get_thread_local_address)
- return target_beneath->to_get_thread_local_address (ptid, objfile,
- offset);
-
- error (_("Cannot find thread-local values on this target."));
+ return target_beneath->to_get_thread_local_address (ptid, lm, offset);
+ else
+ throw_error (TLS_GENERIC_ERROR,
+ _("TLS not supported on this target"));
}
static void