[PATCH] D127969: [gdb-scripts] Add to_string methods to printer implementations

Krzysztof Drewniak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 21 09:09:38 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c5c4e781b8c: [gdb-scripts] Add to_string methods to printer implementations (authored by krzysz00).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127969/new/

https://reviews.llvm.org/D127969

Files:
  llvm/utils/gdb-scripts/prettyprinters.py
  mlir/utils/gdb-scripts/prettyprinters.py


Index: mlir/utils/gdb-scripts/prettyprinters.py
===================================================================
--- mlir/utils/gdb-scripts/prettyprinters.py
+++ mlir/utils/gdb-scripts/prettyprinters.py
@@ -16,6 +16,8 @@
       else:
         yield field.name, self.val[field.name]
 
+  def to_string(self):
+    return 'mlir::Storage'
 
 class TupleTypeStoragePrinter(StoragePrinter):
 
@@ -27,6 +29,8 @@
     for i in range(self.val['numElements']):
       yield 'elements[%u]' % i, elements[i]
 
+  def to_string(self):
+    return 'mlir::TupleTypeStorage of %u elements' % self.val['numElements']
 
 class FusedLocationStoragePrinter(StoragePrinter):
 
@@ -38,6 +42,9 @@
     for i in range(self.val['numLocs']):
       yield 'locs[%u]' % i, elements[i]
 
+  def to_string(self):
+    return 'mlir::FusedLocationStorage of %u locs' % self.val['numLocs']
+
 
 class StorageTypeMap:
   """Maps a TypeID to the corresponding concrete type.
@@ -105,7 +112,10 @@
 
     def children(self):
       yield 'typeID', self.type_id
-      yield 'cast<%s>(impl)' % self.impl.type, self.impl
+      yield 'impl', self.impl
+
+    def to_string(self):
+      return 'cast<%s>' % self.impl.type
 
   if not val['impl']:
     return None
@@ -125,10 +135,15 @@
   """Printer for an instance with a single 'impl' member pointer."""
 
   def __init__(self, val):
+    self.val = val
     self.impl = val['impl']
 
   def children(self):
-    yield 'impl', (self.impl.dereference() if self.impl else self.impl)
+    if self.impl:
+      yield 'impl', self.impl.dereference()
+
+  def to_string(self):
+    return self.val.type.name
 
 
 # Printers of types deriving from Attribute::AttrBase or Type::TypeBase.
Index: llvm/utils/gdb-scripts/prettyprinters.py
===================================================================
--- llvm/utils/gdb-scripts/prettyprinters.py
+++ llvm/utils/gdb-scripts/prettyprinters.py
@@ -386,6 +386,9 @@
     yield ('pointer', self.pointer)
     yield ('value', self.value)
 
+  def to_string(self):
+    return '(%s, %s)' % self.pointer.type, self.value.type
+
 def make_pointer_int_pair_printer(val):
   """Factory for an llvm::PointerIntPair printer."""
   try:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127969.438731.patch
Type: text/x-patch
Size: 2184 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220621/71367989/attachment.bin>


More information about the llvm-commits mailing list