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 BTreeSet and BTreeMap gdb pretty-printers #56144

Merged
merged 1 commit into from
Nov 25, 2018

Conversation

tromey
Copy link
Contributor

@tromey tromey commented Nov 21, 2018

The BTreeSet and BTreeMap gdb pretty-printers did not take the node
structure into account, and consequently only worked for shallow sets.
This fixes the problem by iterating over child nodes when needed.

This patch avoids the current approach of implementing some of the
value manipulations in debugger-indepdendent code. This was done for
convenience: a type lookup was needed for the first time, and there
currently are no lldb formatters for these types.

Closes #55771

@rust-highfive
Copy link
Collaborator

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 21, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:14e11330:start=1542828866948556325,finish=1542828952978692451,duration=86030136126
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:53:22] .................................................................................................... 100/5043
[00:53:25] .................................................................................................... 200/5043
[00:53:28] .............................ii............................................ii...................ii.. 300/5043
[00:53:31] ..............................................................................................iii... 400/5043
[00:53:34] .....iiiiiiii.iii............................iii...........................................i........ 500/5043
[00:53:41] .................................................................................................... 700/5043
[00:53:47] ..................................................................................i...........i..... 800/5043
[00:53:51] .................................................................................................... 900/5043
[00:53:54] .iiiii..................ii.iiii..................................................................... 1000/5043
---
[00:54:31] .................................................................................................... 2200/5043
[00:54:35] .................................................................................................... 2300/5043
[00:54:39] .................................................................................................... 2400/5043
[00:54:43] .................................................................................................... 2500/5043
[00:54:46] ......................................................................................iiiiiiiii..... 2600/5043
[00:54:54] ....................................................ii.............................................. 2800/5043
[00:54:56] .................................................................................................... 2900/5043
[00:55:01] .................................................................................................... 3000/5043
[00:55:04] ................................................i................................................... 3100/5043
---
travis_time:start:test_codegen
Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:09:38] 
[01:09:38] running 117 tests
[01:09:41] i..ii...iii..iiii.....i...i.........i..iii...........i.....i.....ii...i..i.ii..............i...ii..i 100/117
[01:09:41] i.i.....iiii.....
[01:09:41] 
[01:09:41]  finished in 3.630
[01:09:41] travis_fold:end:test_codegen

---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:09:57] 
[01:09:57] running 118 tests
[01:10:22] .iiiii...i.....i..i...i..i.i..i.i..i.....i..i....i..........iiii.........i.i...Fi...i.......ii.i.i.i 100/118
[01:10:26] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:503:22
[01:10:26] ......iii.i.....ii
[01:10:26] 
[01:10:26] ---- [debuginfo-both] debuginfo/pretty-std-collections.rs stdout ----
[01:10:26] ---- [debuginfo-both] debuginfo/pretty-std-collections.rs stdout ----
[01:10:26] NOTE: compiletest thinks it is using GDB without native rust support
[01:10:26] NOTE: compiletest thinks it is using GDB version 7011001
[01:10:26] 
[01:10:26] error: line not found in debugger output: $1 = BTreeSet<i32>(len: 15) = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}
[01:10:26] status: exit code: 0
[01:10:26] command: "/usr/bin/gdb" "-quiet" "-batch" "-nx" "-command=/checkout/obj/build/x86_64-unknown-linux-gnu/test/debuginfo/pretty-std-collections/pretty-std-collections.debugger.script"
[01:10:26] ------------------------------------------
[01:10:26] GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
[01:10:26] Copyright (C) 2016 Free Software Foundation, Inc.
[01:10:26] Copyright (C) 2016 Free Software Foundation, Inc.
[01:10:26] License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[01:10:26] This is free software: you are free to change and redistribute it.
[01:10:26] There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[01:10:26] and "show warranty" for details.
[01:10:26] This GDB was configured as "x86_64-linux-gnu".
[01:10:26] Type "show configuration" for configuration details.
[01:10:26] For bug reporting instructions, please see:
[01:10:26] <http://www.gnu.org/software/gdb/bugs/>.
[01:10:26] Find the GDB manual and other documentation resources online at:
[01:10:26] <http://www.gnu.org/software/gdb/documentation/>.
[01:10:26] For help, type "help".
[01:10:26] Type "apropos word" to search for commands related to "word".
[01:10:26] Breakpoint 1 at 0x1380a: file /checkout/src/test/debuginfo/pretty-std-collections.rs, line 58.
[01:10:26] [Thread debugging using libthread_db enabled]
[01:10:26] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[01:10:26] 
[01:10:26] Breakpoint 1, pretty_std_collections::main::h8f4e9a7b836baf63 () at /checkout/src/test/debuginfo/pretty-std-collections.rs:58
[01:10:26] 58     zzz(); // #break
[01:10:26] $1 = BTreeSet<i32>(len: 15)
[01:10:26] $2 = BTreeMap<i32, i32>(len: 15)
[01:10:26] $3 = VecDeque<i32>(len: 3, cap: 8) = {5, 3, 7}
[01:10:26] A debugging session is active.
[01:10:26] 
[01:10:26]  Inferior 1 [process 3868] will be killed.
[01:10:26] 
[01:10:26] Quit anyway? (y or n) [answered Y; input not from terminal]
[01:10:26] ------------------------------------------
[01:10:26] stderr:
[01:10:26] ------------------------------------------
[01:10:26] ------------------------------------------
[01:10:26] Python Exception <class 'TypeError'> 'gdb.Value' object cannot be interpreted as an integer: 
[01:10:26] Python Exception <class 'TypeError'> 'gdb.Value' object cannot be interpreted as an integer: 
[01:10:26] ------------------------------------------
[01:10:26] 
[01:10:26] thread '[debuginfo-both] debuginfo/pretty-std-collections.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[01:10:26] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[01:10:26] test result: FAILED. 81 passed; 1 failed; 36 ignored; 0 measured; 0 filtered out
[01:10:26] 
[01:10:26] 
[01:10:26] 
[01:10:26] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/debuginfo" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/debuginfo" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "debuginfo-both" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "5.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:10:26] 
[01:10:26] 
[01:10:26] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:10:26] Build completed unsuccessfully in 0:21:07
[01:10:26] Build completed unsuccessfully in 0:21:07
[01:10:26] make: *** [check] Error 1
[01:10:26] Makefile:58: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:03299408
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Wed Nov 21 20:46:28 UTC 2018

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@tromey
Copy link
Contributor Author

