[Lldb-commits] [lldb] [lldb-dap] Add an introductory message on startup. (PR #170795)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 4 18:23:01 PST 2025


https://github.com/ashgti created https://github.com/llvm/llvm-project/pull/170795

This adds an introductory message to try to inform users on how the debug console works and adds a little more information on the current target/process, similiar to the lldb driver.

Here is an example of the introduction:

```
To get started with the lldb-dap debug console try "<variable>", "help [<cmd-name>]", or "apropos <search-word>".
For more information visit https://github.com/llvm/llvm-project/blob/main/lldb/tools/lldb-dap/README.md
Executable binary set to 'a.out' (arm64-apple-macosx15.0.0).
Attached to process 1234.
```

We may want to change the URL for more information to a page under lldb.llvm.org but that does not yet exist.

>From 60cb07b17688241060c1c71c97fb1d752774a544 Mon Sep 17 00:00:00 2001
From: John Harrison <harjohn at google.com>
Date: Thu, 4 Dec 2025 18:18:53 -0800
Subject: [PATCH] [lldb-dap] Add an introductory message on startup.

This adds an introductory message to try to inform users on how the debug console works and adds a little more information on the current target/process, similiar to the lldb driver.

Here is an example of the introduction:

```
To get started with the lldb-dap debug console try "<variable>", "help [<cmd-name>]", or "apropos <search-word>".
For more information visit https://github.com/llvm/llvm-project/blob/main/lldb/tools/lldb-dap/README.md
Executable binary set to 'a.out' (arm64-apple-macosx15.0.0).
Attached to process 1234.
```

We may want to change the URL for more information to a page under lldb.llvm.org but that does not yet exist.
---
 .../ConfigurationDoneRequestHandler.cpp       |  2 ++
 .../tools/lldb-dap/Handler/RequestHandler.cpp | 21 +++++++++++++++++++
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  4 ++++
 3 files changed, 27 insertions(+)

diff --git a/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp
index 1bfe7b7f6ef5c..5ef44cba4ebcc 100644
--- a/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp
@@ -50,6 +50,8 @@ ConfigurationDoneRequestHandler::Run(const ConfigurationDoneArguments &) const {
   /// lldb-dap specific editor extension.
   SendExtraCapabilities(dap);
 
+  PrintIntroductionMessage();
+
   // Clients can request a baseline of currently existing threads after
   // we acknowledge the configurationDone request.
   // Client requests the baseline of currently existing threads after
diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
index d67437ad5b3ae..3841db45eae8b 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
@@ -17,6 +17,7 @@
 #include "RunInTerminal.h"
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBEnvironment.h"
+#include "lldb/API/SBStream.h"
 #include "llvm/Support/Error.h"
 #include <mutex>
 
@@ -261,6 +262,26 @@ void BaseRequestHandler::PrintWelcomeMessage() const {
 #endif
 }
 
+void BaseRequestHandler::PrintIntroductionMessage() const {
+  lldb::SBStream msg;
+  msg.Print("To get started with the lldb-dap debug console try "
+            "\"<variable>\", \"help [<cmd-name>]\", or \"apropos "
+            "<search-word>\".\r\nFor more information visit "
+            "https://github.com/llvm/llvm-project/blob/main/lldb/tools/"
+            "lldb-dap/README.md\r\n");
+  if (dap.target && dap.target.GetExecutable()) {
+    char path[PATH_MAX] = {0};
+    dap.target.GetExecutable().GetPath(path, sizeof(path));
+    msg.Printf("Executable binary set to '%s' (%s).\r\n", path,
+               dap.target.GetTriple());
+  }
+  if (dap.target.GetProcess()) {
+    msg.Printf("Attached to process %llu.\r\n",
+               dap.target.GetProcess().GetProcessID());
+  }
+  dap.SendOutput(OutputType::Console, {msg.GetData(), msg.GetSize()});
+}
+
 bool BaseRequestHandler::HasInstructionGranularity(
     const llvm::json::Object &arguments) const {
   if (std::optional<llvm::StringRef> value = arguments.getString("granularity"))
diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 5d235352b7738..c0b1722d26a9b 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -64,6 +64,10 @@ class BaseRequestHandler {
   /// LLDB_DAP_WELCOME_MESSAGE is defined.
   void PrintWelcomeMessage() const;
 
+  /// Prints an introduction to the debug console and information about the
+  /// debug session.
+  void PrintIntroductionMessage() const;
+
   // Takes a LaunchRequest object and launches the process, also handling
   // runInTerminal if applicable. It doesn't do any of the additional
   // initialization and bookkeeping stuff that is needed for `request_launch`.



More information about the lldb-commits mailing list