aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Gingold <gingold@adacore.com>2012-04-02 11:57:30 +0000
committerTristan Gingold <gingold@adacore.com>2012-04-02 11:57:30 +0000
commitece0061f93a5a99e3f5b063d271267b6414cd129 (patch)
treef0620d27dca274edddf58722ea36cb87948cb629
parentcf65ecd3b9293e2710da931249638cedded6a737 (diff)
downloadgdb-ece0061f93a5a99e3f5b063d271267b6414cd129.zip
gdb-ece0061f93a5a99e3f5b063d271267b6414cd129.tar.gz
gdb-ece0061f93a5a99e3f5b063d271267b6414cd129.tar.bz2
2012-04-02 Tristan Gingold <gingold@adacore.com>
PR gdb/13901 * darwin-nat.c (darwin_execvp): Sey binary preference.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/darwin-nat.c17
2 files changed, 22 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9a0a720..f76ee76 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2012-04-02 Tristan Gingold <gingold@adacore.com>
+
+ PR gdb/13901
+ * darwin-nat.c (darwin_execvp): Sey binary preference.
+
2012-04-02 Jan Kratochvil <jan.kratochvil@redhat.com>
* NEWS (set breakpoint condition-evaluation): Use imperative mood.
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index de661a3..010700c 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -39,6 +39,7 @@
#include "value.h"
#include "arch-utils.h"
#include "bfd.h"
+#include "bfd/mach-o.h"
#include <sys/ptrace.h>
#include <sys/signal.h>
@@ -1538,6 +1539,22 @@ darwin_execvp (const char *file, char * const argv[], char * const env[])
return;
}
+ /* Specify the same binary preference to spawn the shell as the
+ exec binary. This avoids spawning a 64bit shell while debugging
+ a 32bit program, which may confuse gdb.
+ Also, this slightly breaks internal layers as we suppose the binary
+ is Mach-O. Doesn't harm in practice. */
+ if (exec_bfd != NULL)
+ {
+ cpu_type_t pref;
+ size_t ocount;
+
+ pref = bfd_mach_o_get_data (exec_bfd)->header.cputype;
+ res = posix_spawnattr_setbinpref_np (&attr, 1, &pref, &ocount);
+ if (res != 0 || ocount != 1)
+ fprintf_unfiltered (gdb_stderr, "Cannot set posix_spawn binpref\n");
+ }
+
posix_spawnp (NULL, argv[0], NULL, &attr, argv, env);
}