From fb151210966ed045c124b7accfb3422d35166607 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Wed, 15 Jan 2014 20:00:05 +0400 Subject: Try printing array range using the name of its index type type Char_Table is array (Character range Character'First .. Character'Last) of Natural; Trying to print the type description of this type currently yields: (gdb) ptype char_table type = array ('["00"]' .. '["ff"]') of natural Although technically correct, it seemed more useful to print the array range as: (gdb) ptype char_table type = array (character) of natural This patch implements this suggestion. gdb/ChangeLog: * ada-typeprint (type_is_full_subrange_of_target_type): New function. (print_range): Add parameter bounds_prefered_p. If not set, try printing range types using the name of their base type. (print_range_type): Add parameter bounds_prefered_p. Use it in call to print_range. (print_array_type, ada_print_type): Update calls to print_range and print_range_type. gdb/testsuite/ChangeLog: * gdb.ada/array_char_idx: New testcase. --- gdb/testsuite/gdb.ada/array_char_idx.exp | 32 ++++++++++++++++++++++++++++ gdb/testsuite/gdb.ada/array_char_idx/foo.adb | 20 +++++++++++++++++ gdb/testsuite/gdb.ada/array_char_idx/pck.adb | 21 ++++++++++++++++++ gdb/testsuite/gdb.ada/array_char_idx/pck.ads | 23 ++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 gdb/testsuite/gdb.ada/array_char_idx.exp create mode 100644 gdb/testsuite/gdb.ada/array_char_idx/foo.adb create mode 100644 gdb/testsuite/gdb.ada/array_char_idx/pck.adb create mode 100644 gdb/testsuite/gdb.ada/array_char_idx/pck.ads (limited to 'gdb/testsuite/gdb.ada') diff --git a/gdb/testsuite/gdb.ada/array_char_idx.exp b/gdb/testsuite/gdb.ada/array_char_idx.exp new file mode 100644 index 0000000..fca84fc --- /dev/null +++ b/gdb/testsuite/gdb.ada/array_char_idx.exp @@ -0,0 +1,32 @@ +# Copyright 2014 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 . + +load_lib "ada.exp" + +if { [skip_ada_tests] } { return -1 } + +standard_ada_testfile foo + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} { + return -1 +} + +clean_restart ${testfile} + +gdb_test "ptype char_table" \ + "= array \\(character\\) of natural" + +gdb_test "ptype global_char_table" \ + "= array \\(character\\) of natural" diff --git a/gdb/testsuite/gdb.ada/array_char_idx/foo.adb b/gdb/testsuite/gdb.ada/array_char_idx/foo.adb new file mode 100644 index 0000000..b1c73d9 --- /dev/null +++ b/gdb/testsuite/gdb.ada/array_char_idx/foo.adb @@ -0,0 +1,20 @@ +-- Copyright 2012-2014 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 . + +With Pck; use Pck; +procedure Foo is +begin + Do_Nothing (Global_Char_Table'Address); +end Foo; diff --git a/gdb/testsuite/gdb.ada/array_char_idx/pck.adb b/gdb/testsuite/gdb.ada/array_char_idx/pck.adb new file mode 100644 index 0000000..8e519fa --- /dev/null +++ b/gdb/testsuite/gdb.ada/array_char_idx/pck.adb @@ -0,0 +1,21 @@ +-- Copyright 2012-2014 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 . + +package body Pck is + procedure Do_Nothing (A : System.Address) is + begin + null; + end Do_Nothing; +end Pck; diff --git a/gdb/testsuite/gdb.ada/array_char_idx/pck.ads b/gdb/testsuite/gdb.ada/array_char_idx/pck.ads new file mode 100644 index 0000000..ec0cd22 --- /dev/null +++ b/gdb/testsuite/gdb.ada/array_char_idx/pck.ads @@ -0,0 +1,23 @@ +-- Copyright 2012-2014 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 . + +with System; +package Pck is + type Char_Table is array (Character range Character'First .. Character'Last) + of Natural; + Global_Char_Table : Char_Table := (others => 0); + + procedure Do_Nothing (A : System.Address); +end Pck; -- cgit v1.1