diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 8379a6911afc..a416b460f318 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -181,6 +181,8 @@ public: static const char *StateAsCString(lldb::StateType state); + static SBStructuredData GetBuildConfiguration(); + static bool StateIsRunningState(lldb::StateType state); static bool StateIsStoppedState(lldb::StateType state); diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index f0afa9aea849..c6e5815360ac 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -763,3 +763,11 @@ def skipUnlessAddressSanitizer(func): return "Compiler cannot compile with -fsanitize=address" return None return skipTestIfFn(is_compiler_with_address_sanitizer)(func) + +def skipIfXmlSupportMissing(func): + config = lldb.SBDebugger.GetBuildConfiguration() + xml = config.GetValueForKey("xml") + + fail_value = True # More likely to notice if something goes wrong + have_xml = xml.GetValueForKey("value").GetBooleanValue(fail_value) + return unittest2.skipIf(not have_xml, "requires xml support")(func) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py index b12b8f1356a9..b6d38955807f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py @@ -6,7 +6,7 @@ from gdbclientutils import * class TestTargetXMLArch(GDBRemoteTestBase): - @skipIf(hostoslist=no_match(lldbplatformutil.getDarwinOSTriples())) + @skipIfXmlSupportMissing @expectedFailureAll(archs=["i386"]) @skipIfRemote def test(self): diff --git a/lldb/scripts/interface/SBDebugger.i b/lldb/scripts/interface/SBDebugger.i index 9f746d36348c..8ac2c51e12fe 100644 --- a/lldb/scripts/interface/SBDebugger.i +++ b/lldb/scripts/interface/SBDebugger.i @@ -320,6 +320,8 @@ public: static const char * StateAsCString (lldb::StateType state); + static SBStructuredData GetBuildConfiguration(); + static bool StateIsRunningState (lldb::StateType state); diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index d3294dab582d..6f568f4e0172 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -43,6 +43,7 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/DataFormatters/DataVisualization.h" +#include "lldb/Host/XML.h" #include "lldb/Initialization/SystemLifetimeManager.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -491,6 +492,26 @@ const char *SBDebugger::StateAsCString(StateType state) { return lldb_private::StateAsCString(state); } +static void AddBoolConfigEntry(StructuredData::Dictionary &dict, + llvm::StringRef name, bool value, + llvm::StringRef description) { + auto entry_up = llvm::make_unique(); + entry_up->AddBooleanItem("value", value); + entry_up->AddStringItem("description", description); + dict.AddItem(name, 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"); + + SBStructuredData data; + data.m_impl_up->SetObjectSP(std::move(config_up)); + return data; +} + bool SBDebugger::StateIsRunningState(StateType state) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));