From patchwork Wed Jul 4 04:30:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 28220 Received: (qmail 31487 invoked by alias); 4 Jul 2018 04:31:32 -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 31262 invoked by uid 89); 4 Jul 2018 04:31:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_SOFTFAIL, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=reserved, our X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Jul 2018 04:30:54 +0000 Received: from smtp.ebox.ca (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id RbxLg2YvQAMXgJJw (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 04 Jul 2018 00:30:36 -0400 (EDT) Received: from simark.lan (unknown [192.222.164.54]) by smtp.ebox.ca (Postfix) with ESMTP id 61A3C441D65; Wed, 4 Jul 2018 00:30:36 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: tom@tromey.com, Simon Marchi Subject: [PATCH 2/2] darwin: Don't use sbrk Date: Wed, 4 Jul 2018 00:30:33 -0400 Message-Id: <20180704043033.29212-2-simon.marchi@polymtl.ca> In-Reply-To: <20180704043033.29212-1-simon.marchi@polymtl.ca> References: <20180704043033.29212-1-simon.marchi@polymtl.ca> X-IsSubscribed: yes This patch gets rid of this warning on macOS: CXX main.o /Users/simark/src/binutils-gdb/gdb/main.c:492:27: error: 'sbrk' is deprecated [-Werror,-Wdeprecated-declarations] lim_at_start = (char *) sbrk (0); ^ /usr/include/unistd.h:585:1: note: 'sbrk' has been explicitly marked deprecated here __deprecated __WATCHOS_PROHIBITED __TVOS_PROHIBITED ^ /usr/include/sys/cdefs.h:176:37: note: expanded from macro '__deprecated' #define __deprecated __attribute__((deprecated)) ^ sbrk on macOS is not useful for our purposes, since sbrk(0) always returns the same value. From what I read, brk/sbrk on macOS is just an emulation, it always returns a pointer in a 4MB section reserved for that. So instead of letting users use "maint set per-command space on" and print silly results, I think we should just disable that feature for this platform (as we do for platforms that don't have sbrk). I defined a HAVE_USEFUL_SBRK macro and used that instead of HAVE_SBRK. gdb/ChangeLog: * common/common-defs.h (HAVE_USEFUL_SBRK): Define. * main.c: Use HAVE_USEFUL_SBRK instead of HAVE_SBRK. * maint.c: Likewise. * top.c: Likewise. --- gdb/common/common-defs.h | 4 ++++ gdb/main.c | 2 +- gdb/maint.c | 4 ++-- gdb/top.c | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h index eb0ec214926c..8209e13943d7 100644 --- a/gdb/common/common-defs.h +++ b/gdb/common/common-defs.h @@ -105,4 +105,8 @@ /* String containing the current directory (what getwd would return). */ extern char *current_directory; +#if defined (HAVE_SBRK) && !__APPLE__ +#define HAVE_USEFUL_SBRK 1 +#endif + #endif /* COMMON_DEFS_H */ diff --git a/gdb/main.c b/gdb/main.c index 9694af242699..e925128a4263 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -487,7 +487,7 @@ captured_main_1 (struct captured_main_args *context) int save_auto_load; struct objfile *objfile; -#ifdef HAVE_SBRK +#ifdef HAVE_USEFUL_SBRK /* Set this before constructing scoped_command_stats. */ lim_at_start = (char *) sbrk (0); #endif diff --git a/gdb/maint.c b/gdb/maint.c index a8a1fcbc2996..5d4701cfacca 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -828,7 +828,7 @@ scoped_command_stats::~scoped_command_stats () if (m_space_enabled && per_command_space) { -#ifdef HAVE_SBRK +#ifdef HAVE_USEFUL_SBRK char *lim = (char *) sbrk (0); long space_now = lim - lim_at_start; @@ -866,7 +866,7 @@ scoped_command_stats::scoped_command_stats (bool msg_type) { if (!m_msg_type || per_command_space) { -#ifdef HAVE_SBRK +#ifdef HAVE_USEFUL_SBRK char *lim = (char *) sbrk (0); m_start_space = lim - lim_at_start; m_space_enabled = 1; diff --git a/gdb/top.c b/gdb/top.c index fdef3e0d0bf2..de1a335e40a4 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -171,7 +171,7 @@ int remote_timeout = 2; int remote_debug = 0; /* Sbrk location on entry to main. Used for statistics only. */ -#ifdef HAVE_SBRK +#ifdef HAVE_USEFUL_SBRK char *lim_at_start; #endif