[Lldb-commits] [lldb] [lldb-dap] Add module symbol table viewer to VS Code extension #140626 (PR #153836)
Ely Ronnen via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 15 16:52:01 PDT 2025
https://github.com/eronnen updated https://github.com/llvm/llvm-project/pull/153836
>From b70f3ca3b6f0c7dd9784b3a8d4685a26c1d462b9 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Sat, 9 Aug 2025 15:40:53 +0200
Subject: [PATCH 01/22] add DAP gettModuleSymbols request
---
lldb/tools/lldb-dap/Handler/RequestHandler.h | 10 ++++++
lldb/tools/lldb-dap/Protocol/DAPTypes.cpp | 30 ++++++++++++++++
lldb/tools/lldb-dap/Protocol/DAPTypes.h | 31 ++++++++++++++++
.../lldb-dap/Protocol/ProtocolRequests.h | 14 ++++++++
lldb/unittests/DAP/CMakeLists.txt | 1 +
lldb/unittests/DAP/DAPTypesTest.cpp | 35 +++++++++++++++++++
6 files changed, 121 insertions(+)
create mode 100644 lldb/unittests/DAP/DAPTypesTest.cpp
diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 16f8062f97d7b..b010b6525a8d1 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -594,6 +594,16 @@ class CancelRequestHandler : public RequestHandler<protocol::CancelArguments,
llvm::Error Run(const protocol::CancelArguments &args) const override;
};
+class DAPGetModuleSymbolsRequestHandler
+ : public RequestHandler<protocol::DAPGetModuleSymbolsArguments,
+ llvm::Expected<protocol::DAPGetModuleSymbolsResponseBody>> {
+public:
+ using RequestHandler::RequestHandler;
+ static llvm::StringLiteral GetCommand() { return "dapGetModuleSymbols"; }
+ llvm::Expected<protocol::DAPGetModuleSymbolsResponseBody>
+ Run(const protocol::DAPGetModuleSymbolsArguments &args) const override;
+};
+
/// A request used in testing to get the details on all breakpoints that are
/// currently set in the target. This helps us to test "setBreakpoints" and
/// "setFunctionBreakpoints" requests to verify we have the correct set of
diff --git a/lldb/tools/lldb-dap/Protocol/DAPTypes.cpp b/lldb/tools/lldb-dap/Protocol/DAPTypes.cpp
index ecb4baef56e80..1c73328680cdb 100644
--- a/lldb/tools/lldb-dap/Protocol/DAPTypes.cpp
+++ b/lldb/tools/lldb-dap/Protocol/DAPTypes.cpp
@@ -33,4 +33,34 @@ llvm::json::Value toJSON(const SourceLLDBData &SLD) {
return result;
}
+bool fromJSON(const llvm::json::Value &Params, DAPSymbol &DS,
+ llvm::json::Path P) {
+ json::ObjectMapper O(Params, P);
+ return O && O.map("userId", DS.userId) &&
+ O.map("isDebug", DS.isDebug) &&
+ O.map("isSynthesized", DS.isSynthesized) &&
+ O.map("isExternal", DS.isExternal) &&
+ O.map("type", DS.type) &&
+ O.map("fileAddress", DS.fileAddress) &&
+ O.mapOptional("loadAddress", DS.loadAddress) &&
+ O.map("size", DS.size) &&
+ O.map("name", DS.name);
+}
+
+llvm::json::Value toJSON(const DAPSymbol &DS) {
+ json::Object result{
+ {"userId", DS.userId},
+ {"isDebug", DS.isDebug},
+ {"isSynthesized", DS.isSynthesized},
+ {"isExternal", DS.isExternal},
+ {"type", DS.type},
+ {"fileAddress", DS.fileAddress},
+ {"loadAddress", DS.loadAddress},
+ {"size", DS.size},
+ {"name", DS.name},
+ };
+
+ return result;
+}
+
} // namespace lldb_dap::protocol
\ No newline at end of file
diff --git a/lldb/tools/lldb-dap/Protocol/DAPTypes.h b/lldb/tools/lldb-dap/Protocol/DAPTypes.h
index 716d8b491b258..3f2bec81a0436 100644
--- a/lldb/tools/lldb-dap/Protocol/DAPTypes.h
+++ b/lldb/tools/lldb-dap/Protocol/DAPTypes.h
@@ -48,6 +48,37 @@ struct SourceLLDBData {
bool fromJSON(const llvm::json::Value &, SourceLLDBData &, llvm::json::Path);
llvm::json::Value toJSON(const SourceLLDBData &);
+struct DAPSymbol {
+ /// The symbol uid.
+ uint32_t userId;
+
+ /// True if this symbol is debug information in a symbol.
+ bool isDebug;
+
+ /// True if this symbol is not actually in the symbol table, but synthesized from other info in the object file.
+ bool isSynthesized;
+
+ /// True if this symbol is globally visible.
+ bool isExternal;
+
+ /// The symbol type.
+ std::string type;
+
+ /// The symbol file address.
+ lldb::addr_t fileAddress;
+
+ /// The symbol load address.
+ std::optional<lldb::addr_t> loadAddress;
+
+ /// The symbol size.
+ lldb::addr_t size;
+
+ /// The symbol name.
+ std::string name;
+};
+bool fromJSON(const llvm::json::Value &, DAPSymbol &, llvm::json::Path);
+llvm::json::Value toJSON(const DAPSymbol &);
+
} // namespace lldb_dap::protocol
#endif
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
index c45ee10e77d1c..d496433cc02ac 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
@@ -981,6 +981,20 @@ struct WriteMemoryResponseBody {
};
llvm::json::Value toJSON(const WriteMemoryResponseBody &);
+struct DAPGetModuleSymbolsArguments {
+ /// The module for which to retrieve symbols.
+ std::string moduleId;
+};
+bool fromJSON(const llvm::json::Value &,
+ DAPGetModuleSymbolsArguments &, llvm::json::Path);
+
+/// Response to `getModuleSymbols` request.
+struct DAPGetModuleSymbolsResponseBody {
+ /// The symbols for the specified module.
+ std::vector<DAPSymbol> symbols;
+};
+llvm::json::Value toJSON(const DAPGetModuleSymbolsResponseBody &);
+
} // namespace lldb_dap::protocol
#endif
diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt
index 156cd625546bd..716159b454231 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -1,6 +1,7 @@
add_lldb_unittest(DAPTests
DAPErrorTest.cpp
DAPTest.cpp
+ DAPTypesTest.cpp
FifoFilesTest.cpp
Handler/DisconnectTest.cpp
Handler/ContinueTest.cpp
diff --git a/lldb/unittests/DAP/DAPTypesTest.cpp b/lldb/unittests/DAP/DAPTypesTest.cpp
new file mode 100644
index 0000000000000..8226fc7660d60
--- /dev/null
+++ b/lldb/unittests/DAP/DAPTypesTest.cpp
@@ -0,0 +1,35 @@
+//===-- DAPTypesTest.cpp ----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Protocol/DAPTypes.h"
+#include "TestingSupport/TestUtilities.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include <optional>
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+using lldb_private::roundtripJSON;
+
+TEST(DAPTypesTest, SourceLLDBData) {
+ SourceLLDBData source_data;
+ source_data.persistenceData = PersistenceData{"module_path123", "symbol_name456"};
+
+ llvm::Expected<SourceLLDBData> deserialized_data = roundtripJSON(source_data);
+ ASSERT_THAT_EXPECTED(deserialized_data, llvm::Succeeded());
+
+ EXPECT_EQ(source_data.persistenceData->module_path,
+ deserialized_data->persistenceData->module_path);
+ EXPECT_EQ(source_data.persistenceData->symbol_name,
+ deserialized_data->persistenceData->symbol_name);
+}
>From 92d84da4c3bc3bea6d8b4cb9d761812f15e8d341 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Sat, 9 Aug 2025 19:12:09 +0200
Subject: [PATCH 02/22] implement DAPGetModuleSymbolsRequestHandler
---
lldb/include/lldb/API/SBSymbol.h | 5 +
lldb/include/lldb/API/SBTarget.h | 2 +
lldb/source/API/SBSymbol.cpp | 16 ++
lldb/source/API/SBTarget.cpp | 12 ++
lldb/tools/lldb-dap/CMakeLists.txt | 1 +
lldb/tools/lldb-dap/DAP.cpp | 1 +
.../DAPGetModuleSymbolsRequestHandler.cpp | 146 ++++++++++++++++++
lldb/tools/lldb-dap/Handler/RequestHandler.h | 5 +-
lldb/tools/lldb-dap/Protocol/DAPTypes.cpp | 13 +-
lldb/tools/lldb-dap/Protocol/DAPTypes.h | 5 +-
.../lldb-dap/Protocol/ProtocolRequests.cpp | 13 ++
.../lldb-dap/Protocol/ProtocolRequests.h | 11 +-
lldb/unittests/DAP/DAPTypesTest.cpp | 29 +++-
13 files changed, 242 insertions(+), 17 deletions(-)
create mode 100644 lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
diff --git a/lldb/include/lldb/API/SBSymbol.h b/lldb/include/lldb/API/SBSymbol.h
index 94521881f82f9..6777494bad1d2 100644
--- a/lldb/include/lldb/API/SBSymbol.h
+++ b/lldb/include/lldb/API/SBSymbol.h
@@ -85,6 +85,8 @@ class LLDB_API SBSymbol {
SymbolType GetType();
+ uint32_t GetID();
+
bool operator==(const lldb::SBSymbol &rhs) const;
bool operator!=(const lldb::SBSymbol &rhs) const;
@@ -99,6 +101,9 @@ class LLDB_API SBSymbol {
// other than the actual symbol table itself in the object file.
bool IsSynthetic();
+ /// Returns true if the symbol is a debug symbol.
+ bool IsDebug();
+
protected:
lldb_private::Symbol *get();
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 22b6c63ed5b97..90fada3aea4ec 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -324,6 +324,8 @@ class LLDB_API SBTarget {
lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec);
+ lldb::SBModule FindModule(const lldb::SBModuleSpec &module_spec);
+
/// Find compile units related to *this target and passed source
/// file.
///
diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp
index 79477dd3a70fc..7bcc7f99079c4 100644
--- a/lldb/source/API/SBSymbol.cpp
+++ b/lldb/source/API/SBSymbol.cpp
@@ -193,6 +193,14 @@ SymbolType SBSymbol::GetType() {
return eSymbolTypeInvalid;
}
+uint32_t SBSymbol::GetID() {
+ LLDB_INSTRUMENT_VA(this);
+
+ if (m_opaque_ptr)
+ return m_opaque_ptr->GetID();
+ return 0;
+}
+
bool SBSymbol::IsExternal() {
LLDB_INSTRUMENT_VA(this);
@@ -208,3 +216,11 @@ bool SBSymbol::IsSynthetic() {
return m_opaque_ptr->IsSynthetic();
return false;
}
+
+bool SBSymbol::IsDebug() {
+ LLDB_INSTRUMENT_VA(this);
+
+ if (m_opaque_ptr)
+ return m_opaque_ptr->IsDebug();
+ return false;
+}
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 6aa41c52f3731..c761b96135a86 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1570,6 +1570,18 @@ SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) {
return sb_module;
}
+SBModule SBTarget::FindModule(const SBModuleSpec &sb_module_spec) {
+ LLDB_INSTRUMENT_VA(this, sb_module_spec);
+
+ SBModule sb_module;
+ if (TargetSP target_sp = GetSP(); target_sp && sb_module_spec.IsValid()) {
+ // The module list is thread safe, no need to lock
+ sb_module.SetSP(
+ target_sp->GetImages().FindFirstModule(*sb_module_spec.m_opaque_up));
+ }
+ return sb_module;
+}
+
SBSymbolContextList SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) {
LLDB_INSTRUMENT_VA(this, sb_file_spec);
diff --git a/lldb/tools/lldb-dap/CMakeLists.txt b/lldb/tools/lldb-dap/CMakeLists.txt
index 5e0ad53b82f89..c3ba53754f8ad 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -36,6 +36,7 @@ add_lldb_library(lldbDAP
Handler/CompletionsHandler.cpp
Handler/ConfigurationDoneRequestHandler.cpp
Handler/ContinueRequestHandler.cpp
+ Handler/DAPGetModuleSymbolsRequestHandler.cpp
Handler/DataBreakpointInfoRequestHandler.cpp
Handler/DisassembleRequestHandler.cpp
Handler/DisconnectRequestHandler.cpp
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index ce910b1f60b85..08d50c9b93a7e 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -1566,6 +1566,7 @@ void DAP::RegisterRequests() {
// Custom requests
RegisterRequest<CompileUnitsRequestHandler>();
RegisterRequest<ModulesRequestHandler>();
+ RegisterRequest<DAPGetModuleSymbolsRequestHandler>();
// Testing requests
RegisterRequest<TestGetTargetBreakpointsRequestHandler>();
diff --git a/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
new file mode 100644
index 0000000000000..aeea45ee2224d
--- /dev/null
+++ b/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
@@ -0,0 +1,146 @@
+//===-- DAPGetModuleSymbolsRequestHandler.cpp -----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "DAP.h"
+#include "DAPError.h"
+#include "Protocol/DAPTypes.h"
+#include "RequestHandler.h"
+#include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBModule.h"
+#include "lldb/API/SBModuleSpec.h"
+#include "lldb/lldb-enumerations.h"
+#include "llvm/Support/Error.h"
+#include <cstddef>
+
+using namespace lldb_dap::protocol;
+namespace lldb_dap {
+
+static std::string SymbolTypeToString(lldb::SymbolType symbol_type) {
+ switch (symbol_type) {
+ case lldb::eSymbolTypeInvalid:
+ return "Invalid";
+ case lldb::eSymbolTypeAbsolute:
+ return "Absolute";
+ case lldb::eSymbolTypeCode:
+ return "Code";
+ case lldb::eSymbolTypeResolver:
+ return "Resolver";
+ case lldb::eSymbolTypeData:
+ return "Data";
+ case lldb::eSymbolTypeTrampoline:
+ return "Trampoline";
+ case lldb::eSymbolTypeRuntime:
+ return "Runtime";
+ case lldb::eSymbolTypeException:
+ return "Exception";
+ case lldb::eSymbolTypeSourceFile:
+ return "SourceFile";
+ case lldb::eSymbolTypeHeaderFile:
+ return "HeaderFile";
+ case lldb::eSymbolTypeObjectFile:
+ return "ObjectFile";
+ case lldb::eSymbolTypeCommonBlock:
+ return "CommonBlock";
+ case lldb::eSymbolTypeBlock:
+ return "Block";
+ case lldb::eSymbolTypeLocal:
+ return "Local";
+ case lldb::eSymbolTypeParam:
+ return "Param";
+ case lldb::eSymbolTypeVariable:
+ return "Variable";
+ case lldb::eSymbolTypeVariableType:
+ return "VariableType";
+ case lldb::eSymbolTypeLineEntry:
+ return "LineEntry";
+ case lldb::eSymbolTypeLineHeader:
+ return "LineHeader";
+ case lldb::eSymbolTypeScopeBegin:
+ return "ScopeBegin";
+ case lldb::eSymbolTypeScopeEnd:
+ return "ScopeEnd";
+ case lldb::eSymbolTypeAdditional:
+ return "Additional";
+ case lldb::eSymbolTypeCompiler:
+ return "Compiler";
+ case lldb::eSymbolTypeInstrumentation:
+ return "Instrumentation";
+ case lldb::eSymbolTypeUndefined:
+ return "Undefined";
+ case lldb::eSymbolTypeObjCClass:
+ return "ObjCClass";
+ case lldb::eSymbolTypeObjCMetaClass:
+ return "ObjCMetaClass";
+ case lldb::eSymbolTypeObjCIVar:
+ return "ObjCIVar";
+ case lldb::eSymbolTypeReExported:
+ return "ReExported";
+ }
+
+ llvm_unreachable("unhandled symbol type.");
+}
+
+/// Modules can be retrieved from the debug adapter with this request which can
+/// either return all modules or a range of modules to support paging.
+///
+/// Clients should only call this request if the corresponding capability
+/// `supportsModulesRequest` is true.
+llvm::Expected<DAPGetModuleSymbolsResponseBody>
+DAPGetModuleSymbolsRequestHandler::Run(
+ const DAPGetModuleSymbolsArguments &args) const {
+ DAPGetModuleSymbolsResponseBody response;
+
+ lldb::SBModuleSpec module_spec;
+ if (args.moduleId)
+ module_spec.SetUUIDBytes(
+ reinterpret_cast<const uint8_t *>(args.moduleId->data()),
+ args.moduleId->size());
+
+ if (args.moduleName) {
+ lldb::SBFileSpec file_spec;
+ file_spec.SetFilename(args.moduleName->c_str());
+ module_spec.SetFileSpec(file_spec);
+ }
+
+ // Empty request, return empty response.
+ // We use it in the client to check if the lldb-dap server supports this
+ // request.
+ if (!module_spec.IsValid())
+ return response;
+
+ std::vector<DAPSymbol> &symbols = response.symbols;
+ lldb::SBModule module = dap.target.FindModule(module_spec);
+ if (!module.IsValid())
+ return llvm::make_error<DAPError>("Module not found");
+
+ size_t num_symbols = module.GetNumSymbols();
+ for (size_t i = 0; i < num_symbols; ++i) {
+ lldb::SBSymbol symbol = module.GetSymbolAtIndex(i);
+ if (!symbol.IsValid())
+ continue;
+
+ DAPSymbol dap_symbol;
+ dap_symbol.userId = symbol.GetID();
+ dap_symbol.type = SymbolTypeToString(symbol.GetType());
+ dap_symbol.isDebug = symbol.IsDebug();
+ dap_symbol.isSynthetic = symbol.IsSynthetic();
+ dap_symbol.isExternal = symbol.IsExternal();
+
+ dap_symbol.fileAddress = symbol.GetStartAddress().GetFileAddress();
+ dap_symbol.loadAddress =
+ symbol.GetStartAddress().GetLoadAddress(dap.target);
+ dap_symbol.size = symbol.GetSize();
+
+ dap_symbol.name = symbol.GetName();
+ symbols.push_back(std::move(dap_symbol));
+ }
+
+ return response;
+}
+
+} // namespace lldb_dap
diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index b010b6525a8d1..e605a8bc1b9f1 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -595,8 +595,9 @@ class CancelRequestHandler : public RequestHandler<protocol::CancelArguments,
};
class DAPGetModuleSymbolsRequestHandler
- : public RequestHandler<protocol::DAPGetModuleSymbolsArguments,
- llvm::Expected<protocol::DAPGetModuleSymbolsResponseBody>> {
+ : public RequestHandler<
+ protocol::DAPGetModuleSymbolsArguments,
+ llvm::Expected<protocol::DAPGetModuleSymbolsResponseBody>> {
public:
using RequestHandler::RequestHandler;
static llvm::StringLiteral GetCommand() { return "dapGetModuleSymbols"; }
diff --git a/lldb/tools/lldb-dap/Protocol/DAPTypes.cpp b/lldb/tools/lldb-dap/Protocol/DAPTypes.cpp
index 1c73328680cdb..212bbd2fe7be6 100644
--- a/lldb/tools/lldb-dap/Protocol/DAPTypes.cpp
+++ b/lldb/tools/lldb-dap/Protocol/DAPTypes.cpp
@@ -36,22 +36,19 @@ llvm::json::Value toJSON(const SourceLLDBData &SLD) {
bool fromJSON(const llvm::json::Value &Params, DAPSymbol &DS,
llvm::json::Path P) {
json::ObjectMapper O(Params, P);
- return O && O.map("userId", DS.userId) &&
- O.map("isDebug", DS.isDebug) &&
- O.map("isSynthesized", DS.isSynthesized) &&
- O.map("isExternal", DS.isExternal) &&
- O.map("type", DS.type) &&
+ return O && O.map("userId", DS.userId) && O.map("isDebug", DS.isDebug) &&
+ O.map("isSynthetic", DS.isSynthetic) &&
+ O.map("isExternal", DS.isExternal) && O.map("type", DS.type) &&
O.map("fileAddress", DS.fileAddress) &&
O.mapOptional("loadAddress", DS.loadAddress) &&
- O.map("size", DS.size) &&
- O.map("name", DS.name);
+ O.map("size", DS.size) && O.map("name", DS.name);
}
llvm::json::Value toJSON(const DAPSymbol &DS) {
json::Object result{
{"userId", DS.userId},
{"isDebug", DS.isDebug},
- {"isSynthesized", DS.isSynthesized},
+ {"isSynthetic", DS.isSynthetic},
{"isExternal", DS.isExternal},
{"type", DS.type},
{"fileAddress", DS.fileAddress},
diff --git a/lldb/tools/lldb-dap/Protocol/DAPTypes.h b/lldb/tools/lldb-dap/Protocol/DAPTypes.h
index 3f2bec81a0436..83f9947b1ab57 100644
--- a/lldb/tools/lldb-dap/Protocol/DAPTypes.h
+++ b/lldb/tools/lldb-dap/Protocol/DAPTypes.h
@@ -55,8 +55,9 @@ struct DAPSymbol {
/// True if this symbol is debug information in a symbol.
bool isDebug;
- /// True if this symbol is not actually in the symbol table, but synthesized from other info in the object file.
- bool isSynthesized;
+ /// True if this symbol is not actually in the symbol table, but synthesized
+ /// from other info in the object file.
+ bool isSynthetic;
/// True if this symbol is globally visible.
bool isExternal;
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
index 29855ca50e9e0..e0d49a7d03ce5 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
@@ -598,4 +598,17 @@ json::Value toJSON(const WriteMemoryResponseBody &WMR) {
return result;
}
+bool fromJSON(const llvm::json::Value &Params,
+ DAPGetModuleSymbolsArguments &Args, llvm::json::Path P) {
+ json::ObjectMapper O(Params, P);
+ return O && O.mapOptional("moduleId", Args.moduleId) &&
+ O.mapOptional("moduleName", Args.moduleName);
+}
+
+llvm::json::Value toJSON(const DAPGetModuleSymbolsResponseBody &DGMSR) {
+ json::Object result;
+ result.insert({"symbols", DGMSR.symbols});
+ return result;
+}
+
} // namespace lldb_dap::protocol
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
index d496433cc02ac..ebf58424f6aa4 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
@@ -982,11 +982,14 @@ struct WriteMemoryResponseBody {
llvm::json::Value toJSON(const WriteMemoryResponseBody &);
struct DAPGetModuleSymbolsArguments {
- /// The module for which to retrieve symbols.
- std::string moduleId;
+ /// The module UUID for which to retrieve symbols.
+ std::optional<std::string> moduleId;
+
+ /// The module path.
+ std::optional<std::string> moduleName;
};
-bool fromJSON(const llvm::json::Value &,
- DAPGetModuleSymbolsArguments &, llvm::json::Path);
+bool fromJSON(const llvm::json::Value &, DAPGetModuleSymbolsArguments &,
+ llvm::json::Path);
/// Response to `getModuleSymbols` request.
struct DAPGetModuleSymbolsResponseBody {
diff --git a/lldb/unittests/DAP/DAPTypesTest.cpp b/lldb/unittests/DAP/DAPTypesTest.cpp
index 8226fc7660d60..180917364b0e2 100644
--- a/lldb/unittests/DAP/DAPTypesTest.cpp
+++ b/lldb/unittests/DAP/DAPTypesTest.cpp
@@ -23,7 +23,8 @@ using lldb_private::roundtripJSON;
TEST(DAPTypesTest, SourceLLDBData) {
SourceLLDBData source_data;
- source_data.persistenceData = PersistenceData{"module_path123", "symbol_name456"};
+ source_data.persistenceData =
+ PersistenceData{"module_path123", "symbol_name456"};
llvm::Expected<SourceLLDBData> deserialized_data = roundtripJSON(source_data);
ASSERT_THAT_EXPECTED(deserialized_data, llvm::Succeeded());
@@ -33,3 +34,29 @@ TEST(DAPTypesTest, SourceLLDBData) {
EXPECT_EQ(source_data.persistenceData->symbol_name,
deserialized_data->persistenceData->symbol_name);
}
+
+TEST(DAPTypesTest, DAPSymbol) {
+ DAPSymbol symbol;
+ symbol.userId = 42;
+ symbol.isDebug = true;
+ symbol.isExternal = false;
+ symbol.isSynthetic = true;
+ symbol.type = "Trampoline";
+ symbol.fileAddress = 0x12345678;
+ symbol.loadAddress = 0x87654321;
+ symbol.size = 64;
+ symbol.name = "testSymbol";
+
+ llvm::Expected<DAPSymbol> deserialized_symbol = roundtripJSON(symbol);
+ ASSERT_THAT_EXPECTED(deserialized_symbol, llvm::Succeeded());
+
+ EXPECT_EQ(symbol.userId, deserialized_symbol->userId);
+ EXPECT_EQ(symbol.isDebug, deserialized_symbol->isDebug);
+ EXPECT_EQ(symbol.isExternal, deserialized_symbol->isExternal);
+ EXPECT_EQ(symbol.isSynthetic, deserialized_symbol->isSynthetic);
+ EXPECT_EQ(symbol.type, deserialized_symbol->type);
+ EXPECT_EQ(symbol.fileAddress, deserialized_symbol->fileAddress);
+ EXPECT_EQ(symbol.loadAddress, deserialized_symbol->loadAddress);
+ EXPECT_EQ(symbol.size, deserialized_symbol->size);
+ EXPECT_EQ(symbol.name, deserialized_symbol->name);
+}
>From ef36ed550574d902b188d3b7edcc6608dafc3817 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Mon, 11 Aug 2025 01:25:15 +0200
Subject: [PATCH 03/22] adding lldb-dap.modules.showSymbols to the
commandPallette
---
.../DAPGetModuleSymbolsRequestHandler.cpp | 12 +-
lldb/tools/lldb-dap/package.json | 9 ++
lldb/tools/lldb-dap/src-ts/extension.ts | 7 +-
.../lldb-dap/src-ts/ui/symbols-provider.ts | 133 ++++++++++++++++++
4 files changed, 156 insertions(+), 5 deletions(-)
create mode 100644 lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
diff --git a/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
index aeea45ee2224d..d502897027993 100644
--- a/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
@@ -13,6 +13,7 @@
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBModule.h"
#include "lldb/API/SBModuleSpec.h"
+#include "lldb/Utility/UUID.h"
#include "lldb/lldb-enumerations.h"
#include "llvm/Support/Error.h"
#include <cstddef>
@@ -96,10 +97,15 @@ DAPGetModuleSymbolsRequestHandler::Run(
DAPGetModuleSymbolsResponseBody response;
lldb::SBModuleSpec module_spec;
- if (args.moduleId)
+ if (args.moduleId) {
+ llvm::SmallVector<uint8_t, 20> uuid_bytes;
+ if (!lldb_private::UUID::DecodeUUIDBytesFromString(*args.moduleId, uuid_bytes).empty())
+ return llvm::make_error<DAPError>("Invalid module ID");
+
module_spec.SetUUIDBytes(
- reinterpret_cast<const uint8_t *>(args.moduleId->data()),
- args.moduleId->size());
+ uuid_bytes.data(),
+ uuid_bytes.size());
+ }
if (args.moduleName) {
lldb::SBFileSpec file_spec;
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index d677a81cc7974..b93fd732d93ab 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -259,6 +259,11 @@
{
"command": "lldb-dap.modules.copyProperty",
"title": "Copy Value"
+ },
+ {
+ "category": "lldb-dap",
+ "command": "lldb-dap.modules.showSymbols",
+ "title": "Show Module Symbols"
}
],
"menus": {
@@ -266,6 +271,10 @@
{
"command": "lldb-dap.modules.copyProperty",
"when": "false"
+ },
+ {
+ "command": "lldb-dap.modules.showSymbols",
+ "when": "debuggersAvailable && debugType == 'lldb-dap'"
}
],
"view/item/context": [
diff --git a/lldb/tools/lldb-dap/src-ts/extension.ts b/lldb/tools/lldb-dap/src-ts/extension.ts
index 4b7a35e6944c6..a54831b5a4025 100644
--- a/lldb/tools/lldb-dap/src-ts/extension.ts
+++ b/lldb/tools/lldb-dap/src-ts/extension.ts
@@ -12,6 +12,7 @@ import {
ModuleProperty,
} from "./ui/modules-data-provider";
import { LogFilePathProvider } from "./logging";
+import { SymbolsProvider } from "./ui/symbols-provider";
/**
* This class represents the extension and manages its life cycle. Other extensions
@@ -52,10 +53,12 @@ export class LLDBDapExtension extends DisposableContext {
vscode.window.registerUriHandler(new LaunchUriHandler()),
);
- vscode.commands.registerCommand(
+ this.pushSubscription(vscode.commands.registerCommand(
"lldb-dap.modules.copyProperty",
(node: ModuleProperty) => vscode.env.clipboard.writeText(node.value),
- );
+ ));
+
+ this.pushSubscription(new SymbolsProvider(sessionTracker));
}
}
diff --git a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
new file mode 100644
index 0000000000000..28fe59e15e484
--- /dev/null
+++ b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
@@ -0,0 +1,133 @@
+import * as vscode from "vscode";
+import { DebugProtocol } from "@vscode/debugprotocol";
+
+import { DebugSessionTracker } from "../debug-session-tracker";
+import { DisposableContext } from "../disposable-context";
+
+export class SymbolsProvider extends DisposableContext {
+ constructor(private readonly tracker: DebugSessionTracker) {
+ super();
+
+ this.pushSubscription(vscode.commands.registerCommand(
+ "lldb-dap.modules.showSymbols",
+ () => {
+ this.SelectModuleAndShowSymbols();
+ },
+ ));
+ }
+
+ static async doesServerSupportSymbolsRequest(session: vscode.DebugSession): Promise<boolean> {
+ try {
+ const dummyArguments = { _dummy: true };
+ const _result = await session.customRequest("dapGetModuleSymbols", dummyArguments);
+ return true;
+ } catch (_error) {
+ return false;
+ }
+ }
+
+ private async SelectModuleAndShowSymbols() {
+ const session = vscode.debug.activeDebugSession;
+ if (!session) {
+ return;
+ }
+
+ if (!await SymbolsProvider.doesServerSupportSymbolsRequest(session)) {
+ vscode.window.showErrorMessage("The debug adapter does not support symbol requests.");
+ return;
+ }
+
+ const modules = this.tracker.debugSessionModules(session);
+ if (!modules || modules.length === 0) {
+ return;
+ }
+
+ // Let the user select a module to show symbols for
+ const selectedModule = await vscode.window.showQuickPick(modules.map(m => new ModuleQuickPickItem(m)), {
+ placeHolder: "Select a module to show symbols for"
+ });
+ if (!selectedModule) {
+ return;
+ }
+
+ let symbols = [];
+ try {
+ symbols = await this.getSymbolsForModule(session, selectedModule.module.id.toString());
+ this.showSymbolsForModule(selectedModule.module.name.toString(), symbols);
+ } catch (error) {
+ if (error instanceof Error) {
+ vscode.window.showErrorMessage("Failed to retrieve symbols: " + error.message);
+ } else {
+ vscode.window.showErrorMessage("Failed to retrieve symbols due to an unknown error.");
+ }
+
+ return;
+ }
+
+ this.showSymbolsForModule(selectedModule.module.name.toString(), symbols);
+ }
+
+ private async getSymbolsForModule(session: vscode.DebugSession, moduleId: string): Promise<DAPSymbol[]> {
+ console.log(`Getting symbols for module: ${moduleId}`);
+ const symbols_response: { symbols: Array<DAPSymbolType> } = await session.customRequest("dapGetModuleSymbols", { moduleId });
+
+
+ return symbols_response?.symbols.map(symbol => new DAPSymbol(
+ symbol.userId,
+ symbol.isDebug,
+ symbol.isSynthetic,
+ symbol.isExternal,
+ symbol.type,
+ symbol.fileAddress,
+ symbol.loadAddress,
+ symbol.size,
+ symbol.name,
+ )) || [];
+ }
+
+ private showSymbolsForModule(moduleName: string, symbols: DAPSymbol[]) {
+ console.log(`Showing symbols for module: ${moduleName}`);
+ symbols.forEach(symbol => {
+ console.log(` - ${symbol.name} (${symbol.type})`);
+ });
+ }
+}
+
+class ModuleQuickPickItem implements vscode.QuickPickItem {
+ constructor(public readonly module: DebugProtocol.Module) {}
+
+ get label(): string {
+ return this.module.name;
+ }
+
+ get description(): string {
+ return this.module.id.toString();
+ }
+}
+
+/// The symbol type we get from the lldb-dap server
+type DAPSymbolType = {
+ userId: number;
+ isDebug: boolean;
+ isSynthetic: boolean;
+ isExternal: boolean;
+ type: string;
+ fileAddress: number;
+ loadAddress?: number;
+ size: number;
+ name: string;
+};
+
+class DAPSymbol {
+ constructor(
+ public readonly userId: number,
+ public readonly isDebug: boolean,
+ public readonly isSynthetic: boolean,
+ public readonly isExternal: boolean,
+ public readonly type: string,
+ public readonly fileAddress: number,
+ public readonly loadAddress: number | undefined,
+ public readonly size: number,
+ public readonly name: string,
+ ) {}
+}
>From df3d8ddc1afe3f2fdf3c6f08de2af380eafed706 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Mon, 11 Aug 2025 01:34:58 +0200
Subject: [PATCH 04/22] basic HTML for symbols webview
---
.../lldb-dap/src-ts/ui/symbols-provider.ts | 24 ++++++++++++-------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
index 28fe59e15e484..9c2f0c7799efe 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
@@ -50,9 +50,8 @@ export class SymbolsProvider extends DisposableContext {
return;
}
- let symbols = [];
try {
- symbols = await this.getSymbolsForModule(session, selectedModule.module.id.toString());
+ const symbols = await this.getSymbolsForModule(session, selectedModule.module.id.toString());
this.showSymbolsForModule(selectedModule.module.name.toString(), symbols);
} catch (error) {
if (error instanceof Error) {
@@ -63,8 +62,6 @@ export class SymbolsProvider extends DisposableContext {
return;
}
-
- this.showSymbolsForModule(selectedModule.module.name.toString(), symbols);
}
private async getSymbolsForModule(session: vscode.DebugSession, moduleId: string): Promise<DAPSymbol[]> {
@@ -85,11 +82,20 @@ export class SymbolsProvider extends DisposableContext {
)) || [];
}
- private showSymbolsForModule(moduleName: string, symbols: DAPSymbol[]) {
- console.log(`Showing symbols for module: ${moduleName}`);
- symbols.forEach(symbol => {
- console.log(` - ${symbol.name} (${symbol.type})`);
- });
+ private async showSymbolsForModule(moduleName: string, symbols: DAPSymbol[]) {
+ const panel = vscode.window.createWebviewPanel(
+ "lldb-dap.symbols",
+ `Symbols for ${moduleName}`,
+ vscode.ViewColumn.Active,
+ {}
+ );
+
+ panel.webview.html = SymbolsProvider.getHTMLContentForSymbols(moduleName, symbols);
+ }
+
+ private static getHTMLContentForSymbols(moduleName: string, symbols: DAPSymbol[]): string {
+ const symbolLines = symbols.map(symbol => ` - ${symbol.name} (${symbol.type})`);
+ return `Symbols for module: ${moduleName}\n${symbolLines.join("\n")}`;
}
}
>From 2ae745df17aa4dff3c21836bf95c4b4c91ac7d36 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Tue, 12 Aug 2025 00:56:52 +0200
Subject: [PATCH 05/22] show symbols in a simple tabulator table
---
lldb/tools/lldb-dap/package-lock.json | 12 +++-
lldb/tools/lldb-dap/package.json | 6 +-
lldb/tools/lldb-dap/src-ts/extension.ts | 5 +-
.../lldb-dap/src-ts/ui/symbols-provider.ts | 59 +++++++++++++++++--
4 files changed, 70 insertions(+), 12 deletions(-)
diff --git a/lldb/tools/lldb-dap/package-lock.json b/lldb/tools/lldb-dap/package-lock.json
index 1969b196accc6..a3dd8e0dd5142 100644
--- a/lldb/tools/lldb-dap/package-lock.json
+++ b/lldb/tools/lldb-dap/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "lldb-dap",
- "version": "0.2.15",
+ "version": "0.2.16",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "lldb-dap",
- "version": "0.2.15",
+ "version": "0.2.16",
"license": "Apache 2.0 License with LLVM exceptions",
"devDependencies": {
"@types/node": "^18.19.41",
@@ -15,6 +15,7 @@
"@vscode/vsce": "^3.2.2",
"prettier": "^3.4.2",
"prettier-plugin-curly": "^0.3.1",
+ "tabulator-tables": "^6.3.1",
"typescript": "^5.7.3"
},
"engines": {
@@ -2557,6 +2558,13 @@
"node": ">=4"
}
},
+ "node_modules/tabulator-tables": {
+ "version": "6.3.1",
+ "resolved": "https://registry.npmjs.org/tabulator-tables/-/tabulator-tables-6.3.1.tgz",
+ "integrity": "sha512-qFW7kfadtcaISQIibKAIy0f3eeIXUVi8242Vly1iJfMD79kfEGzfczNuPBN/80hDxHzQJXYbmJ8VipI40hQtfA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/tar-fs": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz",
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index b93fd732d93ab..3c7c5c288fc55 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -34,6 +34,7 @@
"@vscode/vsce": "^3.2.2",
"prettier": "^3.4.2",
"prettier-plugin-curly": "^0.3.1",
+ "tabulator-tables": "^6.3.1",
"typescript": "^5.7.3"
},
"activationEvents": [
@@ -42,8 +43,9 @@
],
"main": "./out/extension",
"scripts": {
- "vscode:prepublish": "tsc -p ./",
- "watch": "tsc -watch -p ./",
+ "bundle-assets": "cp node_modules/tabulator-tables/dist/js/tabulator.min.js ./out/ && cp node_modules/tabulator-tables/dist/css/tabulator.min.css ./out/",
+ "vscode:prepublish": "npm run bundle-assets && tsc -p ./",
+ "watch": "npm run bundle-assets && tsc -watch -p ./",
"format": "npx prettier './src-ts/' --write",
"package": "rm -rf ./out/lldb-dap.vsix && vsce package --out ./out/lldb-dap.vsix",
"publish": "vsce publish",
diff --git a/lldb/tools/lldb-dap/src-ts/extension.ts b/lldb/tools/lldb-dap/src-ts/extension.ts
index a54831b5a4025..7119cba972fa4 100644
--- a/lldb/tools/lldb-dap/src-ts/extension.ts
+++ b/lldb/tools/lldb-dap/src-ts/extension.ts
@@ -20,6 +20,7 @@ import { SymbolsProvider } from "./ui/symbols-provider";
*/
export class LLDBDapExtension extends DisposableContext {
constructor(
+ context: vscode.ExtensionContext,
logger: vscode.LogOutputChannel,
logFilePath: LogFilePathProvider,
outputChannel: vscode.OutputChannel,
@@ -58,7 +59,7 @@ export class LLDBDapExtension extends DisposableContext {
(node: ModuleProperty) => vscode.env.clipboard.writeText(node.value),
));
- this.pushSubscription(new SymbolsProvider(sessionTracker));
+ this.pushSubscription(new SymbolsProvider(sessionTracker, context));
}
}
@@ -70,7 +71,7 @@ export async function activate(context: vscode.ExtensionContext) {
outputChannel.info("LLDB-DAP extension activating...");
const logFilePath = new LogFilePathProvider(context, outputChannel);
context.subscriptions.push(
- new LLDBDapExtension(outputChannel, logFilePath, outputChannel),
+ new LLDBDapExtension(context, outputChannel, logFilePath, outputChannel),
);
outputChannel.info("LLDB-DAP extension activated");
}
diff --git a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
index 9c2f0c7799efe..d82d1a68c5001 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
@@ -5,7 +5,10 @@ import { DebugSessionTracker } from "../debug-session-tracker";
import { DisposableContext } from "../disposable-context";
export class SymbolsProvider extends DisposableContext {
- constructor(private readonly tracker: DebugSessionTracker) {
+ constructor(
+ private readonly tracker: DebugSessionTracker,
+ private readonly extensionContext: vscode.ExtensionContext,
+ ) {
super();
this.pushSubscription(vscode.commands.registerCommand(
@@ -87,15 +90,59 @@ export class SymbolsProvider extends DisposableContext {
"lldb-dap.symbols",
`Symbols for ${moduleName}`,
vscode.ViewColumn.Active,
- {}
+ {
+ enableScripts: true,
+ localResourceRoots: [
+ this.getExtensionResourcePath()
+ ]
+ }
);
- panel.webview.html = SymbolsProvider.getHTMLContentForSymbols(moduleName, symbols);
+ const tabulatorJsPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "tabulator.min.js"));
+ const tabulatorCssPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "tabulator.min.css"));
+
+ panel.webview.html = this.getHTMLContentForSymbols(tabulatorJsPath, tabulatorCssPath, symbols);
+ }
+
+ private getHTMLContentForSymbols(tabulatorJsPath: vscode.Uri, tabulatorCssPath: vscode.Uri, symbols: DAPSymbol[]): string {
+ const dataJson = JSON.stringify(symbols);
+ return `<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="UTF-8">
+ <link href="${tabulatorCssPath}" rel="stylesheet">
+ <style>
+ body { font-family: sans-serif; margin: 0; padding: 0; }
+ #table { height: 100vh; }
+ </style>
+</head>
+<body>
+ <div id="table"></div>
+ <script src="${tabulatorJsPath}"></script>
+ <script>
+ const tableData = ${dataJson};
+ new Tabulator("#table", {
+ data: tableData,
+ layout: "fitColumns",
+ columns: [
+ {title: "User ID", field: "userId", sorter: "number"},
+ {title: "Debug", field: "isDebug", sorter: "boolean"},
+ {title: "Synthetic", field: "isSynthetic", sorter: "boolean"},
+ {title: "External", field: "isExternal", sorter: "boolean"},
+ {title: "Type", field: "type", sorter: "string"},
+ {title: "File Address", field: "fileAddress", sorter: "number"},
+ {title: "Load Address", field: "loadAddress", sorter: "number"},
+ {title: "Size", field: "size", sorter: "number"},
+ {title: "Name", field: "name", sorter: "string"},
+ ]
+ });
+ </script>
+</body>
+</html>`;
}
- private static getHTMLContentForSymbols(moduleName: string, symbols: DAPSymbol[]): string {
- const symbolLines = symbols.map(symbol => ` - ${symbol.name} (${symbol.type})`);
- return `Symbols for module: ${moduleName}\n${symbolLines.join("\n")}`;
+ private getExtensionResourcePath(): vscode.Uri {
+ return vscode.Uri.joinPath(this.extensionContext.extensionUri, "out");
}
}
>From c6345937d324ee75506a0999c00460985394b5dc Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Wed, 13 Aug 2025 09:55:15 +0200
Subject: [PATCH 06/22] split symbols webview script to a new ts directory
---
lldb/tools/lldb-dap/package-lock.json | 8 +++
lldb/tools/lldb-dap/package.json | 7 +--
.../src-ts-webview/symbols-table-view.ts | 52 +++++++++++++++++++
.../lldb-dap/src-ts-webview/tsconfig.json | 10 ++++
.../tools/lldb-dap/{ => src-ts}/tsconfig.json | 9 ++--
.../lldb-dap/src-ts/ui/symbols-provider.ts | 28 +++-------
6 files changed, 85 insertions(+), 29 deletions(-)
create mode 100644 lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts
create mode 100644 lldb/tools/lldb-dap/src-ts-webview/tsconfig.json
rename lldb/tools/lldb-dap/{ => src-ts}/tsconfig.json (58%)
diff --git a/lldb/tools/lldb-dap/package-lock.json b/lldb/tools/lldb-dap/package-lock.json
index a3dd8e0dd5142..b419b1589b85a 100644
--- a/lldb/tools/lldb-dap/package-lock.json
+++ b/lldb/tools/lldb-dap/package-lock.json
@@ -10,6 +10,7 @@
"license": "Apache 2.0 License with LLVM exceptions",
"devDependencies": {
"@types/node": "^18.19.41",
+ "@types/tabulator-tables": "^6.2.10",
"@types/vscode": "1.75.0",
"@vscode/debugprotocol": "^1.68.0",
"@vscode/vsce": "^3.2.2",
@@ -400,6 +401,13 @@
"undici-types": "~5.26.4"
}
},
+ "node_modules/@types/tabulator-tables": {
+ "version": "6.2.10",
+ "resolved": "https://registry.npmjs.org/@types/tabulator-tables/-/tabulator-tables-6.2.10.tgz",
+ "integrity": "sha512-g6o0gG3lu/ozmxPw9rLY1p57T6rvV8OhbJKyzWwPwjdnN3JuSQ3gWxb06v2+dl2tdoqNXTvlylipSSKpS8UzzQ==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@types/vscode": {
"version": "1.75.0",
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.75.0.tgz",
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 3c7c5c288fc55..9e3b215adea35 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -29,6 +29,7 @@
],
"devDependencies": {
"@types/node": "^18.19.41",
+ "@types/tabulator-tables": "^6.2.10",
"@types/vscode": "1.75.0",
"@vscode/debugprotocol": "^1.68.0",
"@vscode/vsce": "^3.2.2",
@@ -43,9 +44,9 @@
],
"main": "./out/extension",
"scripts": {
- "bundle-assets": "cp node_modules/tabulator-tables/dist/js/tabulator.min.js ./out/ && cp node_modules/tabulator-tables/dist/css/tabulator.min.css ./out/",
- "vscode:prepublish": "npm run bundle-assets && tsc -p ./",
- "watch": "npm run bundle-assets && tsc -watch -p ./",
+ "bundle-webview": "tsc -p ./src-ts-webview/ && cp node_modules/tabulator-tables/dist/js/tabulator.min.js ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator.min.css ./out/webview/",
+ "vscode:prepublish": "npm run bundle-webview && tsc -p ./src-ts/",
+ "watch": "npm run bundle-webview && tsc -watch -p ./src-ts/",
"format": "npx prettier './src-ts/' --write",
"package": "rm -rf ./out/lldb-dap.vsix && vsce package --out ./out/lldb-dap.vsix",
"publish": "vsce publish",
diff --git a/lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts b/lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts
new file mode 100644
index 0000000000000..75f62d5f68d6b
--- /dev/null
+++ b/lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts
@@ -0,0 +1,52 @@
+import type { ColumnDefinition } from "tabulator-tables";
+
+const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
+ { title: "User ID", field: "userId", sorter: "number" },
+ { title: "Debug", field: "isDebug", sorter: "boolean" },
+ { title: "Synthetic", field: "isSynthetic", sorter: "boolean" },
+ { title: "External", field: "isExternal", sorter: "boolean" },
+ { title: "Type", field: "type", sorter: "string" },
+ {
+ title: "File Address",
+ field: "fileAddress",
+ sorter: "number",
+ formatter: cell => "0x" + cell.getValue().toString(16).toUpperCase()
+ },
+ {
+ title: "Load Address",
+ field: "loadAddress",
+ sorter: "number",
+ formatter: cell => {
+ const val = cell.getValue();
+ return val !== undefined ? "0x" + val.toString(16).toUpperCase() : "";
+ }
+ },
+ { title: "Size", field: "size", sorter: "number" },
+ {
+ title: "Name",
+ field: "name",
+ sorter: "string",
+ widthGrow: 2,
+ minWidth: 200
+ }
+]
+
+console.log("FUCK");
+console.log("Symbols table columns:", SYMBOL_TABLE_COLUMNS);
+
+declare const Tabulator: any; // HACK: real definition comes from tabulator.min.js
+const SYMBOLS_TABLE = new Tabulator("#symbols-table", {
+ columns: SYMBOL_TABLE_COLUMNS,
+ layout: "fitData",
+ data: [],
+});
+
+window.addEventListener("message", (event: MessageEvent<any>) => {
+ const message = event.data;
+ switch (message.type) {
+ case "updateSymbols":
+ SYMBOLS_TABLE.setData(message.symbols);
+ break;
+ }
+});
+
diff --git a/lldb/tools/lldb-dap/src-ts-webview/tsconfig.json b/lldb/tools/lldb-dap/src-ts-webview/tsconfig.json
new file mode 100644
index 0000000000000..2ba15e79be4f7
--- /dev/null
+++ b/lldb/tools/lldb-dap/src-ts-webview/tsconfig.json
@@ -0,0 +1,10 @@
+{
+ "compilerOptions": {
+ "moduleResolution": "node",
+ "module": "ESNext",
+ "target": "ESNext",
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
+ "outDir": "../out/webview"
+ },
+ "include": ["./**/*"]
+}
diff --git a/lldb/tools/lldb-dap/tsconfig.json b/lldb/tools/lldb-dap/src-ts/tsconfig.json
similarity index 58%
rename from lldb/tools/lldb-dap/tsconfig.json
rename to lldb/tools/lldb-dap/src-ts/tsconfig.json
index 2092148888904..04b74ae0d90fd 100644
--- a/lldb/tools/lldb-dap/tsconfig.json
+++ b/lldb/tools/lldb-dap/src-ts/tsconfig.json
@@ -1,16 +1,17 @@
{
"compilerOptions": {
+ "moduleResolution": "node",
"module": "commonjs",
- "outDir": "out",
- "rootDir": "src-ts",
+ "outDir": "../out",
+ "rootDir": ".",
"sourceMap": true,
"strict": true,
"target": "es6"
},
"include": [
- "src-ts"
+ "./**/*"
],
"exclude": [
- "node_modules",
+ "../node_modules",
]
}
diff --git a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
index d82d1a68c5001..bb1fe5a29d83f 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
@@ -100,12 +100,13 @@ export class SymbolsProvider extends DisposableContext {
const tabulatorJsPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "tabulator.min.js"));
const tabulatorCssPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "tabulator.min.css"));
+ const symbolsTableScriptPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "symbols-table-view.js"));
- panel.webview.html = this.getHTMLContentForSymbols(tabulatorJsPath, tabulatorCssPath, symbols);
+ panel.webview.html = this.getHTMLContentForSymbols(tabulatorJsPath, tabulatorCssPath, symbolsTableScriptPath, symbols);
+ panel.webview.postMessage({ command: "setSymbols", symbols: symbols });
}
- private getHTMLContentForSymbols(tabulatorJsPath: vscode.Uri, tabulatorCssPath: vscode.Uri, symbols: DAPSymbol[]): string {
- const dataJson = JSON.stringify(symbols);
+ private getHTMLContentForSymbols(tabulatorJsPath: vscode.Uri, tabulatorCssPath: vscode.Uri, symbolsTableScriptPath: vscode.Uri, symbols: DAPSymbol[]): string {
return `<!DOCTYPE html>
<html>
<head>
@@ -119,30 +120,13 @@ export class SymbolsProvider extends DisposableContext {
<body>
<div id="table"></div>
<script src="${tabulatorJsPath}"></script>
- <script>
- const tableData = ${dataJson};
- new Tabulator("#table", {
- data: tableData,
- layout: "fitColumns",
- columns: [
- {title: "User ID", field: "userId", sorter: "number"},
- {title: "Debug", field: "isDebug", sorter: "boolean"},
- {title: "Synthetic", field: "isSynthetic", sorter: "boolean"},
- {title: "External", field: "isExternal", sorter: "boolean"},
- {title: "Type", field: "type", sorter: "string"},
- {title: "File Address", field: "fileAddress", sorter: "number"},
- {title: "Load Address", field: "loadAddress", sorter: "number"},
- {title: "Size", field: "size", sorter: "number"},
- {title: "Name", field: "name", sorter: "string"},
- ]
- });
- </script>
+ <script src="${symbolsTableScriptPath}"></script>
</body>
</html>`;
}
private getExtensionResourcePath(): vscode.Uri {
- return vscode.Uri.joinPath(this.extensionContext.extensionUri, "out");
+ return vscode.Uri.joinPath(this.extensionContext.extensionUri, "out", "webview");
}
}
>From 2ea7136470c71760491a2f727faef0d8ba996849 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Thu, 14 Aug 2025 22:59:10 +0200
Subject: [PATCH 07/22] working symbol table white default theme
---
lldb/tools/lldb-dap/package-lock.json | 485 ++++++++++++++++++
lldb/tools/lldb-dap/package.json | 5 +-
.../src-ts-webview/symbols-table-view.ts | 9 +-
.../lldb-dap/src-ts/ui/symbols-provider.ts | 2 +-
4 files changed, 494 insertions(+), 7 deletions(-)
diff --git a/lldb/tools/lldb-dap/package-lock.json b/lldb/tools/lldb-dap/package-lock.json
index b419b1589b85a..38c477d73fa7d 100644
--- a/lldb/tools/lldb-dap/package-lock.json
+++ b/lldb/tools/lldb-dap/package-lock.json
@@ -14,6 +14,7 @@
"@types/vscode": "1.75.0",
"@vscode/debugprotocol": "^1.68.0",
"@vscode/vsce": "^3.2.2",
+ "esbuild": "^0.25.9",
"prettier": "^3.4.2",
"prettier-plugin-curly": "^0.3.1",
"tabulator-tables": "^6.3.1",
@@ -320,6 +321,448 @@
"node": ">=6.9.0"
}
},
+ "node_modules/@esbuild/aix-ppc64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.9.tgz",
+ "integrity": "sha512-OaGtL73Jck6pBKjNIe24BnFE6agGl+6KxDtTfHhy1HmhthfKouEcOhqpSL64K4/0WCtbKFLOdzD/44cJ4k9opA==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "aix"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/android-arm": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.9.tgz",
+ "integrity": "sha512-5WNI1DaMtxQ7t7B6xa572XMXpHAaI/9Hnhk8lcxF4zVN4xstUgTlvuGDorBguKEnZO70qwEcLpfifMLoxiPqHQ==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/android-arm64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.9.tgz",
+ "integrity": "sha512-IDrddSmpSv51ftWslJMvl3Q2ZT98fUSL2/rlUXuVqRXHCs5EUF1/f+jbjF5+NG9UffUDMCiTyh8iec7u8RlTLg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/android-x64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.9.tgz",
+ "integrity": "sha512-I853iMZ1hWZdNllhVZKm34f4wErd4lMyeV7BLzEExGEIZYsOzqDWDf+y082izYUE8gtJnYHdeDpN/6tUdwvfiw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/darwin-arm64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.9.tgz",
+ "integrity": "sha512-XIpIDMAjOELi/9PB30vEbVMs3GV1v2zkkPnuyRRURbhqjyzIINwj+nbQATh4H9GxUgH1kFsEyQMxwiLFKUS6Rg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/darwin-x64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.9.tgz",
+ "integrity": "sha512-jhHfBzjYTA1IQu8VyrjCX4ApJDnH+ez+IYVEoJHeqJm9VhG9Dh2BYaJritkYK3vMaXrf7Ogr/0MQ8/MeIefsPQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/freebsd-arm64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.9.tgz",
+ "integrity": "sha512-z93DmbnY6fX9+KdD4Ue/H6sYs+bhFQJNCPZsi4XWJoYblUqT06MQUdBCpcSfuiN72AbqeBFu5LVQTjfXDE2A6Q==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/freebsd-x64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.9.tgz",
+ "integrity": "sha512-mrKX6H/vOyo5v71YfXWJxLVxgy1kyt1MQaD8wZJgJfG4gq4DpQGpgTB74e5yBeQdyMTbgxp0YtNj7NuHN0PoZg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-arm": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.9.tgz",
+ "integrity": "sha512-HBU2Xv78SMgaydBmdor38lg8YDnFKSARg1Q6AT0/y2ezUAKiZvc211RDFHlEZRFNRVhcMamiToo7bDx3VEOYQw==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-arm64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.9.tgz",
+ "integrity": "sha512-BlB7bIcLT3G26urh5Dmse7fiLmLXnRlopw4s8DalgZ8ef79Jj4aUcYbk90g8iCa2467HX8SAIidbL7gsqXHdRw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-ia32": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.9.tgz",
+ "integrity": "sha512-e7S3MOJPZGp2QW6AK6+Ly81rC7oOSerQ+P8L0ta4FhVi+/j/v2yZzx5CqqDaWjtPFfYz21Vi1S0auHrap3Ma3A==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-loong64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.9.tgz",
+ "integrity": "sha512-Sbe10Bnn0oUAB2AalYztvGcK+o6YFFA/9829PhOCUS9vkJElXGdphz0A3DbMdP8gmKkqPmPcMJmJOrI3VYB1JQ==",
+ "cpu": [
+ "loong64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-mips64el": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.9.tgz",
+ "integrity": "sha512-YcM5br0mVyZw2jcQeLIkhWtKPeVfAerES5PvOzaDxVtIyZ2NUBZKNLjC5z3/fUlDgT6w89VsxP2qzNipOaaDyA==",
+ "cpu": [
+ "mips64el"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-ppc64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.9.tgz",
+ "integrity": "sha512-++0HQvasdo20JytyDpFvQtNrEsAgNG2CY1CLMwGXfFTKGBGQT3bOeLSYE2l1fYdvML5KUuwn9Z8L1EWe2tzs1w==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-riscv64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.9.tgz",
+ "integrity": "sha512-uNIBa279Y3fkjV+2cUjx36xkx7eSjb8IvnL01eXUKXez/CBHNRw5ekCGMPM0BcmqBxBcdgUWuUXmVWwm4CH9kg==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-s390x": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.9.tgz",
+ "integrity": "sha512-Mfiphvp3MjC/lctb+7D287Xw1DGzqJPb/J2aHHcHxflUo+8tmN/6d4k6I2yFR7BVo5/g7x2Monq4+Yew0EHRIA==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-x64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.9.tgz",
+ "integrity": "sha512-iSwByxzRe48YVkmpbgoxVzn76BXjlYFXC7NvLYq+b+kDjyyk30J0JY47DIn8z1MO3K0oSl9fZoRmZPQI4Hklzg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/netbsd-arm64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.9.tgz",
+ "integrity": "sha512-9jNJl6FqaUG+COdQMjSCGW4QiMHH88xWbvZ+kRVblZsWrkXlABuGdFJ1E9L7HK+T0Yqd4akKNa/lO0+jDxQD4Q==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "netbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/netbsd-x64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.9.tgz",
+ "integrity": "sha512-RLLdkflmqRG8KanPGOU7Rpg829ZHu8nFy5Pqdi9U01VYtG9Y0zOG6Vr2z4/S+/3zIyOxiK6cCeYNWOFR9QP87g==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "netbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/openbsd-arm64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.9.tgz",
+ "integrity": "sha512-YaFBlPGeDasft5IIM+CQAhJAqS3St3nJzDEgsgFixcfZeyGPCd6eJBWzke5piZuZ7CtL656eOSYKk4Ls2C0FRQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/openbsd-x64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.9.tgz",
+ "integrity": "sha512-1MkgTCuvMGWuqVtAvkpkXFmtL8XhWy+j4jaSO2wxfJtilVCi0ZE37b8uOdMItIHz4I6z1bWWtEX4CJwcKYLcuA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/openharmony-arm64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.9.tgz",
+ "integrity": "sha512-4Xd0xNiMVXKh6Fa7HEJQbrpP3m3DDn43jKxMjxLLRjWnRsfxjORYJlXPO4JNcXtOyfajXorRKY9NkOpTHptErg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openharmony"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/sunos-x64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.9.tgz",
+ "integrity": "sha512-WjH4s6hzo00nNezhp3wFIAfmGZ8U7KtrJNlFMRKxiI9mxEK1scOMAaa9i4crUtu+tBr+0IN6JCuAcSBJZfnphw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "sunos"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/win32-arm64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.9.tgz",
+ "integrity": "sha512-mGFrVJHmZiRqmP8xFOc6b84/7xa5y5YvR1x8djzXpJBSv/UsNK6aqec+6JDjConTgvvQefdGhFDAs2DLAds6gQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/win32-ia32": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.9.tgz",
+ "integrity": "sha512-b33gLVU2k11nVx1OhX3C8QQP6UHQK4ZtN56oFWvVXvz2VkDoe6fbG8TOgHFxEvqeqohmRnIHe5A1+HADk4OQww==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/win32-x64": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.9.tgz",
+ "integrity": "sha512-PPOl1mi6lpLNQxnGoyAfschAodRFYXJ+9fs6WHXz7CSWKbOqiMZsubC+BQsVKuul+3vKLuwTHsS2c2y9EoKwxQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
"node_modules/@isaacs/cliui": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
@@ -1178,6 +1621,48 @@
"node": ">= 0.4"
}
},
+ "node_modules/esbuild": {
+ "version": "0.25.9",
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.9.tgz",
+ "integrity": "sha512-CRbODhYyQx3qp7ZEwzxOk4JBqmD/seJrzPa/cGjY1VtIn5E09Oi9/dB4JwctnfZ8Q8iT7rioVv5k/FNT/uf54g==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "bin": {
+ "esbuild": "bin/esbuild"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "optionalDependencies": {
+ "@esbuild/aix-ppc64": "0.25.9",
+ "@esbuild/android-arm": "0.25.9",
+ "@esbuild/android-arm64": "0.25.9",
+ "@esbuild/android-x64": "0.25.9",
+ "@esbuild/darwin-arm64": "0.25.9",
+ "@esbuild/darwin-x64": "0.25.9",
+ "@esbuild/freebsd-arm64": "0.25.9",
+ "@esbuild/freebsd-x64": "0.25.9",
+ "@esbuild/linux-arm": "0.25.9",
+ "@esbuild/linux-arm64": "0.25.9",
+ "@esbuild/linux-ia32": "0.25.9",
+ "@esbuild/linux-loong64": "0.25.9",
+ "@esbuild/linux-mips64el": "0.25.9",
+ "@esbuild/linux-ppc64": "0.25.9",
+ "@esbuild/linux-riscv64": "0.25.9",
+ "@esbuild/linux-s390x": "0.25.9",
+ "@esbuild/linux-x64": "0.25.9",
+ "@esbuild/netbsd-arm64": "0.25.9",
+ "@esbuild/netbsd-x64": "0.25.9",
+ "@esbuild/openbsd-arm64": "0.25.9",
+ "@esbuild/openbsd-x64": "0.25.9",
+ "@esbuild/openharmony-arm64": "0.25.9",
+ "@esbuild/sunos-x64": "0.25.9",
+ "@esbuild/win32-arm64": "0.25.9",
+ "@esbuild/win32-ia32": "0.25.9",
+ "@esbuild/win32-x64": "0.25.9"
+ }
+ },
"node_modules/escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 9e3b215adea35..a3c7650636778 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -33,6 +33,7 @@
"@types/vscode": "1.75.0",
"@vscode/debugprotocol": "^1.68.0",
"@vscode/vsce": "^3.2.2",
+ "esbuild": "^0.25.9",
"prettier": "^3.4.2",
"prettier-plugin-curly": "^0.3.1",
"tabulator-tables": "^6.3.1",
@@ -44,7 +45,9 @@
],
"main": "./out/extension",
"scripts": {
- "bundle-webview": "tsc -p ./src-ts-webview/ && cp node_modules/tabulator-tables/dist/js/tabulator.min.js ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator.min.css ./out/webview/",
+ "bundle-symbols-table-view": "npx esbuild src-ts-webview/symbols-table-view.ts --bundle --format=iife --outdir=./out/webview",
+ "bundle-tabulator": "cp node_modules/tabulator-tables/dist/js/tabulator.min.js ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator.min.css ./out/webview/",
+ "bundle-webview": "npm run bundle-symbols-table-view && npm run bundle-tabulator",
"vscode:prepublish": "npm run bundle-webview && tsc -p ./src-ts/",
"watch": "npm run bundle-webview && tsc -watch -p ./src-ts/",
"format": "npx prettier './src-ts/' --write",
diff --git a/lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts b/lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts
index 75f62d5f68d6b..38effc196ac32 100644
--- a/lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts
+++ b/lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts
@@ -31,20 +31,19 @@ const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
}
]
-console.log("FUCK");
-console.log("Symbols table columns:", SYMBOL_TABLE_COLUMNS);
-
declare const Tabulator: any; // HACK: real definition comes from tabulator.min.js
-const SYMBOLS_TABLE = new Tabulator("#symbols-table", {
+const SYMBOLS_TABLE = new Tabulator("#table", {
columns: SYMBOL_TABLE_COLUMNS,
layout: "fitData",
data: [],
});
window.addEventListener("message", (event: MessageEvent<any>) => {
+ console.log("FUCK1");
const message = event.data;
- switch (message.type) {
+ switch (message.command) {
case "updateSymbols":
+ console.log("Received symbols update:", message.symbols);
SYMBOLS_TABLE.setData(message.symbols);
break;
}
diff --git a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
index bb1fe5a29d83f..cd9879778f27f 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
@@ -103,7 +103,7 @@ export class SymbolsProvider extends DisposableContext {
const symbolsTableScriptPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "symbols-table-view.js"));
panel.webview.html = this.getHTMLContentForSymbols(tabulatorJsPath, tabulatorCssPath, symbolsTableScriptPath, symbols);
- panel.webview.postMessage({ command: "setSymbols", symbols: symbols });
+ panel.webview.postMessage({ command: "updateSymbols", symbols: symbols });
}
private getHTMLContentForSymbols(tabulatorJsPath: vscode.Uri, tabulatorCssPath: vscode.Uri, symbolsTableScriptPath: vscode.Uri, symbols: DAPSymbol[]): string {
>From bebaeb82b748ae722161d6f5502d95c47cc2e9e8 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 00:13:12 +0200
Subject: [PATCH 08/22] common formatter
---
.../lldb-dap/src-ts-webview/symbols-table-view.ts | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts b/lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts
index 38effc196ac32..9e0da64b95c8b 100644
--- a/lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts
+++ b/lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts
@@ -1,4 +1,9 @@
-import type { ColumnDefinition } from "tabulator-tables";
+import type { CellComponent, ColumnDefinition } from "tabulator-tables";
+
+const TABULATOR_HEXA_FORMATTER = (cell: CellComponent) => {
+ const val = cell.getValue();
+ return val !== undefined ? "0x" + val.toString(16).toUpperCase() : "";
+};
const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
{ title: "User ID", field: "userId", sorter: "number" },
@@ -10,16 +15,13 @@ const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
title: "File Address",
field: "fileAddress",
sorter: "number",
- formatter: cell => "0x" + cell.getValue().toString(16).toUpperCase()
+ formatter: TABULATOR_HEXA_FORMATTER,
},
{
title: "Load Address",
field: "loadAddress",
sorter: "number",
- formatter: cell => {
- const val = cell.getValue();
- return val !== undefined ? "0x" + val.toString(16).toUpperCase() : "";
- }
+ formatter: TABULATOR_HEXA_FORMATTER,
},
{ title: "Size", field: "size", sorter: "number" },
{
>From e56ffd0cef1e1ec9eb09748a8acd8a3ae540f65f Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 00:17:47 +0200
Subject: [PATCH 09/22] restore ts files to src-ts
---
lldb/tools/lldb-dap/package.json | 2 +-
lldb/tools/lldb-dap/src-ts-webview/tsconfig.json | 10 ----------
.../webview}/symbols-table-view.ts | 0
lldb/tools/lldb-dap/{src-ts => }/tsconfig.json | 9 +++++----
4 files changed, 6 insertions(+), 15 deletions(-)
delete mode 100644 lldb/tools/lldb-dap/src-ts-webview/tsconfig.json
rename lldb/tools/lldb-dap/{src-ts-webview => src-ts/webview}/symbols-table-view.ts (100%)
rename lldb/tools/lldb-dap/{src-ts => }/tsconfig.json (65%)
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index a3c7650636778..031a80941d9b8 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -45,7 +45,7 @@
],
"main": "./out/extension",
"scripts": {
- "bundle-symbols-table-view": "npx esbuild src-ts-webview/symbols-table-view.ts --bundle --format=iife --outdir=./out/webview",
+ "bundle-symbols-table-view": "npx esbuild src-ts/webview/symbols-table-view.ts --bundle --format=iife --outdir=./out/webview",
"bundle-tabulator": "cp node_modules/tabulator-tables/dist/js/tabulator.min.js ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator.min.css ./out/webview/",
"bundle-webview": "npm run bundle-symbols-table-view && npm run bundle-tabulator",
"vscode:prepublish": "npm run bundle-webview && tsc -p ./src-ts/",
diff --git a/lldb/tools/lldb-dap/src-ts-webview/tsconfig.json b/lldb/tools/lldb-dap/src-ts-webview/tsconfig.json
deleted file mode 100644
index 2ba15e79be4f7..0000000000000
--- a/lldb/tools/lldb-dap/src-ts-webview/tsconfig.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "compilerOptions": {
- "moduleResolution": "node",
- "module": "ESNext",
- "target": "ESNext",
- "lib": ["ESNext", "DOM", "DOM.Iterable"],
- "outDir": "../out/webview"
- },
- "include": ["./**/*"]
-}
diff --git a/lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
similarity index 100%
rename from lldb/tools/lldb-dap/src-ts-webview/symbols-table-view.ts
rename to lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
diff --git a/lldb/tools/lldb-dap/src-ts/tsconfig.json b/lldb/tools/lldb-dap/tsconfig.json
similarity index 65%
rename from lldb/tools/lldb-dap/src-ts/tsconfig.json
rename to lldb/tools/lldb-dap/tsconfig.json
index 04b74ae0d90fd..06a484a1fc263 100644
--- a/lldb/tools/lldb-dap/src-ts/tsconfig.json
+++ b/lldb/tools/lldb-dap/tsconfig.json
@@ -2,16 +2,17 @@
"compilerOptions": {
"moduleResolution": "node",
"module": "commonjs",
- "outDir": "../out",
- "rootDir": ".",
+ "outDir": "out",
+ "rootDir": "src-ts",
"sourceMap": true,
"strict": true,
"target": "es6"
},
"include": [
- "./**/*"
+ "src-ts"
],
"exclude": [
- "../node_modules",
+ "node_modules",
+ "src-ts/webview",
]
}
>From 616eb431638ec8b5c66a683a465330044d3bea1c Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 11:09:27 +0200
Subject: [PATCH 10/22] fit table columns to viewport
---
lldb/tools/lldb-dap/package.json | 4 +-
.../lldb-dap/src-ts/ui/symbols-provider.ts | 22 ++-----
.../src-ts/webview/symbols-table-view.ts | 65 ++++++++++++-------
3 files changed, 50 insertions(+), 41 deletions(-)
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 031a80941d9b8..76e78281888d0 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -48,8 +48,8 @@
"bundle-symbols-table-view": "npx esbuild src-ts/webview/symbols-table-view.ts --bundle --format=iife --outdir=./out/webview",
"bundle-tabulator": "cp node_modules/tabulator-tables/dist/js/tabulator.min.js ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator.min.css ./out/webview/",
"bundle-webview": "npm run bundle-symbols-table-view && npm run bundle-tabulator",
- "vscode:prepublish": "npm run bundle-webview && tsc -p ./src-ts/",
- "watch": "npm run bundle-webview && tsc -watch -p ./src-ts/",
+ "vscode:prepublish": "npm run bundle-webview && tsc -p ./",
+ "watch": "npm run bundle-webview && tsc -watch -p ./",
"format": "npx prettier './src-ts/' --write",
"package": "rm -rf ./out/lldb-dap.vsix && vsce package --out ./out/lldb-dap.vsix",
"publish": "vsce publish",
diff --git a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
index cd9879778f27f..41637c32350ce 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
@@ -4,6 +4,8 @@ import { DebugProtocol } from "@vscode/debugprotocol";
import { DebugSessionTracker } from "../debug-session-tracker";
import { DisposableContext } from "../disposable-context";
+import { DAPSymbolType } from "..";
+
export class SymbolsProvider extends DisposableContext {
constructor(
private readonly tracker: DebugSessionTracker,
@@ -22,7 +24,7 @@ export class SymbolsProvider extends DisposableContext {
static async doesServerSupportSymbolsRequest(session: vscode.DebugSession): Promise<boolean> {
try {
const dummyArguments = { _dummy: true };
- const _result = await session.customRequest("dapGetModuleSymbols", dummyArguments);
+ await session.customRequest("dapGetModuleSymbols", dummyArguments);
return true;
} catch (_error) {
return false;
@@ -113,12 +115,11 @@ export class SymbolsProvider extends DisposableContext {
<meta charset="UTF-8">
<link href="${tabulatorCssPath}" rel="stylesheet">
<style>
- body { font-family: sans-serif; margin: 0; padding: 0; }
- #table { height: 100vh; }
+ #symbols-table { height: 100vh; }
</style>
</head>
<body>
- <div id="table"></div>
+ <div id="symbols-table"></div>
<script src="${tabulatorJsPath}"></script>
<script src="${symbolsTableScriptPath}"></script>
</body>
@@ -142,19 +143,6 @@ class ModuleQuickPickItem implements vscode.QuickPickItem {
}
}
-/// The symbol type we get from the lldb-dap server
-type DAPSymbolType = {
- userId: number;
- isDebug: boolean;
- isSynthetic: boolean;
- isExternal: boolean;
- type: string;
- fileAddress: number;
- loadAddress?: number;
- size: number;
- name: string;
-};
-
class DAPSymbol {
constructor(
public readonly userId: number,
diff --git a/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
index 9e0da64b95c8b..b5609b6d3292e 100644
--- a/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
+++ b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
@@ -1,52 +1,73 @@
import type { CellComponent, ColumnDefinition } from "tabulator-tables";
+import type { DAPSymbolType } from ".."
-const TABULATOR_HEXA_FORMATTER = (cell: CellComponent) => {
- const val = cell.getValue();
- return val !== undefined ? "0x" + val.toString(16).toUpperCase() : "";
-};
+function get_tabulator_hexa_formatter(padding: number): (cell: CellComponent) => string {
+ return (cell: CellComponent) => {
+ const val = cell.getValue();
+ return val !== undefined ? "0x" + val.toString(16).toLowerCase().padStart(padding, "0") : "";
+ };
+}
const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
{ title: "User ID", field: "userId", sorter: "number" },
- { title: "Debug", field: "isDebug", sorter: "boolean" },
- { title: "Synthetic", field: "isSynthetic", sorter: "boolean" },
- { title: "External", field: "isExternal", sorter: "boolean" },
+ {
+ title: "Name",
+ field: "name",
+ sorter: "string",
+ widthGrow: 2,
+ minWidth: 200,
+ },
+ {
+ title: "DSX",
+ hozAlign: "center",
+ formatter: (cell: CellComponent) => {
+ const rowData = cell.getRow().getData();
+ let label = "";
+ label += rowData.isDebug ? "D" : "";
+ label += rowData.isSynthetic ? "S" : "";
+ label += rowData.isExternal ? "X" : "";
+ return label;
+ },
+ sorter: (_a, _b, aRow, bRow) => {
+ const valuesA = [aRow.getData().isDebug, aRow.getData().isSynthetic, aRow.getData().isExternal];
+ const valuesB = [bRow.getData().isDebug, bRow.getData().isSynthetic, bRow.getData().isExternal];
+
+ return valuesA < valuesB ? -1 : valuesA > valuesB ? 1 : 0;
+ }
+ },
{ title: "Type", field: "type", sorter: "string" },
{
title: "File Address",
field: "fileAddress",
sorter: "number",
- formatter: TABULATOR_HEXA_FORMATTER,
+ formatter: get_tabulator_hexa_formatter(16),
},
{
title: "Load Address",
field: "loadAddress",
sorter: "number",
- formatter: TABULATOR_HEXA_FORMATTER,
+ formatter: get_tabulator_hexa_formatter(16),
},
- { title: "Size", field: "size", sorter: "number" },
- {
- title: "Name",
- field: "name",
- sorter: "string",
- widthGrow: 2,
- minWidth: 200
- }
+ { title: "Size", field: "size", sorter: "number", formatter: get_tabulator_hexa_formatter(8) },
]
declare const Tabulator: any; // HACK: real definition comes from tabulator.min.js
-const SYMBOLS_TABLE = new Tabulator("#table", {
+const SYMBOLS_TABLE = new Tabulator("#symbols-table", {
+ height: "100vh",
columns: SYMBOL_TABLE_COLUMNS,
- layout: "fitData",
+ layout: "fitColumns",
data: [],
});
+function updateSymbolsTable(symbols: DAPSymbolType[]) {
+ SYMBOLS_TABLE.setData(symbols);
+}
+
window.addEventListener("message", (event: MessageEvent<any>) => {
- console.log("FUCK1");
const message = event.data;
switch (message.command) {
case "updateSymbols":
- console.log("Received symbols update:", message.symbols);
- SYMBOLS_TABLE.setData(message.symbols);
+ updateSymbolsTable(message.symbols);
break;
}
});
>From 04cc82f5af866d05bf43fe2ec2edfa9890a713bc Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 11:25:48 +0200
Subject: [PATCH 11/22] make table data restore after switching tabs
---
lldb/tools/lldb-dap/package-lock.json | 8 ++++++++
lldb/tools/lldb-dap/package.json | 1 +
lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts | 6 +++++-
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/lldb/tools/lldb-dap/package-lock.json b/lldb/tools/lldb-dap/package-lock.json
index 38c477d73fa7d..26db1ce6df2fd 100644
--- a/lldb/tools/lldb-dap/package-lock.json
+++ b/lldb/tools/lldb-dap/package-lock.json
@@ -12,6 +12,7 @@
"@types/node": "^18.19.41",
"@types/tabulator-tables": "^6.2.10",
"@types/vscode": "1.75.0",
+ "@types/vscode-webview": "^1.57.5",
"@vscode/debugprotocol": "^1.68.0",
"@vscode/vsce": "^3.2.2",
"esbuild": "^0.25.9",
@@ -858,6 +859,13 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@types/vscode-webview": {
+ "version": "1.57.5",
+ "resolved": "https://registry.npmjs.org/@types/vscode-webview/-/vscode-webview-1.57.5.tgz",
+ "integrity": "sha512-iBAUYNYkz+uk1kdsq05fEcoh8gJmwT3lqqFPN7MGyjQ3HVloViMdo7ZJ8DFIP8WOK74PjOEilosqAyxV2iUFUw==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@vscode/debugprotocol": {
"version": "1.68.0",
"resolved": "https://registry.npmjs.org/@vscode/debugprotocol/-/debugprotocol-1.68.0.tgz",
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 76e78281888d0..47d1213d45211 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -31,6 +31,7 @@
"@types/node": "^18.19.41",
"@types/tabulator-tables": "^6.2.10",
"@types/vscode": "1.75.0",
+ "@types/vscode-webview": "^1.57.5",
"@vscode/debugprotocol": "^1.68.0",
"@vscode/vsce": "^3.2.2",
"esbuild": "^0.25.9",
diff --git a/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
index b5609b6d3292e..6c85dc8b52a52 100644
--- a/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
+++ b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
@@ -51,12 +51,15 @@ const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
{ title: "Size", field: "size", sorter: "number", formatter: get_tabulator_hexa_formatter(8) },
]
+const vscode = acquireVsCodeApi();
+const previousState: any = vscode.getState();
+
declare const Tabulator: any; // HACK: real definition comes from tabulator.min.js
const SYMBOLS_TABLE = new Tabulator("#symbols-table", {
height: "100vh",
columns: SYMBOL_TABLE_COLUMNS,
layout: "fitColumns",
- data: [],
+ data: previousState?.symbols || [],
});
function updateSymbolsTable(symbols: DAPSymbolType[]) {
@@ -67,6 +70,7 @@ window.addEventListener("message", (event: MessageEvent<any>) => {
const message = event.data;
switch (message.command) {
case "updateSymbols":
+ vscode.setState({ symbols: message.symbols });
updateSymbolsTable(message.symbols);
break;
}
>From 1a73294b25a1785addf7f4293549d9e86117ef36 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 14:36:00 +0200
Subject: [PATCH 12/22] attempt have tabulator with vscode css variables
---
lldb/tools/lldb-dap/package.json | 2 +-
lldb/tools/lldb-dap/src-ts/index.d.ts | 14 ++++++++
.../lldb-dap/src-ts/ui/symbols-provider.ts | 33 +++++++++++++++++--
3 files changed, 46 insertions(+), 3 deletions(-)
create mode 100644 lldb/tools/lldb-dap/src-ts/index.d.ts
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 47d1213d45211..a0f144c39ea55 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -47,7 +47,7 @@
"main": "./out/extension",
"scripts": {
"bundle-symbols-table-view": "npx esbuild src-ts/webview/symbols-table-view.ts --bundle --format=iife --outdir=./out/webview",
- "bundle-tabulator": "cp node_modules/tabulator-tables/dist/js/tabulator.min.js ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator.min.css ./out/webview/",
+ "bundle-tabulator": "cp node_modules/tabulator-tables/dist/js/tabulator.min.js ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator_midnight.min.css ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator_modern.min.css ./out/webview/",
"bundle-webview": "npm run bundle-symbols-table-view && npm run bundle-tabulator",
"vscode:prepublish": "npm run bundle-webview && tsc -p ./",
"watch": "npm run bundle-webview && tsc -watch -p ./",
diff --git a/lldb/tools/lldb-dap/src-ts/index.d.ts b/lldb/tools/lldb-dap/src-ts/index.d.ts
new file mode 100644
index 0000000000000..cd5359d039619
--- /dev/null
+++ b/lldb/tools/lldb-dap/src-ts/index.d.ts
@@ -0,0 +1,14 @@
+export {};
+
+/// The symbol type we get from the lldb-dap server
+export type DAPSymbolType = {
+ userId: number;
+ isDebug: boolean;
+ isSynthetic: boolean;
+ isExternal: boolean;
+ type: string;
+ fileAddress: number;
+ loadAddress?: number;
+ size: number;
+ name: string;
+};
diff --git a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
index 41637c32350ce..5314a4789d6f9 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
@@ -100,8 +100,12 @@ export class SymbolsProvider extends DisposableContext {
}
);
+ let tabulatorJsFilename = "tabulator_modern.min.css";
+ if (vscode.window.activeColorTheme.kind === vscode.ColorThemeKind.Dark || vscode.window.activeColorTheme.kind === vscode.ColorThemeKind.HighContrast) {
+ tabulatorJsFilename = "tabulator_midnight.min.css";
+ }
+ const tabulatorCssPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), tabulatorJsFilename));
const tabulatorJsPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "tabulator.min.js"));
- const tabulatorCssPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "tabulator.min.css"));
const symbolsTableScriptPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "symbols-table-view.js"));
panel.webview.html = this.getHTMLContentForSymbols(tabulatorJsPath, tabulatorCssPath, symbolsTableScriptPath, symbols);
@@ -115,7 +119,32 @@ export class SymbolsProvider extends DisposableContext {
<meta charset="UTF-8">
<link href="${tabulatorCssPath}" rel="stylesheet">
<style>
- #symbols-table { height: 100vh; }
+ .tabulator {
+ background-color: var(--vscode-editor-background);
+ color: var(--vscode-editor-foreground);
+ }
+
+ .tabulator .tabulator-header {
+ background-color: var(--vscode-editor-background);
+ color: var(--vscode-editor-foreground);
+ }
+
+ .tabulator-row {
+ background-color: var(--vscode-editor-background);
+ }
+
+ .tabulator.tabulator-row-even {
+ background-color: var(--vscode-tree-tableOddRowsBackground);
+ }
+
+ .tabulator-row.tabulator-selected {
+ background-color: var(--vscode-editor-background);
+ color: var(--vscode-editor-foreground);
+ }
+
+ #symbols-table {
+ height: 100vh;
+ }
</style>
</head>
<body>
>From 75e41f48daca4fbd92bbc9c25575425c2f2b6598 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 15:05:32 +0200
Subject: [PATCH 13/22] better looking CSS with tabulator
---
lldb/tools/lldb-dap/package.json | 2 +-
lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts | 10 ++++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index a0f144c39ea55..d894070a512c8 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -47,7 +47,7 @@
"main": "./out/extension",
"scripts": {
"bundle-symbols-table-view": "npx esbuild src-ts/webview/symbols-table-view.ts --bundle --format=iife --outdir=./out/webview",
- "bundle-tabulator": "cp node_modules/tabulator-tables/dist/js/tabulator.min.js ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator_midnight.min.css ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator_modern.min.css ./out/webview/",
+ "bundle-tabulator": "cp node_modules/tabulator-tables/dist/js/tabulator.min.js ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator_midnight.min.css ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator_simple.min.css ./out/webview/",
"bundle-webview": "npm run bundle-symbols-table-view && npm run bundle-tabulator",
"vscode:prepublish": "npm run bundle-webview && tsc -p ./",
"watch": "npm run bundle-webview && tsc -watch -p ./",
diff --git a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
index 5314a4789d6f9..55938bc8195c2 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
@@ -100,7 +100,7 @@ export class SymbolsProvider extends DisposableContext {
}
);
- let tabulatorJsFilename = "tabulator_modern.min.css";
+ let tabulatorJsFilename = "tabulator_simple.min.css";
if (vscode.window.activeColorTheme.kind === vscode.ColorThemeKind.Dark || vscode.window.activeColorTheme.kind === vscode.ColorThemeKind.HighContrast) {
tabulatorJsFilename = "tabulator_midnight.min.css";
}
@@ -124,17 +124,19 @@ export class SymbolsProvider extends DisposableContext {
color: var(--vscode-editor-foreground);
}
- .tabulator .tabulator-header {
+ .tabulator .tabulator-header .tabulator-col {
background-color: var(--vscode-editor-background);
color: var(--vscode-editor-foreground);
}
.tabulator-row {
background-color: var(--vscode-editor-background);
+ color: var(--vscode-editor-foreground);
}
- .tabulator.tabulator-row-even {
- background-color: var(--vscode-tree-tableOddRowsBackground);
+ .tabulator-row.tabulator-row-even {
+ background-color: var(--vscode-editor-background);
+ color: var(--vscode-editor-foreground);
}
.tabulator-row.tabulator-selected {
>From 2a4cab848a43e24508086a8f0aa1e971f7c893f4 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 16:00:33 +0200
Subject: [PATCH 14/22] remove ellipsis if text is long
---
lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts | 4 ++++
lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts | 5 +++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
index 55938bc8195c2..f8fc3e8910c27 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
@@ -144,6 +144,10 @@ export class SymbolsProvider extends DisposableContext {
color: var(--vscode-editor-foreground);
}
+ .tabulator-cell {
+ text-overflow: clip !important;
+ }
+
#symbols-table {
height: 100vh;
}
diff --git a/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
index 6c85dc8b52a52..c574222fe9b0f 100644
--- a/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
+++ b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
@@ -9,7 +9,7 @@ function get_tabulator_hexa_formatter(padding: number): (cell: CellComponent) =>
}
const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
- { title: "User ID", field: "userId", sorter: "number" },
+ { title: "User ID", field: "userId", sorter: "number", widthShrink: 2 },
{
title: "Name",
field: "name",
@@ -20,6 +20,7 @@ const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
{
title: "DSX",
hozAlign: "center",
+ widthShrink: 2,
formatter: (cell: CellComponent) => {
const rowData = cell.getRow().getData();
let label = "";
@@ -58,7 +59,7 @@ declare const Tabulator: any; // HACK: real definition comes from tabulator.min.
const SYMBOLS_TABLE = new Tabulator("#symbols-table", {
height: "100vh",
columns: SYMBOL_TABLE_COLUMNS,
- layout: "fitColumns",
+ layout: "fitDataFill",
data: previousState?.symbols || [],
});
>From c0262e2cd463e640feaf18444ec5239c9356eb93 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 17:18:11 +0200
Subject: [PATCH 15/22] few fixes
---
.../DAPGetModuleSymbolsRequestHandler.cpp | 16 ++-
.../lldb-dap/src-ts/ui/symbols-provider.ts | 5 +-
.../src-ts/webview/symbols-table-view.ts | 115 +++++++++++-------
3 files changed, 84 insertions(+), 52 deletions(-)
diff --git a/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
index d502897027993..334ab4f2d9b1e 100644
--- a/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
@@ -10,6 +10,7 @@
#include "DAPError.h"
#include "Protocol/DAPTypes.h"
#include "RequestHandler.h"
+#include "lldb/API/SBAddress.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBModule.h"
#include "lldb/API/SBModuleSpec.h"
@@ -137,11 +138,18 @@ DAPGetModuleSymbolsRequestHandler::Run(
dap_symbol.isSynthetic = symbol.IsSynthetic();
dap_symbol.isExternal = symbol.IsExternal();
- dap_symbol.fileAddress = symbol.GetStartAddress().GetFileAddress();
- dap_symbol.loadAddress =
- symbol.GetStartAddress().GetLoadAddress(dap.target);
- dap_symbol.size = symbol.GetSize();
+ lldb::SBAddress start_address = symbol.GetStartAddress();
+ if (start_address.IsValid()) {
+ lldb::addr_t file_address = start_address.GetFileAddress();
+ if (file_address != LLDB_INVALID_ADDRESS)
+ dap_symbol.fileAddress = file_address;
+
+ lldb::addr_t load_address = start_address.GetLoadAddress(dap.target);
+ if (load_address != LLDB_INVALID_ADDRESS)
+ dap_symbol.loadAddress = load_address;
+ }
+ dap_symbol.size = symbol.GetSize();
dap_symbol.name = symbol.GetName();
symbols.push_back(std::move(dap_symbol));
}
diff --git a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
index f8fc3e8910c27..0446e6273fb0e 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
@@ -148,8 +148,9 @@ export class SymbolsProvider extends DisposableContext {
text-overflow: clip !important;
}
- #symbols-table {
- height: 100vh;
+ #symbols-table {
+ width: 100%;
+ height: 100vh;
}
</style>
</head>
diff --git a/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
index c574222fe9b0f..fac1e56ca5d94 100644
--- a/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
+++ b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
@@ -4,63 +4,86 @@ import type { DAPSymbolType } from ".."
function get_tabulator_hexa_formatter(padding: number): (cell: CellComponent) => string {
return (cell: CellComponent) => {
const val = cell.getValue();
- return val !== undefined ? "0x" + val.toString(16).toLowerCase().padStart(padding, "0") : "";
+ if (val === undefined || val === null) {
+ return "";
+ }
+
+ return "0x" + val.toString(16).toLowerCase().padStart(padding, "0");
};
}
-const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
- { title: "User ID", field: "userId", sorter: "number", widthShrink: 2 },
- {
- title: "Name",
- field: "name",
- sorter: "string",
- widthGrow: 2,
- minWidth: 200,
- },
- {
- title: "DSX",
- hozAlign: "center",
- widthShrink: 2,
- formatter: (cell: CellComponent) => {
- const rowData = cell.getRow().getData();
- let label = "";
- label += rowData.isDebug ? "D" : "";
- label += rowData.isSynthetic ? "S" : "";
- label += rowData.isExternal ? "X" : "";
- return label;
+const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] =
+ [
+ {title : "User ID", field : "userId", sorter : "number", widthGrow : 0.8},
+ {
+ title : "Name",
+ field : "name",
+ sorter : "string",
+ widthGrow : 3,
+ minWidth : 200,
+ tooltip : (_event: MouseEvent, cell: CellComponent) => {
+ const rowData = cell.getRow().getData();
+ return rowData.name;
+ }
+ },
+ {
+ title : "DSX",
+ hozAlign : "center",
+ widthGrow : 0.8,
+ headerTooltip : "Debug / Synthetic / External",
+ formatter : (cell: CellComponent) => {
+ const rowData = cell.getRow().getData();
+ let label = "";
+ label += rowData.isDebug ? "D" : "";
+ label += rowData.isSynthetic ? "S" : "";
+ label += rowData.isExternal ? "X" : "";
+ return label;
},
- sorter: (_a, _b, aRow, bRow) => {
- const valuesA = [aRow.getData().isDebug, aRow.getData().isSynthetic, aRow.getData().isExternal];
- const valuesB = [bRow.getData().isDebug, bRow.getData().isSynthetic, bRow.getData().isExternal];
+ sorter : (_a, _b, aRow, bRow) => {
+ const valuesA = [
+ aRow.getData().isDebug, aRow.getData().isSynthetic,
+ aRow.getData().isExternal
+ ];
+ const valuesB = [
+ bRow.getData().isDebug, bRow.getData().isSynthetic,
+ bRow.getData().isExternal
+ ];
- return valuesA < valuesB ? -1 : valuesA > valuesB ? 1 : 0;
+ return valuesA < valuesB ? -1 : valuesA > valuesB ? 1 : 0;
}
- },
- { title: "Type", field: "type", sorter: "string" },
- {
- title: "File Address",
- field: "fileAddress",
- sorter: "number",
- formatter: get_tabulator_hexa_formatter(16),
- },
- {
- title: "Load Address",
- field: "loadAddress",
- sorter: "number",
- formatter: get_tabulator_hexa_formatter(16),
- },
- { title: "Size", field: "size", sorter: "number", formatter: get_tabulator_hexa_formatter(8) },
-]
+ },
+ {title : "Type", field : "type", sorter : "string"},
+ {
+ title : "File Address",
+ field : "fileAddress",
+ sorter : "number",
+ widthGrow : 1.25,
+ formatter : get_tabulator_hexa_formatter(16),
+ },
+ {
+ title : "Load Address",
+ field : "loadAddress",
+ sorter : "number",
+ widthGrow : 1.25,
+ formatter : get_tabulator_hexa_formatter(16),
+ },
+ {
+ title : "Size",
+ field : "size",
+ sorter : "number",
+ formatter : get_tabulator_hexa_formatter(8)
+ },
+ ]
-const vscode = acquireVsCodeApi();
+ const vscode = acquireVsCodeApi();
const previousState: any = vscode.getState();
declare const Tabulator: any; // HACK: real definition comes from tabulator.min.js
const SYMBOLS_TABLE = new Tabulator("#symbols-table", {
- height: "100vh",
- columns: SYMBOL_TABLE_COLUMNS,
- layout: "fitDataFill",
- data: previousState?.symbols || [],
+ height : "100vh",
+ columns : SYMBOL_TABLE_COLUMNS,
+ layout : "fitColumns",
+ data : previousState?.symbols || [],
});
function updateSymbolsTable(symbols: DAPSymbolType[]) {
>From c8a6f334a81dc922df18fbc2ea48ce16a85fc8cd Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 17:30:01 +0200
Subject: [PATCH 16/22] revert
---
.../src-ts/webview/symbols-table-view.ts | 115 +++++++-----------
1 file changed, 46 insertions(+), 69 deletions(-)
diff --git a/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
index fac1e56ca5d94..c574222fe9b0f 100644
--- a/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
+++ b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
@@ -4,86 +4,63 @@ import type { DAPSymbolType } from ".."
function get_tabulator_hexa_formatter(padding: number): (cell: CellComponent) => string {
return (cell: CellComponent) => {
const val = cell.getValue();
- if (val === undefined || val === null) {
- return "";
- }
-
- return "0x" + val.toString(16).toLowerCase().padStart(padding, "0");
+ return val !== undefined ? "0x" + val.toString(16).toLowerCase().padStart(padding, "0") : "";
};
}
-const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] =
- [
- {title : "User ID", field : "userId", sorter : "number", widthGrow : 0.8},
- {
- title : "Name",
- field : "name",
- sorter : "string",
- widthGrow : 3,
- minWidth : 200,
- tooltip : (_event: MouseEvent, cell: CellComponent) => {
- const rowData = cell.getRow().getData();
- return rowData.name;
- }
- },
- {
- title : "DSX",
- hozAlign : "center",
- widthGrow : 0.8,
- headerTooltip : "Debug / Synthetic / External",
- formatter : (cell: CellComponent) => {
- const rowData = cell.getRow().getData();
- let label = "";
- label += rowData.isDebug ? "D" : "";
- label += rowData.isSynthetic ? "S" : "";
- label += rowData.isExternal ? "X" : "";
- return label;
+const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
+ { title: "User ID", field: "userId", sorter: "number", widthShrink: 2 },
+ {
+ title: "Name",
+ field: "name",
+ sorter: "string",
+ widthGrow: 2,
+ minWidth: 200,
+ },
+ {
+ title: "DSX",
+ hozAlign: "center",
+ widthShrink: 2,
+ formatter: (cell: CellComponent) => {
+ const rowData = cell.getRow().getData();
+ let label = "";
+ label += rowData.isDebug ? "D" : "";
+ label += rowData.isSynthetic ? "S" : "";
+ label += rowData.isExternal ? "X" : "";
+ return label;
},
- sorter : (_a, _b, aRow, bRow) => {
- const valuesA = [
- aRow.getData().isDebug, aRow.getData().isSynthetic,
- aRow.getData().isExternal
- ];
- const valuesB = [
- bRow.getData().isDebug, bRow.getData().isSynthetic,
- bRow.getData().isExternal
- ];
+ sorter: (_a, _b, aRow, bRow) => {
+ const valuesA = [aRow.getData().isDebug, aRow.getData().isSynthetic, aRow.getData().isExternal];
+ const valuesB = [bRow.getData().isDebug, bRow.getData().isSynthetic, bRow.getData().isExternal];
- return valuesA < valuesB ? -1 : valuesA > valuesB ? 1 : 0;
+ return valuesA < valuesB ? -1 : valuesA > valuesB ? 1 : 0;
}
- },
- {title : "Type", field : "type", sorter : "string"},
- {
- title : "File Address",
- field : "fileAddress",
- sorter : "number",
- widthGrow : 1.25,
- formatter : get_tabulator_hexa_formatter(16),
- },
- {
- title : "Load Address",
- field : "loadAddress",
- sorter : "number",
- widthGrow : 1.25,
- formatter : get_tabulator_hexa_formatter(16),
- },
- {
- title : "Size",
- field : "size",
- sorter : "number",
- formatter : get_tabulator_hexa_formatter(8)
- },
- ]
+ },
+ { title: "Type", field: "type", sorter: "string" },
+ {
+ title: "File Address",
+ field: "fileAddress",
+ sorter: "number",
+ formatter: get_tabulator_hexa_formatter(16),
+ },
+ {
+ title: "Load Address",
+ field: "loadAddress",
+ sorter: "number",
+ formatter: get_tabulator_hexa_formatter(16),
+ },
+ { title: "Size", field: "size", sorter: "number", formatter: get_tabulator_hexa_formatter(8) },
+]
- const vscode = acquireVsCodeApi();
+const vscode = acquireVsCodeApi();
const previousState: any = vscode.getState();
declare const Tabulator: any; // HACK: real definition comes from tabulator.min.js
const SYMBOLS_TABLE = new Tabulator("#symbols-table", {
- height : "100vh",
- columns : SYMBOL_TABLE_COLUMNS,
- layout : "fitColumns",
- data : previousState?.symbols || [],
+ height: "100vh",
+ columns: SYMBOL_TABLE_COLUMNS,
+ layout: "fitDataFill",
+ data: previousState?.symbols || [],
});
function updateSymbolsTable(symbols: DAPSymbolType[]) {
>From c55d64936de938bf03a8d40ca04f13bd63415647 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 17:33:50 +0200
Subject: [PATCH 17/22] table improvements
---
.../src-ts/webview/symbols-table-view.ts | 123 ++++++++++--------
1 file changed, 67 insertions(+), 56 deletions(-)
diff --git a/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
index c574222fe9b0f..de39723497309 100644
--- a/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
+++ b/lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts
@@ -2,78 +2,89 @@ import type { CellComponent, ColumnDefinition } from "tabulator-tables";
import type { DAPSymbolType } from ".."
function get_tabulator_hexa_formatter(padding: number): (cell: CellComponent) => string {
- return (cell: CellComponent) => {
- const val = cell.getValue();
- return val !== undefined ? "0x" + val.toString(16).toLowerCase().padStart(padding, "0") : "";
- };
+ return (cell: CellComponent) => {
+ const val = cell.getValue();
+ if (val === undefined || val === null) {
+ return "";
+ }
+
+ return val !== undefined ? "0x" + val.toString(16).toLowerCase().padStart(padding, "0") : "";
+ };
}
const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
- { title: "User ID", field: "userId", sorter: "number", widthShrink: 2 },
- {
- title: "Name",
- field: "name",
- sorter: "string",
- widthGrow: 2,
- minWidth: 200,
+ { title: "User ID", field: "userId", sorter: "number", widthGrow: 0.8 },
+ {
+ title: "Name",
+ field: "name",
+ sorter: "string",
+ widthGrow: 3,
+ minWidth: 200,
+ tooltip : (_event: MouseEvent, cell: CellComponent) => {
+ const rowData = cell.getRow().getData();
+ return rowData.name;
+ }
+ },
+ {
+ title: "DSX",
+ hozAlign: "center",
+ widthGrow: 0.8,
+ headerTooltip : "Debug / Synthetic / External",
+ formatter: (cell: CellComponent) => {
+ const rowData = cell.getRow().getData();
+ let label = "";
+ label += rowData.isDebug ? "D" : "";
+ label += rowData.isSynthetic ? "S" : "";
+ label += rowData.isExternal ? "X" : "";
+ return label;
},
- {
- title: "DSX",
- hozAlign: "center",
- widthShrink: 2,
- formatter: (cell: CellComponent) => {
- const rowData = cell.getRow().getData();
- let label = "";
- label += rowData.isDebug ? "D" : "";
- label += rowData.isSynthetic ? "S" : "";
- label += rowData.isExternal ? "X" : "";
- return label;
- },
- sorter: (_a, _b, aRow, bRow) => {
- const valuesA = [aRow.getData().isDebug, aRow.getData().isSynthetic, aRow.getData().isExternal];
- const valuesB = [bRow.getData().isDebug, bRow.getData().isSynthetic, bRow.getData().isExternal];
+ sorter: (_a, _b, aRow, bRow) => {
+ const valuesA = [aRow.getData().isDebug, aRow.getData().isSynthetic, aRow.getData().isExternal];
+ const valuesB = [bRow.getData().isDebug, bRow.getData().isSynthetic, bRow.getData().isExternal];
- return valuesA < valuesB ? -1 : valuesA > valuesB ? 1 : 0;
- }
- },
- { title: "Type", field: "type", sorter: "string" },
- {
- title: "File Address",
- field: "fileAddress",
- sorter: "number",
- formatter: get_tabulator_hexa_formatter(16),
- },
- {
- title: "Load Address",
- field: "loadAddress",
- sorter: "number",
- formatter: get_tabulator_hexa_formatter(16),
- },
- { title: "Size", field: "size", sorter: "number", formatter: get_tabulator_hexa_formatter(8) },
-]
+ return valuesA < valuesB ? -1 : valuesA > valuesB ? 1 : 0;
+ }
+ },
+ { title: "Type", field: "type", sorter: "string" },
+ {
+ title: "File Address",
+ field: "fileAddress",
+ sorter: "number",
+ widthGrow : 1.25,
+ formatter: get_tabulator_hexa_formatter(16),
+ },
+ {
+ title: "Load Address",
+ field: "loadAddress",
+ sorter: "number",
+ widthGrow : 1.25,
+ formatter: get_tabulator_hexa_formatter(16),
+ },
+ { title: "Size", field: "size", sorter: "number", formatter: get_tabulator_hexa_formatter(8) },
+];
const vscode = acquireVsCodeApi();
const previousState: any = vscode.getState();
declare const Tabulator: any; // HACK: real definition comes from tabulator.min.js
const SYMBOLS_TABLE = new Tabulator("#symbols-table", {
- height: "100vh",
- columns: SYMBOL_TABLE_COLUMNS,
- layout: "fitDataFill",
- data: previousState?.symbols || [],
+ height: "100vh",
+ columns: SYMBOL_TABLE_COLUMNS,
+ layout: "fitColumns",
+ data: previousState?.symbols || [],
});
function updateSymbolsTable(symbols: DAPSymbolType[]) {
- SYMBOLS_TABLE.setData(symbols);
+ SYMBOLS_TABLE.setData(symbols);
}
window.addEventListener("message", (event: MessageEvent<any>) => {
- const message = event.data;
- switch (message.command) {
- case "updateSymbols":
- vscode.setState({ symbols: message.symbols });
- updateSymbolsTable(message.symbols);
- break;
- }
+ const message = event.data;
+ switch (message.command) {
+ case "updateSymbols":
+ vscode.setState({ symbols: message.symbols });
+ updateSymbolsTable(message.symbols);
+ break;
+ }
});
>From 0814cf205da527c1a027d8ee250da3a0d2ccc71e Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 18:59:17 +0200
Subject: [PATCH 18/22] add context menu show symbols for modules
---
lldb/tools/lldb-dap/package.json | 14 +++++++++-
.../src-ts/ui/modules-data-provider.ts | 1 +
.../lldb-dap/src-ts/ui/symbols-provider.ts | 27 ++++++++++++++-----
3 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index d894070a512c8..8cfe0aba15d2d 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -268,9 +268,13 @@
"title": "Copy Value"
},
{
- "category": "lldb-dap",
"command": "lldb-dap.modules.showSymbols",
"title": "Show Module Symbols"
+ },
+ {
+ "category": "lldb-dap",
+ "command": "lldb-dap.debug.showSymbols",
+ "title": "Show Symbols of a Module"
}
],
"menus": {
@@ -281,6 +285,10 @@
},
{
"command": "lldb-dap.modules.showSymbols",
+ "when": "false"
+ },
+ {
+ "command": "lldb-dap.debug.showSymbols",
"when": "debuggersAvailable && debugType == 'lldb-dap'"
}
],
@@ -288,6 +296,10 @@
{
"command": "lldb-dap.modules.copyProperty",
"when": "view == lldb-dap.modules && viewItem == property"
+ },
+ {
+ "command": "lldb-dap.modules.showSymbols",
+ "when": "view == lldb-dap.modules && viewItem == module"
}
]
},
diff --git a/lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts
index d0fb9270c734f..96343cb0a8da6 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts
@@ -19,6 +19,7 @@ class ModuleItem extends vscode.TreeItem {
constructor(module: DebugProtocol.Module) {
super(module.name, vscode.TreeItemCollapsibleState.Collapsed);
this.description = module.symbolStatus;
+ this.contextValue = "module";
}
static getProperties(module: DebugProtocol.Module): ModuleProperty[] {
diff --git a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
index 0446e6273fb0e..0c83cb903f441 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
@@ -14,11 +14,22 @@ export class SymbolsProvider extends DisposableContext {
super();
this.pushSubscription(vscode.commands.registerCommand(
- "lldb-dap.modules.showSymbols",
+ "lldb-dap.debug.showSymbols",
() => {
this.SelectModuleAndShowSymbols();
},
));
+
+ this.pushSubscription(vscode.commands.registerCommand(
+ "lldb-dap.modules.showSymbols",
+ (moduleItem: DebugProtocol.Module) => {
+ const session = vscode.debug.activeDebugSession;
+ if (!session) {
+ return;
+ }
+ this.showSymbolsForModule(session, moduleItem);
+ },
+ ));
}
static async doesServerSupportSymbolsRequest(session: vscode.DebugSession): Promise<boolean> {
@@ -55,9 +66,13 @@ export class SymbolsProvider extends DisposableContext {
return;
}
+ this.showSymbolsForModule(session, selectedModule.module);
+ }
+
+ private async showSymbolsForModule(session: vscode.DebugSession, module: DebugProtocol.Module) {
try {
- const symbols = await this.getSymbolsForModule(session, selectedModule.module.id.toString());
- this.showSymbolsForModule(selectedModule.module.name.toString(), symbols);
+ const symbols = await this.getSymbolsForModule(session, module.id.toString());
+ this.showSymbolsInNewTab(module.name.toString(), symbols);
} catch (error) {
if (error instanceof Error) {
vscode.window.showErrorMessage("Failed to retrieve symbols: " + error.message);
@@ -87,7 +102,7 @@ export class SymbolsProvider extends DisposableContext {
)) || [];
}
- private async showSymbolsForModule(moduleName: string, symbols: DAPSymbol[]) {
+ private async showSymbolsInNewTab(moduleName: string, symbols: DAPSymbol[]) {
const panel = vscode.window.createWebviewPanel(
"lldb-dap.symbols",
`Symbols for ${moduleName}`,
@@ -108,11 +123,11 @@ export class SymbolsProvider extends DisposableContext {
const tabulatorJsPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "tabulator.min.js"));
const symbolsTableScriptPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "symbols-table-view.js"));
- panel.webview.html = this.getHTMLContentForSymbols(tabulatorJsPath, tabulatorCssPath, symbolsTableScriptPath, symbols);
+ panel.webview.html = this.getHTMLContentForSymbols(tabulatorJsPath, tabulatorCssPath, symbolsTableScriptPath);
panel.webview.postMessage({ command: "updateSymbols", symbols: symbols });
}
- private getHTMLContentForSymbols(tabulatorJsPath: vscode.Uri, tabulatorCssPath: vscode.Uri, symbolsTableScriptPath: vscode.Uri, symbols: DAPSymbol[]): string {
+ private getHTMLContentForSymbols(tabulatorJsPath: vscode.Uri, tabulatorCssPath: vscode.Uri, symbolsTableScriptPath: vscode.Uri): string {
return `<!DOCTYPE html>
<html>
<head>
>From 4543bccfe4c8e1e61628ac80dbe4a4163e3d233a Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 19:01:11 +0200
Subject: [PATCH 19/22] remove unecessary type
---
.../lldb-dap/src-ts/ui/symbols-provider.ts | 30 ++-----------------
1 file changed, 3 insertions(+), 27 deletions(-)
diff --git a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
index 0c83cb903f441..a798fa702c34d 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts
@@ -84,25 +84,15 @@ export class SymbolsProvider extends DisposableContext {
}
}
- private async getSymbolsForModule(session: vscode.DebugSession, moduleId: string): Promise<DAPSymbol[]> {
+ private async getSymbolsForModule(session: vscode.DebugSession, moduleId: string): Promise<DAPSymbolType[]> {
console.log(`Getting symbols for module: ${moduleId}`);
const symbols_response: { symbols: Array<DAPSymbolType> } = await session.customRequest("dapGetModuleSymbols", { moduleId });
- return symbols_response?.symbols.map(symbol => new DAPSymbol(
- symbol.userId,
- symbol.isDebug,
- symbol.isSynthetic,
- symbol.isExternal,
- symbol.type,
- symbol.fileAddress,
- symbol.loadAddress,
- symbol.size,
- symbol.name,
- )) || [];
+ return symbols_response?.symbols || [];
}
- private async showSymbolsInNewTab(moduleName: string, symbols: DAPSymbol[]) {
+ private async showSymbolsInNewTab(moduleName: string, symbols: DAPSymbolType[]) {
const panel = vscode.window.createWebviewPanel(
"lldb-dap.symbols",
`Symbols for ${moduleName}`,
@@ -193,17 +183,3 @@ class ModuleQuickPickItem implements vscode.QuickPickItem {
return this.module.id.toString();
}
}
-
-class DAPSymbol {
- constructor(
- public readonly userId: number,
- public readonly isDebug: boolean,
- public readonly isSynthetic: boolean,
- public readonly isExternal: boolean,
- public readonly type: string,
- public readonly fileAddress: number,
- public readonly loadAddress: number | undefined,
- public readonly size: number,
- public readonly name: string,
- ) {}
-}
>From 6e8da77bd3aef03bae7da03d61e2ceb43c24baaa Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Fri, 15 Aug 2025 19:03:42 +0200
Subject: [PATCH 20/22] format
---
.../Handler/DAPGetModuleSymbolsRequestHandler.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
index 334ab4f2d9b1e..99199fb2ac9ca 100644
--- a/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
@@ -100,12 +100,12 @@ DAPGetModuleSymbolsRequestHandler::Run(
lldb::SBModuleSpec module_spec;
if (args.moduleId) {
llvm::SmallVector<uint8_t, 20> uuid_bytes;
- if (!lldb_private::UUID::DecodeUUIDBytesFromString(*args.moduleId, uuid_bytes).empty())
+ if (!lldb_private::UUID::DecodeUUIDBytesFromString(*args.moduleId,
+ uuid_bytes)
+ .empty())
return llvm::make_error<DAPError>("Invalid module ID");
- module_spec.SetUUIDBytes(
- uuid_bytes.data(),
- uuid_bytes.size());
+ module_spec.SetUUIDBytes(uuid_bytes.data(), uuid_bytes.size());
}
if (args.moduleName) {
>From 6e1a19f752ea5409bb8ca5094e638821f341ed75 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Sat, 16 Aug 2025 01:28:30 +0200
Subject: [PATCH 21/22] move DAPTypes to a namespace
---
lldb/tools/lldb-dap/Breakpoint.cpp | 8 ++++----
.../Handler/DAPGetModuleSymbolsRequestHandler.cpp | 4 ++--
lldb/tools/lldb-dap/Protocol/DAPTypes.cpp | 8 ++++----
lldb/tools/lldb-dap/Protocol/DAPTypes.h | 10 +++++-----
lldb/tools/lldb-dap/Protocol/ProtocolRequests.h | 2 +-
lldb/tools/lldb-dap/Protocol/ProtocolTypes.h | 2 +-
lldb/tools/lldb-dap/SourceBreakpoint.cpp | 2 +-
lldb/tools/lldb-dap/SourceBreakpoint.h | 2 +-
lldb/unittests/DAP/DAPTypesTest.cpp | 9 +++------
9 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/lldb/tools/lldb-dap/Breakpoint.cpp b/lldb/tools/lldb-dap/Breakpoint.cpp
index c8039576b29bd..2f7235c1aabb4 100644
--- a/lldb/tools/lldb-dap/Breakpoint.cpp
+++ b/lldb/tools/lldb-dap/Breakpoint.cpp
@@ -25,9 +25,9 @@
using namespace lldb_dap;
-static std::optional<protocol::PersistenceData>
+static std::optional<protocol::dap::PersistenceData>
GetPersistenceDataForSymbol(lldb::SBSymbol &symbol) {
- protocol::PersistenceData persistence_data;
+ protocol::dap::PersistenceData persistence_data;
lldb::SBModule module = symbol.GetStartAddress().GetModule();
if (!module.IsValid())
return std::nullopt;
@@ -105,11 +105,11 @@ protocol::Breakpoint Breakpoint::ToProtocolBreakpoint() {
// Add persistent data so that the breakpoint can be resolved
// in future sessions.
- std::optional<protocol::PersistenceData> persistence_data =
+ std::optional<protocol::dap::PersistenceData> persistence_data =
GetPersistenceDataForSymbol(symbol);
if (persistence_data) {
source->adapterData =
- protocol::SourceLLDBData{std::move(persistence_data)};
+ protocol::dap::SourceLLDBData{std::move(persistence_data)};
}
}
}
diff --git a/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
index 99199fb2ac9ca..a143c814150eb 100644
--- a/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
@@ -120,7 +120,7 @@ DAPGetModuleSymbolsRequestHandler::Run(
if (!module_spec.IsValid())
return response;
- std::vector<DAPSymbol> &symbols = response.symbols;
+ std::vector<dap::Symbol> &symbols = response.symbols;
lldb::SBModule module = dap.target.FindModule(module_spec);
if (!module.IsValid())
return llvm::make_error<DAPError>("Module not found");
@@ -131,7 +131,7 @@ DAPGetModuleSymbolsRequestHandler::Run(
if (!symbol.IsValid())
continue;
- DAPSymbol dap_symbol;
+ dap::Symbol dap_symbol;
dap_symbol.userId = symbol.GetID();
dap_symbol.type = SymbolTypeToString(symbol.GetType());
dap_symbol.isDebug = symbol.IsDebug();
diff --git a/lldb/tools/lldb-dap/Protocol/DAPTypes.cpp b/lldb/tools/lldb-dap/Protocol/DAPTypes.cpp
index 212bbd2fe7be6..4d3bc3d0ff834 100644
--- a/lldb/tools/lldb-dap/Protocol/DAPTypes.cpp
+++ b/lldb/tools/lldb-dap/Protocol/DAPTypes.cpp
@@ -2,7 +2,7 @@
using namespace llvm;
-namespace lldb_dap::protocol {
+namespace lldb_dap::protocol::dap {
bool fromJSON(const llvm::json::Value &Params, PersistenceData &PD,
llvm::json::Path P) {
@@ -33,7 +33,7 @@ llvm::json::Value toJSON(const SourceLLDBData &SLD) {
return result;
}
-bool fromJSON(const llvm::json::Value &Params, DAPSymbol &DS,
+bool fromJSON(const llvm::json::Value &Params, Symbol &DS,
llvm::json::Path P) {
json::ObjectMapper O(Params, P);
return O && O.map("userId", DS.userId) && O.map("isDebug", DS.isDebug) &&
@@ -44,7 +44,7 @@ bool fromJSON(const llvm::json::Value &Params, DAPSymbol &DS,
O.map("size", DS.size) && O.map("name", DS.name);
}
-llvm::json::Value toJSON(const DAPSymbol &DS) {
+llvm::json::Value toJSON(const Symbol &DS) {
json::Object result{
{"userId", DS.userId},
{"isDebug", DS.isDebug},
@@ -60,4 +60,4 @@ llvm::json::Value toJSON(const DAPSymbol &DS) {
return result;
}
-} // namespace lldb_dap::protocol
\ No newline at end of file
+} // namespace lldb_dap::protocol::dap
\ No newline at end of file
diff --git a/lldb/tools/lldb-dap/Protocol/DAPTypes.h b/lldb/tools/lldb-dap/Protocol/DAPTypes.h
index 83f9947b1ab57..5933f08a479ce 100644
--- a/lldb/tools/lldb-dap/Protocol/DAPTypes.h
+++ b/lldb/tools/lldb-dap/Protocol/DAPTypes.h
@@ -21,7 +21,7 @@
#include <optional>
#include <string>
-namespace lldb_dap::protocol {
+namespace lldb_dap::protocol::dap {
/// Data used to help lldb-dap resolve breakpoints persistently across different
/// sessions. This information is especially useful for assembly breakpoints,
@@ -48,7 +48,7 @@ struct SourceLLDBData {
bool fromJSON(const llvm::json::Value &, SourceLLDBData &, llvm::json::Path);
llvm::json::Value toJSON(const SourceLLDBData &);
-struct DAPSymbol {
+struct Symbol {
/// The symbol uid.
uint32_t userId;
@@ -77,9 +77,9 @@ struct DAPSymbol {
/// The symbol name.
std::string name;
};
-bool fromJSON(const llvm::json::Value &, DAPSymbol &, llvm::json::Path);
-llvm::json::Value toJSON(const DAPSymbol &);
+bool fromJSON(const llvm::json::Value &, Symbol &, llvm::json::Path);
+llvm::json::Value toJSON(const Symbol &);
-} // namespace lldb_dap::protocol
+} // namespace lldb_dap::protocol::dap
#endif
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
index ebf58424f6aa4..0d87f6fac1e18 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
@@ -994,7 +994,7 @@ bool fromJSON(const llvm::json::Value &, DAPGetModuleSymbolsArguments &,
/// Response to `getModuleSymbols` request.
struct DAPGetModuleSymbolsResponseBody {
/// The symbols for the specified module.
- std::vector<DAPSymbol> symbols;
+ std::vector<dap::Symbol> symbols;
};
llvm::json::Value toJSON(const DAPGetModuleSymbolsResponseBody &);
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
index c4be7911a662b..d3d579da066b0 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
@@ -340,7 +340,7 @@ struct Source {
/// Additional data that a debug adapter might want to loop through the
/// client. The client should leave the data intact and persist it across
/// sessions. The client should not interpret the data.
- std::optional<SourceLLDBData> adapterData;
+ std::optional<dap::SourceLLDBData> adapterData;
// unsupported keys: origin, sources, checksums
};
diff --git a/lldb/tools/lldb-dap/SourceBreakpoint.cpp b/lldb/tools/lldb-dap/SourceBreakpoint.cpp
index 843a5eb09c7ae..c4fd23ef87bf1 100644
--- a/lldb/tools/lldb-dap/SourceBreakpoint.cpp
+++ b/lldb/tools/lldb-dap/SourceBreakpoint.cpp
@@ -120,7 +120,7 @@ llvm::Error SourceBreakpoint::CreateAssemblyBreakpointWithSourceReference(
}
llvm::Error SourceBreakpoint::CreateAssemblyBreakpointWithPersistenceData(
- const protocol::PersistenceData &persistence_data) {
+ const protocol::dap::PersistenceData &persistence_data) {
lldb::SBFileSpec file_spec(persistence_data.module_path.c_str());
lldb::SBFileSpecList comp_unit_list;
lldb::SBFileSpecList file_spec_list;
diff --git a/lldb/tools/lldb-dap/SourceBreakpoint.h b/lldb/tools/lldb-dap/SourceBreakpoint.h
index 34054a8dcfd5f..6594e46b8af9a 100644
--- a/lldb/tools/lldb-dap/SourceBreakpoint.h
+++ b/lldb/tools/lldb-dap/SourceBreakpoint.h
@@ -55,7 +55,7 @@ class SourceBreakpoint : public Breakpoint {
llvm::Error
CreateAssemblyBreakpointWithSourceReference(int64_t source_reference);
llvm::Error CreateAssemblyBreakpointWithPersistenceData(
- const protocol::PersistenceData &persistence_data);
+ const protocol::dap::PersistenceData &persistence_data);
// logMessage part can be either a raw text or an expression.
struct LogMessagePart {
diff --git a/lldb/unittests/DAP/DAPTypesTest.cpp b/lldb/unittests/DAP/DAPTypesTest.cpp
index 180917364b0e2..a6f2b6b22b6d5 100644
--- a/lldb/unittests/DAP/DAPTypesTest.cpp
+++ b/lldb/unittests/DAP/DAPTypesTest.cpp
@@ -8,17 +8,14 @@
#include "Protocol/DAPTypes.h"
#include "TestingSupport/TestUtilities.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/JSON.h"
#include "llvm/Testing/Support/Error.h"
-#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <optional>
using namespace llvm;
using namespace lldb;
using namespace lldb_dap;
-using namespace lldb_dap::protocol;
+using namespace lldb_dap::protocol::dap;
using lldb_private::roundtripJSON;
TEST(DAPTypesTest, SourceLLDBData) {
@@ -36,7 +33,7 @@ TEST(DAPTypesTest, SourceLLDBData) {
}
TEST(DAPTypesTest, DAPSymbol) {
- DAPSymbol symbol;
+ Symbol symbol;
symbol.userId = 42;
symbol.isDebug = true;
symbol.isExternal = false;
@@ -47,7 +44,7 @@ TEST(DAPTypesTest, DAPSymbol) {
symbol.size = 64;
symbol.name = "testSymbol";
- llvm::Expected<DAPSymbol> deserialized_symbol = roundtripJSON(symbol);
+ llvm::Expected<Symbol> deserialized_symbol = roundtripJSON(symbol);
ASSERT_THAT_EXPECTED(deserialized_symbol, llvm::Succeeded());
EXPECT_EQ(symbol.userId, deserialized_symbol->userId);
>From 0e3ef866c9a1251afed9a64f1af44b24e46ea049 Mon Sep 17 00:00:00 2001
From: Ely Ronnen <elyronnen at gmail.com>
Date: Sat, 16 Aug 2025 01:43:32 +0200
Subject: [PATCH 22/22] rename to ModuleSymbolsRequestHandler
---
lldb/tools/lldb-dap/CMakeLists.txt | 2 +-
lldb/tools/lldb-dap/DAP.cpp | 2 +-
...stHandler.cpp => ModuleSymbolsRequestHandler.cpp} | 12 +++---------
lldb/tools/lldb-dap/Handler/RequestHandler.h | 12 ++++++------
lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp | 6 +++---
lldb/tools/lldb-dap/Protocol/ProtocolRequests.h | 8 ++++----
6 files changed, 18 insertions(+), 24 deletions(-)
rename lldb/tools/lldb-dap/Handler/{DAPGetModuleSymbolsRequestHandler.cpp => ModuleSymbolsRequestHandler.cpp} (91%)
diff --git a/lldb/tools/lldb-dap/CMakeLists.txt b/lldb/tools/lldb-dap/CMakeLists.txt
index c3ba53754f8ad..7db334ca56bcf 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -36,7 +36,6 @@ add_lldb_library(lldbDAP
Handler/CompletionsHandler.cpp
Handler/ConfigurationDoneRequestHandler.cpp
Handler/ContinueRequestHandler.cpp
- Handler/DAPGetModuleSymbolsRequestHandler.cpp
Handler/DataBreakpointInfoRequestHandler.cpp
Handler/DisassembleRequestHandler.cpp
Handler/DisconnectRequestHandler.cpp
@@ -46,6 +45,7 @@ add_lldb_library(lldbDAP
Handler/LaunchRequestHandler.cpp
Handler/LocationsRequestHandler.cpp
Handler/ModulesRequestHandler.cpp
+ Handler/ModuleSymbolsRequestHandler.cpp
Handler/NextRequestHandler.cpp
Handler/PauseRequestHandler.cpp
Handler/ReadMemoryRequestHandler.cpp
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 08d50c9b93a7e..9896ed03a29f2 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -1566,7 +1566,7 @@ void DAP::RegisterRequests() {
// Custom requests
RegisterRequest<CompileUnitsRequestHandler>();
RegisterRequest<ModulesRequestHandler>();
- RegisterRequest<DAPGetModuleSymbolsRequestHandler>();
+ RegisterRequest<ModuleSymbolsRequestHandler>();
// Testing requests
RegisterRequest<TestGetTargetBreakpointsRequestHandler>();
diff --git a/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/ModuleSymbolsRequestHandler.cpp
similarity index 91%
rename from lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
rename to lldb/tools/lldb-dap/Handler/ModuleSymbolsRequestHandler.cpp
index a143c814150eb..87c5737bceb9f 100644
--- a/lldb/tools/lldb-dap/Handler/DAPGetModuleSymbolsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/ModuleSymbolsRequestHandler.cpp
@@ -87,15 +87,9 @@ static std::string SymbolTypeToString(lldb::SymbolType symbol_type) {
llvm_unreachable("unhandled symbol type.");
}
-/// Modules can be retrieved from the debug adapter with this request which can
-/// either return all modules or a range of modules to support paging.
-///
-/// Clients should only call this request if the corresponding capability
-/// `supportsModulesRequest` is true.
-llvm::Expected<DAPGetModuleSymbolsResponseBody>
-DAPGetModuleSymbolsRequestHandler::Run(
- const DAPGetModuleSymbolsArguments &args) const {
- DAPGetModuleSymbolsResponseBody response;
+llvm::Expected<ModuleSymbolsResponseBody>
+ModuleSymbolsRequestHandler::Run(const ModuleSymbolsArguments &args) const {
+ ModuleSymbolsResponseBody response;
lldb::SBModuleSpec module_spec;
if (args.moduleId) {
diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index e605a8bc1b9f1..8e2e408221fed 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -594,15 +594,15 @@ class CancelRequestHandler : public RequestHandler<protocol::CancelArguments,
llvm::Error Run(const protocol::CancelArguments &args) const override;
};
-class DAPGetModuleSymbolsRequestHandler
+class ModuleSymbolsRequestHandler
: public RequestHandler<
- protocol::DAPGetModuleSymbolsArguments,
- llvm::Expected<protocol::DAPGetModuleSymbolsResponseBody>> {
+ protocol::ModuleSymbolsArguments,
+ llvm::Expected<protocol::ModuleSymbolsResponseBody>> {
public:
using RequestHandler::RequestHandler;
- static llvm::StringLiteral GetCommand() { return "dapGetModuleSymbols"; }
- llvm::Expected<protocol::DAPGetModuleSymbolsResponseBody>
- Run(const protocol::DAPGetModuleSymbolsArguments &args) const override;
+ static llvm::StringLiteral GetCommand() { return "moduleSymbols"; }
+ llvm::Expected<protocol::ModuleSymbolsResponseBody>
+ Run(const protocol::ModuleSymbolsArguments &args) const override;
};
/// A request used in testing to get the details on all breakpoints that are
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
index e0d49a7d03ce5..118791e2c1eea 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
@@ -598,14 +598,14 @@ json::Value toJSON(const WriteMemoryResponseBody &WMR) {
return result;
}
-bool fromJSON(const llvm::json::Value &Params,
- DAPGetModuleSymbolsArguments &Args, llvm::json::Path P) {
+bool fromJSON(const llvm::json::Value &Params, ModuleSymbolsArguments &Args,
+ llvm::json::Path P) {
json::ObjectMapper O(Params, P);
return O && O.mapOptional("moduleId", Args.moduleId) &&
O.mapOptional("moduleName", Args.moduleName);
}
-llvm::json::Value toJSON(const DAPGetModuleSymbolsResponseBody &DGMSR) {
+llvm::json::Value toJSON(const ModuleSymbolsResponseBody &DGMSR) {
json::Object result;
result.insert({"symbols", DGMSR.symbols});
return result;
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
index 0d87f6fac1e18..13a3715a075a8 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
@@ -981,22 +981,22 @@ struct WriteMemoryResponseBody {
};
llvm::json::Value toJSON(const WriteMemoryResponseBody &);
-struct DAPGetModuleSymbolsArguments {
+struct ModuleSymbolsArguments {
/// The module UUID for which to retrieve symbols.
std::optional<std::string> moduleId;
/// The module path.
std::optional<std::string> moduleName;
};
-bool fromJSON(const llvm::json::Value &, DAPGetModuleSymbolsArguments &,
+bool fromJSON(const llvm::json::Value &, ModuleSymbolsArguments &,
llvm::json::Path);
/// Response to `getModuleSymbols` request.
-struct DAPGetModuleSymbolsResponseBody {
+struct ModuleSymbolsResponseBody {
/// The symbols for the specified module.
std::vector<dap::Symbol> symbols;
};
-llvm::json::Value toJSON(const DAPGetModuleSymbolsResponseBody &);
+llvm::json::Value toJSON(const ModuleSymbolsResponseBody &);
} // namespace lldb_dap::protocol
More information about the lldb-commits
mailing list