]> git.lizzy.rs Git - rust.git/blob - tests/debuginfo/embedded-visualizer.rs
Auto merge of #106646 - Amanieu:ilp32-object, r=Mark-Simulacrum
[rust.git] / tests / debuginfo / embedded-visualizer.rs
1 // compile-flags:-g
2 // min-gdb-version: 8.1
3 // ignore-lldb
4
5 // === CDB TESTS ==================================================================================
6
7 // cdb-command: g
8
9 // The .nvlist command in cdb does not always have a deterministic output
10 // for the order that NatVis files are displayed.
11
12 // cdb-command: .nvlist
13 // cdb-check:    [...].exe (embedded NatVis "[...]embedded_visualizer-0.natvis")
14
15 // cdb-command: .nvlist
16 // cdb-check:    [...].exe (embedded NatVis "[...]embedded_visualizer-1.natvis")
17
18 // cdb-command: .nvlist
19 // cdb-check:    [...].exe (embedded NatVis "[...]embedded_visualizer-2.natvis")
20
21 // cdb-command: dx point_a
22 // cdb-check:point_a          : (0, 0) [Type: embedded_visualizer::point::Point]
23 // cdb-check:    [<Raw View>]     [Type: embedded_visualizer::point::Point]
24 // cdb-check:    [x]              : 0 [Type: int]
25 // cdb-check:    [y]              : 0 [Type: int]
26
27 // cdb-command: dx point_b
28 // cdb-check:point_b          : (5, 8) [Type: embedded_visualizer::point::Point]
29 // cdb-check:    [<Raw View>]     [Type: embedded_visualizer::point::Point]
30 // cdb-check:    [x]              : 5 [Type: int]
31 // cdb-check:    [y]              : 8 [Type: int]
32
33 // cdb-command: dx line
34 // cdb-check:line             : ((0, 0), (5, 8)) [Type: embedded_visualizer::Line]
35 // cdb-check:    [<Raw View>]     [Type: embedded_visualizer::Line]
36 // cdb-check:    [a]              : (0, 0) [Type: embedded_visualizer::point::Point]
37 // cdb-check:    [b]              : (5, 8) [Type: embedded_visualizer::point::Point]
38
39 // cdb-command: dx person
40 // cdb-check:person           : "Person A" is 10 years old. [Type: dependency_with_embedded_visualizers::Person]
41 // cdb-check:    [<Raw View>]     [Type: dependency_with_embedded_visualizers::Person]
42 // cdb-check:    [name]           : "Person A" [Type: alloc::string::String]
43 // cdb-check:    [age]            : 10 [Type: int]
44
45 // === GDB TESTS ===================================================================================
46
47 // gdb-command: run
48
49 // gdb-command: info auto-load python-scripts
50 // gdb-check:Yes     pretty-printer-embedded_visualizer-0
51 // gdb-check:Yes     pretty-printer-embedded_visualizer-1
52 // gdb-command: print point_a
53 // gdb-check:$1 = (0, 0)
54 // gdb-command: print point_b
55 // gdb-check:$2 = (5, 8)
56 // gdb-command: print line
57 // gdb-check:$3 = ((0, 0), (5, 8))
58 // gdb-command: print person
59 // gdb-check:$4 = "Person A" is 10 years old.
60
61 #![allow(unused_variables)]
62 #![feature(debugger_visualizer)]
63 #![debugger_visualizer(natvis_file = "embedded-visualizer.natvis")]
64 #![debugger_visualizer(gdb_script_file = "embedded-visualizer.py")]
65
66 // aux-build: dependency-with-embedded-visualizers.rs
67 extern crate dependency_with_embedded_visualizers;
68
69 use dependency_with_embedded_visualizers::Person;
70
71 #[debugger_visualizer(natvis_file = "embedded-visualizer-point.natvis")]
72 #[debugger_visualizer(gdb_script_file = "embedded-visualizer-point.py")]
73 mod point {
74     pub struct Point {
75         x: i32,
76         y: i32,
77     }
78
79     impl Point {
80         pub fn new(x: i32, y: i32) -> Point {
81             Point { x: x, y: y }
82         }
83     }
84 }
85
86 use point::Point;
87
88 pub struct Line {
89     a: Point,
90     b: Point,
91 }
92
93 impl Line {
94     pub fn new(a: Point, b: Point) -> Line {
95         Line { a: a, b: b }
96     }
97 }
98
99 fn main() {
100     let point_a = Point::new(0, 0);
101     let point_b = Point::new(5, 8);
102     let line = Line::new(point_a, point_b);
103
104     let name = String::from("Person A");
105     let person = Person::new(name, 10);
106
107     zzz(); // #break
108 }
109
110 fn zzz() {
111     ()
112 }