[Lldb-commits] [lldb] 09c8845 - [lldb]/Tablegen] Use ElementType instead of DefaultValueUnsinged

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 20 18:41:35 PDT 2020


Author: Jonas Devlieghere
Date: 2020-03-20T18:35:13-07:00
New Revision: 09c8845adfd9e86a227d6413d57b462d8566d399

URL: https://github.com/llvm/llvm-project/commit/09c8845adfd9e86a227d6413d57b462d8566d399
DIFF: https://github.com/llvm/llvm-project/commit/09c8845adfd9e86a227d6413d57b462d8566d399.diff

LOG: [lldb]/Tablegen] Use ElementType instead of DefaultValueUnsinged

The fourth field in the property struct is the default unsigned or enum
value for all types, except for Array and Dictionary types. For those,
it is the element type. During the tablegen conversion, this was
incorrectly translated to DefaultValueUnsigned with a value
corresponding to the OptionValue: enum type. So for
OptionValue::eTypeString this became DefaultUnsignedValue<16>. This
patch extends the tablegen backend to understand ElementType to express
this as ElementType<"String">.

Differential revision: https://reviews.llvm.org/D76535

Added: 
    

Modified: 
    lldb/include/lldb/Core/PropertiesBase.td
    lldb/source/Target/TargetProperties.td
    lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Core/PropertiesBase.td b/lldb/include/lldb/Core/PropertiesBase.td
index 6e95ceb779ba..1be3b908ed41 100644
--- a/lldb/include/lldb/Core/PropertiesBase.td
+++ b/lldb/include/lldb/Core/PropertiesBase.td
@@ -49,3 +49,9 @@ class DefaultUnsignedValue<int value> {
 class EnumValues<string enum> {
   string EnumValues = enum;
 }
+
+// Determines the element type for arrays and dictionaries.
+class ElementType<string value> {
+  string ElementType = value;
+  bit HasElementType = 1;
+}

diff  --git a/lldb/source/Target/TargetProperties.td b/lldb/source/Target/TargetProperties.td
index ce08e44acb9b..77579c66ccb0 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -79,7 +79,7 @@ let Definition = "target" in {
     DefaultStringValue<"">,
     Desc<"A list containing all the arguments to be passed to the executable when it is run. Note that this does NOT include the argv[0] which is in target.arg0.">;
   def EnvVars: Property<"env-vars", "Dictionary">,
-    DefaultUnsignedValue<16>,
+    ElementType<"String">,
     Desc<"A list of all the environment variables to be passed to the executable's environment, and their values.">;
   def InheritEnv: Property<"inherit-env", "Boolean">,
     DefaultTrue,
@@ -140,7 +140,7 @@ let Definition = "target" in {
     Desc<"Expressions that crash will show up in crash logs if the host system supports executable specific crash log strings and this setting is set to true.">;
   def TrapHandlerNames: Property<"trap-handler-names", "Array">,
     Global,
-    DefaultUnsignedValue<16>,
+    ElementType<"String">,
     Desc<"A list of trap handler function names, e.g. a common Unix user process one is _sigtramp.">;
   def DisplayRuntimeSupportValues: Property<"display-runtime-support-values", "Boolean">,
     DefaultFalse,
@@ -164,7 +164,7 @@ let Definition = "process" in {
     DefaultFalse,
     Desc<"Disable reading and caching of memory in fixed-size units.">;
   def ExtraStartCommand: Property<"extra-startup-command", "Array">,
-    DefaultUnsignedValue<16>,
+    ElementType<"String">,
     Desc<"A list containing extra commands understood by the particular process plugin used.  For instance, to turn on debugserver logging set this to 'QSetLogging:bitmask=LOG_DEFAULT;'">;
   def IgnoreBreakpointsInExpressions: Property<"ignore-breakpoints-in-expressions", "Boolean">,
     Global,

diff  --git a/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp b/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
index f36deeebf906..e3522f2c7b2d 100644
--- a/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
+++ b/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
@@ -35,8 +35,9 @@ static void emitProperty(Record *Property, raw_ostream &OS) {
   OS << ", ";
 
   // Emit the property type.
+  llvm::StringRef type = Property->getValueAsString("Type");
   OS << "OptionValue::eType";
-  OS << Property->getValueAsString("Type");
+  OS << type;
   OS << ", ";
 
   // Emit the property's global value.
@@ -46,11 +47,12 @@ static void emitProperty(Record *Property, raw_ostream &OS) {
   bool hasDefaultUnsignedValue = Property->getValue("HasDefaultUnsignedValue");
   bool hasDefaultEnumValue = Property->getValue("HasDefaultEnumValue");
   bool hasDefaultStringValue = Property->getValue("HasDefaultStringValue");
+  bool hasElementType = Property->getValue("HasElementType");
 
   // Guarantee that every property has a default value.
   assert((hasDefaultUnsignedValue || hasDefaultEnumValue ||
-          hasDefaultStringValue) &&
-         "Property must have a default value");
+          hasDefaultStringValue || hasElementType) &&
+         "Property must have a default value or an element type");
 
   // Guarantee that no property has both a default unsigned value and a default
   // enum value, since they're bothed stored in the same field.
@@ -72,11 +74,18 @@ static void emitProperty(Record *Property, raw_ostream &OS) {
       !(Property->getValueAsString("Type") == "Enum" && !hasDefaultEnumValue) &&
       "Enum property must have a enum default value.");
 
+  // Guarantee that only arrays and dictionaries have an element type;
+  assert(((type != "Array" && type != "Dictionary") || hasElementType) &&
+         "Only dictionaries and arrays can have an element type.");
+
   // Emit the default uint value.
   if (hasDefaultUnsignedValue) {
     OS << std::to_string(Property->getValueAsInt("DefaultUnsignedValue"));
   } else if (hasDefaultEnumValue) {
     OS << Property->getValueAsString("DefaultEnumValue");
+  } else if (hasElementType) {
+    OS << "OptionValue::eType";
+    OS << Property->getValueAsString("ElementType");
   } else {
     OS << "0";
   }


        


More information about the lldb-commits mailing list