Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix VecDeque pretty-printer #55961

Merged
merged 1 commit into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/etc/gdb_rust_pretty_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,23 @@ def display_hint():
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):
Expand Down
11 changes: 11 additions & 0 deletions src/test/debuginfo/pretty-std-collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
}

Expand Down