[llvm-branch-commits] [lldb] release/22.x: [lldb] Don't link TestingSupport as a component (#184310) (PR #184320)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Mar 3 03:11:13 PST 2026


https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/184320

Backport 447eba88c8d7f219667c9914a0d91bf44c1d1512 d1c563beee794b3a967786fd07c437ffc66fb7f0

Requested by: @Michael137

>From c29e63d6e0b6db859ac7e0cdae7bbf48cbb223c8 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Mon, 2 Mar 2026 17:06:13 +0000
Subject: [PATCH 1/2] [lldb][Target] Allow eLanguageTypeAssembly to use
 ScratchTypeSystemClang (#183771)

After cleaning up some of our `LanguageType`/`SourceLangage`
round-tripping (see `7f51a2a47d2e706d04855b0e41690ebafa2b3238`), a CU
with `DW_LANG_MIPS_Assembler` will get a language type of
`eLanguageTypeAssembly` (as opposed to `eLanguageTypeMipsAssembler`).
Reason being that there is no `DW_LNAME_` (DWARFv6 language code) for
`MIPS Assembler`, only for generic `Assembly`. So it's not possible to
round-trip cleanly between pre-DWARFv6 and DWARFv6 language codes, which
LLDB relies on for storing language types (and will lean into more
heavily in the future). This broke a special provision we have where we
allow `ScratchTypeSystemClang` to be used when evaluating expressions in
assembly CUs (i.e., CUs where the debug-info explicitly sets the
language to assembly).

If we ever want to distinguish MIPS from other Assembly, the proper way
to do so is introduce a `DW_LNAME_Mips_Assembler`. For now, this patch
adds another case for `eLanguageTypeAssembly` in
`GetScratchTypeSystemForLanguage`.

The test is a bit quirky because it checks for error messages in all
cases. For the `TypeSystem`s to exist we would have to initialize the
`TypeSystem` plugins, which I couldn't find a precedent for. But happy
to hear other suggestions for testing

Fixes https://github.com/llvm/llvm-project/issues/183388

(cherry picked from commit 447eba88c8d7f219667c9914a0d91bf44c1d1512)
---
 lldb/source/Target/Target.cpp                 |  3 +-
 lldb/unittests/Target/CMakeLists.txt          |  2 +
 .../Target/ScratchTypeSystemTest.cpp          | 59 +++++++++++++++++++
 3 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 lldb/unittests/Target/ScratchTypeSystemTest.cpp

diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 1ff115e980cf9..bba630636e526 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -2618,7 +2618,8 @@ Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
 
   if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all
                                              // assembly code
-      || language == eLanguageTypeUnknown) {
+      || language == eLanguageTypeAssembly ||
+      language == eLanguageTypeUnknown) {
     LanguageSet languages_for_expressions =
         Language::GetLanguagesSupportingTypeSystemsForExpressions();
 
diff --git a/lldb/unittests/Target/CMakeLists.txt b/lldb/unittests/Target/CMakeLists.txt
index 83eec3b1117bf..47df8c600ca19 100644
--- a/lldb/unittests/Target/CMakeLists.txt
+++ b/lldb/unittests/Target/CMakeLists.txt
@@ -11,12 +11,14 @@ add_lldb_unittest(TargetTests
   PathMappingListTest.cpp
   RegisterFlagsTest.cpp
   RemoteAwarePlatformTest.cpp
+  ScratchTypeSystemTest.cpp
   StackFrameRecognizerTest.cpp
   SummaryStatisticsTest.cpp
   FindFileTest.cpp
 
   LINK_COMPONENTS
       Support
+      TestingSupport
   LINK_LIBS
       lldbCore
       lldbHost
diff --git a/lldb/unittests/Target/ScratchTypeSystemTest.cpp b/lldb/unittests/Target/ScratchTypeSystemTest.cpp
new file mode 100644
index 0000000000000..b86cab80293a5
--- /dev/null
+++ b/lldb/unittests/Target/ScratchTypeSystemTest.cpp
@@ -0,0 +1,59 @@
+//===-- TestTypeSystem.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 "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/TestUtilities.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/lldb-enumerations.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+class TestTypeSystemMap : public testing::Test {
+public:
+  SubsystemRAII<FileSystem, HostInfo, PlatformMacOSX> subsystems;
+
+protected:
+  void SetUp() override {
+    std::call_once(TestUtilities::g_debugger_initialize_flag,
+                   []() { Debugger::Initialize(nullptr); });
+  };
+
+  DebuggerSP m_debugger_sp;
+  PlatformSP m_platform_sp;
+};
+
+TEST_F(TestTypeSystemMap, GetScratchTypeSystemForLanguage) {
+  // Set up the debugger, make sure that was done properly.
+  TargetSP target_sp;
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch));
+
+  m_debugger_sp = Debugger::CreateInstance();
+
+  auto &target = m_debugger_sp->GetDummyTarget();
+  EXPECT_THAT_EXPECTED(
+      target.GetScratchTypeSystemForLanguage(lldb::eLanguageTypeMipsAssembler),
+      llvm::FailedWithMessage("No expression support for any languages"));
+  EXPECT_THAT_EXPECTED(
+      target.GetScratchTypeSystemForLanguage(lldb::eLanguageTypeAssembly),
+      llvm::FailedWithMessage("No expression support for any languages"));
+  EXPECT_THAT_EXPECTED(
+      target.GetScratchTypeSystemForLanguage(lldb::eLanguageTypeUnknown),
+      llvm::FailedWithMessage("No expression support for any languages"));
+  EXPECT_THAT_EXPECTED(
+      target.GetScratchTypeSystemForLanguage(lldb::eLanguageTypeModula2),
+      llvm::FailedWithMessage("TypeSystem for language modula2 doesn't exist"));
+}

>From fc3638d44360c484086473e279f5471f7b23dc78 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Tue, 3 Mar 2026 11:32:26 +0100
Subject: [PATCH 2/2] [lldb] Don't link TestingSupport as a component (#184310)

This doesn't work with dylib builds, because TestingSupport is not part
of the dylib. Instead, we should link it via LINK_LIBS, like other tests
already do.

(cherry picked from commit d1c563beee794b3a967786fd07c437ffc66fb7f0)
---
 lldb/unittests/Target/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/unittests/Target/CMakeLists.txt b/lldb/unittests/Target/CMakeLists.txt
index 47df8c600ca19..bf08a8f015ba0 100644
--- a/lldb/unittests/Target/CMakeLists.txt
+++ b/lldb/unittests/Target/CMakeLists.txt
@@ -18,7 +18,6 @@ add_lldb_unittest(TargetTests
 
   LINK_COMPONENTS
       Support
-      TestingSupport
   LINK_LIBS
       lldbCore
       lldbHost
@@ -33,6 +32,7 @@ add_lldb_unittest(TargetTests
       lldbSymbol
       lldbUtility
       lldbUtilityHelpers
+      LLVMTestingSupport
   )
 
 set(test_inputs



More information about the llvm-branch-commits mailing list