Skip to content

Commit a903271

Browse files
authored
[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
1 parent a90145e commit a903271

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# RUN: not %lldb --wait-for 2>&1 | FileCheck %s
2+
# CHECK: error: --wait-for requires a name (--attach-name)

lldb/tools/driver/Driver.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) {
280280
}
281281

282282
if (args.hasArg(OPT_wait_for)) {
283+
if (!args.hasArg(OPT_attach_name)) {
284+
error.SetErrorStringWithFormat(
285+
"--wait-for requires a name (--attach-name)");
286+
return error;
287+
}
288+
283289
m_option_data.m_wait_for = true;
284290
}
285291

lldb/tools/driver/Options.td

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ def: Separate<["-"], "n">,
1919
HelpText<"Alias for --attach-name">,
2020
Group<grp_attach>;
2121

22-
def wait_for: F<"wait-for">,
23-
HelpText<"Tells the debugger to wait for a process with the given pid or name to launch before attaching.">,
24-
Group<grp_attach>;
22+
def wait_for
23+
: F<"wait-for">,
24+
HelpText<"Tells the debugger to wait for the process with the name "
25+
"specified by --attach-name to launch before attaching.">,
26+
Group<grp_attach>;
2527
def: Flag<["-"], "w">,
2628
Alias<wait_for>,
2729
HelpText<"Alias for --wait-for">,

0 commit comments

Comments
 (0)