aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Roirand <roirand@adacore.com>2018-09-08 16:51:21 +0200
committerXavier Roirand <roirand@adacore.com>2018-09-11 15:42:18 +0200
commitd6be54ef73eacaaf5bf28bafc7dfebc80ebac832 (patch)
tree73b5ff49510eb578e03a8fa569c2904df81a0e8a
parentde1ec836c8cc4eeb68e3e4eb8223eeff9840546e (diff)
downloadfsf-binutils-gdb-d6be54ef73eacaaf5bf28bafc7dfebc80ebac832.zip
fsf-binutils-gdb-d6be54ef73eacaaf5bf28bafc7dfebc80ebac832.tar.gz
fsf-binutils-gdb-d6be54ef73eacaaf5bf28bafc7dfebc80ebac832.tar.bz2
Darwin: set startup-with-shell to off on Sierra and later.
On Mac OS X Sierra and later, the shell is not allowed to be debug so add a check and disable startup with shell in that case. This disabling is done temporary before forking inferior and restored after the fork. gdb/ChangeLog: * darwin-nat.c (should_disable_startup_with_shell): New function. (darwin_nat_target::create_inferior): Add call. Change-Id: Ie4d9090f65fdf2e83ecf7a0f9d0647fb1c27cdcc
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/darwin-nat.c28
2 files changed, 34 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1469366..5f84805 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2018-09-11 Xavier Roirand <roirand@adacore.com>
+ * darwin-nat.c (should_disable_startup_with_shell):
+ New function.
+ (darwin_nat_target::create_inferior): Add call.
+
+2018-09-11 Xavier Roirand <roirand@adacore.com>
+
* darwin-nat.h (struct darwin_thread_info) <gdb_port,
inf_port, msg_state>: Initialize.
(struct darwin_thread_info) <signaled, single_step>: Change
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index be80163..eee9380 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1854,11 +1854,39 @@ darwin_execvp (const char *file, char * const argv[], char * const env[])
posix_spawnp (NULL, argv[0], NULL, &attr, argv, env);
}
+/* Read kernel version, and return TRUE on Sierra or later. */
+
+static bool
+should_disable_startup_with_shell ()
+{
+ char str[16];
+ size_t sz = sizeof (str);
+ int ret;
+
+ ret = sysctlbyname ("kern.osrelease", str, &sz, NULL, 0);
+ if (ret == 0 && sz < sizeof (str))
+ {
+ unsigned long ver = strtoul (str, NULL, 10);
+ if (ver >= 16)
+ return true;
+ }
+ return false;
+}
+
void
darwin_nat_target::create_inferior (const char *exec_file,
const std::string &allargs,
char **env, int from_tty)
{
+ gdb::optional<scoped_restore_tmpl<int>> restore_startup_with_shell;
+
+ if (startup_with_shell && should_disable_startup_with_shell ())
+ {
+ warning (_("startup-with-shell not supported on this macOS version,"
+ " disabling it."));
+ restore_startup_with_shell.emplace (&startup_with_shell, 0);
+ }
+
/* Do the hard work. */
fork_inferior (exec_file, allargs, env, darwin_ptrace_me,
darwin_ptrace_him, darwin_pre_ptrace, NULL,