Skip to content

Commit 91b15c4

Browse files
committed
Only call malloc_usable_size under linux
under OSX `malloc_size` should have the same functionality.
1 parent b1e6f49 commit 91b15c4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/memory-analyzer/gdb_api.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ Author: Malte Mues <[email protected]>
1010
/// \file
1111
/// Low-level interface to gdb
1212

13+
#ifdef __linux__
14+
# include <malloc.h>
15+
#elif __APPLE__
16+
# include <malloc/malloc.h>
17+
#endif
1318

1419
#include <cctype>
1520
#include <cerrno>
@@ -59,7 +64,15 @@ gdb_apit::~gdb_apit()
5964

6065
size_t gdb_apit::query_malloc_size(const std::string &pointer_expr)
6166
{
67+
#ifdef __linux__
6268
write_to_gdb("-var-create tmp * malloc_usable_size(" + pointer_expr + ")");
69+
#elif __APPLE__
70+
write_to_gdb("-var-create tmp * malloc_size(" + pointer_expr + ")");
71+
#else
72+
// Under non-linux/OSX system we simple return 1, i.e. as if the \p
73+
// pointer_expr was not dynamically allocated.
74+
return 1;
75+
#endif
6376

6477
if(!was_command_accepted())
6578
{

0 commit comments

Comments
 (0)