llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: None (llvmbot) <details> <summary>Changes</summary> Backport 447eba88c8d7f219667c9914a0d91bf44c1d1512 d1c563beee794b3a967786fd07c437ffc66fb7f0 Requested by: @<!-- -->Michael137 --- Full diff: https://github.com/llvm/llvm-project/pull/184320.diff 3 Files Affected: - (modified) lldb/source/Target/Target.cpp (+2-1) - (modified) lldb/unittests/Target/CMakeLists.txt (+2) - (added) lldb/unittests/Target/ScratchTypeSystemTest.cpp (+59) ``````````diff 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..bf08a8f015ba0 100644 --- a/lldb/unittests/Target/CMakeLists.txt +++ b/lldb/unittests/Target/CMakeLists.txt @@ -11,6 +11,7 @@ add_lldb_unittest(TargetTests PathMappingListTest.cpp RegisterFlagsTest.cpp RemoteAwarePlatformTest.cpp + ScratchTypeSystemTest.cpp StackFrameRecognizerTest.cpp SummaryStatisticsTest.cpp FindFileTest.cpp @@ -31,6 +32,7 @@ add_lldb_unittest(TargetTests lldbSymbol lldbUtility lldbUtilityHelpers + LLVMTestingSupport ) set(test_inputs 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")); +} `````````` </details> https://github.com/llvm/llvm-project/pull/184320 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
