summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/MacOSX-Kernel
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-07-25 21:36:37 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-07-25 21:36:37 +0000
commit971f9ca612f22d251631f6b7dcc5efd8324bc0f2 (patch)
tree282cdef9ce40fa67215fe675dc77e76b234f467c /lldb/source/Plugins/Process/MacOSX-Kernel
parentd16a034c7cd33208a86301f05eb4c1a358914475 (diff)
downloadbcm5719-llvm-971f9ca612f22d251631f6b7dcc5efd8324bc0f2.tar.gz
bcm5719-llvm-971f9ca612f22d251631f6b7dcc5efd8324bc0f2.zip
Let tablegen generate property definitions
Property definitions are currently defined in a PropertyDefinition array and have a corresponding enum to index in this array. Unfortunately this is quite error prone. Indeed, just today we found an incorrect merge where a discrepancy between the order of the enum values and their definition caused the test suite to fail spectacularly. Tablegen can streamline the process of generating the property definition table while at the same time guaranteeing that the enums stay in sync. That's exactly what this patch does. It adds a new tablegen file for the properties, building on top of the infrastructure that Raphael added recently for the command options. It also introduces two new tablegen backends: one for the property definitions and one for their corresponding enums. It might be worth mentioning that I generated most of the tablegen definitions from the existing property definitions, by adding a dump method to the struct. This seems both more efficient and less error prone that copying everything over by hand. Only Enum properties needed manual fixup for the EnumValues and DefaultEnumValue fields. Differential revision: https://reviews.llvm.org/D65185 llvm-svn: 367058
Diffstat (limited to 'lldb/source/Plugins/Process/MacOSX-Kernel')
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt12
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp12
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/Properties.td8
3 files changed, 28 insertions, 4 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt b/lldb/source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt
index bed0e3b7ab3..56720083631 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt
@@ -1,3 +1,11 @@
+lldb_tablegen(Properties.inc -gen-lldb-property-defs
+ SOURCE Properties.td
+ TARGET LLDBPluginProcessMacOSXKernelPropertiesGen)
+
+lldb_tablegen(PropertiesEnum.inc -gen-lldb-property-enum-defs
+ SOURCE Properties.td
+ TARGET LLDBPluginProcessMacOSXKernelPropertiesEnumGen)
+
add_lldb_library(lldbPluginProcessMacOSXKernel PLUGIN
CommunicationKDP.cpp
ProcessKDP.cpp
@@ -20,3 +28,7 @@ add_lldb_library(lldbPluginProcessMacOSXKernel PLUGIN
lldbPluginDynamicLoaderStatic
lldbPluginProcessUtility
)
+
+add_dependencies(lldbPluginProcessMacOSXKernel
+ LLDBPluginProcessMacOSXKernelPropertiesGen
+ LLDBPluginProcessMacOSXKernelPropertiesEnumGen)
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 52c494db6be..5542018a4f9 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -53,10 +53,14 @@ using namespace lldb_private;
namespace {
static constexpr PropertyDefinition g_properties[] = {
- {"packet-timeout", OptionValue::eTypeUInt64, true, 5, NULL, {},
- "Specify the default packet timeout in seconds."}};
+#define LLDB_PROPERTIES_processkdp
+#include "Properties.inc"
+};
-enum { ePropertyPacketTimeout };
+enum {
+#define LLDB_PROPERTIES_processkdp
+#include "PropertiesEnum.inc"
+};
class PluginProperties : public Properties {
public:
@@ -72,7 +76,7 @@ public:
virtual ~PluginProperties() {}
uint64_t GetPacketTimeout() {
- const uint32_t idx = ePropertyPacketTimeout;
+ const uint32_t idx = ePropertyKDPPacketTimeout;
return m_collection_sp->GetPropertyAtIndexAsUInt64(
NULL, idx, g_properties[idx].default_uint_value);
}
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/Properties.td b/lldb/source/Plugins/Process/MacOSX-Kernel/Properties.td
new file mode 100644
index 00000000000..0063bdbec00
--- /dev/null
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/Properties.td
@@ -0,0 +1,8 @@
+include "../../../../include/lldb/Core/PropertiesBase.td"
+
+let Definition = "processkdp" in {
+ def KDPPacketTimeout: Property<"packet-timeout", "UInt64">,
+ Global,
+ DefaultUnsignedValue<5>,
+ Desc<"Specify the default packet timeout in seconds.">;
+}
OpenPOWER on IntegriCloud