[Lldb-commits] [lldb] [lldb] Use std::optional::value_of (NFC) (PR #140011)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/140011 None >From cb827a2d99f3d700378ddbe4064b60281c5ef85e Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 14 May 2025 23:29:42 -0700 Subject: [PATCH] [lldb] Use std::optional::value_of (NFC) --- .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 4 ++-- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 8 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index a3e809f44ed23..e3a866e2b6d48 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2479,8 +2479,8 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF( std::unique_ptr decl_up; if (decl_file || decl_line || decl_column) decl_up = std::make_unique( - die.GetCU()->GetFile(decl_file ? *decl_file : 0), - decl_line ? *decl_line : 0, decl_column ? *decl_column : 0); + die.GetCU()->GetFile(decl_file.value_or(0)), decl_line.value_or(0), + decl_column.value_or(0)); SymbolFileDWARF *dwarf = die.GetDWARF(); // Supply the type _only_ if it has already been parsed diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 907d63eb51afe..0fc7f79be70ec 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1358,15 +1358,15 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(CompileUnit &comp_unit, if (decl_file || decl_line || decl_column) decl_up = std::make_unique( comp_unit.GetSupportFiles().GetFileSpecAtIndex( - decl_file ? *decl_file : 0), - decl_line ? *decl_line : 0, decl_column ? *decl_column : 0); + decl_file.value_or(0)), + decl_line.value_or(0), decl_column.value_or(0)); std::unique_ptr call_up; if (call_file || call_line || call_column) call_up = std::make_unique( comp_unit.GetSupportFiles().GetFileSpecAtIndex( - call_file ? *call_file : 0), - call_line ? *call_line : 0, call_column ? *call_column : 0); + call_file.value_or(0)), + call_line.value_or(0), call_column.value_or(0)); block->SetInlinedFunctionInfo(name, mangled_name, decl_up.get(), call_up.get()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use std::optional::value_of (NFC) (PR #140011)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Kazu Hirata (kazutakahirata) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/140011.diff 2 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+2-2) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+4-4) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index a3e809f44ed23..e3a866e2b6d48 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2479,8 +2479,8 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF( std::unique_ptr decl_up; if (decl_file || decl_line || decl_column) decl_up = std::make_unique( - die.GetCU()->GetFile(decl_file ? *decl_file : 0), - decl_line ? *decl_line : 0, decl_column ? *decl_column : 0); + die.GetCU()->GetFile(decl_file.value_or(0)), decl_line.value_or(0), + decl_column.value_or(0)); SymbolFileDWARF *dwarf = die.GetDWARF(); // Supply the type _only_ if it has already been parsed diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 907d63eb51afe..0fc7f79be70ec 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1358,15 +1358,15 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(CompileUnit &comp_unit, if (decl_file || decl_line || decl_column) decl_up = std::make_unique( comp_unit.GetSupportFiles().GetFileSpecAtIndex( - decl_file ? *decl_file : 0), - decl_line ? *decl_line : 0, decl_column ? *decl_column : 0); + decl_file.value_or(0)), + decl_line.value_or(0), decl_column.value_or(0)); std::unique_ptr call_up; if (call_file || call_line || call_column) call_up = std::make_unique( comp_unit.GetSupportFiles().GetFileSpecAtIndex( - call_file ? *call_file : 0), - call_line ? *call_line : 0, call_column ? *call_column : 0); + call_file.value_or(0)), + call_line.value_or(0), call_column.value_or(0)); block->SetInlinedFunctionInfo(name, mangled_name, decl_up.get(), call_up.get()); `` https://github.com/llvm/llvm-project/pull/140011 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use std::optional::value_or (NFC) (PR #140011)
https://github.com/kazutakahirata edited https://github.com/llvm/llvm-project/pull/140011 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: John Harrison (ashgti) Changes This is a very simple case that currently only validates we can create a DAP instance and send a message over the transport layer. More in-depth tests will require additional helpers and possibly refactors of DAP to make it more testable, however this is some ground work to have basic support for unit tests. --- Full diff: https://github.com/llvm/llvm-project/pull/139937.diff 3 Files Affected: - (modified) lldb/tools/lldb-dap/DAP.h (+2-1) - (modified) lldb/unittests/DAP/CMakeLists.txt (+1) - (added) lldb/unittests/DAP/DAPTest.cpp (+63) ``diff diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h index c2e4c2dea582e..2ff66d1cd0182 100644 --- a/lldb/tools/lldb-dap/DAP.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -226,7 +226,8 @@ struct DAP { /// \param[in] default_repl_mode /// Default repl mode behavior, as configured by the binary. /// \param[in] pre_init_commands - /// LLDB commands to execute as soon as the debugger instance is allocaed. + /// LLDB commands to execute as soon as the debugger instance is + /// allocated. /// \param[in] transport /// Transport for this debug session. DAP(Log *log, const ReplMode default_repl_mode, diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt index 110733e93b192..6074e9b872c49 100644 --- a/lldb/unittests/DAP/CMakeLists.txt +++ b/lldb/unittests/DAP/CMakeLists.txt @@ -3,6 +3,7 @@ add_lldb_unittest(DAPTests LLDBUtilsTest.cpp TransportTest.cpp ProtocolTypesTest.cpp + DAPTest.cpp LINK_LIBS lldbDAP diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp new file mode 100644 index 0..9d2a9b944678e --- /dev/null +++ b/lldb/unittests/DAP/DAPTest.cpp @@ -0,0 +1,63 @@ +//===-- DAPTest.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 "Protocol/ProtocolBase.h" +#include "Transport.h" +#include "lldb/Host/File.h" +#include "lldb/Host/Pipe.h" +#include "llvm/Testing/Support/Error.h" +#include "gtest/gtest.h" +#include +#include +#include + +using namespace llvm; +using namespace lldb; +using namespace lldb_dap; +using namespace lldb_dap::protocol; +using lldb_private::File; +using lldb_private::NativeFile; +using lldb_private::Pipe; + +class DAPTest : public testing::Test { +protected: + Pipe input; + Pipe output; + std::unique_ptr toDAP; + std::unique_ptr fromDAP; + + void SetUp() override { +ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), Succeeded()); +ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), Succeeded()); +toDAP = std::make_unique( +"toDAP", nullptr, +std::make_shared(input.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(output.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); +fromDAP = std::make_unique( +"fromDAP", nullptr, +std::make_shared(output.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(input.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); + } +}; + +TEST_F(DAPTest, SendProtocolMessages) { + DAP dap{nullptr, ReplMode::Auto, {}, *toDAP}; + dap.Send(Event{"my-event", std::nullopt}); + ASSERT_THAT_EXPECTED(fromDAP->Read(std::chrono::milliseconds(1)), + HasValue(testing::VariantWith(testing::FieldsAre( + /*event=*/"my-event", /*body=*/std::nullopt; +} `` https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Simplify a string comparison (NFC) (PR #139932)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/139932 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
https://github.com/JDevlieghere approved this pull request. Very excited to see more unit testing! https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/138020 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Simplify a string comparison (NFC) (PR #139932)
https://github.com/bulbazord approved this pull request. https://github.com/llvm/llvm-project/pull/139932 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix race condition during iteration through modules (#139283) (PR #139862)
@@ -1510,6 +1510,7 @@ bool Target::IgnoreWatchpointByID(lldb::watch_id_t watch_id, } ModuleSP Target::GetExecutableModule() { + std::lock_guard guard(m_images.GetMutex()); JDevlieghere wrote: Let's use the `Modules()` iterable which allows us to use a for-based loop and does the locking for us: ``` // Search for the first executable in the module list. for (ModuleSP module_sp : m_images.Modules()) { lldb_private::ObjectFile *obj = module_sp->GetObjectFile(); ``` https://github.com/llvm/llvm-project/pull/139862 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
JDevlieghere wrote: > Should I rename `toDAP`/`fromDAP` to `to_dap`/`from_dap`? I think thats more > inline with how lldb names variables, right? Yes, good point. Currently we have a weird mix of styles. Once everything has been migrated to use the protocol classes, we should go through the code and fix the remaining inconsistencies. https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 28d732a - [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (#138020)
Author: Chelsea Cassanova Date: 2025-05-14T10:46:01-07:00 New Revision: 28d732a24ef06bab3a2cd6c17975281155f63cd6 URL: https://github.com/llvm/llvm-project/commit/28d732a24ef06bab3a2cd6c17975281155f63cd6 DIFF: https://github.com/llvm/llvm-project/commit/28d732a24ef06bab3a2cd6c17975281155f63cd6.diff LOG: [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (#138020) CMake 4 no longer sets the `CMAKE_OSX_SYSROOT` variable by default. If you've updated to CMake 4 on macOS (e.g. with brew) and try building LLDB with CMake/ninja, this will yield an error when building debugserver that clang is unable to run since it tries to compile files that don't exist. These files are supposed to be generated by the `mig` process. `mig` needs the `CMAKE_OSX_SYSROOT` variable in order to work and without it, it silently fails to generate the files that later on need to be compiled. This commit sets this SDK path for mig and will fatal error out of config when building debugserver without having set CMAKE_OSX_SYSROOT. Added: Modified: lldb/tools/debugserver/source/CMakeLists.txt Removed: diff --git a/lldb/tools/debugserver/source/CMakeLists.txt b/lldb/tools/debugserver/source/CMakeLists.txt index f7ff76c3e8e84..8340b5ad8948d 100644 --- a/lldb/tools/debugserver/source/CMakeLists.txt +++ b/lldb/tools/debugserver/source/CMakeLists.txt @@ -154,6 +154,21 @@ endif() add_definitions(-DLLDB_USE_OS_LOG) +# Make sure we have the macOS SDK root as mig needs it and will silently +# fail to generate its output files without it. +if(CMAKE_OSX_SYSROOT) + set(MIG_SYSROOT ${CMAKE_OSX_SYSROOT}) +else() + execute_process(COMMAND xcrun --show-sdk-path +OUTPUT_VARIABLE MIG_SYSROOT +ERROR_QUIET +OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +if(NOT MIG_SYSROOT) + message(FATAL_ERROR "Unable to obtain sysroot required by mig (Mach Interface Generator). Set CMAKE_OSX_SYSROOT to explicitly specify a sysroot.") +endif() + if(${CMAKE_OSX_SYSROOT} MATCHES ".Internal.sdk$") message(STATUS "LLDB debugserver energy support is enabled") add_definitions(-DLLDB_ENERGY) @@ -177,7 +192,7 @@ endif() separate_arguments(MIG_ARCH_FLAGS_SEPARTED NATIVE_COMMAND "${MIG_ARCH_FLAGS}") add_custom_command(OUTPUT ${generated_mach_interfaces} - VERBATIM COMMAND mig ${MIG_ARCH_FLAGS_SEPARTED} -isysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs + VERBATIM COMMAND mig ${MIG_ARCH_FLAGS_SEPARTED} -isysroot ${MIG_SYSROOT} ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs ) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)
https://github.com/chelcassanova closed https://github.com/llvm/llvm-project/pull/138020 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)
https://github.com/bulbazord approved this pull request. https://github.com/llvm/llvm-project/pull/138020 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/139937 >From 6f947e38ad4f744754cf13c1094c4e5e3fd249b6 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 10:31:40 -0700 Subject: [PATCH 1/2] [lldb-dap] Setup DAP for unit testing. This is a very simple case that currently only validates we can create a DAP instance and send a message over the transport layer. More in-depth tests will require additional helpers and possibly refactors of DAP to make it more testable, however this is some ground work to have basic support for unit tests. --- lldb/tools/lldb-dap/DAP.h | 3 +- lldb/unittests/DAP/CMakeLists.txt | 1 + lldb/unittests/DAP/DAPTest.cpp| 63 +++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 lldb/unittests/DAP/DAPTest.cpp diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h index c2e4c2dea582e..2ff66d1cd0182 100644 --- a/lldb/tools/lldb-dap/DAP.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -226,7 +226,8 @@ struct DAP { /// \param[in] default_repl_mode /// Default repl mode behavior, as configured by the binary. /// \param[in] pre_init_commands - /// LLDB commands to execute as soon as the debugger instance is allocaed. + /// LLDB commands to execute as soon as the debugger instance is + /// allocated. /// \param[in] transport /// Transport for this debug session. DAP(Log *log, const ReplMode default_repl_mode, diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt index 110733e93b192..6074e9b872c49 100644 --- a/lldb/unittests/DAP/CMakeLists.txt +++ b/lldb/unittests/DAP/CMakeLists.txt @@ -3,6 +3,7 @@ add_lldb_unittest(DAPTests LLDBUtilsTest.cpp TransportTest.cpp ProtocolTypesTest.cpp + DAPTest.cpp LINK_LIBS lldbDAP diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp new file mode 100644 index 0..9d2a9b944678e --- /dev/null +++ b/lldb/unittests/DAP/DAPTest.cpp @@ -0,0 +1,63 @@ +//===-- DAPTest.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 "Protocol/ProtocolBase.h" +#include "Transport.h" +#include "lldb/Host/File.h" +#include "lldb/Host/Pipe.h" +#include "llvm/Testing/Support/Error.h" +#include "gtest/gtest.h" +#include +#include +#include + +using namespace llvm; +using namespace lldb; +using namespace lldb_dap; +using namespace lldb_dap::protocol; +using lldb_private::File; +using lldb_private::NativeFile; +using lldb_private::Pipe; + +class DAPTest : public testing::Test { +protected: + Pipe input; + Pipe output; + std::unique_ptr toDAP; + std::unique_ptr fromDAP; + + void SetUp() override { +ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), Succeeded()); +ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), Succeeded()); +toDAP = std::make_unique( +"toDAP", nullptr, +std::make_shared(input.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(output.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); +fromDAP = std::make_unique( +"fromDAP", nullptr, +std::make_shared(output.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(input.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); + } +}; + +TEST_F(DAPTest, SendProtocolMessages) { + DAP dap{nullptr, ReplMode::Auto, {}, *toDAP}; + dap.Send(Event{"my-event", std::nullopt}); + ASSERT_THAT_EXPECTED(fromDAP->Read(std::chrono::milliseconds(1)), + HasValue(testing::VariantWith(testing::FieldsAre( + /*event=*/"my-event", /*body=*/std::nullopt; +} >From 8bc4880a338dd0d0f2daa64b77c8bdbf567270b2 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 10:46:51 -0700 Subject: [PATCH 2/2] Adjusting the naming of variables. --- lldb/unittests/DAP/DAPTest.cpp | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp index 9d2a9b944678e..8e8c2ea3ccbb0 100644 --- a/lldb/unittests/DAP/DAPTest.cpp +++ b/lldb/unittests/DAP/DAPTest.cpp @@ -29,22 +29,22 @@ class DAPTest : public testing::Test { protected: Pipe input; Pipe output; -
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
ashgti wrote: Should I rename `toDAP`/`fromDAP` to `to_dap`/`from_dap`? I think thats more inline with how lldb names variables, right? https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
ashgti wrote: Yea, thats my mistake. I made the protocol classes to match the names of the spec, but we don't really have to do that as long as the `toJSON`/`fromJSON` adjusts the names, they can be different. https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/139937 >From 6f947e38ad4f744754cf13c1094c4e5e3fd249b6 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 10:31:40 -0700 Subject: [PATCH 1/3] [lldb-dap] Setup DAP for unit testing. This is a very simple case that currently only validates we can create a DAP instance and send a message over the transport layer. More in-depth tests will require additional helpers and possibly refactors of DAP to make it more testable, however this is some ground work to have basic support for unit tests. --- lldb/tools/lldb-dap/DAP.h | 3 +- lldb/unittests/DAP/CMakeLists.txt | 1 + lldb/unittests/DAP/DAPTest.cpp| 63 +++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 lldb/unittests/DAP/DAPTest.cpp diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h index c2e4c2dea582e..2ff66d1cd0182 100644 --- a/lldb/tools/lldb-dap/DAP.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -226,7 +226,8 @@ struct DAP { /// \param[in] default_repl_mode /// Default repl mode behavior, as configured by the binary. /// \param[in] pre_init_commands - /// LLDB commands to execute as soon as the debugger instance is allocaed. + /// LLDB commands to execute as soon as the debugger instance is + /// allocated. /// \param[in] transport /// Transport for this debug session. DAP(Log *log, const ReplMode default_repl_mode, diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt index 110733e93b192..6074e9b872c49 100644 --- a/lldb/unittests/DAP/CMakeLists.txt +++ b/lldb/unittests/DAP/CMakeLists.txt @@ -3,6 +3,7 @@ add_lldb_unittest(DAPTests LLDBUtilsTest.cpp TransportTest.cpp ProtocolTypesTest.cpp + DAPTest.cpp LINK_LIBS lldbDAP diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp new file mode 100644 index 0..9d2a9b944678e --- /dev/null +++ b/lldb/unittests/DAP/DAPTest.cpp @@ -0,0 +1,63 @@ +//===-- DAPTest.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 "Protocol/ProtocolBase.h" +#include "Transport.h" +#include "lldb/Host/File.h" +#include "lldb/Host/Pipe.h" +#include "llvm/Testing/Support/Error.h" +#include "gtest/gtest.h" +#include +#include +#include + +using namespace llvm; +using namespace lldb; +using namespace lldb_dap; +using namespace lldb_dap::protocol; +using lldb_private::File; +using lldb_private::NativeFile; +using lldb_private::Pipe; + +class DAPTest : public testing::Test { +protected: + Pipe input; + Pipe output; + std::unique_ptr toDAP; + std::unique_ptr fromDAP; + + void SetUp() override { +ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), Succeeded()); +ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), Succeeded()); +toDAP = std::make_unique( +"toDAP", nullptr, +std::make_shared(input.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(output.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); +fromDAP = std::make_unique( +"fromDAP", nullptr, +std::make_shared(output.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(input.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); + } +}; + +TEST_F(DAPTest, SendProtocolMessages) { + DAP dap{nullptr, ReplMode::Auto, {}, *toDAP}; + dap.Send(Event{"my-event", std::nullopt}); + ASSERT_THAT_EXPECTED(fromDAP->Read(std::chrono::milliseconds(1)), + HasValue(testing::VariantWith(testing::FieldsAre( + /*event=*/"my-event", /*body=*/std::nullopt; +} >From 8bc4880a338dd0d0f2daa64b77c8bdbf567270b2 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 10:46:51 -0700 Subject: [PATCH 2/3] Adjusting the naming of variables. --- lldb/unittests/DAP/DAPTest.cpp | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp index 9d2a9b944678e..8e8c2ea3ccbb0 100644 --- a/lldb/unittests/DAP/DAPTest.cpp +++ b/lldb/unittests/DAP/DAPTest.cpp @@ -29,22 +29,22 @@ class DAPTest : public testing::Test { protected: Pipe input; Pipe output; -
[Lldb-commits] [lldb] [lldb][RPC] Upstream Python scripts (PR #138028)
@@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +# Usage: convert-lldb-header-to-rpc-header.py +# This scripts takes common LLDB headers (such as lldb-defines.h) and replaces references to LLDB +# with those for RPC. This happens for: +# - namespace definitions +# - namespace usage +# - version string macros +# - ifdef/ifndef lines JDevlieghere wrote: Python has a PEP that describes how to document files/modules. We should use that here too. ```suggestion """ Usage: convert-lldb-header-to-rpc-header.py This scripts takes common LLDB headers (such as lldb-defines.h) and replaces references to LLDB with those for RPC. This happens for: - namespace definitions - namespace usage - version string macros - ifdef/ifndef lines """ ``` https://github.com/llvm/llvm-project/pull/138028 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RPC] Upstream Python scripts (PR #138028)
@@ -0,0 +1,16 @@ +// Copy lldb-rpc-defines.h from source. +# RUN: mkdir -p %t/input +# RUN: mkdir -p %t/output +# RUN: cp %p/../../../../../include/lldb/lldb-defines.h %t/input JDevlieghere wrote: Is the goal to run this on the sources to catch regressions, or are we just using the source file as a meaningful input? If it's the latter, I would recommend copying the file into the Inputs directory and reducing it to the bare minimum needed for the test. https://github.com/llvm/llvm-project/pull/138028 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)
https://github.com/ita-sc updated https://github.com/llvm/llvm-project/pull/139916 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Simplify a string comparison (NFC) (PR #139932)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/139932 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 539265b - [lldb] Simplify a string comparison (NFC) (#139932)
Author: Kazu Hirata Date: 2025-05-14T11:21:42-07:00 New Revision: 539265b9044f8cda513e5e65d11f2630a32176cf URL: https://github.com/llvm/llvm-project/commit/539265b9044f8cda513e5e65d11f2630a32176cf DIFF: https://github.com/llvm/llvm-project/commit/539265b9044f8cda513e5e65d11f2630a32176cf.diff LOG: [lldb] Simplify a string comparison (NFC) (#139932) Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp index a2722db5d24a0..451cf40e2818d 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp @@ -123,8 +123,7 @@ void ASTStructExtractor::ExtractFromTopLevelDecl(Decl *D) { FunctionDecl *function_decl = dyn_cast(D); if (m_ast_context && function_decl && - !m_function.m_wrapper_function_name.compare( - function_decl->getNameAsString())) { + m_function.m_wrapper_function_name == function_decl->getNameAsString()) { ExtractFromFunctionDecl(function_decl); } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)
bulbazord wrote: > Pushed again to address David's comments and remove most of the FIXMEs. > There's one FIXME I've kept in for now: > > ``` > // FIXME: SB class server references are stored as non-const references so > // that we can actually change them as needed. If a parameter is marked > // const, we will fail to compile because we cannot make an > // SBFooServerReference from a `const SBFoo &`. > // To work around this issue, we'll apply a `const_cast` if needed so we > // can continue to generate callbacks for now, but we really should > // rethink the way we store object IDs server-side to support > // const-qualified parameters. > ``` > > @bulbazord This is referring to how we emit storage for const SB parameters > in callback functions. Currently it looks like it only gets applied to one > function that gets generated. Any thoughts here? Given it only applies to one function, it's probably okay to keep it around for now. The fact that we need a `const_cast` at all is concerning but I think we've done a reasonably alright job at explaining why it exists (though I am a partial author, so maybe my perspective is biased). https://github.com/llvm/llvm-project/pull/138032 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RPC] Upstream Python scripts (PR #138028)
@@ -0,0 +1,20 @@ +// Copy lldb-defines.h from source. +# RUN: mkdir -p %t/input +# RUN: mkdir -p %t/output +# RUN: cp %p/../../../../../include/lldb/lldb-defines.h %t/input JDevlieghere wrote: You're mixing two comment styles here, and lit doesn't actually treat these any differently (it just look for RUN lines). So let's settle on one and drop them everywhere else. ```suggestion // Copy lldb-defines.h from source. RUN: mkdir -p %t/input RUN: mkdir -p %t/output RUN: cp %p/../../../../../include/lldb/lldb-defines.h %t/input ``` or ```suggestion # Copy lldb-defines.h from source. RUN: mkdir -p %t/input RUN: mkdir -p %t/output RUN: cp %p/../../../../../include/lldb/lldb-defines.h %t/input ``` I think the latter is slightly more common. https://github.com/llvm/llvm-project/pull/138028 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added 32-bit XCOFF Executable support (PR #139875)
https://github.com/DhruvSrivastavaX updated https://github.com/llvm/llvm-project/pull/139875 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Refactor lldb-dap event handling. (PR #139669)
ashgti wrote: > Yeah, that should be possible, and it may make more sense in a world where > the MainLoop cannot listen on all FD types (since you need the forwarding > thread anyway). It's unfortunate that there's no synchronization operation > (at least, not a portable one, FUTEX_FD seems kinda nice) that allows you do > wait for condition variables and FDs, necessitating these forwarding threads. > Since forwarding would add a bit of latency, one of the factors would be > which kinds of operations do we want to make slower. We could adjust the lldb-dap VSCode extension to launch lldb-dap using a named pipe or local tcp port on Windows. Then we'd uniformly be able to support reading the input using the existing lldb NativeFile/Socket helpers. See https://code.visualstudio.com/api/references/vscode-api#DebugAdapterNamedPipeServer https://github.com/llvm/llvm-project/pull/139669 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
JDevlieghere wrote: > Yea, thats my mistake. I made the protocol classes to match the names of the > spec, but we don't really have to do that as long as the `toJSON`/`fromJSON` > adjusts the names, they can be different. I think we discussed this at some point in the past and I'm personally okay with saying that everything outside the protocol dir should follow the LLDB style and the Protocol dir matches the spec (although we're already diverging from that for the enums). https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Add --pointer-match-depth option to `type summary add` command. (PR #138209)
ZequanWu wrote: Ping. https://github.com/llvm/llvm-project/pull/138209 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)
https://github.com/eronnen edited https://github.com/llvm/llvm-project/pull/139969 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Lldb dap assembly breakpoint (PR #139969)
https://github.com/eronnen created https://github.com/llvm/llvm-project/pull/139969 Enable breakpints from assembly sources Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)
https://github.com/eronnen edited https://github.com/llvm/llvm-project/pull/139969 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
https://github.com/cor3ntin approved this pull request. The clang parts look like a nice improvement, thanks! Please wait for a few other people to review it though. https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)
@@ -0,0 +1,71 @@ +//===-- NativeThreadAIX.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 "NativeThreadAIX.h" +#include "NativeProcessAIX.h" +#include "lldb/Utility/State.h" +#include +#include + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_aix; + +NativeThreadAIX::NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid) +: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid) {} + +std::string NativeThreadAIX::GetName() { + NativeProcessAIX &process = GetProcess(); + auto BufferOrError = getProcFile(process.GetID(), "psinfo"); + if (!BufferOrError) +return ""; + auto &Buffer = *BufferOrError; + if (Buffer->getBufferSize() < sizeof(psinfo_t)) +return ""; + const psinfo_t *psinfo = + reinterpret_cast(Buffer->getBufferStart()); + return std::string(psinfo->pr_fname); +} labath wrote: > In that case, shall I go ahead with this? I think we can say it's up to you, but so far I haven't seen anything that would make me thing this is necessary. You're right that it causes the name field to disappear, but the usefulness of that field comes from the fact that it's different for every thread: ``` lldb) thread list Process 6708 stopped * thread #1: tid = 6708, 0x7fffee7201ac libc.so.6`__select + 332, name = 'lldb', stop reason = signal SIGSTOP thread #2: tid = 6759, 0x7fffee69c0a5 libc.so.6`__futex_abstimed_wait_common + 261, name = 'er.alarm-thread' thread #3: tid = 6760, 0x7fffee69c0a5 libc.so.6`__futex_abstimed_wait_common + 261, name = 'dbg.evt-handler' thread #4: tid = 6765, 0x7fffee70b15a libc.so.6`wait4 + 90, name = 'ait4(pid=6764)>' thread #5: tid = 6766, 0x7fffee7201ac libc.so.6`__select + 332, name = 'b-remote.async>' thread #6: tid = 6771, 0x7fffee69c0a5 libc.so.6`__futex_abstimed_wait_common + 261, name = 'intern-state' thread #7: tid = 6772, 0x7fffee7201ac libc.so.6`__select + 332, name = '.process.stdio>' thread #8: tid = 6773, 0x7fffee69c0a5 libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-0' thread #9: tid = 6774, 0x7fffee69c0a5 libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-1' thread #10: tid = 6775, 0x7fffee69c0a5 libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-2' thread #11: tid = 6776, 0x7fffee69c0a5 libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-3' thread #12: tid = 6777, 0x7fffee69c0a5 libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-4' ``` If all of these said `name='lldb'`, would the result be useful? I think not. And I think the same goes for the single-threaded use case: if there is just a single thread, then you don't need names as there's nothing to distinguish. https://github.com/llvm/llvm-project/pull/139537 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
@@ -107,6 +107,7 @@ class ASTUnit { private: std::unique_ptr LangOpts; + std::shared_ptr DiagOpts; cor3ntin wrote: Can that be unique_ptr ? https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)
@@ -0,0 +1,71 @@ +//===-- NativeThreadAIX.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 "NativeThreadAIX.h" +#include "NativeProcessAIX.h" +#include "lldb/Utility/State.h" +#include +#include + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_aix; + +NativeThreadAIX::NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid) +: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid) {} + +std::string NativeThreadAIX::GetName() { + NativeProcessAIX &process = GetProcess(); + auto BufferOrError = getProcFile(process.GetID(), "psinfo"); + if (!BufferOrError) +return ""; + auto &Buffer = *BufferOrError; + if (Buffer->getBufferSize() < sizeof(psinfo_t)) +return ""; + const psinfo_t *psinfo = + reinterpret_cast(Buffer->getBufferStart()); + return std::string(psinfo->pr_fname); +} labath wrote: You also shouldn't expect that the "process stopped" output will contain the name of the process. That really is the name of the thread -- it just happens that on linux the main thread gets the name of the process. On macos for instance, this output doesn't contain the name of the process, even for the main thread: ``` (lldb) Process 6668 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP frame #0: 0x000185cf1b6c libsystem_kernel.dylib`__read_nocancel + 8 ``` https://github.com/llvm/llvm-project/pull/139537 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
@@ -2032,6 +2032,7 @@ class SourceManagerForFile { // as they are created in `createSourceManagerForFile` so that they can be // deleted in the reverse order as they are created. std::unique_ptr FileMgr; + std::unique_ptr DiagOpts; ojhunt wrote: I don't like that in some cases we have a unique_ptr and later (ATSUnit) we use a shared_ptr<>. It leaves an author unable to know given some arbitrary DiagnosticOptions* what the lifetime and/or ownership rules are. https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Split RegisterContextUnwind::SavedLocationForRegister (PR #139817)
@@ -1243,303 +1243,285 @@ bool RegisterContextUnwind::IsTrapHandlerSymbol( return false; } -// Answer the question: Where did THIS frame save the CALLER frame ("previous" -// frame)'s register value? - -enum UnwindLLDB::RegisterSearchResult -RegisterContextUnwind::SavedLocationForRegister( -uint32_t lldb_regnum, -lldb_private::UnwindLLDB::ConcreteRegisterLocation ®loc) { +/// Search this stack frame's UnwindPlans for the AbstractRegisterLocation labath wrote: The docstring should go in the header. If there are details you think are only relevant for the implementation (not the interface), they can stay here. https://github.com/llvm/llvm-project/pull/139817 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Extending LLDB to work on AIX (PR #102601)
https://github.com/HemangGadhavi updated https://github.com/llvm/llvm-project/pull/102601 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Refactor lldb-dap event handling. (PR #139669)
labath wrote: > I think our tests are not fully specifying their expected state. For example, > lldb/test/API/tools/lldb-dap/console/TestDAP_console.py > `TestDAP_console.test_diagnositcs` was performing an evaluate and then using > `get_important` to fetch output events with category 'important'. > > With the change, the `important` output was always coming after the request > was handled. I updated the test to use a `self.collect_important` instead of > `get_important`. Previously, this could have been emitted while the request > was being handled, but now the output would only ever be emitted after the > request handler is finished. Okay, so it's kind of what I said, right? The "important" output was coming before the message was handled most of the time, although it wasn't guaranteed, and the test could fail if that happens. Now, it *always* comes too late. If that's true, then the test change to use `self.collect_important` could be made before the functionality change, right? > Thinking about this some more, would it be possible to treat everything as an > `SBEvent`? We could use the `DAP::broadcaster` to create events for the DAP > protocol messages we receive, right? Then when we listen for events we'd just > need to check if the event was a > `DAPBroadcasterBits::eBroadcastBitProtocolMessage` as the event type and > handle protocol messages in the same loop we're handling events. > > This would have a similar effect as using a MainLoop but unifies the event > thread with the DAP handler. We'd still need to transport thread to parse > messages and add events to the broadcaster. Yeah, that should be possible, and it may make more sense in a world where the MainLoop cannot listen on all FD types (since you need the forwarding thread anyway). It's unfortunate that there's no synchronization operation (at least, not a portable one, FUTEX_FD seems kinda nice) that allows you do wait for condition variables and FDs, necessitating these forwarding threads. Since forwarding would add a bit of latency, one of the factors would be which kinds of operations do we want to make slower. https://github.com/llvm/llvm-project/pull/139669 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix race condition during iteration through modules (#139283) (PR #139862)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/139862 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix race condition during iteration through modules (#139283) (PR #139862)
https://github.com/nd created https://github.com/llvm/llvm-project/pull/139862 Lock ensures modules don't change during iteration. Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix race condition during iteration through modules (#139283) (PR #139862)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (nd) Changes Lock ensures modules don't change during iteration. --- Full diff: https://github.com/llvm/llvm-project/pull/139862.diff 1 Files Affected: - (modified) lldb/source/Target/Target.cpp (+1) ``diff diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 7f61f8689fb95..485b49aeb64b4 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -1510,6 +1510,7 @@ bool Target::IgnoreWatchpointByID(lldb::watch_id_t watch_id, } ModuleSP Target::GetExecutableModule() { + std::lock_guard guard(m_images.GetMutex()); // search for the first executable in the module list for (size_t i = 0; i < m_images.GetSize(); ++i) { ModuleSP module_sp = m_images.GetModuleAtIndex(i); `` https://github.com/llvm/llvm-project/pull/139862 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions cpp -- lldb/source/Host/common/TCPSocket.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp index 4148ad67b..b6e0f1117 100644 --- a/lldb/source/Host/common/TCPSocket.cpp +++ b/lldb/source/Host/common/TCPSocket.cpp @@ -169,8 +169,8 @@ Status TCPSocket::Connect(llvm::StringRef name) { return error; } - error = Status::FromErrorStringWithFormatv("Failed to connect {0}:{1}", - host_port->hostname, host_port->port); + error = Status::FromErrorStringWithFormatv( + "Failed to connect {0}:{1}", host_port->hostname, host_port->port); return error; } `` https://github.com/llvm/llvm-project/pull/139916 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/139584 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 998dca4 - [lldb-dap] Add unit test for protocol enum types (#139848)
Author: Jonas Devlieghere Date: 2025-05-14T09:10:49-07:00 New Revision: 998dca42351f3292512af56207b603dc2fef565b URL: https://github.com/llvm/llvm-project/commit/998dca42351f3292512af56207b603dc2fef565b DIFF: https://github.com/llvm/llvm-project/commit/998dca42351f3292512af56207b603dc2fef565b.diff LOG: [lldb-dap] Add unit test for protocol enum types (#139848) Add dedicated unit tests for the protocol enum types. Added: Modified: lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp lldb/tools/lldb-dap/Protocol/ProtocolTypes.h lldb/unittests/DAP/ProtocolTypesTest.cpp Removed: diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp index fafd061334bc9..857503b3a0084 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp +++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp @@ -105,7 +105,7 @@ bool fromJSON(const json::Value &Params, ColumnType &CT, json::Path P) { .Case("string", eColumnTypeString) .Case("number", eColumnTypeNumber) .Case("boolean", eColumnTypeBoolean) - .Case("unixTimestampUTC ", eColumnTypeTimestamp) + .Case("unixTimestampUTC", eColumnTypeTimestamp) .Default(std::nullopt); if (!columnType) { P.report("unexpected value, expected 'string', 'number', 'boolean', or " @@ -482,6 +482,18 @@ bool fromJSON(const llvm::json::Value &Params, SteppingGranularity &SG, return true; } +llvm::json::Value toJSON(const SteppingGranularity &SG) { + switch (SG) { + case eSteppingGranularityStatement: +return "statement"; + case eSteppingGranularityLine: +return "line"; + case eSteppingGranularityInstruction: +return "instruction"; + } + llvm_unreachable("unhandled stepping granularity."); +} + bool fromJSON(const llvm::json::Value &Params, ValueFormat &VF, llvm::json::Path P) { json::ObjectMapper O(Params, P); diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h index f8d2b35ce3e14..757037a7b6ed2 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h +++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h @@ -339,6 +339,7 @@ enum SteppingGranularity : unsigned { }; bool fromJSON(const llvm::json::Value &, SteppingGranularity &, llvm::json::Path); +llvm::json::Value toJSON(const SteppingGranularity &); /// Provides formatting information for a value. struct ValueFormat { diff --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp b/lldb/unittests/DAP/ProtocolTypesTest.cpp index fd3e3be073183..d97bbaffa2bc0 100644 --- a/lldb/unittests/DAP/ProtocolTypesTest.cpp +++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp @@ -291,3 +291,201 @@ TEST(ProtocolTypesTest, Capabilities) { EXPECT_EQ(capabilities.lldbExtVersion, deserialized_capabilities->lldbExtVersion); } + +TEST(ProtocolTypesTest, PresentationHint) { + // Test all PresentationHint values. + std::vector> test_cases = { + {ePresentationHintNormal, "normal"}, + {ePresentationHintEmphasize, "emphasize"}, + {ePresentationHintDeemphasize, "deemphasize"}}; + + for (const auto &test_case : test_cases) { +// Serialize the PresentationHint to JSON. +llvm::json::Value serialized = toJSON(test_case.first); +ASSERT_EQ(serialized.kind(), llvm::json::Value::Kind::String); +EXPECT_EQ(serialized.getAsString(), test_case.second); + +// Deserialize the JSON back to PresentationHint. +PresentationHint deserialized; +llvm::json::Path::Root root; +ASSERT_TRUE(fromJSON(serialized, deserialized, root)) +<< llvm::toString(root.getError()); +EXPECT_EQ(deserialized, test_case.first); + } + + // Test invalid value. + llvm::json::Value invalid_value = "invalid_hint"; + PresentationHint deserialized_invalid; + llvm::json::Path::Root root; + EXPECT_FALSE(fromJSON(invalid_value, deserialized_invalid, root)); +} + +TEST(ProtocolTypesTest, SteppingGranularity) { + // Test all SteppingGranularity values. + std::vector> test_cases = { + {eSteppingGranularityStatement, "statement"}, + {eSteppingGranularityLine, "line"}, + {eSteppingGranularityInstruction, "instruction"}}; + + for (const auto &test_case : test_cases) { +// Serialize the SteppingGranularity to JSON. +llvm::json::Value serialized = toJSON(test_case.first); +ASSERT_EQ(serialized.kind(), llvm::json::Value::Kind::String); +EXPECT_EQ(serialized.getAsString(), test_case.second); + +// Deserialize the JSON back to SteppingGranularity. +SteppingGranularity deserialized; +llvm::json::Path::Root root; +ASSERT_TRUE(fromJSON(serialized, deserialized, root)) +<< llvm::toString(root.getError()); +EXPECT_EQ(deserialized, test_case.first); + } + + // Test invalid value. + llvm::json::Value invalid_value = "invalid_granularity"; + SteppingGranularity deser
[Lldb-commits] [lldb] [lldb-dap] Adding unit tests for Transport. (PR #139926)
https://github.com/ashgti created https://github.com/llvm/llvm-project/pull/139926 This adds basic support for testing the Transport class and includes tests for 'Read'. >From 506e8107a397e2ae88d8b952c0a5351cda9fa161 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 09:13:32 -0700 Subject: [PATCH] [lldb-dap] Adding unittests for Transport. This adds basic support for testing the Transport class and includes tests for 'Read'. --- lldb/unittests/DAP/CMakeLists.txt| 1 + lldb/unittests/DAP/TransportTest.cpp | 81 2 files changed, 82 insertions(+) create mode 100644 lldb/unittests/DAP/TransportTest.cpp diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt index 8b240654046e2..110733e93b192 100644 --- a/lldb/unittests/DAP/CMakeLists.txt +++ b/lldb/unittests/DAP/CMakeLists.txt @@ -1,6 +1,7 @@ add_lldb_unittest(DAPTests JSONUtilsTest.cpp LLDBUtilsTest.cpp + TransportTest.cpp ProtocolTypesTest.cpp LINK_LIBS diff --git a/lldb/unittests/DAP/TransportTest.cpp b/lldb/unittests/DAP/TransportTest.cpp new file mode 100644 index 0..d27167cf9da61 --- /dev/null +++ b/lldb/unittests/DAP/TransportTest.cpp @@ -0,0 +1,81 @@ +//===-- LLDBUtilsTest.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 "Transport.h" +#include "Protocol/ProtocolBase.h" +#include "lldb/Host/File.h" +#include "lldb/Host/Pipe.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Testing/Support/Error.h" +#include "gtest/gtest.h" +#include +#include +#include + +using namespace llvm; +using namespace lldb; +using namespace lldb_private; +using namespace lldb_dap; +using namespace lldb_dap::protocol; + +class TransportTest : public testing::Test { +protected: + Pipe input; + Pipe output; + std::unique_ptr transport; + + void SetUp() override { +ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), llvm::Succeeded()); +ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), llvm::Succeeded()); +transport = std::make_unique( +"stdio", nullptr, +std::make_shared(input.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(output.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); + } + + void Write(StringRef json) { +std::string message = +formatv("Content-Length: {0}\r\n\r\n{1}", json.size(), json).str(); +ASSERT_THAT_EXPECTED(input.Write(message.data(), message.size()), + Succeeded()); + } +}; + +TEST_F(TransportTest, MalformedRequests) { + std::string malformed_header = "COnTent-LenGth: -1{}\r\n\r\nnotjosn"; + ASSERT_THAT_EXPECTED( + input.Write(malformed_header.data(), malformed_header.size()), + Succeeded()); + ASSERT_THAT_EXPECTED( + transport->Read(std::chrono::milliseconds(1)), + FailedWithMessage( + "expected 'Content-Length: ' and got 'COnTent-LenGth: '")); +} + +TEST_F(TransportTest, Read) { + Write(R"json({"seq": 1, "type": "request", "command": "abc"})json"); + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + HasValue(testing::VariantWith( + testing::FieldsAre(1, "abc", std::nullopt; +} + +TEST_F(TransportTest, ReadWithTimeout) { + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + Failed()); +} + +TEST_F(TransportTest, ReadWithEOF) { + input.CloseWriteFileDescriptor(); + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + Failed()); +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adding unit tests for Transport. (PR #139926)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: John Harrison (ashgti) Changes This adds basic support for testing the Transport class and includes tests for 'Read'. --- Full diff: https://github.com/llvm/llvm-project/pull/139926.diff 2 Files Affected: - (modified) lldb/unittests/DAP/CMakeLists.txt (+1) - (added) lldb/unittests/DAP/TransportTest.cpp (+81) ``diff diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt index 8b240654046e2..110733e93b192 100644 --- a/lldb/unittests/DAP/CMakeLists.txt +++ b/lldb/unittests/DAP/CMakeLists.txt @@ -1,6 +1,7 @@ add_lldb_unittest(DAPTests JSONUtilsTest.cpp LLDBUtilsTest.cpp + TransportTest.cpp ProtocolTypesTest.cpp LINK_LIBS diff --git a/lldb/unittests/DAP/TransportTest.cpp b/lldb/unittests/DAP/TransportTest.cpp new file mode 100644 index 0..d27167cf9da61 --- /dev/null +++ b/lldb/unittests/DAP/TransportTest.cpp @@ -0,0 +1,81 @@ +//===-- LLDBUtilsTest.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 "Transport.h" +#include "Protocol/ProtocolBase.h" +#include "lldb/Host/File.h" +#include "lldb/Host/Pipe.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Testing/Support/Error.h" +#include "gtest/gtest.h" +#include +#include +#include + +using namespace llvm; +using namespace lldb; +using namespace lldb_private; +using namespace lldb_dap; +using namespace lldb_dap::protocol; + +class TransportTest : public testing::Test { +protected: + Pipe input; + Pipe output; + std::unique_ptr transport; + + void SetUp() override { +ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), llvm::Succeeded()); +ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), llvm::Succeeded()); +transport = std::make_unique( +"stdio", nullptr, +std::make_shared(input.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(output.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); + } + + void Write(StringRef json) { +std::string message = +formatv("Content-Length: {0}\r\n\r\n{1}", json.size(), json).str(); +ASSERT_THAT_EXPECTED(input.Write(message.data(), message.size()), + Succeeded()); + } +}; + +TEST_F(TransportTest, MalformedRequests) { + std::string malformed_header = "COnTent-LenGth: -1{}\r\n\r\nnotjosn"; + ASSERT_THAT_EXPECTED( + input.Write(malformed_header.data(), malformed_header.size()), + Succeeded()); + ASSERT_THAT_EXPECTED( + transport->Read(std::chrono::milliseconds(1)), + FailedWithMessage( + "expected 'Content-Length: ' and got 'COnTent-LenGth: '")); +} + +TEST_F(TransportTest, Read) { + Write(R"json({"seq": 1, "type": "request", "command": "abc"})json"); + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + HasValue(testing::VariantWith( + testing::FieldsAre(1, "abc", std::nullopt; +} + +TEST_F(TransportTest, ReadWithTimeout) { + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + Failed()); +} + +TEST_F(TransportTest, ReadWithEOF) { + input.CloseWriteFileDescriptor(); + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + Failed()); +} `` https://github.com/llvm/llvm-project/pull/139926 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/138032 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adding unit tests for Transport. (PR #139926)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/139926 >From 506e8107a397e2ae88d8b952c0a5351cda9fa161 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 09:13:32 -0700 Subject: [PATCH 1/2] [lldb-dap] Adding unittests for Transport. This adds basic support for testing the Transport class and includes tests for 'Read'. --- lldb/unittests/DAP/CMakeLists.txt| 1 + lldb/unittests/DAP/TransportTest.cpp | 81 2 files changed, 82 insertions(+) create mode 100644 lldb/unittests/DAP/TransportTest.cpp diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt index 8b240654046e2..110733e93b192 100644 --- a/lldb/unittests/DAP/CMakeLists.txt +++ b/lldb/unittests/DAP/CMakeLists.txt @@ -1,6 +1,7 @@ add_lldb_unittest(DAPTests JSONUtilsTest.cpp LLDBUtilsTest.cpp + TransportTest.cpp ProtocolTypesTest.cpp LINK_LIBS diff --git a/lldb/unittests/DAP/TransportTest.cpp b/lldb/unittests/DAP/TransportTest.cpp new file mode 100644 index 0..d27167cf9da61 --- /dev/null +++ b/lldb/unittests/DAP/TransportTest.cpp @@ -0,0 +1,81 @@ +//===-- LLDBUtilsTest.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 "Transport.h" +#include "Protocol/ProtocolBase.h" +#include "lldb/Host/File.h" +#include "lldb/Host/Pipe.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Testing/Support/Error.h" +#include "gtest/gtest.h" +#include +#include +#include + +using namespace llvm; +using namespace lldb; +using namespace lldb_private; +using namespace lldb_dap; +using namespace lldb_dap::protocol; + +class TransportTest : public testing::Test { +protected: + Pipe input; + Pipe output; + std::unique_ptr transport; + + void SetUp() override { +ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), llvm::Succeeded()); +ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), llvm::Succeeded()); +transport = std::make_unique( +"stdio", nullptr, +std::make_shared(input.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(output.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); + } + + void Write(StringRef json) { +std::string message = +formatv("Content-Length: {0}\r\n\r\n{1}", json.size(), json).str(); +ASSERT_THAT_EXPECTED(input.Write(message.data(), message.size()), + Succeeded()); + } +}; + +TEST_F(TransportTest, MalformedRequests) { + std::string malformed_header = "COnTent-LenGth: -1{}\r\n\r\nnotjosn"; + ASSERT_THAT_EXPECTED( + input.Write(malformed_header.data(), malformed_header.size()), + Succeeded()); + ASSERT_THAT_EXPECTED( + transport->Read(std::chrono::milliseconds(1)), + FailedWithMessage( + "expected 'Content-Length: ' and got 'COnTent-LenGth: '")); +} + +TEST_F(TransportTest, Read) { + Write(R"json({"seq": 1, "type": "request", "command": "abc"})json"); + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + HasValue(testing::VariantWith( + testing::FieldsAre(1, "abc", std::nullopt; +} + +TEST_F(TransportTest, ReadWithTimeout) { + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + Failed()); +} + +TEST_F(TransportTest, ReadWithEOF) { + input.CloseWriteFileDescriptor(); + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + Failed()); +} >From 8d5ffc83c6fce70a3fe66fb726781e7bd2b08d77 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 09:16:34 -0700 Subject: [PATCH 2/2] Fixing the filename in the top comment. --- lldb/unittests/DAP/TransportTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/unittests/DAP/TransportTest.cpp b/lldb/unittests/DAP/TransportTest.cpp index d27167cf9da61..b8eade5442814 100644 --- a/lldb/unittests/DAP/TransportTest.cpp +++ b/lldb/unittests/DAP/TransportTest.cpp @@ -1,4 +1,4 @@ -//===-- LLDBUtilsTest.cpp -===// +//===-- TransportTest.cpp -===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/
[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/138032 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Simplify a string comparison (NFC) (PR #139932)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/139932 None Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Simplify a string comparison (NFC) (PR #139932)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Kazu Hirata (kazutakahirata) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/139932.diff 1 Files Affected: - (modified) lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp (+1-2) ``diff diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp index a2722db5d24a0..451cf40e2818d 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp @@ -123,8 +123,7 @@ void ASTStructExtractor::ExtractFromTopLevelDecl(Decl *D) { FunctionDecl *function_decl = dyn_cast(D); if (m_ast_context && function_decl && - !m_function.m_wrapper_function_name.compare( - function_decl->getNameAsString())) { + m_function.m_wrapper_function_name == function_decl->getNameAsString()) { ExtractFromFunctionDecl(function_decl); } } `` https://github.com/llvm/llvm-project/pull/139932 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
ashgti wrote: I added a few extra tests here and some extra base classes to help setup tests. LMKWYT https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Complete the Implementation of DAP modules explorer. (PR #139934)
https://github.com/ashgti approved this pull request. https://github.com/llvm/llvm-project/pull/139934 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/139937 >From 6f947e38ad4f744754cf13c1094c4e5e3fd249b6 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 10:31:40 -0700 Subject: [PATCH 1/5] [lldb-dap] Setup DAP for unit testing. This is a very simple case that currently only validates we can create a DAP instance and send a message over the transport layer. More in-depth tests will require additional helpers and possibly refactors of DAP to make it more testable, however this is some ground work to have basic support for unit tests. --- lldb/tools/lldb-dap/DAP.h | 3 +- lldb/unittests/DAP/CMakeLists.txt | 1 + lldb/unittests/DAP/DAPTest.cpp| 63 +++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 lldb/unittests/DAP/DAPTest.cpp diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h index c2e4c2dea582e..2ff66d1cd0182 100644 --- a/lldb/tools/lldb-dap/DAP.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -226,7 +226,8 @@ struct DAP { /// \param[in] default_repl_mode /// Default repl mode behavior, as configured by the binary. /// \param[in] pre_init_commands - /// LLDB commands to execute as soon as the debugger instance is allocaed. + /// LLDB commands to execute as soon as the debugger instance is + /// allocated. /// \param[in] transport /// Transport for this debug session. DAP(Log *log, const ReplMode default_repl_mode, diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt index 110733e93b192..6074e9b872c49 100644 --- a/lldb/unittests/DAP/CMakeLists.txt +++ b/lldb/unittests/DAP/CMakeLists.txt @@ -3,6 +3,7 @@ add_lldb_unittest(DAPTests LLDBUtilsTest.cpp TransportTest.cpp ProtocolTypesTest.cpp + DAPTest.cpp LINK_LIBS lldbDAP diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp new file mode 100644 index 0..9d2a9b944678e --- /dev/null +++ b/lldb/unittests/DAP/DAPTest.cpp @@ -0,0 +1,63 @@ +//===-- DAPTest.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 "Protocol/ProtocolBase.h" +#include "Transport.h" +#include "lldb/Host/File.h" +#include "lldb/Host/Pipe.h" +#include "llvm/Testing/Support/Error.h" +#include "gtest/gtest.h" +#include +#include +#include + +using namespace llvm; +using namespace lldb; +using namespace lldb_dap; +using namespace lldb_dap::protocol; +using lldb_private::File; +using lldb_private::NativeFile; +using lldb_private::Pipe; + +class DAPTest : public testing::Test { +protected: + Pipe input; + Pipe output; + std::unique_ptr toDAP; + std::unique_ptr fromDAP; + + void SetUp() override { +ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), Succeeded()); +ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), Succeeded()); +toDAP = std::make_unique( +"toDAP", nullptr, +std::make_shared(input.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(output.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); +fromDAP = std::make_unique( +"fromDAP", nullptr, +std::make_shared(output.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(input.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); + } +}; + +TEST_F(DAPTest, SendProtocolMessages) { + DAP dap{nullptr, ReplMode::Auto, {}, *toDAP}; + dap.Send(Event{"my-event", std::nullopt}); + ASSERT_THAT_EXPECTED(fromDAP->Read(std::chrono::milliseconds(1)), + HasValue(testing::VariantWith(testing::FieldsAre( + /*event=*/"my-event", /*body=*/std::nullopt; +} >From 8bc4880a338dd0d0f2daa64b77c8bdbf567270b2 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 10:46:51 -0700 Subject: [PATCH 2/5] Adjusting the naming of variables. --- lldb/unittests/DAP/DAPTest.cpp | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp index 9d2a9b944678e..8e8c2ea3ccbb0 100644 --- a/lldb/unittests/DAP/DAPTest.cpp +++ b/lldb/unittests/DAP/DAPTest.cpp @@ -29,22 +29,22 @@ class DAPTest : public testing::Test { protected: Pipe input; Pipe output; -
[Lldb-commits] [lldb] Complete the Implementation of DAP modules explorer. (PR #139934)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/139934 >From 7dbd5f7467cf1ab31caf935633062a7a66a49757 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Wed, 14 May 2025 17:32:47 +0100 Subject: [PATCH 1/4] [lldb][lldb-dap] clarify the todo. --- lldb/tools/lldb-dap/package.json | 14 +++ lldb/tools/lldb-dap/src-ts/extension.ts | 10 +- .../src-ts/ui/modules-data-provider.ts| 98 --- 3 files changed, 85 insertions(+), 37 deletions(-) diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index e3e46526f379f..3c73534fd3180 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -244,6 +244,20 @@ } } ], +"commands": [ + { +"command": "lldb-dap.modules.copyProperty", +"title": "Copy Value" + } +], +"menus": { + "view/item/context": [ +{ + "command": "lldb-dap.modules.copyProperty", + "when": "view == lldb-dap.modules && viewItem == property" +} + ] +}, "breakpoints": [ { "language": "ada" diff --git a/lldb/tools/lldb-dap/src-ts/extension.ts b/lldb/tools/lldb-dap/src-ts/extension.ts index a5c0a09ae60cf..c8e5146e29cea 100644 --- a/lldb/tools/lldb-dap/src-ts/extension.ts +++ b/lldb/tools/lldb-dap/src-ts/extension.ts @@ -6,7 +6,10 @@ import { LaunchUriHandler } from "./uri-launch-handler"; import { LLDBDapConfigurationProvider } from "./debug-configuration-provider"; import { LLDBDapServer } from "./lldb-dap-server"; import { DebugSessionTracker } from "./debug-session-tracker"; -import { ModulesDataProvider } from "./ui/modules-data-provider"; +import { + ModulesDataProvider, + ModuleProperty, +} from "./ui/modules-data-provider"; /** * This class represents the extension and manages its life cycle. Other extensions @@ -40,6 +43,11 @@ export class LLDBDapExtension extends DisposableContext { ), vscode.window.registerUriHandler(new LaunchUriHandler()), ); + +vscode.commands.registerCommand( + "lldb-dap.modules.copyProperty", + (node: ModuleProperty) => vscode.env.clipboard.writeText(node.value), +); } } 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 478c162de8878..da527b04ba509 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 @@ -2,60 +2,86 @@ import * as vscode from "vscode"; import { DebugProtocol } from "@vscode/debugprotocol"; import { DebugSessionTracker } from "../debug-session-tracker"; -/** A tree data provider for listing loaded modules for the active debug session. */ -export class ModulesDataProvider - implements vscode.TreeDataProvider -{ - private changeTreeData = new vscode.EventEmitter(); - readonly onDidChangeTreeData = this.changeTreeData.event; +export interface ModuleProperty { + key: string; + value: string; +} - constructor(private readonly tracker: DebugSessionTracker) { -tracker.onDidChangeModules(() => this.changeTreeData.fire()); -vscode.debug.onDidChangeActiveDebugSession(() => - this.changeTreeData.fire(), -); +/** Type to represent both Module and ModuleProperty since TreeDataProvider + * expects one concrete type */ +type TreeData = DebugProtocol.Module | ModuleProperty; + +function isModule(type: TreeData): type is DebugProtocol.Module { + return (type as DebugProtocol.Module).id !== undefined; +} + +class ModuleItem extends vscode.TreeItem { + constructor(module: DebugProtocol.Module) { +super(module.name, vscode.TreeItemCollapsibleState.Collapsed); +this.description = module.symbolStatus; } - getTreeItem(module: DebugProtocol.Module): vscode.TreeItem { -let treeItem = new vscode.TreeItem(/*label=*/ module.name); -if (module.path) { - treeItem.description = `${module.id} -- ${module.path}`; -} else { - treeItem.description = `${module.id}`; -} + static getProperties(module: DebugProtocol.Module): ModuleProperty[] { +// does not include the name and symbol status as it is show in the parent. +let children: ModuleProperty[] = []; +children.push({ key: "id:", value: module.id.toString() }); -const tooltip = new vscode.MarkdownString(); -tooltip.appendMarkdown(`# ${module.name}\n\n`); -tooltip.appendMarkdown(`- **ID**: ${module.id}\n`); if (module.addressRange) { - tooltip.appendMarkdown( -`- **Load address**: 0x${Number(module.addressRange).toString(16)}\n`, - ); + children.push({ +key: "load address:", +value: `0x${Number(module.addressRange).toString(16)}`, + }); } if (module.path) { - tooltip.appendMarkdown(`- **Path**: ${module.path}\n`); + children.push({ key: "path:", value: module.path }); } if (module.version) { - tooltip.app
[Lldb-commits] [lldb] [lldb][NFC] Split RegisterContextUnwind::SavedLocationForRegister (PR #139817)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/139817 >From e63e53adc0909f481a165eca958a3ac2ca4374ee Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Tue, 13 May 2025 17:11:08 -0700 Subject: [PATCH 1/7] [lldb][NFC] Split RegisterContextUnwind::SavedLocationForRegister RegisterContextUnwind::SavedLocationForRegister is around 450 lines that first find an abstract register location (e.g. "CFA-8") for a register by looking in the UnwindPlans. Then it evaluates the abstract register location to create a concrete register location (e.g. "stored at address 0x...", "live in register at frame 0"). There are some complicated cases in the first half of the method to handle return address register architectures correctly, in particular. Looking at the two halves, they're both exactly 226 lines long and there's little involvement between them except for passing an abstract register location along. (there were some parts in the "abstract register location" code that would set the concrete register location, unnecessarily) It's also a complex enough method that there are some bits of code that aren't actually doing anything at this point. This patch adds a RegisterContextUnwind::GetAbstractRegisterLocation method, which does the first half, and has a clearly defined return values. The code to convert an AbstractRegisterLocation into a ConcreteRegisterLocation remains in SavedLocationForRegister. It's a bit of a tricky patch to visually inspect, despite it not changing functionality, the reorganizations and rewrites make the diff unreadable. Nearly all the real changes are in the "find the abstract register location" first half of the method. I think reading the new code in its new form is the easiest way to inspect this PR. With a defined interface between the two of what is expected, it's pretty easy to look at the code and reason about whether it is written correctly. (whereas before, that was very difficult, for me at least.) --- .../lldb/Target/RegisterContextUnwind.h | 3 + lldb/source/Target/RegisterContextUnwind.cpp | 530 +- lldb/source/Target/RegisterNumber.cpp | 1 + 3 files changed, 259 insertions(+), 275 deletions(-) diff --git a/lldb/include/lldb/Target/RegisterContextUnwind.h b/lldb/include/lldb/Target/RegisterContextUnwind.h index 044a387fe5aa2..b10a364823b83 100644 --- a/lldb/include/lldb/Target/RegisterContextUnwind.h +++ b/lldb/include/lldb/Target/RegisterContextUnwind.h @@ -151,6 +151,9 @@ class RegisterContextUnwind : public lldb_private::RegisterContext { uint32_t lldb_regnum, lldb_private::UnwindLLDB::ConcreteRegisterLocation ®loc); + std::optional + GetAbstractRegisterLocation(uint32_t lldb_regnum, lldb::RegisterKind &kind); + bool ReadRegisterValueFromRegisterLocation( lldb_private::UnwindLLDB::ConcreteRegisterLocation regloc, const lldb_private::RegisterInfo *reg_info, diff --git a/lldb/source/Target/RegisterContextUnwind.cpp b/lldb/source/Target/RegisterContextUnwind.cpp index cf4b96c6eda9f..a3931abefb054 100644 --- a/lldb/source/Target/RegisterContextUnwind.cpp +++ b/lldb/source/Target/RegisterContextUnwind.cpp @@ -1243,247 +1243,194 @@ bool RegisterContextUnwind::IsTrapHandlerSymbol( return false; } -// Answer the question: Where did THIS frame save the CALLER frame ("previous" -// frame)'s register value? - -enum UnwindLLDB::RegisterSearchResult -RegisterContextUnwind::SavedLocationForRegister( -uint32_t lldb_regnum, -lldb_private::UnwindLLDB::ConcreteRegisterLocation ®loc) { +// Search this stack frame's UnwindPlans for the AbstractRegisterLocation +// for this register. +// +// When an AbstractRegisterLocation is found in an UnwindPlan, that is +// returned, regardless of the ABI rules for volatile/non-volatile registers +// in effect. +// +// If there is no unwind rule for a volatile (caller-preserved) register +// the returned AbstractRegisterLocation will be IsUndefined, +// indicating that we should stop searching. +// +// If there is no unwind rule for a non-volatile (callee-preserved) +// register, the returned AbstractRegisterLocation will be IsSame. +// In frame 0, IsSame means get the value from the live register context. +// Else it means to continue descending down the stack to more-live frames +// looking for a location/value. +// +// An empty optional indicates that there was an error in processing. +std::optional +RegisterContextUnwind::GetAbstractRegisterLocation(uint32_t lldb_regnum, + lldb::RegisterKind &kind) { RegisterNumber regnum(m_thread, eRegisterKindLLDB, lldb_regnum); Log *log = GetLog(LLDBLog::Unwind); - // Have we already found this register location? - if (!m_registers.empty()) { -std::map::const_iterator -iterator; -iterator = m_registers.find(regnum.GetAsKind(eRegisterKindLLDB)); -if (iterator != m_registers.end()) { - regloc = iterator
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
@@ -0,0 +1,35 @@ +//===-- DisconnectRequestHandlerTest.cpp --===// JDevlieghere wrote: ```suggestion //===-- DisconnectTest.cpp ===// ``` https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Split RegisterContextUnwind::SavedLocationForRegister (PR #139817)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/139817 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)
https://github.com/eronnen edited https://github.com/llvm/llvm-project/pull/139969 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/139937 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
@@ -107,6 +107,7 @@ class ASTUnit { private: std::unique_ptr LangOpts; + std::shared_ptr DiagOpts; jansvoboda11 wrote: I was hoping it could be, but the situation is a bit weird. The documentation for `ASTUnit::LoadFromCommandLine()` says the `DiagnosticsEngine` parameter is expected to outlive the returned value. However, it's being passed in `IntrusiveRefCntPtr`, so the lifetime is not enforced, and of course some clients started to rely on `ASTUnit` taking shared ownership of that object. And the clients also use the `DiagnosticsEngine` object themselves after passing it to that function, so the ownership is indeed shared. And since `DiagnosticsEngine` now relies on `DiagnosticOptions` to live long enough, sharing ownership in `ASTUnit` was the best fit. Does that make sense? In general `ASTUnit` is a big pile of lifetime hacks which I'd like to clean up one day, but today is not the day. https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
@@ -837,6 +838,7 @@ class ASTUnit { static std::unique_ptr LoadFromCommandLine( const char **ArgBegin, const char **ArgEnd, std::shared_ptr PCHContainerOps, + std::shared_ptr DiagOpts, jansvoboda11 wrote: Explained above. https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)
https://github.com/JDevlieghere approved this pull request. LGTM modulo (pre-existing) typo. https://github.com/llvm/llvm-project/pull/139916 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)
@@ -169,7 +169,8 @@ Status TCPSocket::Connect(llvm::StringRef name) { return error; } - error = Status::FromErrorString("Failed to connect port"); + error = Status::FromErrorStringWithFormatv( + "Failed to connect {0}:{1}", host_port->hostname, host_port->port); JDevlieghere wrote: ```suggestion error = Status::FromErrorStringWithFormatv( "Failed to connect to {0}:{1}", host_port->hostname, host_port->port); ``` https://github.com/llvm/llvm-project/pull/139916 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/139916 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add unit test for protocol enum types (PR #139848)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/139848 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb][RPC] Design doc for upstreaming PR (PR #138612)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/138612 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adding unit tests for Transport. (PR #139926)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/139926 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
https://github.com/cor3ntin approved this pull request. https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #136121)
quic-akaryaki wrote: @anjenner : an alternative way to report error would be to pass a "diagnostic object" to CachedFileStream that would collect errors happening during calling its destructors, report them later, and fail the compilation if any. That might have been a less intrusive way. https://github.com/llvm/llvm-project/pull/136121 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)
https://github.com/ita-sc created https://github.com/llvm/llvm-project/pull/139916 Before: ``` (lldb) r error: connect remote failed (Failed to connect port) error: Failed to connect port ``` After the patch: ``` (lldb) r error: connect remote failed (Failed to connect localhost:47140) error: Failed to connect localhost:47140 ``` >From 845a7365f4f0f2cc06a65ca36f8344f9f81ead77 Mon Sep 17 00:00:00 2001 From: Ivan Tetyushkin Date: Wed, 14 May 2025 14:47:41 + Subject: [PATCH] Extend information for failed connection for gdb server Before: ``` (lldb) r error: connect remote failed (Failed to connect port) error: Failed to connect port ``` After the patch: ``` (lldb) r error: connect remote failed (Failed to connect localhost:47140) error: Failed to connect localhost:47140 ``` --- lldb/source/Host/common/TCPSocket.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp index d3282ab58b818..4148ad67b04bf 100644 --- a/lldb/source/Host/common/TCPSocket.cpp +++ b/lldb/source/Host/common/TCPSocket.cpp @@ -169,7 +169,8 @@ Status TCPSocket::Connect(llvm::StringRef name) { return error; } - error = Status::FromErrorString("Failed to connect port"); + error = Status::FromErrorStringWithFormatv("Failed to connect {0}:{1}", + host_port->hostname, host_port->port); return error; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (ita-sc) Changes Before: ``` (lldb) r error: connect remote failed (Failed to connect port) error: Failed to connect port ``` After the patch: ``` (lldb) r error: connect remote failed (Failed to connect localhost:47140) error: Failed to connect localhost:47140 ``` --- Full diff: https://github.com/llvm/llvm-project/pull/139916.diff 1 Files Affected: - (modified) lldb/source/Host/common/TCPSocket.cpp (+2-1) ``diff diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp index d3282ab58b818..4148ad67b04bf 100644 --- a/lldb/source/Host/common/TCPSocket.cpp +++ b/lldb/source/Host/common/TCPSocket.cpp @@ -169,7 +169,8 @@ Status TCPSocket::Connect(llvm::StringRef name) { return error; } - error = Status::FromErrorString("Failed to connect port"); + error = Status::FromErrorStringWithFormatv("Failed to connect {0}:{1}", + host_port->hostname, host_port->port); return error; } `` https://github.com/llvm/llvm-project/pull/139916 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
@@ -107,6 +107,7 @@ class ASTUnit { private: std::unique_ptr LangOpts; + std::shared_ptr DiagOpts; cor3ntin wrote: Ouch, this is not great :smile: Can you leave a FIXME comment in the source? Thanks https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)
@@ -714,6 +714,8 @@ uint32_t ModuleList::ResolveSymbolContextsForFileSpec( const FileSpec &file_spec, uint32_t line, bool check_inlines, SymbolContextItem resolve_scope, SymbolContextList &sc_list) const { std::lock_guard guard(m_modules_mutex); + // If we're looking for a header (not source), then need to check inline. + check_inlines = check_inlines || !file_spec.IsSourceImplementationFile(); labath wrote: I don't think this should be done here. The breakpoint setting code also goes through this code path and it works fine without it. I suggest looking at how that works and emulating it. I suspect it involves looking at the `target.inline-breakpoint-strategy` setting. I think it'd make sense to do that here as well (if anyone disagrees with that, do chime in), even though the setting is called inline-*breakpoint*-strategy, as the setting is really about where we go to search when looking up a file. https://github.com/llvm/llvm-project/pull/139002 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5fb9dca - Revert "[lldb] Call Target::ClearAllLoadedSections earlier (#138892)"
Author: Pavel Labath Date: 2025-05-14T18:22:02+02:00 New Revision: 5fb9dca14aeaf12219ff149bf3a4f94c8dc58d8b URL: https://github.com/llvm/llvm-project/commit/5fb9dca14aeaf12219ff149bf3a4f94c8dc58d8b DIFF: https://github.com/llvm/llvm-project/commit/5fb9dca14aeaf12219ff149bf3a4f94c8dc58d8b.diff LOG: Revert "[lldb] Call Target::ClearAllLoadedSections earlier (#138892)" This reverts commit 97aa01bef770ec651c86978d137933e09221dd00 and 7e7871d3f58b9da72ca180fcd7f0d2da3f92ec4a due to failures on windows. Added: Modified: lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp lldb/source/Target/Process.cpp lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py Removed: diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp index 1270d57423c7b..578ab12268ea3 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -872,6 +872,7 @@ void DynamicLoaderDarwin::PrivateInitialize(Process *process) { StateAsCString(m_process->GetState())); Clear(true); m_process = process; + m_process->GetTarget().ClearAllLoadedSections(); } // Member function that gets called when the process state changes. diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index f136271a3b8a8..13ff12b4ff953 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -2675,7 +2675,6 @@ Status Process::LaunchPrivate(ProcessLaunchInfo &launch_info, StateType &state, m_jit_loaders_up.reset(); m_system_runtime_up.reset(); m_os_up.reset(); - GetTarget().ClearAllLoadedSections(); { std::lock_guard guard(m_process_input_reader_mutex); @@ -2800,7 +2799,6 @@ Status Process::LaunchPrivate(ProcessLaunchInfo &launch_info, StateType &state, } Status Process::LoadCore() { - GetTarget().ClearAllLoadedSections(); Status error = DoLoadCore(); if (error.Success()) { ListenerSP listener_sp( @@ -3096,8 +3094,6 @@ void Process::CompleteAttach() { Log *log(GetLog(LLDBLog::Process | LLDBLog::Target)); LLDB_LOGF(log, "Process::%s()", __FUNCTION__); - GetTarget().ClearAllLoadedSections(); - // Let the process subclass figure out at much as it can about the process // before we go looking for a dynamic loader plug-in. ArchSpec process_arch; diff --git a/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py b/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py index faa35421ff60b..cd95a9ff3fe8c 100644 --- a/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py +++ b/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py @@ -282,6 +282,7 @@ def test_from_forward_decl(self): @no_debug_info_test @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663") +@expectedFailureDarwin # dynamic loader unloads modules @expectedFailureAll(archs=["arm"]) # Minidump saving not implemented def test_from_core_file(self): """Test fetching C++ dynamic values from core files. Specifically, test ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix offset computation in RegisterContextUnwind (PR #137155)
labath wrote: Jason, could you take a look at this as well? https://github.com/llvm/llvm-project/pull/137155 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)
chelcassanova wrote: Pushed again to address David's comments and remove most of the FIXMEs. There's one FIXME I've kept in for now: ``` // FIXME: SB class server references are stored as non-const references so // that we can actually change them as needed. If a parameter is marked // const, we will fail to compile because we cannot make an // SBFooServerReference from a `const SBFoo &`. // To work around this issue, we'll apply a `const_cast` if needed so we // can continue to generate callbacks for now, but we really should // rethink the way we store object IDs server-side to support // const-qualified parameters. ``` @bulbazord This is referring to how we emit storage for const SB parameters in callback functions. Currently it looks like it only gets applied to one function that gets generated. Any thoughts here? https://github.com/llvm/llvm-project/pull/138032 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Complete the Implementation of DAP modules explorer. (PR #139934)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/139934 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
@@ -2032,6 +2032,7 @@ class SourceManagerForFile { // as they are created in `createSourceManagerForFile` so that they can be // deleted in the reverse order as they are created. std::unique_ptr FileMgr; + std::unique_ptr DiagOpts; ojhunt wrote: @jansvoboda11 the problem is that now an author does not know if a given DiagnosticOption is a unique_ptr or a shared_ptr. A given DiagnosticOption* may or may not be protectable, etc depending on the context and origin of the object. Philosophically I prefer intrusive refcounts over shared_ptr because to me they make the lifetime much clearer as the lifetime rules are embedded in the type, but I don't think that's an issue in this PR. My understanding is that the goal of this PR is to say "For API purposes, a given DiagnosticOption reference is only live as long as the API object that vends it. As an implementation detail there are some cases where it can outlast the vending object, but that's not generally part of the user visible API." That's a perfectly reasonable change, but my concern is that by mixing and matching shared and unique_ptr an author loses the ability to reason about what a given object's lifetime is. It seems like the reason for shared_ptr is to deal with some slightly gross bits of the API, and I wonder if it's possible to fix those APIs so we can just use unique_ptr everywhere? https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
@@ -0,0 +1,70 @@ +//===-- TestBase.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 "TestBase.h" +#include "Protocol/ProtocolBase.h" +#include "lldb/Host/File.h" +#include "lldb/Host/Pipe.h" +#include "llvm/Testing/Support/Error.h" + +using namespace llvm; +using namespace lldb; +using namespace lldb_dap; +using namespace lldb_dap::protocol; +using namespace lldb_dap_tests; +using lldb_private::File; +using lldb_private::NativeFile; +using lldb_private::Pipe; + +void PipeBase::SetUp() { + ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), Succeeded()); + ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), Succeeded()); +} + +void TransportBase::SetUp() { + PipeBase::SetUp(); + to_dap = std::make_unique( + "to_dap", nullptr, + std::make_shared(input.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), + std::make_shared(output.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); + from_dap = std::make_unique( + "from_dap", nullptr, + std::make_shared(output.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), + std::make_shared(input.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); +} + +void DAPTestBase::SetUp() { + TransportBase::SetUp(); + dap = std::make_unique( + /*log=*/nullptr, + /*default_repl_mode=*/ReplMode::Auto, + /*pre_init_commands=*/std::vector(), + /*transport=*/*to_dap); +} + +std::vector DAPTestBase::DrainOutput() { + std::vector msgs; + output.CloseWriteFileDescriptor(); + while (true) { +Expected next = from_dap->Read(std::chrono::milliseconds(1)); +if (!next) { + consumeError(next.takeError()); + break; +} +msgs.push_back(*next); + } + return msgs; +} JDevlieghere wrote: newline https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
@@ -1,8 +1,11 @@ add_lldb_unittest(DAPTests + DAPTest.cpp + Handler/DisconnectRequestHandlerTest.cpp JDevlieghere wrote: I somewhat regret the naming of the request handlers (*). Learning from our mistakes, maybe here we should just call it `Handler/DisconnectTest.cpp` to reduce the verbosity? (*) In hindsight, I wish I called them `RequestHandlerDisconnect` instead of `DisconnectRequestHandler`, though that doesn't apply here as all the unit test files end with `Test` and I think consistency is more important. https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
https://github.com/JDevlieghere approved this pull request. I like the test base classes. https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/139937 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
@@ -0,0 +1,70 @@ +//===-- TestBase.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 "TestBase.h" +#include "Protocol/ProtocolBase.h" +#include "lldb/Host/File.h" +#include "lldb/Host/Pipe.h" +#include "llvm/Testing/Support/Error.h" + +using namespace llvm; +using namespace lldb; +using namespace lldb_dap; +using namespace lldb_dap::protocol; +using namespace lldb_dap_tests; +using lldb_private::File; +using lldb_private::NativeFile; +using lldb_private::Pipe; + +void PipeBase::SetUp() { + ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), Succeeded()); + ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), Succeeded()); +} + +void TransportBase::SetUp() { + PipeBase::SetUp(); + to_dap = std::make_unique( + "to_dap", nullptr, + std::make_shared(input.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), + std::make_shared(output.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); + from_dap = std::make_unique( + "from_dap", nullptr, + std::make_shared(output.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), + std::make_shared(input.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); +} + +void DAPTestBase::SetUp() { + TransportBase::SetUp(); + dap = std::make_unique( + /*log=*/nullptr, + /*default_repl_mode=*/ReplMode::Auto, + /*pre_init_commands=*/std::vector(), + /*transport=*/*to_dap); +} + +std::vector DAPTestBase::DrainOutput() { + std::vector msgs; + output.CloseWriteFileDescriptor(); + while (true) { +Expected next = from_dap->Read(std::chrono::milliseconds(1)); +if (!next) { + consumeError(next.takeError()); + break; +} +msgs.push_back(*next); + } + return msgs; +} ashgti wrote: Done. https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
@@ -1,8 +1,11 @@ add_lldb_unittest(DAPTests + DAPTest.cpp + Handler/DisconnectRequestHandlerTest.cpp ashgti wrote: I renamed the file to `Handler/DisconnectTest.cpp` but should the test be `DisconnectTest` or should it be `DisconnectRequestHandlerTest` since thats the actual class I'm testing? https://github.com/llvm/llvm-project/pull/139937 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/139937 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 441d382 - [lldb-dap] Adding unit tests for Transport. (#139926)
Author: John Harrison Date: 2025-05-14T10:00:01-07:00 New Revision: 441d382f9350c134c958244f252c00923824 URL: https://github.com/llvm/llvm-project/commit/441d382f9350c134c958244f252c00923824 DIFF: https://github.com/llvm/llvm-project/commit/441d382f9350c134c958244f252c00923824.diff LOG: [lldb-dap] Adding unit tests for Transport. (#139926) This adds basic support for testing the Transport class and includes tests for 'Read' and 'Write'. Added: lldb/unittests/DAP/TransportTest.cpp Modified: lldb/unittests/DAP/CMakeLists.txt Removed: diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt index 8b240654046e2..110733e93b192 100644 --- a/lldb/unittests/DAP/CMakeLists.txt +++ b/lldb/unittests/DAP/CMakeLists.txt @@ -1,6 +1,7 @@ add_lldb_unittest(DAPTests JSONUtilsTest.cpp LLDBUtilsTest.cpp + TransportTest.cpp ProtocolTypesTest.cpp LINK_LIBS diff --git a/lldb/unittests/DAP/TransportTest.cpp b/lldb/unittests/DAP/TransportTest.cpp new file mode 100644 index 0..5c77b4bb26343 --- /dev/null +++ b/lldb/unittests/DAP/TransportTest.cpp @@ -0,0 +1,98 @@ +//===-- TransportTest.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 "Transport.h" +#include "Protocol/ProtocolBase.h" +#include "lldb/Host/File.h" +#include "lldb/Host/Pipe.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Testing/Support/Error.h" +#include "gtest/gtest.h" +#include +#include +#include + +using namespace llvm; +using namespace lldb; +using namespace lldb_dap; +using namespace lldb_dap::protocol; +using lldb_private::File; +using lldb_private::NativeFile; +using lldb_private::Pipe; + +class TransportTest : public testing::Test { +protected: + Pipe input; + Pipe output; + std::unique_ptr transport; + + void SetUp() override { +ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), Succeeded()); +ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), Succeeded()); +transport = std::make_unique( +"stdio", nullptr, +std::make_shared(input.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(output.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); + } + + void Write(StringRef json) { +std::string message = +formatv("Content-Length: {0}\r\n\r\n{1}", json.size(), json).str(); +ASSERT_THAT_EXPECTED(input.Write(message.data(), message.size()), + Succeeded()); + } +}; + +TEST_F(TransportTest, MalformedRequests) { + std::string malformed_header = "COnTent-LenGth: -1{}\r\n\r\nnotjosn"; + ASSERT_THAT_EXPECTED( + input.Write(malformed_header.data(), malformed_header.size()), + Succeeded()); + ASSERT_THAT_EXPECTED( + transport->Read(std::chrono::milliseconds(1)), + FailedWithMessage( + "expected 'Content-Length: ' and got 'COnTent-LenGth: '")); +} + +TEST_F(TransportTest, Read) { + Write(R"json({"seq": 1, "type": "request", "command": "abc"})json"); + ASSERT_THAT_EXPECTED( + transport->Read(std::chrono::milliseconds(1)), + HasValue(testing::VariantWith(testing::FieldsAre( + /*seq=*/1, /*command=*/"abc", /*arguments=*/std::nullopt; +} + +TEST_F(TransportTest, ReadWithTimeout) { + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + Failed()); +} + +TEST_F(TransportTest, ReadWithEOF) { + input.CloseWriteFileDescriptor(); + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + Failed()); +} + +TEST_F(TransportTest, Write) { + ASSERT_THAT_ERROR(transport->Write(Event{"my-event", std::nullopt}), +Succeeded()); + output.CloseWriteFileDescriptor(); + char buf[1024]; + Expected bytes_read = + output.Read(buf, sizeof(buf), std::chrono::milliseconds(1)); + ASSERT_THAT_EXPECTED(bytes_read, Succeeded()); + ASSERT_EQ( + StringRef(buf, *bytes_read), + StringRef("Content-Length: 43\r\n\r\n" +R"json({"event":"my-event","seq":0,"type":"event"})json")); +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adding unit tests for Transport. (PR #139926)
https://github.com/ashgti closed https://github.com/llvm/llvm-project/pull/139926 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Complete the Implementation of DAP modules explorer. (PR #139934)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Ebuka Ezike (da-viper) Changes What it now looks like. It is a good idea to remove the, symbol status and name from the tree children ?.  --- Full diff: https://github.com/llvm/llvm-project/pull/139934.diff 4 Files Affected: - (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+5-2) - (modified) lldb/tools/lldb-dap/package.json (+14) - (modified) lldb/tools/lldb-dap/src-ts/extension.ts (+9-1) - (modified) lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts (+62-36) ``diff diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index 279e6d3d93814..31eb91f9f6b61 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -416,8 +416,11 @@ llvm::json::Value CreateModule(lldb::SBTarget &target, lldb::SBModule &module, } else { object.try_emplace("symbolStatus", "Symbols not found."); } - std::string loaded_addr = std::to_string( - module.GetObjectFileHeaderAddress().GetLoadAddress(target)); + std::string loaded_addr; + llvm::raw_string_ostream os_hex(loaded_addr); + os_hex << llvm::format_hex( + module.GetObjectFileHeaderAddress().GetLoadAddress(target), + sizeof(lldb::addr_t)); object.try_emplace("addressRange", loaded_addr); std::string version_str; uint32_t version_nums[3]; diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index e3e46526f379f..3c73534fd3180 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -244,6 +244,20 @@ } } ], +"commands": [ + { +"command": "lldb-dap.modules.copyProperty", +"title": "Copy Value" + } +], +"menus": { + "view/item/context": [ +{ + "command": "lldb-dap.modules.copyProperty", + "when": "view == lldb-dap.modules && viewItem == property" +} + ] +}, "breakpoints": [ { "language": "ada" diff --git a/lldb/tools/lldb-dap/src-ts/extension.ts b/lldb/tools/lldb-dap/src-ts/extension.ts index a5c0a09ae60cf..c8e5146e29cea 100644 --- a/lldb/tools/lldb-dap/src-ts/extension.ts +++ b/lldb/tools/lldb-dap/src-ts/extension.ts @@ -6,7 +6,10 @@ import { LaunchUriHandler } from "./uri-launch-handler"; import { LLDBDapConfigurationProvider } from "./debug-configuration-provider"; import { LLDBDapServer } from "./lldb-dap-server"; import { DebugSessionTracker } from "./debug-session-tracker"; -import { ModulesDataProvider } from "./ui/modules-data-provider"; +import { + ModulesDataProvider, + ModuleProperty, +} from "./ui/modules-data-provider"; /** * This class represents the extension and manages its life cycle. Other extensions @@ -40,6 +43,11 @@ export class LLDBDapExtension extends DisposableContext { ), vscode.window.registerUriHandler(new LaunchUriHandler()), ); + +vscode.commands.registerCommand( + "lldb-dap.modules.copyProperty", + (node: ModuleProperty) => vscode.env.clipboard.writeText(node.value), +); } } 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 478c162de8878..091c1d69ac647 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 @@ -2,60 +2,86 @@ import * as vscode from "vscode"; import { DebugProtocol } from "@vscode/debugprotocol"; import { DebugSessionTracker } from "../debug-session-tracker"; -/** A tree data provider for listing loaded modules for the active debug session. */ -export class ModulesDataProvider - implements vscode.TreeDataProvider -{ - private changeTreeData = new vscode.EventEmitter(); - readonly onDidChangeTreeData = this.changeTreeData.event; +export interface ModuleProperty { + key: string; + value: string; +} - constructor(private readonly tracker: DebugSessionTracker) { -tracker.onDidChangeModules(() => this.changeTreeData.fire()); -vscode.debug.onDidChangeActiveDebugSession(() => - this.changeTreeData.fire(), -); +/** Type to represent both Module and ModuleProperty since TreeDataProvider + * expects one concrete type */ +type TreeData = DebugProtocol.Module | ModuleProperty; + +function isModule(type: TreeData): type is DebugProtocol.Module { + return (type as DebugProtocol.Module).id !== undefined; +} + +class ModuleItem extends vscode.TreeItem { + constructor(module: DebugProtocol.Module) { +super(module.name, vscode.TreeItemCollapsibleState.Collapsed); +this.description = module.symbolStatus; } - getTreeItem(module: DebugProtocol.Module): vscode.TreeItem { -let treeItem = new vscode.TreeItem(/*label=*/ module.name); -if (module.path) { - treeItem.description = `${module.id} -- ${module.path}`; -} else { - treeItem.descr
[Lldb-commits] [lldb] Complete the Implementation of DAP modules explorer. (PR #139934)
https://github.com/da-viper created https://github.com/llvm/llvm-project/pull/139934 What it now looks like. It is a good idea to remove the, symbol status and name from the tree children ?.  Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)
chelcassanova wrote: @bulbazord @JDevlieghere Is it possible to take another pass over at this? I think this should be good to land now. https://github.com/llvm/llvm-project/pull/138020 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adding unit tests for Transport. (PR #139926)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/139926 >From 506e8107a397e2ae88d8b952c0a5351cda9fa161 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 09:13:32 -0700 Subject: [PATCH 1/3] [lldb-dap] Adding unittests for Transport. This adds basic support for testing the Transport class and includes tests for 'Read'. --- lldb/unittests/DAP/CMakeLists.txt| 1 + lldb/unittests/DAP/TransportTest.cpp | 81 2 files changed, 82 insertions(+) create mode 100644 lldb/unittests/DAP/TransportTest.cpp diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt index 8b240654046e2..110733e93b192 100644 --- a/lldb/unittests/DAP/CMakeLists.txt +++ b/lldb/unittests/DAP/CMakeLists.txt @@ -1,6 +1,7 @@ add_lldb_unittest(DAPTests JSONUtilsTest.cpp LLDBUtilsTest.cpp + TransportTest.cpp ProtocolTypesTest.cpp LINK_LIBS diff --git a/lldb/unittests/DAP/TransportTest.cpp b/lldb/unittests/DAP/TransportTest.cpp new file mode 100644 index 0..d27167cf9da61 --- /dev/null +++ b/lldb/unittests/DAP/TransportTest.cpp @@ -0,0 +1,81 @@ +//===-- LLDBUtilsTest.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 "Transport.h" +#include "Protocol/ProtocolBase.h" +#include "lldb/Host/File.h" +#include "lldb/Host/Pipe.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Testing/Support/Error.h" +#include "gtest/gtest.h" +#include +#include +#include + +using namespace llvm; +using namespace lldb; +using namespace lldb_private; +using namespace lldb_dap; +using namespace lldb_dap::protocol; + +class TransportTest : public testing::Test { +protected: + Pipe input; + Pipe output; + std::unique_ptr transport; + + void SetUp() override { +ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), llvm::Succeeded()); +ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), llvm::Succeeded()); +transport = std::make_unique( +"stdio", nullptr, +std::make_shared(input.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(output.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); + } + + void Write(StringRef json) { +std::string message = +formatv("Content-Length: {0}\r\n\r\n{1}", json.size(), json).str(); +ASSERT_THAT_EXPECTED(input.Write(message.data(), message.size()), + Succeeded()); + } +}; + +TEST_F(TransportTest, MalformedRequests) { + std::string malformed_header = "COnTent-LenGth: -1{}\r\n\r\nnotjosn"; + ASSERT_THAT_EXPECTED( + input.Write(malformed_header.data(), malformed_header.size()), + Succeeded()); + ASSERT_THAT_EXPECTED( + transport->Read(std::chrono::milliseconds(1)), + FailedWithMessage( + "expected 'Content-Length: ' and got 'COnTent-LenGth: '")); +} + +TEST_F(TransportTest, Read) { + Write(R"json({"seq": 1, "type": "request", "command": "abc"})json"); + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + HasValue(testing::VariantWith( + testing::FieldsAre(1, "abc", std::nullopt; +} + +TEST_F(TransportTest, ReadWithTimeout) { + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + Failed()); +} + +TEST_F(TransportTest, ReadWithEOF) { + input.CloseWriteFileDescriptor(); + ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)), + Failed()); +} >From 8d5ffc83c6fce70a3fe66fb726781e7bd2b08d77 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 09:16:34 -0700 Subject: [PATCH 2/3] Fixing the filename in the top comment. --- lldb/unittests/DAP/TransportTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/unittests/DAP/TransportTest.cpp b/lldb/unittests/DAP/TransportTest.cpp index d27167cf9da61..b8eade5442814 100644 --- a/lldb/unittests/DAP/TransportTest.cpp +++ b/lldb/unittests/DAP/TransportTest.cpp @@ -1,4 +1,4 @@ -//===-- LLDBUtilsTest.cpp -===// +//===-- TransportTest.cpp -===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. >From 8de3cd6569f6a17de1f0607666953f06b1593e5b Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 09:32:23
[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)
@@ -154,6 +154,21 @@ endif() add_definitions(-DLLDB_USE_OS_LOG) +# Make sure we have the macOS SDK root as mig needs it and will silently +# fail to generate its output files without it. +if(CMAKE_OSX_SYSROOT) + set(MIG_SYSROOT ${CMAKE_OSX_SYSROOT}) +else() + execute_process(COMMAND xcrun --show-sdk-path +OUTPUT_VARIABLE MIG_SYSROOT +ERROR_QUIET +OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +if(NOT MIG_SYSROOT) + message(FATAL_ERROR "Unable to obtain macOS SDK root, debugserver cannot be built.") JDevlieghere wrote: Let's make this more specific and actionable. ```suggestion message(FATAL_ERROR "Unable to obtain sysroot required by mig (Mach Interface Generator). Set CMAKE_OSX_SYSROOT to explicitly specify a sysroot.") ``` https://github.com/llvm/llvm-project/pull/138020 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)
https://github.com/JDevlieghere approved this pull request. LGTM modulo wording. https://github.com/llvm/llvm-project/pull/138020 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/138020 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/138020 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)
https://github.com/ashgti created https://github.com/llvm/llvm-project/pull/139937 This is a very simple case that currently only validates we can create a DAP instance and send a message over the transport layer. More in-depth tests will require additional helpers and possibly refactors of DAP to make it more testable, however this is some ground work to have basic support for unit tests. >From 6f947e38ad4f744754cf13c1094c4e5e3fd249b6 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 14 May 2025 10:31:40 -0700 Subject: [PATCH] [lldb-dap] Setup DAP for unit testing. This is a very simple case that currently only validates we can create a DAP instance and send a message over the transport layer. More in-depth tests will require additional helpers and possibly refactors of DAP to make it more testable, however this is some ground work to have basic support for unit tests. --- lldb/tools/lldb-dap/DAP.h | 3 +- lldb/unittests/DAP/CMakeLists.txt | 1 + lldb/unittests/DAP/DAPTest.cpp| 63 +++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 lldb/unittests/DAP/DAPTest.cpp diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h index c2e4c2dea582e..2ff66d1cd0182 100644 --- a/lldb/tools/lldb-dap/DAP.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -226,7 +226,8 @@ struct DAP { /// \param[in] default_repl_mode /// Default repl mode behavior, as configured by the binary. /// \param[in] pre_init_commands - /// LLDB commands to execute as soon as the debugger instance is allocaed. + /// LLDB commands to execute as soon as the debugger instance is + /// allocated. /// \param[in] transport /// Transport for this debug session. DAP(Log *log, const ReplMode default_repl_mode, diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt index 110733e93b192..6074e9b872c49 100644 --- a/lldb/unittests/DAP/CMakeLists.txt +++ b/lldb/unittests/DAP/CMakeLists.txt @@ -3,6 +3,7 @@ add_lldb_unittest(DAPTests LLDBUtilsTest.cpp TransportTest.cpp ProtocolTypesTest.cpp + DAPTest.cpp LINK_LIBS lldbDAP diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp new file mode 100644 index 0..9d2a9b944678e --- /dev/null +++ b/lldb/unittests/DAP/DAPTest.cpp @@ -0,0 +1,63 @@ +//===-- DAPTest.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 "Protocol/ProtocolBase.h" +#include "Transport.h" +#include "lldb/Host/File.h" +#include "lldb/Host/Pipe.h" +#include "llvm/Testing/Support/Error.h" +#include "gtest/gtest.h" +#include +#include +#include + +using namespace llvm; +using namespace lldb; +using namespace lldb_dap; +using namespace lldb_dap::protocol; +using lldb_private::File; +using lldb_private::NativeFile; +using lldb_private::Pipe; + +class DAPTest : public testing::Test { +protected: + Pipe input; + Pipe output; + std::unique_ptr toDAP; + std::unique_ptr fromDAP; + + void SetUp() override { +ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), Succeeded()); +ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), Succeeded()); +toDAP = std::make_unique( +"toDAP", nullptr, +std::make_shared(input.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(output.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); +fromDAP = std::make_unique( +"fromDAP", nullptr, +std::make_shared(output.GetReadFileDescriptor(), + File::eOpenOptionReadOnly, + NativeFile::Unowned), +std::make_shared(input.GetWriteFileDescriptor(), + File::eOpenOptionWriteOnly, + NativeFile::Unowned)); + } +}; + +TEST_F(DAPTest, SendProtocolMessages) { + DAP dap{nullptr, ReplMode::Auto, {}, *toDAP}; + dap.Send(Event{"my-event", std::nullopt}); + ASSERT_THAT_EXPECTED(fromDAP->Read(std::chrono::milliseconds(1)), + HasValue(testing::VariantWith(testing::FieldsAre( + /*event=*/"my-event", /*body=*/std::nullopt; +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Complete the Implementation of DAP modules explorer. (PR #139934)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/139934 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits