+2015-06-25 Gary Benson <gbenson@redhat.com>
+
+ * solib.c (solib_find_1): Set local variable sysroot to NULL if
+ it is the empty string after trailing slashes have been stripped.
+
2015-06-25 Gary Benson <gbenson@redhat.com>
* exec.c (exec_file_locate_attach): Remove gdb_sysroot NULL check.
const char *fskind = effective_target_file_system_kind ();
struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
char *sysroot = gdb_sysroot;
+ int prefix_len, orig_prefix_len;
/* If the absolute prefix starts with "target:" but the filesystem
accessed by the target_fileio_* methods is the local filesystem
if (is_target_filename (sysroot) && target_filesystem_is_local ())
sysroot += strlen (TARGET_SYSROOT_PREFIX);
- if (*sysroot == '\0')
- sysroot = NULL;
- else
- {
- int prefix_len = strlen (sysroot);
+ /* Strip any trailing slashes from the absolute prefix. */
+ prefix_len = orig_prefix_len = strlen (sysroot);
- /* Remove trailing slashes from absolute prefix. */
- while (prefix_len > 0
- && IS_DIR_SEPARATOR (sysroot[prefix_len - 1]))
- prefix_len--;
+ while (prefix_len > 0 && IS_DIR_SEPARATOR (sysroot[prefix_len - 1]))
+ prefix_len--;
+ if (prefix_len == 0)
+ sysroot = NULL;
+ else if (prefix_len != orig_prefix_len)
+ {
sysroot = savestring (sysroot, prefix_len);
make_cleanup (xfree, sysroot);
}