Message ID | 1536593619-12889-1-git-send-email-roirand@adacore.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 51408 invoked by alias); 10 Sep 2018 15:33:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 51117 invoked by uid 89); 10 Sep 2018 15:33:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=H*RU:74.125.82.65, Hx-spam-relays-external:74.125.82.65 X-HELO: mail-wm0-f65.google.com Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Sep 2018 15:33:46 +0000 Received: by mail-wm0-f65.google.com with SMTP id f21-v6so22014177wmc.5 for <gdb-patches@sourceware.org>; Mon, 10 Sep 2018 08:33:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=YUPBEj7zy39KL5oK0eoeeN1afWOVMNL3JXSrFHspCy8=; b=TZP+kYaGlTyEt/c9HyriL2qyIuNYkvzKXS2Qy8V8bSpmlA0CqY4iE/sZPG2oL9oPMo WyQHwg70zxGLrpL6q7BeZVhve3Y+MsDnVBg6zqz1fXZqYCx3oJKds7RKIJODk39QQ2/Z PV8NmRmD+AMty16jZr4RYnDIj6t5EvjozSSmt0tGD64UhoRWVH1w0WIViNG+YdKD9A2O DdrNPi6XUHvqX4BrXgKK/1/yZgx3/9+TlL73TZxeLeNZ32q5H3YBVlZlByD8DzC9fjEy jeZWQ52luXq1DqFJvrCGWSfwexX09YDgp6NFaSfeZtZgZr9BkBLuXU1PRKxfszJ3nH+T 1+Cg== Return-Path: <roirand@adacore.com> Received: from adacore.com (static-css-csd-010062.business.bouyguestelecom.com. [176.162.10.62]) by smtp.gmail.com with ESMTPSA id a6-v6sm15164412wmf.22.2018.09.10.08.33.41 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Sep 2018 08:33:42 -0700 (PDT) Received: by adacore.com (sSMTP sendmail emulation); Mon, 10 Sep 2018 17:33:40 +0200 From: Xavier Roirand <roirand@adacore.com> To: gdb-patches@sourceware.org Cc: brobecker@adacore.com, simon.marchi@polymtl.ca, tom@tromey.com, Xavier Roirand <roirand@adacore.com> Subject: [RFA 3/5 v4] Darwin: set startup-with-shell to off on Sierra and later. Date: Mon, 10 Sep 2018 17:33:39 +0200 Message-Id: <1536593619-12889-1-git-send-email-roirand@adacore.com> X-IsSubscribed: yes |
Commit Message
Xavier Roirand
Sept. 10, 2018, 3:33 p.m. UTC
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 --- gdb/darwin-nat.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
Comments
On 2018-09-10 04:33 PM, Xavier Roirand wrote: > 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 > --- > gdb/darwin-nat.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c > index be80163d22e..eee9380d650 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, > Just to avoid confusion, I think this should actually be v5. The new change is the line wrapping. Still LGTM, thanks. Simon
Hello, Le 9/10/18 à 9:11 PM, Simon Marchi a écrit : > On 2018-09-10 04:33 PM, Xavier Roirand wrote: >> 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 >> --- >> gdb/darwin-nat.c | 28 ++++++++++++++++++++++++++++ >> 1 file changed, 28 insertions(+) >> >> diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c >> index be80163d22e..eee9380d650 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, >> > > Just to avoid confusion, I think this should actually be v5. The new change > is the line wrapping. Still LGTM, thanks. Agree :) Xavier > > Simon >
Thanks. Pushed to master. https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d6be54ef73eacaaf5bf28bafc7dfebc80ebac832 Le 9/10/18 à 9:11 PM, Simon Marchi a écrit : > On 2018-09-10 04:33 PM, Xavier Roirand wrote: >> 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 >> --- >> gdb/darwin-nat.c | 28 ++++++++++++++++++++++++++++ >> 1 file changed, 28 insertions(+) >> >> diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c >> index be80163d22e..eee9380d650 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, >> > > Just to avoid confusion, I think this should actually be v5. The new change > is the line wrapping. Still LGTM, thanks. > > Simon >
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index be80163d22e..eee9380d650 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,