[Lldb-commits] [lldb] [lldb] Emit an error when using --wait-for without a name or pid (PR #142424)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 2 21:24:07 PDT 2025
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/142424
>From 988faae7eebaea3869d6717c35ac8757e19aa7d8 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Mon, 2 Jun 2025 09:21:17 -0700
Subject: [PATCH] [lldb] Emit an error when using --wait-for without a name
Emit an error when using --wait-for without a name and correct the help
output to specify a name must be provided, rather than a name or PID.
Motivated by https://discourse.llvm.org/t/why-is-wait-for-not-attaching/86636
---
lldb/test/Shell/Driver/TestWaitFor.test | 2 ++
lldb/tools/driver/Driver.cpp | 6 ++++++
lldb/tools/driver/Options.td | 8 +++++---
3 files changed, 13 insertions(+), 3 deletions(-)
create mode 100644 lldb/test/Shell/Driver/TestWaitFor.test
diff --git a/lldb/test/Shell/Driver/TestWaitFor.test b/lldb/test/Shell/Driver/TestWaitFor.test
new file mode 100644
index 0000000000000..dde8e747713ad
--- /dev/null
+++ b/lldb/test/Shell/Driver/TestWaitFor.test
@@ -0,0 +1,2 @@
+# RUN: not %lldb --wait-for 2>&1 | FileCheck %s
+# CHECK: error: --wait-for requires a name (--attach-name)
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index e19fded051941..16cc736441b59 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -280,6 +280,12 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) {
}
if (args.hasArg(OPT_wait_for)) {
+ if (!args.hasArg(OPT_attach_name)) {
+ error.SetErrorStringWithFormat(
+ "--wait-for requires a name (--attach-name)");
+ return error;
+ }
+
m_option_data.m_wait_for = true;
}
diff --git a/lldb/tools/driver/Options.td b/lldb/tools/driver/Options.td
index a24fb3826b909..1d8372c4aa404 100644
--- a/lldb/tools/driver/Options.td
+++ b/lldb/tools/driver/Options.td
@@ -19,9 +19,11 @@ def: Separate<["-"], "n">,
HelpText<"Alias for --attach-name">,
Group<grp_attach>;
-def wait_for: F<"wait-for">,
- HelpText<"Tells the debugger to wait for a process with the given pid or name to launch before attaching.">,
- Group<grp_attach>;
+def wait_for
+ : F<"wait-for">,
+ HelpText<"Tells the debugger to wait for the process with the name "
+ "specified by --attach-name to launch before attaching.">,
+ Group<grp_attach>;
def: Flag<["-"], "w">,
Alias<wait_for>,
HelpText<"Alias for --wait-for">,
More information about the lldb-commits
mailing list