Skip to content

Commit 0b000c4

Browse files
authored
Merge pull request #10654 from swiftlang/cherrypick-swift/release/6.2-18c43d01fc61
[lldb-dap] Add a -v/--version command line argument (llvm#134114)
2 parents e416887 + dc4a98f commit 0b000c4

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

lldb/test/Shell/DAP/TestOptions.test renamed to lldb/test/Shell/DAP/TestHelp.test

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# CHECK: -g
33
# CHECK: --help
44
# CHECK: -h
5-
# CHECK: --port
6-
# CHECK: -p
5+
# CHECK: --repl-mode
6+
# CHECK: --version
77
# CHECK: --wait-for-debugger
8-

lldb/test/Shell/DAP/TestVersion.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# RUN: lldb-dap --version | FileCheck %s
2+
# CHECK: lldb-dap:
3+
# CHECK: liblldb:

lldb/tools/lldb-dap/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ def: Flag<["-"], "h">,
1111
Alias<help>,
1212
HelpText<"Alias for --help">;
1313

14+
def version: F<"version">,
15+
HelpText<"Prints out the lldb-dap version.">;
16+
def: Flag<["-"], "v">,
17+
Alias<version>,
18+
HelpText<"Alias for --version">;
19+
1420
def wait_for_debugger: F<"wait-for-debugger">,
1521
HelpText<"Pause the program at startup.">;
1622
def: Flag<["-"], "g">,

lldb/tools/lldb-dap/lldb-dap.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
#include "llvm/Option/OptTable.h"
3131
#include "llvm/Option/Option.h"
3232
#include "llvm/Support/Base64.h"
33+
#include "llvm/Support/CommandLine.h"
3334
#include "llvm/Support/Errno.h"
35+
#include "llvm/Support/Error.h"
3436
#include "llvm/Support/FileSystem.h"
3537
#include "llvm/Support/InitLLVM.h"
3638
#include "llvm/Support/Path.h"
@@ -5140,6 +5142,12 @@ static void printHelp(LLDBDAPOptTable &table, llvm::StringRef tool_name) {
51405142
llvm::outs() << examples;
51415143
}
51425144

5145+
static void PrintVersion() {
5146+
llvm::outs() << "lldb-dap: ";
5147+
llvm::cl::PrintVersionMessage();
5148+
llvm::outs() << "liblldb: " << lldb::SBDebugger::GetVersionString() << '\n';
5149+
}
5150+
51435151
// If --launch-target is provided, this instance of lldb-dap becomes a
51445152
// runInTerminal launcher. It will ultimately launch the program specified in
51455153
// the --launch-target argument, which is the original program the user wanted
@@ -5246,6 +5254,11 @@ int main(int argc, char *argv[]) {
52465254
return EXIT_SUCCESS;
52475255
}
52485256

5257+
if (input_args.hasArg(OPT_version)) {
5258+
PrintVersion();
5259+
return EXIT_SUCCESS;
5260+
}
5261+
52495262
ReplMode default_repl_mode = ReplMode::Auto;
52505263
if (input_args.hasArg(OPT_repl_mode)) {
52515264
llvm::opt::Arg *repl_mode = input_args.getLastArg(OPT_repl_mode);

0 commit comments

Comments
 (0)