This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Fix logic in exec_file_locate_attach
- From: Gary Benson <gary at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 24 Feb 2016 11:55:24 -0000
- Subject: [binutils-gdb] Fix logic in exec_file_locate_attach
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bf74e428bca61022bd5cdf6bf28789a184748b4d
commit bf74e428bca61022bd5cdf6bf28789a184748b4d
Author: Gary Benson <gbenson@redhat.com>
Date: Wed Feb 24 11:31:58 2016 +0000
Fix logic in exec_file_locate_attach
This commit fixes an error in exec_file_locate_attach where
the main executable could be loaded from outside the sysroot
if a nonempty, non-"target:" sysroot was set but the discovered
executable filename did not exist in that sysroot and did exist
on the main filesystem.
gdb/ChangeLog:
* exec.c (exec_file_locate_attach): Do not attempt to
locate main executable locally if not found in sysroot.
gdb/testsuite/ChangeLog:
* gdb.base/attach-pie-noexec.exp: Do not expect an error
message on attach.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/exec.c | 9 ++++++---
gdb/testsuite/ChangeLog | 5 +++++
gdb/testsuite/gdb.base/attach-pie-noexec.exp | 2 +-
4 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d6b4a6b..ea9f3f4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2016-02-24 Gary Benson <gbenson@redhat.com>
+
+ * exec.c (exec_file_locate_attach): Do not attempt to
+ locate main executable locally if not found in sysroot.
+
2016-02-24 Joel Brobecker <brobecker@adacore.com>
GDB 7.11 released.
diff --git a/gdb/exec.c b/gdb/exec.c
index 0b8c077..90811c0 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -156,9 +156,12 @@ exec_file_locate_attach (int pid, int from_tty)
/* If gdb_sysroot is not empty and the discovered filename
is absolute then prefix the filename with gdb_sysroot. */
if (*gdb_sysroot != '\0' && IS_ABSOLUTE_PATH (exec_file))
- full_exec_path = exec_file_find (exec_file, NULL);
-
- if (full_exec_path == NULL)
+ {
+ full_exec_path = exec_file_find (exec_file, NULL);
+ if (full_exec_path == NULL)
+ return;
+ }
+ else
{
/* 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
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 54dcfd6..1dcbe79 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-02-24 Gary Benson <gbenson@redhat.com>
+
+ * gdb.base/attach-pie-noexec.exp: Do not expect an error
+ message on attach.
+
2016-02-23 Doug Evans <dje@google.com>
* gdb.base/skip.c (test_skip): New function.
diff --git a/gdb/testsuite/gdb.base/attach-pie-noexec.exp b/gdb/testsuite/gdb.base/attach-pie-noexec.exp
index f3e693a..1a51049 100644
--- a/gdb/testsuite/gdb.base/attach-pie-noexec.exp
+++ b/gdb/testsuite/gdb.base/attach-pie-noexec.exp
@@ -60,7 +60,7 @@ set testpid [spawn_id_get_pid $test_spawn_id]
gdb_start
file delete -- $binfile
-gdb_test "attach $testpid" "Attaching to process $testpid\r\n.*: No such file or directory\\." "attach"
+gdb_test "attach $testpid" "Attaching to process $testpid\r\n.*" "attach"
gdb_test "set architecture $arch" "The target architecture is assumed to be $arch"
gdb_test "info shared" "From\[ \t\]+To\[ \t\]+Syms Read\[ \t\]+Shared Object Library\r\n0x.*"