Author: Jonas Devlieghere
Date: 2025-06-03T09:19:50-07:00
New Revision: a9032712c453bda70449dedcaf00bead0fea6e88

URL: 
https://github.com/llvm/llvm-project/commit/a9032712c453bda70449dedcaf00bead0fea6e88
DIFF: 
https://github.com/llvm/llvm-project/commit/a9032712c453bda70449dedcaf00bead0fea6e88.diff

LOG: [lldb] Emit an error when using --wait-for without a name or pid (#142424)

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

Added: 
    lldb/test/Shell/Driver/TestWaitFor.test

Modified: 
    lldb/tools/driver/Driver.cpp
    lldb/tools/driver/Options.td

Removed: 
    


################################################################################
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">,


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to