Skip to content

Commit d7ef1ac

Browse files
authored
Auto merge of #34639 - dzamlo:master, r=michaelwoerister
Use lazy iterator in vec/slice gdb pretty printers
2 parents e7cf491 + 5de76af commit d7ef1ac

File tree

3 files changed

+79
-7
lines changed

3 files changed

+79
-7
lines changed

Diff for: src/etc/gdb_rust_pretty_printing.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,12 @@ def to_string(self):
211211
("(len: %i)" % length))
212212

213213
def children(self):
214-
cs = []
215214
(length, data_ptr) = rustpp.extract_length_and_ptr_from_slice(self.__val)
216215
assert data_ptr.type.get_dwarf_type_kind() == rustpp.DWARF_TYPE_CODE_PTR
217216
raw_ptr = data_ptr.get_wrapped_value()
218217

219218
for index in range(0, length):
220-
cs.append((str(index), (raw_ptr + index).dereference()))
221-
222-
return cs
219+
yield (str(index), (raw_ptr + index).dereference())
223220

224221

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

247244
def children(self):
248-
cs = []
249245
(length, data_ptr, cap) = rustpp.extract_length_ptr_and_cap_from_std_vec(self.__val)
250246
gdb_ptr = data_ptr.get_wrapped_value()
251247
for index in range(0, length):
252-
cs.append((str(index), (gdb_ptr + index).dereference()))
253-
return cs
248+
yield (str(index), (gdb_ptr + index).dereference())
254249

255250

256251
class RustStdStringPrinter:

Diff for: src/test/debuginfo/pretty-huge-vec.rs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2013-2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// ignore-windows failing on win32 bot
12+
// ignore-freebsd: gdb package too new
13+
// ignore-android: FIXME(#10381)
14+
// compile-flags:-g
15+
// min-gdb-version 7.7
16+
// min-lldb-version: 310
17+
18+
// === GDB TESTS ===================================================================================
19+
20+
// gdb-command: run
21+
22+
// gdb-command: print vec
23+
// gdb-check:$1 = Vec<u8>(len: 1000000000, cap: 1000000000) = {[...]...}
24+
25+
// gdb-command: print slice
26+
// gdb-check:$2 = &[u8](len: 1000000000) = {[...]...}
27+
28+
29+
#![allow(unused_variables)]
30+
31+
fn main() {
32+
33+
// Vec
34+
let mut vec: Vec<u8> = Vec::with_capacity(1_000_000_000);
35+
unsafe{ vec.set_len(1_000_000_000) }
36+
let slice = &vec[..];
37+
38+
zzz(); // #break
39+
}
40+
41+
fn zzz() { () }

Diff for: src/test/debuginfo/pretty-uninitialized-vec.rs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2013-2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// ignore-windows failing on win32 bot
12+
// ignore-freebsd: gdb package too new
13+
// ignore-android: FIXME(#10381)
14+
// compile-flags:-g
15+
// min-gdb-version 7.7
16+
// min-lldb-version: 310
17+
18+
// === GDB TESTS ===================================================================================
19+
20+
// gdb-command: run
21+
22+
// gdb-command: print vec
23+
// gdb-check:$1 = Vec<i32>(len: [...], cap: [...])[...]
24+
25+
26+
#![allow(unused_variables)]
27+
28+
fn main() {
29+
30+
let vec;
31+
zzz(); // #break
32+
vec = vec![0];
33+
34+
}
35+
36+
fn zzz() { () }

0 commit comments

Comments
 (0)