-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[lldb-dap] Add a -v/--version command line argument #134114
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add a -v/--version command line argument to print the version of both the lldb-dap binary and the liblldb it's linked against. This is motivated by me trying to figure out which lldb-dap I had in my PATH.
@llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) ChangesAdd a -v/--version command line argument to print the version of both the lldb-dap binary and the liblldb it's linked against. This is motivated by me trying to figure out which lldb-dap I had in my PATH. Full diff: https://github.com/llvm/llvm-project/pull/134114.diff 4 Files Affected:
diff --git a/lldb/test/Shell/DAP/TestOptions.test b/lldb/test/Shell/DAP/TestHelp.test
similarity index 88%
rename from lldb/test/Shell/DAP/TestOptions.test
rename to lldb/test/Shell/DAP/TestHelp.test
index d290cdae590fd..6033cf15e3835 100644
--- a/lldb/test/Shell/DAP/TestOptions.test
+++ b/lldb/test/Shell/DAP/TestHelp.test
@@ -4,5 +4,5 @@
# CHECK: --help
# CHECK: -h
# CHECK: --repl-mode
+# CHECK: --version
# CHECK: --wait-for-debugger
-
diff --git a/lldb/test/Shell/DAP/TestVersion.test b/lldb/test/Shell/DAP/TestVersion.test
new file mode 100644
index 0000000000000..ad3ff67e45d79
--- /dev/null
+++ b/lldb/test/Shell/DAP/TestVersion.test
@@ -0,0 +1,3 @@
+# RUN: lldb-dap --version | FileCheck %s
+# CHECK: lldb-dap:
+# CHECK: liblldb:
diff --git a/lldb/tools/lldb-dap/Options.td b/lldb/tools/lldb-dap/Options.td
index a1baf2f0370bd..aecf91797ac70 100644
--- a/lldb/tools/lldb-dap/Options.td
+++ b/lldb/tools/lldb-dap/Options.td
@@ -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">,
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index b91c62e921428..ec87db6aab330 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -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"
@@ -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
@@ -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);
|
ToT output:
|
ashgti
approved these changes
Apr 2, 2025
hstk30-hw
approved these changes
Apr 3, 2025
JDevlieghere
added a commit
to swiftlang/llvm-project
that referenced
this pull request
May 8, 2025
Add a -v/--version command line argument to print the version of both the lldb-dap binary and the liblldb it's linked against. This is motivated by me trying to figure out which lldb-dap I had in my PATH. (cherry picked from commit 18c43d0)
JDevlieghere
added a commit
to swiftlang/llvm-project
that referenced
this pull request
May 9, 2025
…-18c43d01fc61 [lldb-dap] Add a -v/--version command line argument (llvm#134114)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a -v/--version command line argument to print the version of both the lldb-dap binary and the liblldb it's linked against.
This is motivated by me trying to figure out which lldb-dap I had in my PATH.