From 03856dd9c6469b770a5c804453f5f0333e88adc2 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Thu, 5 Jul 2018 23:23:06 +0000 Subject: [PATCH] Address a few post facto review comments from Adrian. Thanks, Adrian! llvm-svn: 336398 --- lldb/include/lldb/Target/Platform.h | 6 +++++- lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index 1e0eb6a..217b945 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -840,7 +840,11 @@ public: /// The process to load the image. /// /// @param[in] library_name - /// The name of the library to look for. + /// The name of the library to look for. If library_name is an + /// absolute path, the basename will be extracted and searched for + /// along the paths. This emulates the behavior of the loader when + /// given an install name and a set (e.g. DYLD_LIBRARY_PATH provided) of + /// alternate paths. /// /// @param[in] path_list /// The list of paths to use to search for the library. First diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index d351fcc..16934be 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -946,7 +946,7 @@ PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx, const char *error_str; }; - extern void *memcpy(void *, void *, size_t size); + extern void *memcpy(void *, const void *, size_t size); extern size_t strlen(const char *); @@ -956,23 +956,23 @@ PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx, __lldb_dlopen_result *result_ptr) { // This is the case where the name is the full path: - if (path_strings == (char *) 0x0) { + if (!path_strings) { result_ptr->image_ptr = dlopen(name, 2); - if (result_ptr->image_ptr != (void *) 0x0) + if (result_ptr->image_ptr) result_ptr->error_str = nullptr; return nullptr; } // This is the case where we have a list of paths: size_t name_len = strlen(name); - while (path_strings != (void *) 0x0 && path_strings[0] != '\0') { + while (path_strings && path_strings[0] != '\0') { size_t path_len = strlen(path_strings); memcpy((void *) buffer, (void *) path_strings, path_len); buffer[path_len] = '/'; char *target_ptr = buffer+path_len+1; memcpy((void *) target_ptr, (void *) name, name_len + 1); result_ptr->image_ptr = dlopen(buffer, 2); - if (result_ptr->image_ptr != (void *) 0x0) { + if (result_ptr->image_ptr) { result_ptr->error_str = nullptr; break; } -- 2.7.4