[haiku-commits] haiku: hrev49025 - src/system/kernel src/system/runtime_loader src/system/libroot/posix/malloc_debug headers/private/runtime_loader headers/private/system

  • From: mmlr@xxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 11 Apr 2015 11:18:51 +0200 (CEST)

hrev49025 adds 3 changesets to branch 'master'
old head: 215756b065d8c65e0c0fbfd4b7e62fee87511e92
new head: 459e651fd518aaecda9ff6079ea0385456e0be5b
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=459e651fd518+%5E215756b065d8

----------------------------------------------------------------------------

ebdc1d480e80: runtime_loader: Add imageName and exactMatch to symbol lookup.

Extend the get_nearest_symbol_at_address() private runtime_loader
export to include imageName and exactMatch arguments.

The imageName holds the SONAME of the image, if available, so cannot
neccessarily be extracted from the image path.

Whether or not there was an exact match, i.e. the symbol with its size
contains the address, is now returned in exactMatch.

bd5dea318a09: 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.

459e651fd518: syscalls: Remove lookup_symbol syscall again.

This partially reverts b959d46dbd2f9087ae860dbced40440c28596a6e.

[ Michael Lotz <mmlr@xxxxxxxx> ]

----------------------------------------------------------------------------

9 files changed, 25 insertions(+), 63 deletions(-)
headers/private/kernel/elf.h | 5 ---
headers/private/runtime_loader/runtime_loader.h | 4 +--
headers/private/system/syscalls.h | 4 ---
src/system/kernel/elf.cpp | 38 --------------------
src/system/libroot/posix/dlfcn.c | 2 +-
src/system/libroot/posix/malloc_debug/Jamfile | 2 +-
.../libroot/posix/malloc_debug/guarded_heap.cpp | 15 ++++----
src/system/runtime_loader/elf.cpp | 15 +++++---
.../runtime_loader/runtime_loader_private.h | 3 +-

############################################################################

Commit: ebdc1d480e809b6ab0b1ad58822a21395706be25
URL: http://cgit.haiku-os.org/haiku/commit/?id=ebdc1d480e80
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Sat Apr 11 09:00:07 2015 UTC

runtime_loader: Add imageName and exactMatch to symbol lookup.

Extend the get_nearest_symbol_at_address() private runtime_loader
export to include imageName and exactMatch arguments.

The imageName holds the SONAME of the image, if available, so cannot
neccessarily be extracted from the image path.

Whether or not there was an exact match, i.e. the symbol with its size
contains the address, is now returned in exactMatch.

----------------------------------------------------------------------------

diff --git a/headers/private/runtime_loader/runtime_loader.h
b/headers/private/runtime_loader/runtime_loader.h
index 6fa83bb..ab4c3b2 100644
--- a/headers/private/runtime_loader/runtime_loader.h
+++ b/headers/private/runtime_loader/runtime_loader.h
@@ -38,8 +38,8 @@ struct rld_export {
char *symbolName, int32 *nameLength, int32 *symbolType,
void **_location);
status_t (*get_nearest_symbol_at_address)(void* address,
- image_id* _imageID, char** _imagePath, char** _symbolName,
- int32* _type, void** _location);
+ image_id* _imageID, char** _imagePath, char** _imageName,
+ char** _symbolName, int32* _type, void** _location, bool*
_exactMatch);
status_t (*test_executable)(const char *path, char *interpreter);
status_t (*get_executable_architecture)(const char *path,
const char** _architecture);
diff --git a/src/system/libroot/posix/dlfcn.c b/src/system/libroot/posix/dlfcn.c
index d85c649..58fb161 100644
--- a/src/system/libroot/posix/dlfcn.c
+++ b/src/system/libroot/posix/dlfcn.c
@@ -81,7 +81,7 @@ dladdr(void *address, Dl_info *info)
image_info imageInfo;

