aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@adacore.com>2013-11-07 17:40:48 +0400
committerJoel Brobecker <brobecker@adacore.com>2013-11-12 06:45:29 +0400
commit778865d3e288f4fcf3b293e78d52cd5dacb4b999 (patch)
tree9bc37efb587b92f4e942f94cb9d5d5d07339a04c /gdb/testsuite/gdb.ada
parent304a8ac17c606a83a60a371267daa71ab0bcbc12 (diff)
downloadfsf-binutils-gdb-778865d3e288f4fcf3b293e78d52cd5dacb4b999.zip
fsf-binutils-gdb-778865d3e288f4fcf3b293e78d52cd5dacb4b999.tar.gz
fsf-binutils-gdb-778865d3e288f4fcf3b293e78d52cd5dacb4b999.tar.bz2
Add command to list Ada exceptions
This patch adds a new command "info exceptions" whose purpose is to provide the list of exceptions currently defined in the inferior. The usage is: (gdb) info exceptions [REGEXP] Without argument, the command lists all exceptions. Otherwise, only those whose name match REGEXP are listed. For instance: (gdb) info exceptions All defined Ada exceptions: constraint_error: 0x613dc0 program_error: 0x613d40 storage_error: 0x613d00 tasking_error: 0x613cc0 global_exceptions.a_global_exception: 0x613a80 global_exceptions.a_private_exception: 0x613ac0 The name of the command, as well as its output is part of a legacy I inherited long ago. It's output being parsed by frontends such as GPS, I cannot easily change it. Same for the command name. The implementation is mostly self-contained, and is written in a way that should make it easy to implement the GDB/MI equivalent. The careful reviewer will notice that the code added in ada-lang.h could normally be made private inside ada-lang.c. But these will be used by the GDB/MI implementation. Rather than making those private now, only to move them later, I've made them public right away. gdb/ChangeLog: * ada-lang.h: #include "vec.h". (struct ada_exc_info): New. (ada_exc_info): New typedef. (DEF_VEC_O(ada_exc_info)): New vector. (ada_exceptions_list): Add declaration. * ada-lang.c (ada_is_exception_sym) (ada_is_non_standard_exception_sym, compare_ada_exception_info) (sort_remove_dups_ada_exceptions_list) (ada_exc_search_name_matches, ada_add_standard_exceptions) (ada_add_exceptions_from_frame, ada_add_global_exceptions) (ada_exceptions_list_1, ada_exceptions_list) (info_exceptions_command): New function. (_initialize_ada_language): Add "info exception" command. gdb/testsuite/ChangeLog: * gdb.ada/info_exc: New testcase.
Diffstat (limited to 'gdb/testsuite/gdb.ada')
-rw-r--r--gdb/testsuite/gdb.ada/info_exc.exp57
-rw-r--r--gdb/testsuite/gdb.ada/info_exc/const.ads18
-rw-r--r--gdb/testsuite/gdb.ada/info_exc/foo.adb20
3 files changed, 95 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/info_exc.exp b/gdb/testsuite/gdb.ada/info_exc.exp
new file mode 100644
index 0000000..3ff5180
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_exc.exp
@@ -0,0 +1,57 @@
+# Copyright 2013 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/>.
+
+load_lib "ada.exp"
+
+standard_ada_testfile foo
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
+ return -1
+}
+
+# A convenience function that joins all the arguments together,
+# with a regexp that matches zero-or-more end of lines in between
+# each argument. This function is ideal to write the expected output
+# of a GDB command that generates more than a couple of lines, as
+# this allows us to write each line as a separate string, which is
+# easier to read by a human being.
+
+proc multi_line { args } {
+ return [join $args "\[\r\n\]*"]
+}
+
+clean_restart ${testfile}
+
+gdb_test "info exceptions" \
+ [multi_line "All defined Ada exceptions:" \
+ "constraint_error: $hex" \
+ "program_error: $hex" \
+ "storage_error: $hex" \
+ "tasking_error: $hex" \
+ "const.aint_global_e: $hex"]
+
+gdb_test "info exceptions task" \
+ [multi_line "All Ada exceptions matching regular expression \"task\":" \
+ "tasking_error: $hex"]
+
+gdb_test "info exceptions global" \
+ [multi_line "All Ada exceptions matching regular expression \"global\":" \
+ "const.aint_global_e: $hex"]
+
+gdb_test "info exceptions const.aint" \
+ [multi_line "All Ada exceptions matching regular expression \"const\\.aint\":" \
+ "constraint_error: $hex" \
+ "const.aint_global_e: $hex"]
+
diff --git a/gdb/testsuite/gdb.ada/info_exc/const.ads b/gdb/testsuite/gdb.ada/info_exc/const.ads
new file mode 100644
index 0000000..753241e
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_exc/const.ads
@@ -0,0 +1,18 @@
+-- Copyright 2013 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 Const is
+ Aint_Global_E : exception;
+end Const;
diff --git a/gdb/testsuite/gdb.ada/info_exc/foo.adb b/gdb/testsuite/gdb.ada/info_exc/foo.adb
new file mode 100644
index 0000000..e047db2
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_exc/foo.adb
@@ -0,0 +1,20 @@
+-- Copyright 2013 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 Const; use Const;
+procedure Foo is
+begin
+ raise Aint_Global_E;
+end Foo;