merge dev-trace

This commit is contained in:
Daan 2021-12-10 12:09:14 -08:00
commit e3de22a067
3 changed files with 7 additions and 12 deletions

View file

@ -125,14 +125,9 @@ if(MI_DEBUG_FULL)
endif() endif()
if(MI_DEBUG_TRACE) if(MI_DEBUG_TRACE)
if (APPLE) message(STATUS "Enable allocation trace in each heap block (MI_DEBUG_TRACE=ON)")
message(WARNING "Cannot enable MI_DEBUG_TRACE on Apple") list(APPEND mi_defines MI_DEBUG_TRACE=1)
set(MI_DEBUG_TRACE OFF) set(CMAKE_ENABLE_EXPORTS TRUE)
else()
message(STATUS "Enable allocation trace in each heap block (MI_DEBUG_TRACE=ON)")
list(APPEND mi_defines MI_DEBUG_TRACE=1)
set(CMAKE_ENABLE_EXPORTS TRUE)
endif()
endif() endif()
if(MI_PADDING_EXTRA) if(MI_PADDING_EXTRA)

View file

@ -379,7 +379,7 @@ void _mi_stack_trace_print(const char* msg, void** strace, size_t len, const mi_
} }
} }
} }
#elif (MI_DEBUG_TRACE > 0) && (defined(__linux__) || defined(__FreeBSD__)) #elif (MI_DEBUG_TRACE > 0) && (defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__))
#include <execinfo.h> #include <execinfo.h>
#define MI_TRACE_LEN (64) #define MI_TRACE_LEN (64)
void _mi_stack_trace_capture(void** strace, size_t len, size_t skip) { void _mi_stack_trace_capture(void** strace, size_t len, size_t skip) {

View file

@ -194,8 +194,8 @@ int main() {
// detect double frees and heap corruption // detect double frees and heap corruption
// double_free1(); // double_free1();
// double_free2(); // double_free2();
// double_free3(); double_free3();
// corrupt_free1(); corrupt_free1();
// corrupt_free2(); // corrupt_free2();
// block_overflow1(); // block_overflow1();
// block_overflow2(); // block_overflow2();
@ -385,7 +385,7 @@ static void test_reserved(void) {
static void negative_stat(void) { static void negative_stat(void) {
int* p = mi_malloc(60000); int* p = (int*)mi_malloc(60000);
mi_stats_print_out(NULL, NULL); mi_stats_print_out(NULL, NULL);
*p = 100; *p = 100;
mi_free(p); mi_free(p);