diff options
author | Tom Tromey <tom@tromey.com> | 2018-11-14 16:22:14 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-11-14 16:22:14 -0700 |
commit | a9a48ed3da1134364052322d628fd9d9418998f4 (patch) | |
tree | 751f89182a416a44e212a02cbfca3f93170686ce /src | |
parent | 9fefb67669f00c25b476e7a80c9c9300a987d517 (diff) | |
download | rust-a9a48ed3da1134364052322d628fd9d9418998f4.tar.gz |
Fix VecDeque pretty-printer
This fixes the VecDeque pretty-printer to handle cases where
head < tail.
Closes #55944
Diffstat (limited to 'src')
-rwxr-xr-x | src/etc/gdb_rust_pretty_printing.py | 14 | ||||
-rw-r--r-- | src/test/debuginfo/pretty-std-collections.rs | 11 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/etc/gdb_rust_pretty_printing.py b/src/etc/gdb_rust_pretty_printing.py index e6d5ef1a23f..27275ba3795 100755 --- a/src/etc/gdb_rust_pretty_printing.py +++ b/src/etc/gdb_rust_pretty_printing.py @@ -293,15 +293,23 @@ class RustStdVecDequePrinter(object): def to_string(self): (tail, head, data_ptr, cap) = \ rustpp.extract_tail_head_ptr_and_cap_from_std_vecdeque(self.__val) + if head >= tail: + size = head - tail + else: + size = cap + head - tail return (self.__val.type.get_unqualified_type_name() + - ("(len: %i, cap: %i)" % (head - tail, cap))) + ("(len: %i, cap: %i)" % (size, cap))) def children(self): (tail, head, data_ptr, cap) = \ rustpp.extract_tail_head_ptr_and_cap_from_std_vecdeque(self.__val) gdb_ptr = data_ptr.get_wrapped_value() - for index in xrange(tail, head): - yield (str(index), (gdb_ptr + index).dereference()) + if head >= tail: + size = head - tail + else: + size = cap + head - tail + for index in xrange(0, size): + yield (str(index), (gdb_ptr + ((tail + index) % cap)).dereference()) class RustStdBTreeSetPrinter(object): diff --git a/src/test/debuginfo/pretty-std-collections.rs b/src/test/debuginfo/pretty-std-collections.rs index 8e37a884b34..0d3f4b90f23 100644 --- a/src/test/debuginfo/pretty-std-collections.rs +++ b/src/test/debuginfo/pretty-std-collections.rs @@ -28,6 +28,9 @@ // gdb-command: print vec_deque // gdb-check:$3 = VecDeque<i32>(len: 3, cap: 8) = {5, 3, 7} +// gdb-command: print vec_deque2 +// gdb-check:$4 = VecDeque<i32>(len: 7, cap: 8) = {2, 3, 4, 5, 6, 7, 8} + #![allow(unused_variables)] use std::collections::BTreeSet; use std::collections::BTreeMap; @@ -54,6 +57,14 @@ fn main() { vec_deque.push_back(3); vec_deque.push_back(7); + // VecDeque where an element was popped. + let mut vec_deque2 = VecDeque::new(); + for i in 1..8 { + vec_deque2.push_back(i) + } + vec_deque2.pop_front(); + vec_deque2.push_back(8); + zzz(); // #break } |