@@ -304,6 +304,32 @@ def children(self):
304
304
yield (str (index ), (gdb_ptr + index ).dereference ())
305
305
306
306
307
+ # Yield each key (and optionally value) from a BoxedNode.
308
+ def children_of_node (boxed_node , height , want_values ):
309
+ ptr = boxed_node ['ptr' ]['pointer' ]
310
+ # This is written oddly because we don't want to rely on the field name being `__0`.
311
+ node_ptr = ptr [ptr .type .fields ()[0 ]]
312
+ if height > 0 :
313
+ type_name = str (node_ptr .type .target ()).replace ('LeafNode' , 'InternalNode' )
314
+ node_type = gdb .lookup_type (type_name )
315
+ node_ptr = node_ptr .cast (node_type .pointer ())
316
+ leaf = node_ptr ['data' ]
317
+ else :
318
+ leaf = node_ptr .dereference ()
319
+ keys = leaf ['keys' ]['value' ]['value' ]
320
+ if want_values :
321
+ values = leaf ['vals' ]['value' ]['value' ]
322
+ length = int (leaf ['len' ])
323
+ for i in xrange (0 , length + 1 ):
324
+ if height > 0 :
325
+ for child in children_of_node (node_ptr ['edges' ][i ], height - 1 , want_values ):
326
+ yield child
327
+ if i < length :
328
+ if want_values :
329
+ yield (keys [i ], values [i ])
330
+ else :
331
+ yield keys [i ]
332
+
307
333
class RustStdBTreeSetPrinter (object ):
308
334
def __init__ (self , val ):
309
335
self .__val = val
@@ -313,21 +339,16 @@ def display_hint():
313
339
return "array"
314
340
315
341
def to_string (self ):
316
- (length , data_ptr ) = \
317
- rustpp .extract_length_and_ptr_from_std_btreeset (self .__val )
318
342
return (self .__val .type .get_unqualified_type_name () +
319
- ("(len: %i)" % length ))
343
+ ("(len: %i)" % self . __val . get_wrapped_value ()[ 'map' ][ ' length' ] ))
320
344
321
345
def children (self ):
322
- (length , data_ptr ) = \
323
- rustpp .extract_length_and_ptr_from_std_btreeset (self .__val )
324
- leaf_node = GdbValue (data_ptr .get_wrapped_value ().dereference ())
325
- maybe_uninit_keys = leaf_node .get_child_at_index (3 )
326
- manually_drop_keys = maybe_uninit_keys .get_child_at_index (1 )
327
- keys = manually_drop_keys .get_child_at_index (0 )
328
- gdb_ptr = keys .get_wrapped_value ()
329
- for index in xrange (length ):
330
- yield (str (index ), gdb_ptr [index ])
346
+ root = self .__val .get_wrapped_value ()['map' ]['root' ]
347
+ node_ptr = root ['node' ]
348
+ i = 0
349
+ for child in children_of_node (node_ptr , root ['height' ], False ):
350
+ yield (str (i ), child )
351
+ i = i + 1
331
352
332
353
333
354
class RustStdBTreeMapPrinter (object ):
@@ -339,26 +360,17 @@ def display_hint():
339
360
return "map"
340
361
341
362
def to_string (self ):
342
- (length , data_ptr ) = \
343
- rustpp .extract_length_and_ptr_from_std_btreemap (self .__val )
344
363
return (self .__val .type .get_unqualified_type_name () +
345
- ("(len: %i)" % length ))
364
+ ("(len: %i)" % self . __val . get_wrapped_value ()[ ' length' ] ))
346
365
347
366
def children (self ):
348
- (length , data_ptr ) = \
349
- rustpp .extract_length_and_ptr_from_std_btreemap (self .__val )
350
- leaf_node = GdbValue (data_ptr .get_wrapped_value ().dereference ())
351
- maybe_uninit_keys = leaf_node .get_child_at_index (3 )
352
- manually_drop_keys = maybe_uninit_keys .get_child_at_index (1 )
353
- keys = manually_drop_keys .get_child_at_index (0 )
354
- keys_ptr = keys .get_wrapped_value ()
355
- maybe_uninit_vals = leaf_node .get_child_at_index (4 )
356
- manually_drop_vals = maybe_uninit_vals .get_child_at_index (1 )
357
- vals = manually_drop_vals .get_child_at_index (0 )
358
- vals_ptr = vals .get_wrapped_value ()
359
- for index in xrange (length ):
360
- yield (str (index ), keys_ptr [index ])
361
- yield (str (index ), vals_ptr [index ])
367
+ root = self .__val .get_wrapped_value ()['root' ]
368
+ node_ptr = root ['node' ]
369
+ i = 0
370
+ for child in children_of_node (node_ptr , root ['height' ], True ):
371
+ yield (str (i ), child [0 ])
372
+ yield (str (i ), child [1 ])
373
+ i = i + 1
362
374
363
375
364
376
class RustStdStringPrinter (object ):
0 commit comments