aboutsummaryrefslogtreecommitdiff
path: root/gdb/exec.c
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2015-04-17 09:47:30 +0100
committerGary Benson <gbenson@redhat.com>2015-04-17 09:47:30 +0100
commita9a5a3d1d27fc443934ed4919f69b34144288cf0 (patch)
tree3f8c3997e9e9664245cc5033998ba09c965c88ce /gdb/exec.c
parentaf1900b01b378126d8826591be7b7ec0d18271d7 (diff)
downloadgdb-a9a5a3d1d27fc443934ed4919f69b34144288cf0.zip
gdb-a9a5a3d1d27fc443934ed4919f69b34144288cf0.tar.gz
gdb-a9a5a3d1d27fc443934ed4919f69b34144288cf0.tar.bz2
Use gdb_sysroot for main executable on attach
This commit updates exec_file_locate_attach to use exec_file_find to compute the full pathname of the main executable in some cases. The net effect of this is that the main executable's path will be prefixed with gdb_sysroot in the same way that shared library paths currently are. gdb/ChangeLog: * exec.c (solist.h): New include. (exec_file_locate_attach): Prefix absolute executable paths with gdb_sysroot if set. * NEWS: Mention that executable paths may be prepended with sysroot. gdb/doc/ChangeLog: * gdb.texinfo (set sysroot): Document that "set sysroot" also applies to executable paths if supplied to GDB as absolute.
Diffstat (limited to 'gdb/exec.c')
-rw-r--r--gdb/exec.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/gdb/exec.c b/gdb/exec.c
index 9d4ad90..872b86c 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -42,6 +42,7 @@
#include <ctype.h>
#include <sys/stat.h>
+#include "solist.h"
void (*deprecated_file_changed_hook) (char *);
@@ -151,15 +152,30 @@ exec_file_locate_attach (int pid, int from_tty)
if (exec_file == NULL)
return;
- /* It's possible we don't have a full path, but rather just a
- filename. Some targets, such as HP-UX, don't provide the
- full path, sigh.
+ /* If gdb_sysroot is not empty and the discovered filename
+ is absolute then prefix the filename with gdb_sysroot. */
+ if (gdb_sysroot != NULL && *gdb_sysroot != '\0'
+ && IS_ABSOLUTE_PATH (exec_file))
+ {
+ int fd = -1;
+
+ full_exec_path = exec_file_find (exec_file, &fd);
+ if (fd >= 0)
+ close (fd);
+ }
- Attempt to qualify the filename against the source path.
- (If that fails, we'll just fall back on the original
- filename. Not much more we can do...) */
- if (!source_full_path_of (exec_file, &full_exec_path))
- full_exec_path = xstrdup (exec_file);
+ if (full_exec_path == NULL)
+ {
+ /* It's possible we don't have a full path, but rather just a
+ filename. Some targets, such as HP-UX, don't provide the
+ full path, sigh.
+
+ Attempt to qualify the filename against the source path.
+ (If that fails, we'll just fall back on the original
+ filename. Not much more we can do...) */
+ if (!source_full_path_of (exec_file, &full_exec_path))
+ full_exec_path = xstrdup (exec_file);
+ }
exec_file_attach (full_exec_path, from_tty);
symbol_file_add_main (full_exec_path, from_tty);