diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2018-07-04 12:40:25 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2018-07-04 12:40:25 -0400 |
commit | 6242c6a690ce8e18aad711103902bfff00cc2757 (patch) | |
tree | fc9b9cc1d2ceaa39b8cc0be111137d781bafacdf /gdb/common | |
parent | 4e5b2f8961a385056922f45a5cbb02bbbad4a737 (diff) | |
download | binutils-6242c6a690ce8e18aad711103902bfff00cc2757.zip binutils-6242c6a690ce8e18aad711103902bfff00cc2757.tar.gz binutils-6242c6a690ce8e18aad711103902bfff00cc2757.tar.bz2 |
darwin: Don't use sbrk
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.
Diffstat (limited to 'gdb/common')
-rw-r--r-- | gdb/common/common-defs.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h index eb0ec21..80f1ff4 100644 --- a/gdb/common/common-defs.h +++ b/gdb/common/common-defs.h @@ -105,4 +105,13 @@ /* String containing the current directory (what getwd would return). */ extern char *current_directory; +/* sbrk on macOS is not useful for our purposes, since sbrk(0) always + returns the same value. brk/sbrk on macOS is just an emulation + that always returns a pointer to a 4MB section reserved for + that. */ + +#if defined (HAVE_SBRK) && !__APPLE__ +#define HAVE_USEFUL_SBRK 1 +#endif + #endif /* COMMON_DEFS_H */ |