+2019-12-10 Tom Tromey <tromey@adacore.com>
+
+ * ada-typeprint.c (print_choices): Use a single "?".
+ (print_variant_part): Print "?" if the discriminant name
+ is not known.
+
2019-12-10 George Barrett <bob@bob131.so>
Fix scripted probe breakpoints.
}
Huh:
- fprintf_filtered (stream, "?? =>");
+ fprintf_filtered (stream, "? =>");
return 0;
}
struct ui_file *stream, int show, int level,
const struct type_print_options *flags)
{
- fprintf_filtered (stream, "\n%*scase %s is", level + 4, "",
- ada_variant_discrim_name
- (TYPE_FIELD_TYPE (type, field_num)));
+ const char *variant
+ = ada_variant_discrim_name (TYPE_FIELD_TYPE (type, field_num));
+ if (*variant == '\0')
+ variant = "?";
+
+ fprintf_filtered (stream, "\n%*scase %s is", level + 4, "", variant);
print_variant_clauses (type, field_num, outer_type, stream, show,
level + 4, flags);
fprintf_filtered (stream, "\n%*send case;", level + 4, "");
+2019-12-10 Tom Tromey <tromey@adacore.com>
+
+ * gdb.ada/unchecked_union.exp: New file.
+ * gdb.ada/unchecked_union/pck.adb: New file.
+ * gdb.ada/unchecked_union/pck.ads: New file.
+ * gdb.ada/unchecked_union/unchecked_union.adb: New file.
+ * gdb-utils.exp (string_to_regexp): Also quote "?".
+
2019-12-10 George Barrett <bob@bob131.so>
Test scripted probe breakpoints.
--- /dev/null
+# Copyright 2019 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 ptype of an unchecked union.
+
+load_lib "ada.exp"
+
+standard_ada_testfile unchecked_union
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "BREAK" ${testdir}/unchecked_union.adb]
+runto "unchecked_union.adb:$bp_location"
+
+proc multi_line_string {str} {
+ set result {}
+ foreach line [split $str \n] {
+ lappend result [string_to_regexp $line]
+ }
+ return [eval multi_line $result]
+}
+
+set inner_string { case ? is
+ when ? =>
+ small: range 0 .. 255;
+ when ? =>
+ large: range 255 .. 510;
+ end case;
+}
+set inner_full "type = record (?) is\n${inner_string}end record"
+
+set pair_string { case ? is
+ when ? =>
+ field_one: range 0 .. 255;
+ when ? =>
+ field_two: range 255 .. 510;
+ end case;
+}
+set pair_full "type = record\n${inner_string}${pair_string}end record"
+
+gdb_test "ptype Pair" [multi_line_string $pair_full]
+gdb_test "ptype Inner" [multi_line_string $inner_full]
--- /dev/null
+-- Copyright 2019 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/>.
+
+package body Pck is
+ procedure Do_Nothing (A : System.Address) is
+ begin
+ null;
+ end Do_Nothing;
+end Pck;
--- /dev/null
+-- Copyright 2019 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/>.
+
+with System;
+package Pck is
+ procedure Do_Nothing (A : System.Address);
+end Pck;
--- /dev/null
+-- Copyright 2019 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/>.
+
+with System;
+with Pck; use Pck;
+
+procedure Foo is
+ type Key is (Alpha, Omega);
+
+ type Inner(Disc : Key := Omega) is record
+ case Disc is
+ when Alpha =>
+ Small : Integer range 0..255;
+ when others =>
+ Large : Integer range 255..510;
+ end case;
+ end record;
+ pragma Unchecked_Union (Inner);
+
+ type Outer(Disc : Key := Alpha) is record
+ case Disc is
+ when Alpha =>
+ Field_One : Integer range 0..255;
+ when others =>
+ Field_Two : Integer range 255..510;
+ end case;
+ end record;
+ pragma Unchecked_Union (Outer);
+
+ type Pair is record
+ Pone : Inner;
+ Ptwo : Outer;
+ end record;
+
+ Value : Pair;
+
+begin
+ Do_Nothing (Value'Address); -- BREAK
+end Foo;
proc string_to_regexp {str} {
set result $str
- regsub -all {[]*+.|(){}^$\[\\]} $str {\\&} result
+ regsub -all {[]?*+.|(){}^$\[\\]} $str {\\&} result
return $result
}