Skip to content

Commit c8f12b3

Browse files
authored
Merge pull request #6399 from bulbazord/cherrypick/20221013/106279228
[lldb] Respect empty arguments in target.run-args
2 parents 91de136 + 02f5dac commit c8f12b3

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

lldb/source/Host/common/ProcessLaunchInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ bool ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell(
321321
} else {
322322
for (size_t i = 0; argv[i] != nullptr; ++i) {
323323
std::string safe_arg = Args::GetShellSafeArgument(m_shell, argv[i]);
324+
if (safe_arg.empty())
325+
safe_arg = "\"\"";
324326
// Add a space to separate this arg from the previous one.
325327
shell_command.PutCString(" ");
326328
shell_command.PutCString(safe_arg);

lldb/source/Interpreter/OptionValueArgs.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ size_t OptionValueArgs::GetArgs(Args &args) const {
1717
args.Clear();
1818
for (const auto &value : m_values) {
1919
llvm::StringRef string_value = value->GetStringValue();
20-
if (!string_value.empty())
21-
args.AppendArgument(string_value);
20+
args.AppendArgument(string_value);
2221
}
2322

2423
return args.GetArgumentCount();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdio.h>
2+
3+
int main(int argc, char *argv[]) {
4+
for (int i = 0; i < argc; i++) {
5+
printf("argv[%d] = \"%s\"\n", i, argv[i]);
6+
}
7+
return 0;
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# RUN: %clang_host %S/Inputs/dumpargs.c -o %t.out
2+
# RUN: %lldb -b -o "r" %t.out -- "one" "two" "" "three" | FileCheck %s
3+
4+
# CHECK: argv[1] = "one"
5+
# CHECK: argv[2] = "two"
6+
# CHECK: argv[3] = ""
7+
# CHECK: argv[4] = "three"

0 commit comments

Comments
 (0)