Global variable GDB_SYSROOT is used as a prefix directory
to search for shared libraries if they have an absolute path.
+ If GDB_SYSROOT starts with "target:" and target filesystem
+ is the local filesystem then the "target:" prefix will be
+ stripped before the search starts. This ensures that the
+ same search algorithm is used for local files regardless of
+ whether a "target:" prefix was used.
Global variable SOLIB_SEARCH_PATH is used as a prefix directory
(or set of directories, as in LD_LIBRARY_PATH) to search for all
- shared libraries if not found in GDB_SYSROOT.
+ shared libraries if not found in either the sysroot (if set) or
+ the local filesystem.
Search algorithm:
- * If there is a gdb_sysroot and path is absolute:
- * Search for gdb_sysroot/path.
+ * If a sysroot is set and path is absolute:
+ * Search for sysroot/path.
* else
* Look for it literally (unmodified).
* Look in SOLIB_SEARCH_PATH.
* If available, use target defined search function.
- * If gdb_sysroot is NOT set, perform the following two searches:
+ * If NO sysroot is set, perform the following two searches:
* Look in inferior's $PATH.
* Look in inferior's $LD_LIBRARY_PATH.
*
* The last check avoids doing this search when targetting remote
- * machines since gdb_sysroot will almost always be set.
+ * machines since a sysroot will almost always be set.
*/
char *
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
int found_file = -1;
char *temp_pathname = NULL;
- int gdb_sysroot_is_empty;
const char *solib_symbols_extension
= gdbarch_solib_symbols_extension (target_gdbarch ());
const char *fskind = effective_target_file_system_kind ();
struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
- char *sysroot = NULL;
+ char *sysroot = gdb_sysroot;
/* If solib_symbols_extension is set, replace the file's
extension. */
}
}
- gdb_sysroot_is_empty = (gdb_sysroot == NULL || *gdb_sysroot == 0);
+ if (sysroot != NULL)
+ {
+ /* If the absolute prefix starts with "target:" but the
+ filesystem accessed by the target_fileio_* methods
+ is the local filesystem then we strip the "target:"
+ prefix now and work with the local filesystem. This
+ ensures that the same search algorithm is used for
+ all local files regardless of whether a "target:"
+ prefix was used. */
+ if (is_target_filename (sysroot) && target_filesystem_is_local ())
+ sysroot += strlen (TARGET_SYSROOT_PREFIX);
+
+ if (*sysroot == '\0')
+ sysroot = NULL;
+ }
- if (!gdb_sysroot_is_empty)
+ if (sysroot != NULL)
{
- int prefix_len = strlen (gdb_sysroot);
+ int prefix_len = strlen (sysroot);
/* Remove trailing slashes from absolute prefix. */
while (prefix_len > 0
- && IS_DIR_SEPARATOR (gdb_sysroot[prefix_len - 1]))
+ && IS_DIR_SEPARATOR (sysroot[prefix_len - 1]))
prefix_len--;
- sysroot = savestring (gdb_sysroot, prefix_len);
+ sysroot = savestring (sysroot, prefix_len);
make_cleanup (xfree, sysroot);
}
3rd attempt, c:/foo/bar.dll ==> /sysroot/foo/bar.dll
*/
- if (!IS_TARGET_ABSOLUTE_PATH (fskind, in_pathname) || gdb_sysroot_is_empty)
+ if (!IS_TARGET_ABSOLUTE_PATH (fskind, in_pathname) || sysroot == NULL)
temp_pathname = xstrdup (in_pathname);
else
{
c:/foo/bar.dll ==> /sysroot/c/foo/bar.dll. */
if (found_file < 0
- && !gdb_sysroot_is_empty
+ && sysroot != NULL
&& HAS_TARGET_DRIVE_SPEC (fskind, in_pathname))
{
int need_dir_separator = !IS_DIR_SEPARATOR (in_pathname[2]);
&temp_pathname);
/* If not found, next search the inferior's $PATH environment variable. */
- if (found_file < 0 && gdb_sysroot_is_empty)
+ if (found_file < 0 && sysroot == NULL)
found_file = openp (get_in_environ (current_inferior ()->environment,
"PATH"),
OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname,
/* If not found, next search the inferior's $LD_LIBRARY_PATH
environment variable. */
- if (found_file < 0 && gdb_sysroot_is_empty)
+ if (found_file < 0 && sysroot == NULL)
found_file = openp (get_in_environ (current_inferior ()->environment,
"LD_LIBRARY_PATH"),
OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname,