[Lldb-commits] [lldb] [lldb] Allow env override for LLDB_ARGDUMPER_PATH (PR #91688)
Keith Smiley via lldb-commits
lldb-commits at lists.llvm.org
Thu May 9 18:20:12 PDT 2024
https://github.com/keith created https://github.com/llvm/llvm-project/pull/91688
This mirrors the LLDB_DEBUGSERVER_PATH environment variable and allows you to have lldb-argdumper in a non-standard location and still use it at runtime.
>From 98ddf4ed99a10c46a43d9a750bd826623a8c7e6f Mon Sep 17 00:00:00 2001
From: Keith Smiley <keithbsmiley at gmail.com>
Date: Thu, 9 May 2024 18:10:36 -0700
Subject: [PATCH] [lldb] Allow env override for LLDB_ARGDUMPER_PATH
This mirrors the LLDB_DEBUGSERVER_PATH environment variable and allows
you to have lldb-argdumper in a non-standard location and still use it
at runtime.
---
lldb/source/Host/macosx/objcxx/Host.mm | 35 ++++++++++++++++++--------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm
index 4fba5550ba10a..e6f1c0ea3d295 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -1387,18 +1387,31 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info) {
Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
Status error;
if (launch_info.GetFlags().Test(eLaunchFlagShellExpandArguments)) {
- FileSpec expand_tool_spec = HostInfo::GetSupportExeDir();
- if (!expand_tool_spec) {
- error.SetErrorString(
- "could not get support executable directory for lldb-argdumper tool");
- return error;
+ FileSpec expand_tool_spec;
+ Environment host_env = Host::GetEnvironment();
+ std::string env_argdumper_path = host_env.lookup("LLDB_ARGDUMPER_PATH");
+ if (!env_argdumper_path.empty()) {
+ expand_tool_spec.SetFile(env_argdumper_path, FileSpec::Style::native);
+ Log *log(GetLog(LLDBLog::Host | LLDBLog::Process));
+ LLDB_LOGF(log,
+ "lldb-argdumper exe path set from environment variable: %s",
+ env_argdumper_path.c_str());
}
- expand_tool_spec.AppendPathComponent("lldb-argdumper");
- if (!FileSystem::Instance().Exists(expand_tool_spec)) {
- error.SetErrorStringWithFormat(
- "could not find the lldb-argdumper tool: %s",
- expand_tool_spec.GetPath().c_str());
- return error;
+ bool argdumper_exists = FileSystem::Instance().Exists(env_argdumper_path);
+ if (!argdumper_exists) {
+ expand_tool_spec = HostInfo::GetSupportExeDir();
+ if (!expand_tool_spec) {
+ error.SetErrorString("could not get support executable directory for "
+ "lldb-argdumper tool");
+ return error;
+ }
+ expand_tool_spec.AppendPathComponent("lldb-argdumper");
+ if (!FileSystem::Instance().Exists(expand_tool_spec)) {
+ error.SetErrorStringWithFormat(
+ "could not find the lldb-argdumper tool: %s",
+ expand_tool_spec.GetPath().c_str());
+ return error;
+ }
}
StreamString expand_tool_spec_stream;
More information about the lldb-commits
mailing list