Index: lldb/trunk/packages/Python/lldbsuite/test/decorators.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/decorators.py +++ lldb/trunk/packages/Python/lldbsuite/test/decorators.py @@ -783,6 +783,17 @@ have_xml = xml.GetValueForKey("value").GetBooleanValue(fail_value) return unittest2.skipIf(not have_xml, "requires xml support")(func) +def skipIfLLVMTargetMissing(target): + config = lldb.SBDebugger.GetBuildConfiguration() + targets = config.GetValueForKey("targets").GetValueForKey("value") + found = False + for i in range(targets.GetSize()): + if targets.GetItemAtIndex(i).GetStringValue(99) == target: + found = True + break + + return unittest2.skipIf(not found, "requires " + target) + # Call sysctl on darwin to see if a specified hardware feature is available on this machine. def skipUnlessFeature(feature): def is_feature_enabled(self): Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -42,23 +42,27 @@ @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_i386(self): """Test that lldb can read the process information from an i386 linux core file.""" self.do_test("linux-i386", self._i386_pid, self._i386_regions, "a.out") @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) + @skipIfLLVMTargetMissing("Mips") def test_mips_o32(self): """Test that lldb can read the process information from an MIPS O32 linux core file.""" self.do_test("linux-mipsel-gnuabio32", self._mips_o32_pid, self._mips_regions, "linux-mipsel-gn") @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) + @skipIfLLVMTargetMissing("Mips") def test_mips_n32(self): """Test that lldb can read the process information from an MIPS N32 linux core file """ self.do_test("linux-mips64el-gnuabin32", self._mips64_n32_pid, self._mips_regions, "linux-mips64el-") @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) + @skipIfLLVMTargetMissing("Mips") def test_mips_n64(self): """Test that lldb can read the process information from an MIPS N64 linux core file """ self.do_test("linux-mips64el-gnuabi64", self._mips64_n64_pid, @@ -66,6 +70,7 @@ @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("PowerPC") def test_ppc64le(self): """Test that lldb can read the process information from an ppc64le linux core file.""" self.do_test("linux-ppc64le", self._ppc64le_pid, self._ppc64le_regions, @@ -73,6 +78,7 @@ @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions, @@ -80,6 +86,7 @@ @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("SystemZ") def test_s390x(self): """Test that lldb can read the process information from an s390x linux core file.""" self.do_test("linux-s390x", self._s390x_pid, self._s390x_regions, @@ -87,6 +94,7 @@ @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_same_pid_running(self): """Test that we read the information from the core correctly even if we have a running process with the same PID around""" @@ -115,6 +123,7 @@ @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_two_cores_same_pid(self): """Test that we handle the situation if we have two core files with the same PID around""" @@ -145,6 +154,7 @@ @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_FPR_SSE(self): # check x86_64 core file target = self.dbg.CreateTarget(None) Index: lldb/trunk/source/API/SBDebugger.cpp =================================================================== --- lldb/trunk/source/API/SBDebugger.cpp +++ lldb/trunk/source/API/SBDebugger.cpp @@ -500,11 +500,23 @@ dict.AddItem(name, std::move(entry_up)); } +static void AddLLVMTargets(StructuredData::Dictionary &dict) { + auto array_up = llvm::make_unique(); +#define LLVM_TARGET(target) \ + array_up->AddItem(llvm::make_unique(#target)); +#include "llvm/Config/Targets.def" + auto entry_up = llvm::make_unique(); + entry_up->AddItem("value", std::move(array_up)); + entry_up->AddStringItem("description", "A list of configured LLVM targets."); + dict.AddItem("targets", std::move(entry_up)); +} + SBStructuredData SBDebugger::GetBuildConfiguration() { auto config_up = llvm::make_unique(); AddBoolConfigEntry( *config_up, "xml", XMLDocument::XMLEnabled(), "A boolean value that indicates if XML support is enabled in LLDB"); + AddLLVMTargets(*config_up); SBStructuredData data; data.m_impl_up->SetObjectSP(std::move(config_up));