[llvm] 45d1cca - [llvm][utils] Fix SmallString summary provider (#78527)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 10:35:23 PST 2024


Author: Dave Lee
Date: 2024-01-18T10:35:18-08:00
New Revision: 45d1cca3394fa4b14561dd6c36104ff8e20e51db

URL: https://github.com/llvm/llvm-project/commit/45d1cca3394fa4b14561dd6c36104ff8e20e51db
DIFF: https://github.com/llvm/llvm-project/commit/45d1cca3394fa4b14561dd6c36104ff8e20e51db.diff

LOG: [llvm][utils] Fix SmallString summary provider (#78527)

Fixes `SmallString` summary provider, which was incorrectly producing the empty string. 
Initially I thought the strings I was debugging were empty for unknown reasons, but 
that was not the case.

Added: 
    

Modified: 
    llvm/utils/lldbDataFormatters.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/lldbDataFormatters.py b/llvm/utils/lldbDataFormatters.py
index 0b61db60e80c7f..de101abdabc8ec 100644
--- a/llvm/utils/lldbDataFormatters.py
+++ b/llvm/utils/lldbDataFormatters.py
@@ -218,12 +218,14 @@ def get_child_at_index(self, index):
 
 
 def SmallStringSummaryProvider(valobj, internal_dict):
-    num_elements = valobj.GetNumChildren()
+    # The underlying SmallVector base class is the first child.
+    vector = valobj.GetChildAtIndex(0)
+    num_elements = vector.GetNumChildren()
     res = '"'
-    for i in range(0, num_elements):
-        c = valobj.GetChildAtIndex(i).GetValue()
+    for i in range(num_elements):
+        c = vector.GetChildAtIndex(i)
         if c:
-            res += c.strip("'")
+            res += chr(c.GetValueAsUnsigned())
     res += '"'
     return res
 


        


More information about the llvm-commits mailing list