Skip to content

[lldb-dap] Add a -v/--version command line argument (#134114) #10654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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 @@ -2,7 +2,6 @@
# CHECK: -g
# CHECK: --help
# CHECK: -h
# CHECK: --port
# CHECK: -p
# 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
13 changes: 13 additions & 0 deletions lldb/tools/lldb-dap/lldb-dap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
#include "llvm/Option/OptTable.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/Base64.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Errno.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/Path.h"
Expand Down Expand Up @@ -5140,6 +5142,12 @@ static void printHelp(LLDBDAPOptTable &table, llvm::StringRef tool_name) {
llvm::outs() << examples;
}

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 @@ -5246,6 +5254,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