From patchwork Wed Aug 22 10:11:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Roirand X-Patchwork-Id: 29006 Received: (qmail 60397 invoked by alias); 22 Aug 2018 10:11:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 60287 invoked by uid 89); 22 Aug 2018 10:11:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 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= X-HELO: mail-wr1-f65.google.com Received: from mail-wr1-f65.google.com (HELO mail-wr1-f65.google.com) (209.85.221.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Aug 2018 10:11:31 +0000 Received: by mail-wr1-f65.google.com with SMTP id v17-v6so1134816wrr.9 for ; Wed, 22 Aug 2018 03:11:30 -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:in-reply-to:references; bh=mznWm0+QwoEhRY6sKb1YxIg3iIyVHWb6G7hDbLl7ZvA=; b=FmuQJ+PyFjEnekDF+OFWrUQvbmsDdgfs6wZQyUuw3VHPBx/u+903TItjEVw6HlkAcI w/GNPFo2R8Bwu9iTvZk3+NBcK6WoBVW2XE7No/8K13gy/qQg5iWdT1uipa/SGfJE8CpC lIQdOmpVmR5x+VAZ/DK/NcLdX1Ba0GVfB2S6spOpyAj7i9p/RPHNlSX07jJ6hYEMSaB7 BwQqCW6mLqZ0qdkL60JtitpcrH0Aa+YEJE99lE33uGE8G+eFiaaykIrPIDiZ7SJKIRYM YYS/dtT24we8Kzh73GKObRuXLiVKFl2EPx+it6xytxTyWgt9j0pyNwOsOeU0Ea/yCkKz T94A== Return-Path: Received: from adacore.com ([46.18.100.10]) by smtp.gmail.com with ESMTPSA id n11-v6sm1280859wra.26.2018.08.22.03.11.27 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 22 Aug 2018 03:11:28 -0700 (PDT) Received: by adacore.com (sSMTP sendmail emulation); Wed, 22 Aug 2018 12:11:26 +0200 From: Xavier Roirand To: gdb-patches@sourceware.org Cc: brobecker@adacore.com, Xavier Roirand Subject: [RFA 3/5] Darwin: set startup-with-shell to off on Sierra and later. Date: Wed, 22 Aug 2018 12:11:15 +0200 Message-Id: <1534932677-9496-4-git-send-email-roirand@adacore.com> In-Reply-To: <1534932677-9496-1-git-send-email-roirand@adacore.com> References: <1534932677-9496-1-git-send-email-roirand@adacore.com> X-IsSubscribed: yes 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. gdb/ChangeLog: * darwin-nat.c (disable_startup_with_shell): New function. (_initialize_darwin_inferior): Add call. Change-Id: Ia3cbeaa89b2b44a173b93ee22cce0d3884a16924 --- gdb/darwin-nat.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index be80163..96f70cf 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -2362,6 +2362,26 @@ darwin_nat_target::supports_multi_process () return true; } +/* Read kernel version, and set startup-with-shell to false on Sierra or + later. */ + +void +disable_startup_with_shell () +{ + char str[16]; + size_t sz = sizeof (str); + int ret; + unsigned long ver; + + ret = sysctlbyname ("kern.osrelease", str, &sz, NULL, 0); + if (ret == 0 && sz < sizeof (str)) + { + ver = strtoul (str, NULL, 10); + if (ver >= 16) + startup_with_shell = 0; + } +} + void _initialize_darwin_nat () { @@ -2396,4 +2416,6 @@ When this mode is on, all low level exceptions are reported before being\n\ reported by the kernel."), &set_enable_mach_exceptions, NULL, &setlist, &showlist); + + disable_startup_with_shell (); }