diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-07-25 21:36:37 +0000 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-07-25 21:36:37 +0000 |
| commit | 971f9ca612f22d251631f6b7dcc5efd8324bc0f2 (patch) | |
| tree | 282cdef9ce40fa67215fe675dc77e76b234f467c /lldb/source/Plugins/Platform | |
| parent | d16a034c7cd33208a86301f05eb4c1a358914475 (diff) | |
| download | bcm5719-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/Platform')
| -rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt | 14 | ||||
| -rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp | 16 | ||||
| -rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/Properties.td | 11 |
3 files changed, 32 insertions, 9 deletions
diff --git a/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt b/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt index 6f0d952c35f..d8fd2aafe71 100644 --- a/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt +++ b/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt @@ -1,3 +1,11 @@ +lldb_tablegen(Properties.inc -gen-lldb-property-defs + SOURCE Properties.td + TARGET LLDBPluginPlatformMacOSXPropertiesGen) + +lldb_tablegen(PropertiesEnum.inc -gen-lldb-property-enum-defs + SOURCE Properties.td + TARGET LLDBPluginPlatformMacOSXPropertiesEnumGen) + list(APPEND PLUGIN_PLATFORM_MACOSX_SOURCES PlatformDarwin.cpp PlatformDarwinKernel.cpp @@ -29,7 +37,7 @@ endif() add_lldb_library(lldbPluginPlatformMacOSX PLUGIN ${PLUGIN_PLATFORM_MACOSX_SOURCES} - + LINK_LIBS clangBasic lldbBreakpoint @@ -44,3 +52,7 @@ add_lldb_library(lldbPluginPlatformMacOSX PLUGIN LINK_COMPONENTS Support ) + +add_dependencies(lldbPluginPlatformMacOSX + LLDBPluginPlatformMacOSXPropertiesGen + LLDBPluginPlatformMacOSXPropertiesEnumGen) diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp index ee0d19253bf..b1e0f87cbb2 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -178,14 +178,14 @@ const char *PlatformDarwinKernel::GetDescriptionStatic() { /// Code to handle the PlatformDarwinKernel settings static constexpr PropertyDefinition g_properties[] = { - {"search-locally-for-kexts", OptionValue::eTypeBoolean, true, true, NULL, - {}, "Automatically search for kexts on the local system when doing " - "kernel debugging."}, - {"kext-directories", OptionValue::eTypeFileSpecList, false, 0, NULL, {}, - "Directories/KDKs to search for kexts in when starting a kernel debug " - "session."}}; - -enum { ePropertySearchForKexts = 0, ePropertyKextDirectories }; +#define LLDB_PROPERTIES_platformdarwinkernel +#include "Properties.inc" +}; + +enum { +#define LLDB_PROPERTIES_platformdarwinkernel +#include "PropertiesEnum.inc" +}; class PlatformDarwinKernelProperties : public Properties { public: diff --git a/lldb/source/Plugins/Platform/MacOSX/Properties.td b/lldb/source/Plugins/Platform/MacOSX/Properties.td new file mode 100644 index 00000000000..07e4e3e81d8 --- /dev/null +++ b/lldb/source/Plugins/Platform/MacOSX/Properties.td @@ -0,0 +1,11 @@ +include "../../../../include/lldb/Core/PropertiesBase.td" + +let Definition = "platformdarwinkernel" in { + def SearchForKexts: Property<"search-locally-for-kexts", "Boolean">, + Global, + DefaultTrue, + Desc<"Automatically search for kexts on the local system when doing kernel debugging.">; + def KextDirectories: Property<"kext-directories", "FileSpecList">, + DefaultStringValue<"">, + Desc<"Directories/KDKs to search for kexts in when starting a kernel debug session.">; +} |

