/* libthread_db assisted debugging support, generic parts.
- Copyright (C) 1999-2013 Free Software Foundation, Inc.
+ Copyright (C) 1999-2014 Free Software Foundation, Inc.
This file is part of GDB.
relative, or just LIBTHREAD_DB. */
static int
-try_thread_db_load (const char *library)
+try_thread_db_load (const char *library, int check_auto_load_safe)
{
void *handle;
struct thread_db_info *info;
if (libthread_db_debug)
printf_unfiltered (_("Trying host libthread_db library: %s.\n"),
library);
+
+ if (check_auto_load_safe)
+ {
+ if (access (library, R_OK) != 0)
+ {
+ /* Do not print warnings by file_is_auto_load_safe if the library does
+ not exist at this place. */
+ if (libthread_db_debug)
+ printf_unfiltered (_("open failed: %s.\n"), safe_strerror (errno));
+ return 0;
+ }
+
+ if (!file_is_auto_load_safe (library, _("auto-load: Loading libthread-db "
+ "library \"%s\" from explicit "
+ "directory.\n"),
+ library))
+ return 0;
+ }
+
handle = dlopen (library, RTLD_NOW);
if (handle == NULL)
{
}
strcat (cp, LIBTHREAD_DB_SO);
- if (!file_is_auto_load_safe (path, _("auto-load: Loading libthread-db "
- "library \"%s\" from $pdir.\n"),
- path))
- result = 0;
- else
- result = try_thread_db_load (path);
+ result = try_thread_db_load (path, 1);
do_cleanups (cleanup);
return result;
static int
try_thread_db_load_from_sdir (void)
{
- return try_thread_db_load (LIBTHREAD_DB_SO);
+ return try_thread_db_load (LIBTHREAD_DB_SO, 0);
}
/* Try to load libthread_db from directory DIR of length DIR_LEN.
path[dir_len] = '/';
strcpy (path + dir_len + 1, LIBTHREAD_DB_SO);
- if (!file_is_auto_load_safe (path, _("auto-load: Loading libthread-db "
- "library \"%s\" from explicit "
- "directory.\n"),
- path))
- result = 0;
- else
- result = try_thread_db_load (path);
+ result = try_thread_db_load (path, 1);
do_cleanups (cleanup);
return result;
}
static void
-thread_db_detach (struct target_ops *ops, char *args, int from_tty)
+thread_db_detach (struct target_ops *ops, const char *args, int from_tty)
{
struct target_ops *target_beneath = find_target_beneath (ops);
struct thread_db_info *info;
/* Bail out early if we're not at a thread event breakpoint. */
stop_pc = regcache_read_pc (regcache)
- - gdbarch_decr_pc_after_break (gdbarch);
+ - target_decr_pc_after_break (gdbarch);
if (stop_pc != info->td_create_bp_addr
&& stop_pc != info->td_death_bp_addr)
return;