From 6620cd25234a42ca4b51490627afcb93fa443dc3 Mon Sep 17 00:00:00 2001 From: Walter Erquinigo Date: Tue, 5 Nov 2024 06:33:25 -0500 Subject: [LLDB] Add a target.launch-working-dir setting (#113521) Internally we use bazel in a way in which it can drop you in a LLDB session with the target launched in a particular cwd, which is needed for things to work. We've been making this automation work via `process launch -w`. However, if later the user wants to restart the process with `r`, then they end up using a different cwd for relaunching the process. As a way to fix this, I'm adding a target-level setting that allows configuring a default cwd used for launching the process without needing the user to specify it manually. --- lldb/source/Commands/CommandObjectProcess.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lldb/source/Commands/CommandObjectProcess.cpp') diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index e7c7d07ad477..7444e46aa729 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -201,6 +201,13 @@ protected: if (target->GetDisableSTDIO()) m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO); + if (!m_options.launch_info.GetWorkingDirectory()) { + if (llvm::StringRef wd = target->GetLaunchWorkingDirectory(); + !wd.empty()) { + m_options.launch_info.SetWorkingDirectory(FileSpec(wd)); + } + } + // Merge the launch info environment with the target environment. Environment target_env = target->GetEnvironment(); m_options.launch_info.GetEnvironment().insert(target_env.begin(), -- cgit v1.2.3