sStatus = __gRuntimeLoader->get_nearest_symbol_at_address(address,
&image,
- &imagePath, &symbolName, NULL, &location);
+ &imagePath, NULL, &symbolName, NULL, &location, NULL);
if (sStatus != B_OK)
return 0;

diff --git a/src/system/runtime_loader/elf.cpp
b/src/system/runtime_loader/elf.cpp
index 37ccc5e..6d30bbb 100644
--- a/src/system/runtime_loader/elf.cpp
+++ b/src/system/runtime_loader/elf.cpp
@@ -713,7 +713,8 @@ out:

status_t
get_nearest_symbol_at_address(void* address, image_id* _imageID,
- char** _imagePath, char** _symbolName, int32* _type, void** _location)
+ char** _imagePath, char** _imageName, char** _symbolName, int32* _type,
+ void** _location, bool* _exactMatch)
{
rld_lock();

@@ -723,11 +724,11 @@ get_nearest_symbol_at_address(void* address, image_id*
_imageID,
return B_BAD_VALUE;
}

+ bool exactMatch = false;
elf_sym* foundSymbol = NULL;
addr_t foundLocation = (addr_t)NULL;

- bool found = false;
- for (uint32 i = 0; i < HASHTABSIZE(image) && !found; i++) {
+ for (uint32 i = 0; i < HASHTABSIZE(image) && !exactMatch; i++) {
for (int32 j = HASHBUCKETS(image)[i]; j != STN_UNDEF;
j = HASHCHAINS(image)[j]) {
elf_sym *symbol = &image->syms[j];
@@ -738,8 +739,8 @@ get_nearest_symbol_at_address(void* address, image_id*
_imageID,
foundLocation = location;

// jump out if we have an exact match
- if (foundLocation == (addr_t)address) {
- found = true;
+ if (location + symbol->st_size >
(addr_t)address) {
+ exactMatch = true;
break;
}
}
@@ -750,6 +751,10 @@ get_nearest_symbol_at_address(void* address, image_id*
_imageID,
*_imageID = image->id;
if (_imagePath != NULL)
*_imagePath = image->path;
+ if (_imageName != NULL)
+ *_imageName = image->name;
+ if (_exactMatch != NULL)
+ *_exactMatch = exactMatch;

if (foundSymbol != NULL) {
*_symbolName = SYMNAME(image, foundSymbol);
diff --git a/src/system/runtime_loader/runtime_loader_private.h
b/src/system/runtime_loader/runtime_loader_private.h
index 7774e12..be40233 100644
--- a/src/system/runtime_loader/runtime_loader_private.h
+++ b/src/system/runtime_loader/runtime_loader_private.h
@@ -68,7 +68,8 @@ status_t unload_library(void* handle, image_id imageID, bool
addOn);
status_t get_nth_symbol(image_id imageID, int32 num, char* nameBuffer,
int32* _nameLength, int32* _type, void** _location);
status_t get_nearest_symbol_at_address(void* address, image_id* _imageID,
- char** _imagePath, char** _symbolName, int32* _type, void** _location);
+ char** _imagePath, char** _imageName, char** _symbolName, int32* _type,
+ void** _location, bool* _exactMatch);
status_t get_symbol(image_id imageID, char const* symbolName, int32 symbolType,
bool recursive, image_id* _inImage, void** _location);
status_t get_library_symbol(void* handle, void* caller, const char* symbolName,

############################################################################

Commit: bd5dea318a091a3ff074ed1823cd961473177c9a
URL: http://cgit.haiku-os.org/haiku/commit/?id=bd5dea318a09
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Sat Apr 11 09:11:30 2015 UTC

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.

----------------------------------------------------------------------------

diff --git a/src/system/libroot/posix/malloc_debug/Jamfile
b/src/system/libroot/posix/malloc_debug/Jamfile
index ef1d3f3..98d3b0b 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 5475c03..12fb7f5 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 <locks.h>
#include <syscalls.h>

+#include <runtime_loader.h>
+

// #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)");
}
}


############################################################################

Revision: hrev49025
Commit: 459e651fd518aaecda9ff6079ea0385456e0be5b
URL: http://cgit.haiku-os.org/haiku/commit/?id=459e651fd518
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Sat Apr 11 09:13:33 2015 UTC

syscalls: Remove lookup_symbol syscall again.

This partially reverts b959d46dbd2f9087ae860dbced40440c28596a6e.

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/elf.h b/headers/private/kernel/elf.h
index b8c6a42..3851504 100644
--- a/headers/private/kernel/elf.h
+++ b/headers/private/kernel/elf.h
@@ -54,11 +54,6 @@ status_t _user_read_kernel_image_symbols(image_id id,
elf_sym* symbolTable,
int32* _symbolCount, char* stringTable, size_t*
_stringTableSize,
addr_t* _imageDelta);

-status_t _user_lookup_symbol(addr_t address, addr_t* baseAddress,
- char* symbolNameBuffer, size_t symbolNameBufferSize,
- char* imageNameBuffer, size_t imageNameBufferSize,
- bool* exactMatch);
-
#ifdef __cplusplus
}
#endif
diff --git a/headers/private/system/syscalls.h
b/headers/private/system/syscalls.h
index f55639b..8cd608c 100644
--- a/headers/private/system/syscalls.h
+++ b/headers/private/system/syscalls.h
@@ -494,10 +494,6 @@ extern status_t _kern_system_profiler_recorded(

extern ssize_t _kern_get_stack_trace(size_t addressCount,
addr_t* adresses);
-extern status_t _kern_lookup_symbol(addr_t address, addr_t*
baseAddress,
- char* symbolNameBuffer, size_t
symbolNameBufferSize,
- char* imageNameBuffer, size_t
imageNameBufferSize,
- bool* exactMatch);

/* atomic_* ops (needed for CPUs that don't support them directly) */
#ifdef ATOMIC_FUNCS_ARE_SYSCALLS
diff --git a/src/system/kernel/elf.cpp b/src/system/kernel/elf.cpp
index 1e876b7..66764f7 100644
--- a/src/system/kernel/elf.cpp
+++ b/src/system/kernel/elf.cpp
@@ -2686,41 +2686,3 @@ _user_read_kernel_image_symbols(image_id id, elf_sym*
symbolTable,

return B_OK;
}
-
-
-status_t
-_user_lookup_symbol(addr_t address, addr_t* userBaseAddress,
- char* userSymbolNameBuffer, size_t symbolNameBufferSize,
- char* userImageNameBuffer, size_t imageNameBufferSize, bool*
userExactMatch)
-{
- MutexLocker locker(&sImageMutex);
-
- addr_t baseAddress;
- const char *symbolName;
- const char *imageName;
- bool exactMatch;
- status_t status;
-
- if (IS_KERNEL_ADDRESS(address)) {
- status = elf_debug_lookup_symbol_address(address, &baseAddress,
- &symbolName, &imageName, &exactMatch);
- } else {
- status = elf_debug_lookup_user_symbol_address(
- thread_get_current_thread()->team, address,
&baseAddress,
- &symbolName, &imageName, &exactMatch);
- }
-
- if (status != B_OK)
- return status;
-
- if (user_memcpy(userBaseAddress, &baseAddress, sizeof(addr_t)) != B_OK
- || user_memcpy(userExactMatch, &exactMatch, sizeof(bool)) !=
B_OK
- || user_strlcpy(userSymbolNameBuffer, symbolName,
symbolNameBufferSize)
- < 0
- || user_strlcpy(userImageNameBuffer, imageName,
imageNameBufferSize)
- < 0) {
- return B_BAD_ADDRESS;
- }
-
- return B_OK;
-}


Other related posts:

  • » [haiku-commits] haiku: hrev49025 - src/system/kernel src/system/runtime_loader src/system/libroot/posix/malloc_debug headers/private/runtime_loader headers/private/system - mmlr