tromey commented Nov 21, 2018

Bah, the long-fixed https://sourceware.org/bugzilla/show_bug.cgi?id=17386.

The BTreeSet and BTreeMap gdb pretty-printers did not take the node
structure into account, and consequently only worked for shallow sets.
This fixes the problem by iterating over child nodes when needed.

This patch avoids the current approach of implementing some of the
value manipulations in debugger-indepdendent code.  This was done for
convenience: a type lookup was needed for the first time, and there
currently are no lldb formatters for these types.

Closes rust-lang#55771
@tromey
Copy link
Contributor Author

tromey commented Nov 21, 2018

This version adds an int() cast to work around the problem.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Nov 21, 2018

📌 Commit d4ee1c9 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 21, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Nov 25, 2018
…ichton

Fix BTreeSet and BTreeMap gdb pretty-printers

The BTreeSet and BTreeMap gdb pretty-printers did not take the node
structure into account, and consequently only worked for shallow sets.
This fixes the problem by iterating over child nodes when needed.

This patch avoids the current approach of implementing some of the
value manipulations in debugger-indepdendent code.  This was done for
convenience: a type lookup was needed for the first time, and there
currently are no lldb formatters for these types.

Closes rust-lang#55771
bors added a commit that referenced this pull request Nov 25, 2018
Rollup of 14 pull requests

Successful merges:

 - #56024 (Don't auto-inline const functions)
 - #56045 (Check arg/ret sizedness at ExprKind::Path)
 - #56072 (Stabilize macro_literal_matcher)
 - #56075 (Encode a custom "producers" section in wasm files)
 - #56100 (generator fields are not necessarily initialized)
 - #56101 (Incorporate `dyn` into more comments and docs.)
 - #56144 (Fix BTreeSet and BTreeMap gdb pretty-printers)
 - #56151 (Move a flaky process test out of libstd)
 - #56170 (Fix self profiler ICE on Windows)
 - #56176 (Panic setup msg)
 - #56204 (Suggest correct enum variant on typo)
 - #56207 (Stabilize the int_to_from_bytes feature)
 - #56210 (read_c_str should call the AllocationExtra hooks)
 - #56211 ([master] Forward-ports from beta)

Failed merges:

r? @ghost
@bors bors merged commit d4ee1c9 into rust-lang:master Nov 25, 2018
@tromey tromey deleted the Bug-55771-btreemap branch November 26, 2018 15:26
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 22, 2020
…Mark-Simulacrum

Test gdb pretty printing more and fix overzealous type substitution

Adresses a problem concerning printing BTreeMap / BTreeSet data in gdb: when the key or value type name contains substring "LeafNode", and the map has multiple nodes (e.g. more than 11 elements), printing causes an exception. E.g.

```
rustc -g - <<EOF
    use std::collections::BTreeMap;

    struct MyLeafNode(i8);

    fn main() {
        let m: BTreeMap<i8, MyLeafNode> = (0..12).map(|i| (i, MyLeafNode(i))).collect();
        assert!(!m.is_empty());
    }
EOF
```

```
$ rust-gdb rust_out
(gdb) b 7
(gdb) r
(gdb) p m
$1 = BTreeMap<i8, rust_out::MyLeafNode>(len: 12)Python Exception <class 'gdb.error'> No type named alloc::collections::btree::node::InternalNode<i8, rust_out::MyInternalNode>.:
use std::collections::BTreeMap;
```

The code was written in rust-lang#56144 by @tromey (and later touched upon by @RalfJung in rust-lang#57045, but I think that had nothing to do with the issues in this PR).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gdb BTreeMap pretty printer is incorrect
4 participants