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/DynamicLoader | |
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/DynamicLoader')
3 files changed, 33 insertions, 8 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/CMakeLists.txt b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/CMakeLists.txt index ffc797b7475..b4ba84a7fde 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/CMakeLists.txt +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/CMakeLists.txt @@ -1,3 +1,11 @@ +lldb_tablegen(Properties.inc -gen-lldb-property-defs + SOURCE Properties.td + TARGET LLDBPluginDynamicLoaderDarwinKernelPropertiesGen) + +lldb_tablegen(PropertiesEnum.inc -gen-lldb-property-enum-defs + SOURCE Properties.td + TARGET LLDBPluginDynamicLoaderDarwinKernelPropertiesEnumGen) + add_lldb_library(lldbPluginDynamicLoaderDarwinKernel PLUGIN DynamicLoaderDarwinKernel.cpp @@ -11,3 +19,7 @@ add_lldb_library(lldbPluginDynamicLoaderDarwinKernel PLUGIN lldbUtility lldbPluginPlatformMacOSX ) + +add_dependencies(lldbPluginDynamicLoaderDarwinKernel + LLDBPluginDynamicLoaderDarwinKernelPropertiesGen + LLDBPluginDynamicLoaderDarwinKernelPropertiesEnumGen) diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 7ff783da346..0d55e341dae 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -73,14 +73,14 @@ static constexpr OptionEnumValueElement g_kaslr_kernel_scan_enum_values[] = { "on 32-bit targets)."}}; static constexpr PropertyDefinition g_properties[] = { - {"load-kexts", OptionValue::eTypeBoolean, true, true, nullptr, {}, - "Automatically loads kext images when attaching to a kernel."}, - {"scan-type", OptionValue::eTypeEnum, true, eKASLRScanNearPC, nullptr, - OptionEnumValues(g_kaslr_kernel_scan_enum_values), - "Control how many reads lldb will make while searching for a Darwin " - "kernel on attach."}}; - -enum { ePropertyLoadKexts, ePropertyScanType }; +#define LLDB_PROPERTIES_dynamicloaderdarwinkernel +#include "Properties.inc" +}; + +enum { +#define LLDB_PROPERTIES_dynamicloaderdarwinkernel +#include "PropertiesEnum.inc" +}; class DynamicLoaderDarwinKernelProperties : public Properties { public: diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/Properties.td b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/Properties.td new file mode 100644 index 00000000000..6c662d737fa --- /dev/null +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/Properties.td @@ -0,0 +1,13 @@ +include "../../../../include/lldb/Core/PropertiesBase.td" + +let Definition = "dynamicloaderdarwinkernel" in { + def LoadKexts: Property<"load-kexts", "Boolean">, + Global, + DefaultTrue, + Desc<"Automatically loads kext images when attaching to a kernel.">; + def ScanType: Property<"scan-type", "Enum">, + Global, + DefaultEnumValue<"eKASLRScanNearPC">, + EnumValues<"OptionEnumValues(g_kaslr_kernel_scan_enum_values)">, + Desc<"Control how many reads lldb will make while searching for a Darwin kernel on attach.">; +} |