aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectPlatform.cpp
diff options
context:
space:
mode:
authorDavid Spickett <david.spickett@linaro.org>2023-06-23 14:31:14 +0000
committerDavid Spickett <david.spickett@linaro.org>2023-06-27 07:41:18 +0000
commitcc0fc358540517a3d205243c27bd543afeae2b02 (patch)
tree8f563588d54d419d71a9e616f2d7ebed550cd434 /lldb/source/Commands/CommandObjectPlatform.cpp
parentc31eb827b72da784d7f18512a51e5396ac302d72 (diff)
downloadllvm-cc0fc358540517a3d205243c27bd543afeae2b02.zip
llvm-cc0fc358540517a3d205243c27bd543afeae2b02.tar.gz
llvm-cc0fc358540517a3d205243c27bd543afeae2b02.tar.bz2
[LLDB] Fix the use of "platform process launch" with no extra arguments
This fixes #62068. After 8d1de7b34af46a089eb5433c700419ad9b2923ee the following issue appeared: ``` $ ./bin/lldb /tmp/test.o (lldb) target create "/tmp/test.o" Current executable set to '/tmp/test.o' (aarch64). (lldb) platform process launch -s error: Cannot launch '': Nothing to launch ``` Previously would call target->GetRunArguments when there were no extra arguments, so we could find out what target.run-args might be. Once that change started relying on the first arg being the exe, the fact that that call clears the existing argument list caused the bug. Instead, have it set a local arg list and append that to the existing one. Which in this case will just contain the exe name. Since there's no existing tests for this command I've added a new file that covers enough to check this issue. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D153636
Diffstat (limited to 'lldb/source/Commands/CommandObjectPlatform.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 92aa110..6c954ce 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1207,8 +1207,12 @@ protected:
if (m_options.launch_info.GetExecutableFile()) {
Debugger &debugger = GetDebugger();
- if (argc == 0)
- target->GetRunArguments(m_options.launch_info.GetArguments());
+ if (argc == 0) {
+ // If no arguments were given to the command, use target.run-args.
+ Args target_run_args;
+ target->GetRunArguments(target_run_args);
+ m_options.launch_info.GetArguments().AppendArguments(target_run_args);
+ }
ProcessSP process_sp(platform_sp->DebugProcess(
m_options.launch_info, debugger, *target, error));