[Lldb-commits] [PATCH] D76535: [lldb]/Tablegen] Use ElementType instead of DefaultValueUnsinged for Array and Dictionary

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 20 16:50:43 PDT 2020


JDevlieghere created this revision.
JDevlieghere added a reviewer: friss.

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">`.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D76535

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


Index: lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
===================================================================
--- lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
+++ lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
@@ -35,8 +35,9 @@
   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 @@
   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 @@
       !(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";
   }
Index: lldb/source/Target/TargetProperties.td
===================================================================
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -79,7 +79,7 @@
     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 @@
     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 @@
     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,
Index: lldb/include/lldb/Core/PropertiesBase.td
===================================================================
--- lldb/include/lldb/Core/PropertiesBase.td
+++ lldb/include/lldb/Core/PropertiesBase.td
@@ -49,3 +49,9 @@
 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;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76535.251800.patch
Type: text/x-patch
Size: 4300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200320/940cb360/attachment.bin>


More information about the lldb-commits mailing list