Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# CHECK: --help
# CHECK: -h
# CHECK: --repl-mode
# CHECK: --version
# CHECK: --wait-for-debugger

3 changes: 3 additions & 0 deletions lldb/test/Shell/DAP/TestVersion.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# RUN: lldb-dap --version | FileCheck %s
# CHECK: lldb-dap:
# CHECK: liblldb:
6 changes: 6 additions & 0 deletions lldb/tools/lldb-dap/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def: Flag<["-"], "h">,
Alias<help>,
HelpText<"Alias for --help">;

def version: F<"version">,
HelpText<"Prints out the lldb-dap version.">;
def: Flag<["-"], "v">,
Alias<version>,
HelpText<"Alias for --version">;

def wait_for_debugger: F<"wait-for-debugger">,
HelpText<"Pause the program at startup.">;
def: Flag<["-"], "g">,
Expand Down
12 changes: 12 additions & 0 deletions lldb/tools/lldb-dap/lldb-dap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "llvm/Option/ArgList.h"
#include "llvm/Option/OptTable.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/InitLLVM.h"
Expand Down Expand Up @@ -177,6 +178,12 @@ static void PrintHelp(LLDBDAPOptTable &table, llvm::StringRef tool_name) {
)___";
}

static void PrintVersion() {
llvm::outs() << "lldb-dap: ";
llvm::cl::PrintVersionMessage();
llvm::outs() << "liblldb: " << lldb::SBDebugger::GetVersionString() << '\n';
}

// If --launch-target is provided, this instance of lldb-dap becomes a
// runInTerminal launcher. It will ultimately launch the program specified in
// the --launch-target argument, which is the original program the user wanted
Expand Down Expand Up @@ -421,6 +428,11 @@ int main(int argc, char *argv[]) {
return EXIT_SUCCESS;
}

if (input_args.hasArg(OPT_version)) {
PrintVersion();
return EXIT_SUCCESS;
}

ReplMode default_repl_mode = ReplMode::Auto;
if (input_args.hasArg(OPT_repl_mode)) {
llvm::opt::Arg *repl_mode = input_args.getLastArg(OPT_repl_mode);
Expand Down