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

>From 60cb07b17688241060c1c71c97fb1d752774a544 Mon Sep 17 00:00:00 2001
From: John Harrison <[email protected]>
Date: Thu, 4 Dec 2025 18:18:53 -0800
Subject: [PATCH 1/4] [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`.

>From 03e2d3b839cdc6a3a41060ae202f9e5abd184512 Mon Sep 17 00:00:00 2001
From: John Harrison <[email protected]>
Date: Fri, 5 Dec 2025 13:33:05 -0800
Subject: [PATCH 2/4] Adjusting the message, moving part of it to the
 PrintWelcomeMessage function and switched to using llvm::raw_ostream instead
 of lldb::SBStream.

---
 .../tools/lldb-dap/Handler/RequestHandler.cpp | 46 ++++++++++++++-----
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
index 3841db45eae8b..512896be564aa 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
@@ -17,8 +17,8 @@
 #include "RunInTerminal.h"
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBEnvironment.h"
-#include "lldb/API/SBStream.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
 #include <mutex>
 
 #if !defined(_WIN32)
@@ -260,26 +260,48 @@ void BaseRequestHandler::PrintWelcomeMessage() const {
 #ifdef LLDB_DAP_WELCOME_MESSAGE
   dap.SendOutput(OutputType::Console, LLDB_DAP_WELCOME_MESSAGE);
 #endif
+
+  std::string message;
+  llvm::raw_string_ostream OS(message);
+  OS << "To get started with the lldb-dap debug console try ";
+
+  switch (dap.repl_mode) {
+  case ReplMode::Auto:
+    OS << "\"<variable>\", \"<lldb-cmd>\" or \"help [<cmd-name>]\" for more "
+          "information.\r\n";
+    OS << "Use '" << dap.configuration.commandEscapePrefix
+       << "' to prefix commands that may conflict with local variables.\r\n";
+    break;
+  case ReplMode::Command:
+    OS << "\"<lldb-cmd>\" or \"help [<cmd-name>]\" for more information.\r\n";
+    break;
+  case ReplMode::Variable:
+    OS << "\"<variable>\" or \"" << dap.configuration.commandEscapePrefix
+       << "help [<cmd-name>]\" for more information.\r\n";
+    break;
+  }
+
+  OS << "For more information visit "
+        "https://github.com/llvm/llvm-project/blob/main/lldb/tools/";
+        "lldb-dap/README.md#debug-console\r\n";
+
+  dap.SendOutput(OutputType::Console, message);
 }
 
 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");
+  std::string msg;
+  llvm::raw_string_ostream os(msg);
   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());
+    os << llvm::formatv("Executable binary set to '{0}' ({1}).\r\n", path,
+                        dap.target.GetTriple());
   }
   if (dap.target.GetProcess()) {
-    msg.Printf("Attached to process %llu.\r\n",
-               dap.target.GetProcess().GetProcessID());
+    os << llvm::formatv("Attached to process {0}\r\n",
+                        dap.target.GetProcess().GetProcessID());
   }
-  dap.SendOutput(OutputType::Console, {msg.GetData(), msg.GetSize()});
+  dap.SendOutput(OutputType::Console, msg);
 }
 
 bool BaseRequestHandler::HasInstructionGranularity(

>From 4c4444a9c2a1682eb67ba9b1bb063da55e14c753 Mon Sep 17 00:00:00 2001
From: John Harrison <[email protected]>
Date: Mon, 8 Dec 2025 11:32:31 -0800
Subject: [PATCH 3/4] Integrating the existing `LLDB_DAP_WELCOME_MESSAGE` into
 the same welcome message about the debug console and adding a
 `LLDB_DAP_README_URL` in case a custom build of lldb-dap has its own URL for
 finding help.

---
 .../tools/lldb-dap/Handler/RequestHandler.cpp | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
index 512896be564aa..80b91d75bb449 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
@@ -25,6 +25,12 @@
 #include <unistd.h>
 #endif
 
+#ifndef LLDB_DAP_README_URL
+#define LLDB_DAP_README_URL                                                    
\
+  "https://github.com/llvm/llvm-project/blob/main/lldb/tools/lldb-dap/";        
\
+  "README.md#debug-console"
+#endif
+
 using namespace lldb_dap::protocol;
 
 namespace lldb_dap {
@@ -257,12 +263,15 @@ llvm::Error BaseRequestHandler::LaunchProcess(
 }
 
 void BaseRequestHandler::PrintWelcomeMessage() const {
+  std::string message;
+  llvm::raw_string_ostream OS(message);
+
 #ifdef LLDB_DAP_WELCOME_MESSAGE
-  dap.SendOutput(OutputType::Console, LLDB_DAP_WELCOME_MESSAGE);
+  OS << LLDB_DAP_WELCOME_MESSAGE << "\r\n";
 #endif
 
-  std::string message;
-  llvm::raw_string_ostream OS(message);
+  // Trying to provide a brief but helpful welcome message for users to better
+  // understand how the debug console repl works.
   OS << "To get started with the lldb-dap debug console try ";
 
   switch (dap.repl_mode) {
@@ -281,9 +290,7 @@ void BaseRequestHandler::PrintWelcomeMessage() const {
     break;
   }
 
-  OS << "For more information visit "
-        "https://github.com/llvm/llvm-project/blob/main/lldb/tools/";
-        "lldb-dap/README.md#debug-console\r\n";
+  OS << "For more information visit " LLDB_DAP_README_URL "\r\n";
 
   dap.SendOutput(OutputType::Console, message);
 }

>From 3e01a51d8636fa8561c63dc2884f7e39e0161d7e Mon Sep 17 00:00:00 2001
From: John Harrison <[email protected]>
Date: Tue, 9 Dec 2025 12:59:19 -0800
Subject: [PATCH 4/4] Adjusting wording for the welcome message.

---
 lldb/tools/lldb-dap/Handler/RequestHandler.cpp | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
index 80b91d75bb449..982ae8d8e2f2c 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
@@ -272,21 +272,18 @@ void BaseRequestHandler::PrintWelcomeMessage() const {
 
   // Trying to provide a brief but helpful welcome message for users to better
   // understand how the debug console repl works.
-  OS << "To get started with the lldb-dap debug console try ";
-
+  OS << "To get started with the debug console try ";
   switch (dap.repl_mode) {
   case ReplMode::Auto:
-    OS << "\"<variable>\", \"<lldb-cmd>\" or \"help [<cmd-name>]\" for more "
+    OS << "\"<variable>\", \"<lldb-cmd>\" or \"help [<lldb-cmd>]\" for more "
           "information.\r\n";
-    OS << "Use '" << dap.configuration.commandEscapePrefix
-       << "' to prefix commands that may conflict with local variables.\r\n";
     break;
   case ReplMode::Command:
-    OS << "\"<lldb-cmd>\" or \"help [<cmd-name>]\" for more information.\r\n";
+    OS << "\"<lldb-cmd>\" or \"help [<lldb-cmd>]\" for more information.\r\n";
     break;
   case ReplMode::Variable:
     OS << "\"<variable>\" or \"" << dap.configuration.commandEscapePrefix
-       << "help [<cmd-name>]\" for more information.\r\n";
+       << "help [<lldb-cmd>]\" for more information.\r\n";
     break;
   }
 

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to