Skip to content

Commit

Permalink
Fixed probing for stack trace availability (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Boswell authored Nov 5, 2019
1 parent cbf339c commit 4bd17cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 0 additions & 4 deletions include/aws/common/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ enum aws_mem_trace_level {
AWS_MEMTRACE_STACKS = 2, /* capture callstacks for each allocation */
};

#if defined(AWS_HAVE_EXECINFO) || defined(WIN32) || defined(__APPLE__)
# define AWS_MEMTRACE_STACKS_AVAILABLE
#endif

/*
* Wraps an allocator and tracks all external allocations. If aws_mem_trace_dump() is called
* and there are still allocations active, they will be reported to the aws_logger at TRACE level.
Expand Down
9 changes: 6 additions & 3 deletions tests/memtrace_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ static struct aws_logger s_test_logger;

static int s_test_memtrace_stacks(struct aws_allocator *allocator, void *ctx) {
(void)ctx;
#if !defined(AWS_MEMTRACE_STACKS_AVAILABLE)
return 0;
#endif

/* only bother to run this test if the platform can do a backtrace */
void *probe_stack[1];
if (!aws_backtrace(probe_stack, 1)) {
return 0;
}

test_logger_init(&s_test_logger, allocator, AWS_LL_TRACE, 0);
aws_logger_set(&s_test_logger);
Expand Down

0 comments on commit 4bd17cf

Please sign in to comment.