Skip to content

Commit 47138b7

Browse files
committed
Only call malloc_usable_size under linux
and not under OSX or other systems that may not support it.
1 parent b1e6f49 commit 47138b7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/memory-analyzer/gdb_api.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ gdb_apit::~gdb_apit()
5959

6060
size_t gdb_apit::query_malloc_size(const std::string &pointer_expr)
6161
{
62+
#ifndef __linux__
63+
// The memory analyzer can be compiled under OSX and other systems that can
64+
// interact with the machine interface of gdb but `malloc_usable_size` is only
65+
// available under linux. Under non-linux system we simple return 1, i.e. as
66+
// if the \p pointer_expr was not dynamically allocated.
67+
return 1;
68+
#endif
69+
6270
write_to_gdb("-var-create tmp * malloc_usable_size(" + pointer_expr + ")");
6371

6472
if(!was_command_accepted())

0 commit comments

Comments
 (0)