+2021-05-14 Tom Tromey <tom@tromey.com>
+
+ * rust-lang.c (rust_language::val_print_struct)
+ (rust_language::print_enum): Use common_val_print, not
+ value_print_inner.
+
2021-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* python/py-inferior.c (infpy_get_connection_num): New function.
fputs_filtered (": ", stream);
}
- value_print_inner (value_field (val, i), stream, recurse + 1, &opts);
+ common_val_print (value_field (val, i), stream, recurse + 1, &opts,
+ this);
}
if (options->prettyformat)
styled_string (variable_name_style.style (),
TYPE_FIELD_NAME (variant_type, j)));
- value_print_inner (value_field (val, j), stream, recurse + 1, &opts);
+ common_val_print (value_field (val, j), stream, recurse + 1, &opts,
+ this);
}
if (is_tuple)
+2021-05-14 Tom Tromey <tom@tromey.com>
+
+ * gdb.rust/pp.exp: New file.
+ * gdb.rust/pp.py: New file.
+ * gdb.rust/pp.rs: New file.
+
2021-05-14 Bernd Edlinger <bernd.edlinger@hotmail.de>
* gdb.base/index-cache.exp: Cleanup $cache_dir/*.gdb-index and
--- /dev/null
+# Copyright (C) 2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test expression parsing and evaluation that requires Rust compiler.
+
+load_lib gdb-python.exp
+load_lib rust-support.exp
+if {[skip_rust_tests]} {
+ continue
+}
+
+standard_testfile .rs
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
+ return -1
+}
+
+if { [skip_python_tests] } { continue }
+
+set remote_python_file [gdb_remote_download host \
+ ${srcdir}/${subdir}/${testfile}.py]
+gdb_test_no_output "source ${remote_python_file}" "load python file"
+
+set line [gdb_get_line_number "set breakpoint here"]
+if {![runto ${srcfile}:$line]} {
+ untested "could not run to breakpoint"
+ return -1
+}
+
+gdb_test "print outer" " = pp::Outer \\(x\\(5\\)\\)"
+gdb_test "print outer.0" " = x\\(5\\)"
--- /dev/null
+# Copyright (C) 2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite. It tests python pretty
+# printers.
+
+import re
+import gdb
+
+
+# Printer for Inner.
+class inner_print(object):
+ def __init__(self, val):
+ self.val = val
+
+ def to_string(self):
+ return "x(" + str(self.val["x"]) + ")"
+
+
+def lookup_function(val):
+ "Look-up and return a pretty-printer that can print val."
+
+ # Get the type.
+ type = val.type
+
+ # Get the type name.
+ typename = type.tag
+
+ if typename == None:
+ return None
+
+ if typename == "pp::Inner":
+ return inner_print(val)
+ return None
+
+
+gdb.pretty_printers.append(lookup_function)
--- /dev/null
+// Copyright (C) 2021 Free Software Foundation, Inc.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#![allow(dead_code)]
+#![allow(unused_variables)]
+#![allow(unused_assignments)]
+
+struct Inner{ x : u8 }
+struct Outer(Inner);
+
+fn main () {
+ let outer = Outer(Inner{x: 5});
+ println!("{}", outer.0.x); // set breakpoint here
+}