[Lldb-commits] [PATCH] D114675: [lldb] [Target] Support fallback to file address in ReadMemory()

2021-11-28 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski.
Herald added a subscriber: arichardson.
mgorny requested review of this revision.

Add a fallback to `GetFileAddress()` when `GetLoadAddress()` fails
in `ReadMemory()`.  This is consistent with how expression evaluation
behaves, and fixes the inconsistency between the two following commands
run on top of FreeBSD vmcore:

- `p *(int *)&hz` (prints correct value)
- `memory read &hz` (prints zeros)


https://reviews.llvm.org/D114675

Files:
  lldb/source/Target/Target.cpp


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1782,36 +1782,27 @@
   if (ProcessIsValid()) {
 if (load_addr == LLDB_INVALID_ADDRESS)
   load_addr = resolved_addr.GetLoadAddress(this);
-
-if (load_addr == LLDB_INVALID_ADDRESS) {
-  ModuleSP addr_module_sp(resolved_addr.GetModule());
-  if (addr_module_sp && addr_module_sp->GetFileSpec())
-error.SetErrorStringWithFormatv(
-"{0:F}[{1:x+}] can't be resolved, {0:F} is not currently loaded",
-addr_module_sp->GetFileSpec(), resolved_addr.GetFileAddress());
-  else
-error.SetErrorStringWithFormat("0x%" PRIx64 " can't be resolved",
-   resolved_addr.GetFileAddress());
-} else {
-  bytes_read = m_process_sp->ReadMemory(load_addr, dst, dst_len, error);
-  if (bytes_read != dst_len) {
-if (error.Success()) {
-  if (bytes_read == 0)
-error.SetErrorStringWithFormat(
-"read memory from 0x%" PRIx64 " failed", load_addr);
-  else
-error.SetErrorStringWithFormat(
-"only %" PRIu64 " of %" PRIu64
-" bytes were read from memory at 0x%" PRIx64,
-(uint64_t)bytes_read, (uint64_t)dst_len, load_addr);
-}
-  }
-  if (bytes_read) {
-if (load_addr_ptr)
-  *load_addr_ptr = load_addr;
-return bytes_read;
+if (load_addr == LLDB_INVALID_ADDRESS)
+  load_addr = resolved_addr.GetFileAddress();
+
+bytes_read = m_process_sp->ReadMemory(load_addr, dst, dst_len, error);
+if (bytes_read != dst_len) {
+  if (error.Success()) {
+if (bytes_read == 0)
+  error.SetErrorStringWithFormat(
+  "read memory from 0x%" PRIx64 " failed", load_addr);
+else
+  error.SetErrorStringWithFormat(
+  "only %" PRIu64 " of %" PRIu64
+  " bytes were read from memory at 0x%" PRIx64,
+  (uint64_t)bytes_read, (uint64_t)dst_len, load_addr);
   }
 }
+if (bytes_read) {
+  if (load_addr_ptr)
+*load_addr_ptr = load_addr;
+  return bytes_read;
+}
   }
 
   if (file_cache_read_buffer && file_cache_bytes_read > 0) {


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1782,36 +1782,27 @@
   if (ProcessIsValid()) {
 if (load_addr == LLDB_INVALID_ADDRESS)
   load_addr = resolved_addr.GetLoadAddress(this);
-
-if (load_addr == LLDB_INVALID_ADDRESS) {
-  ModuleSP addr_module_sp(resolved_addr.GetModule());
-  if (addr_module_sp && addr_module_sp->GetFileSpec())
-error.SetErrorStringWithFormatv(
-"{0:F}[{1:x+}] can't be resolved, {0:F} is not currently loaded",
-addr_module_sp->GetFileSpec(), resolved_addr.GetFileAddress());
-  else
-error.SetErrorStringWithFormat("0x%" PRIx64 " can't be resolved",
-   resolved_addr.GetFileAddress());
-} else {
-  bytes_read = m_process_sp->ReadMemory(load_addr, dst, dst_len, error);
-  if (bytes_read != dst_len) {
-if (error.Success()) {
-  if (bytes_read == 0)
-error.SetErrorStringWithFormat(
-"read memory from 0x%" PRIx64 " failed", load_addr);
-  else
-error.SetErrorStringWithFormat(
-"only %" PRIu64 " of %" PRIu64
-" bytes were read from memory at 0x%" PRIx64,
-(uint64_t)bytes_read, (uint64_t)dst_len, load_addr);
-}
-  }
-  if (bytes_read) {
-if (load_addr_ptr)
-  *load_addr_ptr = load_addr;
-return bytes_read;
+if (load_addr == LLDB_INVALID_ADDRESS)
+  load_addr = resolved_addr.GetFileAddress();
+
+bytes_read = m_process_sp->ReadMemory(load_addr, dst, dst_len, error);
+if (bytes_read != dst_len) {
+  if (error.Success()) {
+if (bytes_read == 0)
+  error.SetErrorStringWithFormat(
+  "read memory from 0x%" PRIx64 " failed", load_addr);
+else
+  error.SetErrorStringWithFormat(
+  "only %" PRIu64 " of %" PRIu64
+  " bytes were read from memory at 0x%" PRIx64,
+   

[Lldb-commits] [PATCH] D114668: [lldb] Move generic DWARFASTParser code out of Clang-specific code

2021-11-28 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp:77
+  default:
+  case DW_AT_abstract_origin:
+  case DW_AT_accessibility:

Why we are including just these specific attributes? Maybe we should add a 
comment explaining it. According to the DWARF standard, any attribute is 
eligible for any tag.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114668/new/

https://reviews.llvm.org/D114668

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 6488bd1 - test: add a lit configuration for Windows subdirectory

2021-11-28 Thread Saleem Abdulrasool via lldb-commits

Author: Saleem Abdulrasool
Date: 2021-11-28T18:27:47-08:00
New Revision: 6488bd1d51715501632778e3c9a1d4eedfac2998

URL: 
https://github.com/llvm/llvm-project/commit/6488bd1d51715501632778e3c9a1d4eedfac2998
DIFF: 
https://github.com/llvm/llvm-project/commit/6488bd1d51715501632778e3c9a1d4eedfac2998.diff

LOG: test: add a lit configuration for Windows subdirectory

This adds a local configuration to the Windows subdirectory to filter
out the tests on non-Windows platforms using the lit filtering.

Added: 
lldb/test/Shell/Process/Windows/lit.local.cfg

Modified: 


Removed: 




diff  --git a/lldb/test/Shell/Process/Windows/lit.local.cfg 
b/lldb/test/Shell/Process/Windows/lit.local.cfg
new file mode 100644
index 0..c10f33b2ad4b6
--- /dev/null
+++ b/lldb/test/Shell/Process/Windows/lit.local.cfg
@@ -0,0 +1,2 @@
+if 'system-windows' not in config.available_features:
+  config.unsupported = True



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112564: [lldb] Add support for custom char8_t types with different name

2021-11-28 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 added a comment.

In D112564#3089399 , @labath wrote:

> What exactly do you need the test to do? Is printing a global variable 
> (`char8_t_ish foo[] = "my string"`) sufficient?
> If so, you can take a look at the tests in `test/Shell/SymbolFile/DWARF` for 
> inspiration. There are .s and .ll tests there.
> The pattern would roughly be:
>
>   # RUN: llvm-mc (or llc) -o %t %s
>   # RUN: %lldb %t -o "target variable foo" | FileCheck %s
>   
>   # CHECK: (char8_t_ish[]) foo = "my string"
>   
>   your code here

I was writing the tests locally, although I can't reproduce the failure with a 
simple type. I can get the error when using a custom LLDB formatter, however. 
See 
https://github.com/ljmf00/lldb-d/blob/main/lldb/source/Plugins/Language/D/DTypeUtils.cpp#L82
 . I should also rename this patch to something less misleading, since it is 
not the type name the issue, I just got this right due to fallback on invalid 
encoding on my side.

That said, do you know an easier way to test this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112564/new/

https://reviews.llvm.org/D112564

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77287: Windows: support `DoLoadImage`

2021-11-28 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd updated this revision to Diff 390245.
compnerd retitled this revision from "Windows: add very basic support for 
`DoLoadImage`" to "Windows: support `DoLoadImage`".
compnerd edited the summary of this revision.
compnerd added a comment.

This is a more complete implementation that allows for error reporting and use 
of UCS-2 as that is needed for the search path alteration.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77287/new/

https://reviews.llvm.org/D77287

Files:
  lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
  lldb/source/Plugins/Platform/Windows/PlatformWindows.h
  lldb/test/Shell/Process/Windows/process_load.cpp

Index: lldb/test/Shell/Process/Windows/process_load.cpp
===
--- /dev/null
+++ lldb/test/Shell/Process/Windows/process_load.cpp
@@ -0,0 +1,12 @@
+// clang-format off
+
+// REQUIRES: system-windows
+// RUN: %build --compiler=clang-cl -o %t.exe -- %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -o "b main" -o "process launch" -o "process load kernel32.dll" | FileCheck %s
+
+int main(int argc, char *argv[]) {
+  return 0;
+}
+
+// CHECK: "Loading "kernel32.dll"...ok{{.*}}
+// CHECK: Image 0 loaded.
Index: lldb/source/Plugins/Platform/Windows/PlatformWindows.h
===
--- lldb/source/Plugins/Platform/Windows/PlatformWindows.h
+++ lldb/source/Plugins/Platform/Windows/PlatformWindows.h
@@ -44,6 +44,15 @@
 
   lldb_private::Status DisconnectRemote() override;
 
+  uint32_t DoLoadImage(lldb_private::Process *process,
+   const lldb_private::FileSpec &remote_file,
+   const std::vector *paths,
+   lldb_private::Status &error,
+   lldb_private::FileSpec *loaded_path) override;
+
+  lldb_private::Status UnloadImage(lldb_private::Process *process,
+   uint32_t image_token) override;
+
   lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
lldb_private::Debugger &debugger,
lldb_private::Target &target,
@@ -71,6 +80,15 @@
  BreakpointSite *bp_site) override;
 
   std::vector m_supported_architectures;
+
+private:
+  std::unique_ptr
+  MakeLoadImageUtilityFunction(lldb_private::ExecutionContext &context,
+   lldb_private::Status &status);
+
+  lldb_private::Status EvaluateLoaderExpression(lldb_private::Process *process,
+const char *expression,
+lldb::ValueObjectSP &value);
 };
 
 } // namespace lldb_private
Index: lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
===
--- lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -19,10 +19,19 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Expression/DiagnosticManager.h"
+#include "lldb/Expression/FunctionCaller.h"
+#include "lldb/Expression/UserExpression.h"
+#include "lldb/Expression/UtilityFunction.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/Status.h"
 
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/ConvertUTF.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -151,6 +160,281 @@
   return error;
 }
 
+uint32_t PlatformWindows::DoLoadImage(Process *process,
+  const FileSpec &remote_file,
+  const std::vector *paths,
+  Status &error, FileSpec *loaded_image) {
+  DiagnosticManager diagnostics;
+
+  if (loaded_image)
+loaded_image->Clear();
+
+  ThreadSP thread = process->GetThreadList().GetExpressionExecutionThread();
+  if (!thread) {
+error.SetErrorString("LoadLibrary error: no thread available to invoke LoadLibrary");
+return LLDB_INVALID_IMAGE_TOKEN;
+  }
+
+  ExecutionContext context;
+  thread->CalculateExecutionContext(context);
+
+  Status status;
+  UtilityFunction *loader =
+  process->GetLoadImageUtilityFunction(this, [&]() -> std::unique_ptr {
+return MakeLoadImageUtilityFunction(context, status);
+  });
+  if (loader == nullptr)
+return LLDB_INVALID_IMAGE_TOKEN;
+
+  FunctionCaller *invocation = loader->GetFunctionCaller();
+  if (!invocation) {
+error.SetErrorString("LoadLibrary error: could not get function caller");
+return LLDB_INVALID_IMAGE_TOKEN;
+  }
+
+  /* Convert name */
+  llvm::SmallVector name;
+  if (!llvm::convertUTF8ToUTF16String(remote_file.GetPath(), name)) {
+error.SetErrorString("

[Lldb-commits] [PATCH] D77287: Windows: support `DoLoadImage`

2021-11-28 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd updated this revision to Diff 390246.
compnerd added a comment.
Herald added a subscriber: mgorny.

Fix build rules


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77287/new/

https://reviews.llvm.org/D77287

Files:
  lldb/source/Plugins/Platform/Windows/CMakeLists.txt
  lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
  lldb/source/Plugins/Platform/Windows/PlatformWindows.h
  lldb/test/Shell/Process/Windows/process_load.cpp

Index: lldb/test/Shell/Process/Windows/process_load.cpp
===
--- /dev/null
+++ lldb/test/Shell/Process/Windows/process_load.cpp
@@ -0,0 +1,12 @@
+// clang-format off
+
+// REQUIRES: system-windows
+// RUN: %build --compiler=clang-cl -o %t.exe -- %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -o "b main" -o "process launch" -o "process load kernel32.dll" | FileCheck %s
+
+int main(int argc, char *argv[]) {
+  return 0;
+}
+
+// CHECK: "Loading "kernel32.dll"...ok{{.*}}
+// CHECK: Image 0 loaded.
Index: lldb/source/Plugins/Platform/Windows/PlatformWindows.h
===
--- lldb/source/Plugins/Platform/Windows/PlatformWindows.h
+++ lldb/source/Plugins/Platform/Windows/PlatformWindows.h
@@ -44,6 +44,15 @@
 
   lldb_private::Status DisconnectRemote() override;
 
+  uint32_t DoLoadImage(lldb_private::Process *process,
+   const lldb_private::FileSpec &remote_file,
+   const std::vector *paths,
+   lldb_private::Status &error,
+   lldb_private::FileSpec *loaded_path) override;
+
+  lldb_private::Status UnloadImage(lldb_private::Process *process,
+   uint32_t image_token) override;
+
   lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
lldb_private::Debugger &debugger,
lldb_private::Target &target,
@@ -71,6 +80,15 @@
  BreakpointSite *bp_site) override;
 
   std::vector m_supported_architectures;
+
+private:
+  std::unique_ptr
+  MakeLoadImageUtilityFunction(lldb_private::ExecutionContext &context,
+   lldb_private::Status &status);
+
+  lldb_private::Status EvaluateLoaderExpression(lldb_private::Process *process,
+const char *expression,
+lldb::ValueObjectSP &value);
 };
 
 } // namespace lldb_private
Index: lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
===
--- lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -19,10 +19,19 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Expression/DiagnosticManager.h"
+#include "lldb/Expression/FunctionCaller.h"
+#include "lldb/Expression/UserExpression.h"
+#include "lldb/Expression/UtilityFunction.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/Status.h"
 
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/ConvertUTF.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -151,6 +160,281 @@
   return error;
 }
 
+uint32_t PlatformWindows::DoLoadImage(Process *process,
+  const FileSpec &remote_file,
+  const std::vector *paths,
+  Status &error, FileSpec *loaded_image) {
+  DiagnosticManager diagnostics;
+
+  if (loaded_image)
+loaded_image->Clear();
+
+  ThreadSP thread = process->GetThreadList().GetExpressionExecutionThread();
+  if (!thread) {
+error.SetErrorString("LoadLibrary error: no thread available to invoke LoadLibrary");
+return LLDB_INVALID_IMAGE_TOKEN;
+  }
+
+  ExecutionContext context;
+  thread->CalculateExecutionContext(context);
+
+  Status status;
+  UtilityFunction *loader =
+  process->GetLoadImageUtilityFunction(this, [&]() -> std::unique_ptr {
+return MakeLoadImageUtilityFunction(context, status);
+  });
+  if (loader == nullptr)
+return LLDB_INVALID_IMAGE_TOKEN;
+
+  FunctionCaller *invocation = loader->GetFunctionCaller();
+  if (!invocation) {
+error.SetErrorString("LoadLibrary error: could not get function caller");
+return LLDB_INVALID_IMAGE_TOKEN;
+  }
+
+  /* Convert name */
+  llvm::SmallVector name;
+  if (!llvm::convertUTF8ToUTF16String(remote_file.GetPath(), name)) {
+error.SetErrorString("LoadLibrary error: could not convert path to UCS2");
+return LLDB_INVALID_IMAGE_TOKEN;
+  }
+
+  /* Inject name paramter into inferior */
+  lldb::addr_t injected_name =
+  process->AllocateMemory(na

[Lldb-commits] [PATCH] D77287: Windows: support `DoLoadImage`

2021-11-28 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd updated this revision to Diff 390249.
compnerd added a comment.

Add missing null-terminators.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77287/new/

https://reviews.llvm.org/D77287

Files:
  lldb/source/Plugins/Platform/Windows/CMakeLists.txt
  lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
  lldb/source/Plugins/Platform/Windows/PlatformWindows.h
  lldb/test/Shell/Process/Windows/process_load.cpp

Index: lldb/test/Shell/Process/Windows/process_load.cpp
===
--- /dev/null
+++ lldb/test/Shell/Process/Windows/process_load.cpp
@@ -0,0 +1,12 @@
+// clang-format off
+
+// REQUIRES: system-windows
+// RUN: %build --compiler=clang-cl -o %t.exe -- %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -o "b main" -o "process launch" -o "process load kernel32.dll" | FileCheck %s
+
+int main(int argc, char *argv[]) {
+  return 0;
+}
+
+// CHECK: "Loading "kernel32.dll"...ok{{.*}}
+// CHECK: Image 0 loaded.
Index: lldb/source/Plugins/Platform/Windows/PlatformWindows.h
===
--- lldb/source/Plugins/Platform/Windows/PlatformWindows.h
+++ lldb/source/Plugins/Platform/Windows/PlatformWindows.h
@@ -44,6 +44,15 @@
 
   lldb_private::Status DisconnectRemote() override;
 
+  uint32_t DoLoadImage(lldb_private::Process *process,
+   const lldb_private::FileSpec &remote_file,
+   const std::vector *paths,
+   lldb_private::Status &error,
+   lldb_private::FileSpec *loaded_path) override;
+
+  lldb_private::Status UnloadImage(lldb_private::Process *process,
+   uint32_t image_token) override;
+
   lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
lldb_private::Debugger &debugger,
lldb_private::Target &target,
@@ -71,6 +80,15 @@
  BreakpointSite *bp_site) override;
 
   std::vector m_supported_architectures;
+
+private:
+  std::unique_ptr
+  MakeLoadImageUtilityFunction(lldb_private::ExecutionContext &context,
+   lldb_private::Status &status);
+
+  lldb_private::Status EvaluateLoaderExpression(lldb_private::Process *process,
+const char *expression,
+lldb::ValueObjectSP &value);
 };
 
 } // namespace lldb_private
Index: lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
===
--- lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -19,10 +19,19 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Expression/DiagnosticManager.h"
+#include "lldb/Expression/FunctionCaller.h"
+#include "lldb/Expression/UserExpression.h"
+#include "lldb/Expression/UtilityFunction.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/Status.h"
 
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/ConvertUTF.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -151,6 +160,283 @@
   return error;
 }
 
+uint32_t PlatformWindows::DoLoadImage(Process *process,
+  const FileSpec &remote_file,
+  const std::vector *paths,
+  Status &error, FileSpec *loaded_image) {
+  DiagnosticManager diagnostics;
+
+  if (loaded_image)
+loaded_image->Clear();
+
+  ThreadSP thread = process->GetThreadList().GetExpressionExecutionThread();
+  if (!thread) {
+error.SetErrorString("LoadLibrary error: no thread available to invoke LoadLibrary");
+return LLDB_INVALID_IMAGE_TOKEN;
+  }
+
+  ExecutionContext context;
+  thread->CalculateExecutionContext(context);
+
+  Status status;
+  UtilityFunction *loader =
+  process->GetLoadImageUtilityFunction(this, [&]() -> std::unique_ptr {
+return MakeLoadImageUtilityFunction(context, status);
+  });
+  if (loader == nullptr)
+return LLDB_INVALID_IMAGE_TOKEN;
+
+  FunctionCaller *invocation = loader->GetFunctionCaller();
+  if (!invocation) {
+error.SetErrorString("LoadLibrary error: could not get function caller");
+return LLDB_INVALID_IMAGE_TOKEN;
+  }
+
+  /* Convert name */
+  llvm::SmallVector name;
+  if (!llvm::convertUTF8ToUTF16String(remote_file.GetPath(), name)) {
+error.SetErrorString("LoadLibrary error: could not convert path to UCS2");
+return LLDB_INVALID_IMAGE_TOKEN;
+  }
+  name.emplace_back(L'\0');
+
+  /* Inject name paramter into inferior */
+  lldb::addr_t injected_name =
+  process->AllocateMemory(name.size() * sizeof(llvm::UTF16)