From bd5dea318a091a3ff074ed1823cd961473177c9a Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 11 Apr 2015 11:11:30 +0200 Subject: [PATCH] guarded_heap: Replace symbol lookup syscall with runtime_loader. Use the private runtime_loader API to do the symbol lookup instead of using the syscall. --- src/system/libroot/posix/malloc_debug/Jamfile | 2 +- .../libroot/posix/malloc_debug/guarded_heap.cpp | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/system/libroot/posix/malloc_debug/Jamfile b/src/system/libroot/posix/malloc_debug/Jamfile index ef1d3f3ac6..98d3b0bc58 100644 --- a/src/system/libroot/posix/malloc_debug/Jamfile +++ b/src/system/libroot/posix/malloc_debug/Jamfile @@ -1,6 +1,6 @@ SubDir HAIKU_TOP src system libroot posix malloc_debug ; -UsePrivateHeaders libroot shared ; +UsePrivateHeaders libroot shared runtime_loader ; local architectureObject ; for architectureObject in [ MultiArchSubDirSetup ] { diff --git a/src/system/libroot/posix/malloc_debug/guarded_heap.cpp b/src/system/libroot/posix/malloc_debug/guarded_heap.cpp index 5475c03e45..12fb7f5baf 100644 --- a/src/system/libroot/posix/malloc_debug/guarded_heap.cpp +++ b/src/system/libroot/posix/malloc_debug/guarded_heap.cpp @@ -15,6 +15,8 @@ #include #include +#include + // #pragma mark - Debug Helpers @@ -224,16 +226,17 @@ guarded_heap_page_protect(guarded_heap_area& area, size_t pageIndex, static void guarded_heap_print_stack_trace(addr_t stackTrace[], size_t depth) { - addr_t baseAddress; - char symbolName[1024]; - char imageName[B_PATH_NAME_LENGTH]; + char* imageName; + char* symbolName; + void* location; bool exactMatch; for (size_t i = 0; i < depth; i++) { addr_t address = stackTrace[i]; - status_t status = _kern_lookup_symbol(address, &baseAddress, symbolName, - sizeof(symbolName), imageName, sizeof(imageName), &exactMatch); + status_t status = __gRuntimeLoader->get_nearest_symbol_at_address( + (void*)address, NULL, NULL, &imageName, &symbolName, NULL, + &location, &exactMatch); if (status != B_OK) { print_stdout("\t%#" B_PRIxADDR " (lookup failed: %s)\n", address, strerror(status)); @@ -241,7 +244,7 @@ guarded_heap_print_stack_trace(addr_t stackTrace[], size_t depth) } print_stdout("\t<%s> %s + %#" B_PRIxADDR "%s\n", imageName, symbolName, - address - baseAddress, (exactMatch ? "" : " (nearest)")); + address - (addr_t)location, exactMatch ? "" : " (nearest)"); } }