33
44Load into LLDB with 'command script import /path/to/lldbDataFormatters.py'
55"""
6+
67from __future__ import annotations
78
89import collections
@@ -82,6 +83,11 @@ def __lldb_init_module(debugger, internal_dict):
8283 f"-l { __name__ } .DenseMapSynthetic "
8384 '-x "^llvm::DenseMap<.+>$"'
8485 )
86+ debugger .HandleCommand (
87+ "type synthetic add -w llvm "
88+ f"-l { __name__ } .DenseSetSynthetic "
89+ '-x "^llvm::DenseSet<.+>$"'
90+ )
8591
8692 debugger .HandleCommand (
8793 "type synthetic add -w llvm "
@@ -372,7 +378,8 @@ def update(self):
372378 # For each key, collect a list of buckets it appears in.
373379 key_buckets : dict [str , list [int ]] = collections .defaultdict (list )
374380 for index in range (num_buckets ):
375- key = buckets .GetValueForExpressionPath (f"[{ index } ].first" )
381+ bucket = buckets .GetValueForExpressionPath (f"[{ index } ]" )
382+ key = bucket .GetChildAtIndex (0 )
376383 key_buckets [str (key .data )].append (index )
377384
378385 # Heuristic: This is not a multi-map, any repeated (non-unique) keys are
@@ -383,6 +390,26 @@ def update(self):
383390 self .child_buckets .append (indexes [0 ])
384391
385392
393+ class DenseSetSynthetic :
394+ valobj : lldb .SBValue
395+ map : lldb .SBValue
396+
397+ def __init__ (self , valobj : lldb .SBValue , _ ) -> None :
398+ self .valobj = valobj
399+
400+ def num_children (self ) -> int :
401+ return self .map .num_children
402+
403+ def get_child_at_index (self , idx : int ) -> lldb .SBValue :
404+ map_entry = self .map .child [idx ]
405+ set_entry = map_entry .GetChildAtIndex (0 )
406+ return set_entry .Clone (f"[{ idx } ]" )
407+
408+ def update (self ):
409+ raw_map = self .valobj .GetChildMemberWithName ("TheMap" )
410+ self .map = raw_map .GetSyntheticValue ()
411+
412+
386413class ExpectedSynthetic :
387414 # The llvm::Expected<T> value.
388415 expected : lldb .SBValue
0 commit comments