Skip to content

Commit f918c05

Browse files
authored
[lldb] Allow env override for LLDB_ARGDUMPER_PATH (#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.
1 parent f83df08 commit f918c05

File tree

1 file changed

+24
-11
lines changed
  • lldb/source/Host/macosx/objcxx

1 file changed

+24
-11
lines changed

lldb/source/Host/macosx/objcxx/Host.mm

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,18 +1387,31 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info) {
13871387
Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
13881388
Status error;
13891389
if (launch_info.GetFlags().Test(eLaunchFlagShellExpandArguments)) {
1390-
FileSpec expand_tool_spec = HostInfo::GetSupportExeDir();
1391-
if (!expand_tool_spec) {
1392-
error.SetErrorString(
1393-
"could not get support executable directory for lldb-argdumper tool");
1394-
return error;
1390+
FileSpec expand_tool_spec;
1391+
Environment host_env = Host::GetEnvironment();
1392+
std::string env_argdumper_path = host_env.lookup("LLDB_ARGDUMPER_PATH");
1393+
if (!env_argdumper_path.empty()) {
1394+
expand_tool_spec.SetFile(env_argdumper_path, FileSpec::Style::native);
1395+
Log *log(GetLog(LLDBLog::Host | LLDBLog::Process));
1396+
LLDB_LOGF(log,
1397+
"lldb-argdumper exe path set from environment variable: %s",
1398+
env_argdumper_path.c_str());
13951399
}
1396-
expand_tool_spec.AppendPathComponent("lldb-argdumper");
1397-
if (!FileSystem::Instance().Exists(expand_tool_spec)) {
1398-
error.SetErrorStringWithFormat(
1399-
"could not find the lldb-argdumper tool: %s",
1400-
expand_tool_spec.GetPath().c_str());
1401-
return error;
1400+
bool argdumper_exists = FileSystem::Instance().Exists(env_argdumper_path);
1401+
if (!argdumper_exists) {
1402+
expand_tool_spec = HostInfo::GetSupportExeDir();
1403+
if (!expand_tool_spec) {
1404+
error.SetErrorString("could not get support executable directory for "
1405+
"lldb-argdumper tool");
1406+
return error;
1407+
}
1408+
expand_tool_spec.AppendPathComponent("lldb-argdumper");
1409+
if (!FileSystem::Instance().Exists(expand_tool_spec)) {
1410+
error.SetErrorStringWithFormat(
1411+
"could not find the lldb-argdumper tool: %s",
1412+
expand_tool_spec.GetPath().c_str());
1413+
return error;
1414+
}
14021415
}
14031416

14041417
StreamString expand_tool_spec_stream;

0 commit comments

Comments
 (0)