Skip to content

Use lazy iterator in vec/slice gdb pretty printers #34639

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

Merged
merged 1 commit into from
Jul 5, 2016
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
9 changes: 2 additions & 7 deletions src/etc/gdb_rust_pretty_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,12 @@ def to_string(self):
("(len: %i)" % length))

def children(self):
cs = []
(length, data_ptr) = rustpp.extract_length_and_ptr_from_slice(self.__val)
assert data_ptr.type.get_dwarf_type_kind() == rustpp.DWARF_TYPE_CODE_PTR
raw_ptr = data_ptr.get_wrapped_value()

for index in range(0, length):
cs.append((str(index), (raw_ptr + index).dereference()))

return cs
yield (str(index), (raw_ptr + index).dereference())


class RustStringSlicePrinter:
Expand All @@ -245,12 +242,10 @@ def to_string(self):
("(len: %i, cap: %i)" % (length, cap)))

def children(self):
cs = []
(length, data_ptr, cap) = rustpp.extract_length_ptr_and_cap_from_std_vec(self.__val)
gdb_ptr = data_ptr.get_wrapped_value()
for index in range(0, length):
cs.append((str(index), (gdb_ptr + index).dereference()))
return cs
yield (str(index), (gdb_ptr + index).dereference())


class RustStdStringPrinter:
Expand Down
41 changes: 41 additions & 0 deletions src/test/debuginfo/pretty-huge-vec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2013-2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-windows failing on win32 bot
// ignore-freebsd: gdb package too new
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on what that means?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the same ignore-* lines as the pretty-std.rs test, because the tests I added test a similar part of the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's OK then.

// ignore-android: FIXME(#10381)
// compile-flags:-g
// min-gdb-version 7.7
// min-lldb-version: 310

// === GDB TESTS ===================================================================================

// gdb-command: run

// gdb-command: print vec
// gdb-check:$1 = Vec<u8>(len: 1000000000, cap: 1000000000) = {[...]...}

// gdb-command: print slice
// gdb-check:$2 = &[u8](len: 1000000000) = {[...]...}


#![allow(unused_variables)]

fn main() {

// Vec
let mut vec: Vec<u8> = Vec::with_capacity(1_000_000_000);
unsafe{ vec.set_len(1_000_000_000) }
let slice = &vec[..];

zzz(); // #break
}

fn zzz() { () }
36 changes: 36 additions & 0 deletions src/test/debuginfo/pretty-uninitialized-vec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2013-2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-windows failing on win32 bot
// ignore-freebsd: gdb package too new
// ignore-android: FIXME(#10381)
// compile-flags:-g
// min-gdb-version 7.7
// min-lldb-version: 310

// === GDB TESTS ===================================================================================

// gdb-command: run

// gdb-command: print vec
// gdb-check:$1 = Vec<i32>(len: [...], cap: [...])[...]


#![allow(unused_variables)]

fn main() {

let vec;
zzz(); // #break
vec = vec![0];

}

fn zzz() { () }