labath created this revision.
labath added reviewers: zturner, jingham, clayborg, davide.

This adds a SBDebugger::GetBuildConfiguration static function, which
returns a SBStructuredData describing the the build parameters of
liblldb. Right now, it just contains one entry: whether we were built
with XML support.

I use the new functionality to skip a test which requires XML support,
but concievably the new function could be useful to other liblldb
clients as well (making sure the library supports the feature they are
about to use).


https://reviews.llvm.org/D43333

Files:
  include/lldb/API/SBDebugger.h
  packages/Python/lldbsuite/test/decorators.py
  
packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py
  scripts/interface/SBDebugger.i
  source/API/SBDebugger.cpp


Index: source/API/SBDebugger.cpp
===================================================================
--- source/API/SBDebugger.cpp
+++ 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,15 @@
   return lldb_private::StateAsCString(state);
 }
 
+SBStructuredData SBDebugger::GetBuildConfiguration() {
+  auto config_up = llvm::make_unique<StructuredData::Dictionary>();
+  config_up->AddBooleanItem("xml", XMLDocument::XMLEnabled());
+
+  SBStructuredData data;
+  data.m_impl_up->SetObjectSP(std::move(config_up));
+  return data;
+}
+
 bool SBDebugger::StateIsRunningState(StateType state) {
   Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
 
Index: scripts/interface/SBDebugger.i
===================================================================
--- scripts/interface/SBDebugger.i
+++ scripts/interface/SBDebugger.i
@@ -320,6 +320,8 @@
     static const char *
     StateAsCString (lldb::StateType state);
 
+    static SBStructuredData GetBuildConfiguration();
+
     static bool
     StateIsRunningState (lldb::StateType state);
 
Index: 
packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py
===================================================================
--- 
packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py
+++ 
packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py
@@ -6,7 +6,7 @@
 
 class TestTargetXMLArch(GDBRemoteTestBase):
 
-    @skipIf(hostoslist=no_match(lldbplatformutil.getDarwinOSTriples()))
+    @skipIfXmlSupportMissing
     @expectedFailureAll(archs=["i386"])
     def test(self):
         """
Index: packages/Python/lldbsuite/test/decorators.py
===================================================================
--- packages/Python/lldbsuite/test/decorators.py
+++ packages/Python/lldbsuite/test/decorators.py
@@ -763,3 +763,9 @@
             return "Compiler cannot compile with -fsanitize=address"
         return None
     return skipTestIfFn(is_compiler_with_address_sanitizer)(func)
+
+def skipIfXmlSupportMissing(func):
+    config = lldb.SBDebugger.GetBuildConfiguration()
+    fail_value = True # More likely to notice if something goes wrong
+    have_xml = config.GetValueForKey("xml").GetBooleanValue(fail_value)
+    return unittest2.skipIf(not have_xml, "requires xml support")(func)
Index: include/lldb/API/SBDebugger.h
===================================================================
--- include/lldb/API/SBDebugger.h
+++ include/lldb/API/SBDebugger.h
@@ -181,6 +181,8 @@
 
   static const char *StateAsCString(lldb::StateType state);
 
+  static SBStructuredData GetBuildConfiguration();
+
   static bool StateIsRunningState(lldb::StateType state);
 
   static bool StateIsStoppedState(lldb::StateType state);


Index: source/API/SBDebugger.cpp
===================================================================
--- source/API/SBDebugger.cpp
+++ 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,15 @@
   return lldb_private::StateAsCString(state);
 }
 
+SBStructuredData SBDebugger::GetBuildConfiguration() {
+  auto config_up = llvm::make_unique<StructuredData::Dictionary>();
+  config_up->AddBooleanItem("xml", XMLDocument::XMLEnabled());
+
+  SBStructuredData data;
+  data.m_impl_up->SetObjectSP(std::move(config_up));
+  return data;
+}
+
 bool SBDebugger::StateIsRunningState(StateType state) {
   Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
 
Index: scripts/interface/SBDebugger.i
===================================================================
--- scripts/interface/SBDebugger.i
+++ scripts/interface/SBDebugger.i
@@ -320,6 +320,8 @@
     static const char *
     StateAsCString (lldb::StateType state);
 
+    static SBStructuredData GetBuildConfiguration();
+
     static bool
     StateIsRunningState (lldb::StateType state);
 
Index: packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py
+++ packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py
@@ -6,7 +6,7 @@
 
 class TestTargetXMLArch(GDBRemoteTestBase):
 
-    @skipIf(hostoslist=no_match(lldbplatformutil.getDarwinOSTriples()))
+    @skipIfXmlSupportMissing
     @expectedFailureAll(archs=["i386"])
     def test(self):
         """
Index: packages/Python/lldbsuite/test/decorators.py
===================================================================
--- packages/Python/lldbsuite/test/decorators.py
+++ packages/Python/lldbsuite/test/decorators.py
@@ -763,3 +763,9 @@
             return "Compiler cannot compile with -fsanitize=address"
         return None
     return skipTestIfFn(is_compiler_with_address_sanitizer)(func)
+
+def skipIfXmlSupportMissing(func):
+    config = lldb.SBDebugger.GetBuildConfiguration()
+    fail_value = True # More likely to notice if something goes wrong
+    have_xml = config.GetValueForKey("xml").GetBooleanValue(fail_value)
+    return unittest2.skipIf(not have_xml, "requires xml support")(func)
Index: include/lldb/API/SBDebugger.h
===================================================================
--- include/lldb/API/SBDebugger.h
+++ include/lldb/API/SBDebugger.h
@@ -181,6 +181,8 @@
 
   static const char *StateAsCString(lldb::StateType state);
 
+  static SBStructuredData GetBuildConfiguration();
+
   static bool StateIsRunningState(lldb::StateType state);
 
   static bool StateIsStoppedState(lldb::StateType state);
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to