aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-06-08 13:18:25 -0600
committerTom Tromey <tom@tromey.com>2018-06-26 14:53:17 -0600
commita33ccfc7afd9e32dd310f54d04719efeec8df342 (patch)
tree66b30fdfb22c12b28d36bd7308b74ebec6a3e36c /gdb/testsuite
parente0c547d14ae1d5c06b59178f4b1dd1f5e08b3feb (diff)
downloadgdb-a33ccfc7afd9e32dd310f54d04719efeec8df342.zip
gdb-a33ccfc7afd9e32dd310f54d04719efeec8df342.tar.gz
gdb-a33ccfc7afd9e32dd310f54d04719efeec8df342.tar.bz2
Support ptype/o in Rust
This adds support for ptype/o to the Rust language code. By default, the Rust compiler reorders fields to reduce padding. So, the Rust language code sorts the fields by offset before printing. This may yield somewhat odd-looking results, but it is faithful to "what really happens", and might be useful when doing lower-level debugging. The reordering can be disabled using #[repr(c)]; ptype/o might be more useful in this case. gdb/ChangeLog 2018-06-26 Tom Tromey <tom@tromey.com> PR rust/22574: * typeprint.c (whatis_exp): Allow ptype/o for Rust. * rust-lang.c (rust_print_struct_def): Add podata parameter. Update. (rust_internal_print_type): Add podata parameter. (rust_print_type): Update. gdb/testsuite/ChangeLog 2018-06-26 Tom Tromey <tom@tromey.com> PR rust/22574: * gdb.rust/simple.exp (test_one_slice): Add ptype/o tests. * gdb.rust/simple.rs (struct SimpleLayout): New.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.rust/simple.exp18
-rw-r--r--gdb/testsuite/gdb.rust/simple.rs8
3 files changed, 32 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 73f5545..b2901db 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2018-06-26 Tom Tromey <tom@tromey.com>
+
+ PR rust/22574:
+ * gdb.rust/simple.exp (test_one_slice): Add ptype/o tests.
+ * gdb.rust/simple.rs (struct SimpleLayout): New.
+
2018-06-22 Simon Marchi <simon.marchi@ericsson.com>
* gdb.base/jit-reader.exp (jit_reader_test): Expect spaces in
diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp
index ba90e06..20fe8dd 100644
--- a/gdb/testsuite/gdb.rust/simple.exp
+++ b/gdb/testsuite/gdb.rust/simple.exp
@@ -285,6 +285,24 @@ gdb_test "print parametrized" \
gdb_test "print u" " = simple::Union {f1: -1, f2: 255}"
+gdb_test_sequence "ptype/o Union" "" {
+ "/\\* offset | size \\*/ type = union simple::Union {"
+ "/\\* 1 \\*/ f1: i8,"
+ "/\\* 1 \\*/ f2: u8,"
+ ""
+ " /\\* total size \\(bytes\\): 1 \\*/"
+ " }"
+}
+
+gdb_test_sequence "ptype/o SimpleLayout" "" {
+ "/\\* offset | size \\*/ type = struct simple::SimpleLayout {"
+ "/\\* 0 | 2 \\*/ f1: u16,"
+ "/\\* 2 | 2 \\*/ f2: u16,"
+ ""
+ " /\\* total size \\(bytes\\): 4 \\*/"
+ " }"
+}
+
load_lib gdb-python.exp
if {[skip_python_tests]} {
continue
diff --git a/gdb/testsuite/gdb.rust/simple.rs b/gdb/testsuite/gdb.rust/simple.rs
index e5bbe52..9d89361 100644
--- a/gdb/testsuite/gdb.rust/simple.rs
+++ b/gdb/testsuite/gdb.rust/simple.rs
@@ -85,6 +85,13 @@ union Union {
f2: u8,
}
+// A simple structure whose layout won't be changed by the compiler,
+// so that ptype/o testing will work on any platform.
+struct SimpleLayout {
+ f1: u16,
+ f2: u16
+}
+
fn main () {
let a = ();
let b : [i32; 0] = [];
@@ -159,6 +166,7 @@ fn main () {
};
let u = Union { f2: 255 };
+ let v = SimpleLayout { f1: 8, f2: 9 };
println!("{}, {}", x.0, x.1); // set breakpoint here
println!("{}", diff2(92, 45));