From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14499 invoked by alias); 8 Nov 2013 12:05:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 14488 invoked by uid 89); 8 Nov 2013 12:05:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=4.5 required=5.0 tests=AWL,BAYES_99,RDNS_NONE,SPAM_SUBJECT,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: rock.gnat.com Received: from Unknown (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 08 Nov 2013 12:04:02 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 63DD81167AF for ; Fri, 8 Nov 2013 07:04:24 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id IC4cCiLCFe1S for ; Fri, 8 Nov 2013 07:04:24 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id DDC7B1167AA for ; Fri, 8 Nov 2013 07:04:23 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id B0F3FE9984; Fri, 8 Nov 2013 16:03:49 +0400 (RET) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFA/Ada(v2) 2/3] Implement GDB/MI equivalent of "info exceptions" CLI command. Date: Fri, 08 Nov 2013 12:27:00 -0000 Message-Id: <1383912219-13012-3-git-send-email-brobecker@adacore.com> In-Reply-To: <1383912219-13012-1-git-send-email-brobecker@adacore.com> References: <1383912219-13012-1-git-send-email-brobecker@adacore.com> X-SW-Source: 2013-11/txt/msg00233.txt.bz2 This patch implements a new GDB/MI command implementing the equivalent of the "info exceptions" CLI command. The command syntax is: -info-ada-exceptions [REGEXP] Here is an example of usage (slightly formatted by hand to make it easier to read): -info-ada-exceptions ions\.a_ ^done,ada-exceptions= {nr_rows="2",nr_cols="2", hdr=[{width="1",alignment="-1",col_name="name",colhdr="Name"}, {width="1",alignment="-1",col_name="address",colhdr="Address"}], body=[{name="global_exceptions.a_global_exception", address="0x0000000000613a80"}, {name="global_exceptions.a_private_exception", address="0x0000000000613ac0"}]} Also, in order to allow graphical frontends to easily determine whether this command is available or not, the output of the "-list-features" command has been augmented to contain "info-ada-exceptions". gdb/Changelog: * mi/mi-cmds.h (mi_cmd_info_ada_exceptions): Add declaration. * mi/mi-cmds.c (mi_cmds): Add entry for -info-ada-exceptions command. * mi/mi-cmd-info.c: #include "ada-lang.c" and "arch-utils.c". (mi_cmd_info_ada_exceptions): New function. * mi/mi-main.c (mi_cmd_list_features): Add "info-ada-exceptions". gdb/testsuite/ChangeLog: * gdb.ada/mi_exc_info: New testcase. Tested on x86_64-linux. Ok to commit? --- gdb/mi/mi-cmd-info.c | 51 +++++++++++++++++++++++++++++ gdb/mi/mi-cmds.c | 1 + gdb/mi/mi-cmds.h | 1 + gdb/mi/mi-main.c | 1 + gdb/testsuite/gdb.ada/mi_exc_info.exp | 51 +++++++++++++++++++++++++++++ gdb/testsuite/gdb.ada/mi_exc_info/const.ads | 18 ++++++++++ gdb/testsuite/gdb.ada/mi_exc_info/foo.adb | 20 +++++++++++ 7 files changed, 143 insertions(+) create mode 100644 gdb/testsuite/gdb.ada/mi_exc_info.exp create mode 100644 gdb/testsuite/gdb.ada/mi_exc_info/const.ads create mode 100644 gdb/testsuite/gdb.ada/mi_exc_info/foo.adb diff --git a/gdb/mi/mi-cmd-info.c b/gdb/mi/mi-cmd-info.c index 8eb4220..aa4d210 100644 --- a/gdb/mi/mi-cmd-info.c +++ b/gdb/mi/mi-cmd-info.c @@ -19,6 +19,57 @@ #include "defs.h" #include "osdata.h" #include "mi-cmds.h" +#include "ada-lang.h" +#include "arch-utils.h" + +/* Implement the "-info-ada-exceptions" GDB/MI command. */ + +void +mi_cmd_info_ada_exceptions (char *command, char **argv, int argc) +{ + struct ui_out *uiout = current_uiout; + struct gdbarch *gdbarch = get_current_arch (); + char *regexp; + struct cleanup *old_chain; + VEC(ada_exc_info) *exceptions; + int ix; + struct ada_exc_info *info; + + switch (argc) + { + case 0: + regexp = NULL; + break; + case 1: + regexp = argv[0]; + break; + default: + error (_("Usage: -info-ada-exceptions [REGEXP]")); + break; + } + + exceptions = ada_exceptions_list (regexp); + old_chain = make_cleanup (VEC_cleanup (ada_exc_info), &exceptions); + + make_cleanup_ui_out_table_begin_end + (uiout, 2, VEC_length (ada_exc_info, exceptions), "ada-exceptions"); + ui_out_table_header (uiout, 1, ui_left, "name", "Name"); + ui_out_table_header (uiout, 1, ui_left, "address", "Address"); + ui_out_table_body (uiout); + + for (ix = 0; VEC_iterate(ada_exc_info, exceptions, ix, info); ix++) + { + struct cleanup *sub_chain; + + sub_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_field_string (uiout, "name", info->name); + ui_out_field_core_addr (uiout, "address", gdbarch, info->addr); + + do_cleanups (sub_chain); + } + + do_cleanups (old_chain); +} void mi_cmd_info_os (char *command, char **argv, int argc) diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index 1b8ec92..496a8aa 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c @@ -124,6 +124,7 @@ static struct mi_cmd mi_cmds[] = DEF_MI_CMD_CLI ("gdb-version", "show version", 0), DEF_MI_CMD_MI ("inferior-tty-set", mi_cmd_inferior_tty_set), DEF_MI_CMD_MI ("inferior-tty-show", mi_cmd_inferior_tty_show), + DEF_MI_CMD_MI ("info-ada-exceptions", mi_cmd_info_ada_exceptions), DEF_MI_CMD_MI ("info-os", mi_cmd_info_os), DEF_MI_CMD_MI ("interpreter-exec", mi_cmd_interpreter_exec), DEF_MI_CMD_MI ("list-features", mi_cmd_list_features), diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h index bbca54d..cb8aac1 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h @@ -73,6 +73,7 @@ extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_files; extern mi_cmd_argv_ftype mi_cmd_gdb_exit; extern mi_cmd_argv_ftype mi_cmd_inferior_tty_set; extern mi_cmd_argv_ftype mi_cmd_inferior_tty_show; +extern mi_cmd_argv_ftype mi_cmd_info_ada_exceptions; extern mi_cmd_argv_ftype mi_cmd_info_os; extern mi_cmd_argv_ftype mi_cmd_interpreter_exec; extern mi_cmd_argv_ftype mi_cmd_list_features; diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 24ac1e0..bf0fce3 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1815,6 +1815,7 @@ mi_cmd_list_features (char *command, char **argv, int argc) ui_out_field_string (uiout, NULL, "data-read-memory-bytes"); ui_out_field_string (uiout, NULL, "breakpoint-notifications"); ui_out_field_string (uiout, NULL, "ada-task-info"); + ui_out_field_string (uiout, NULL, "info-ada-exceptions"); #if HAVE_PYTHON if (gdb_python_initialized) diff --git a/gdb/testsuite/gdb.ada/mi_exc_info.exp b/gdb/testsuite/gdb.ada/mi_exc_info.exp new file mode 100644 index 0000000..b77ccbc --- /dev/null +++ b/gdb/testsuite/gdb.ada/mi_exc_info.exp @@ -0,0 +1,51 @@ +# 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 . + +load_lib "ada.exp" + +standard_ada_testfile foo + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } { + return -1 +} + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +gdb_exit +if [mi_gdb_start] { + continue +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_gdb_test "-info-ada-exceptions" \ + "\\^done,ada-exceptions={nr_rows=\"5\",nr_cols=\"2\",hdr=\\\[{width=\"1\",alignment=\"-1\",col_name=\"name\",colhdr=\"Name\"},{width=\"1\",alignment=\"-1\",col_name=\"address\",colhdr=\"Address\"}\\\],body=\\\[{name=\"constraint_error\",address=\"$hex\"},{name=\"program_error\",address=\"$hex\"},{name=\"storage_error\",address=\"$hex\"},{name=\"tasking_error\",address=\"$hex\"},{name=\"const.aint_global_e\",address=\"$hex\"}\\\]}" \ + "-info-ada-exceptions" + +mi_gdb_test "-info-ada-exceptions task" \ + "\\^done,ada-exceptions={nr_rows=\"1\",nr_cols=\"2\",hdr=\\\[{width=\"1\",alignment=\"-1\",col_name=\"name\",colhdr=\"Name\"},{width=\"1\",alignment=\"-1\",col_name=\"address\",colhdr=\"Address\"}\\\],body=\\\[{name=\"tasking_error\",address=\"$hex\"}\\\]}" \ + "-info-ada-exceptions task" + +mi_gdb_test "-info-ada-exceptions global" \ + "\\^done,ada-exceptions={nr_rows=\"1\",nr_cols=\"2\",hdr=\\\[{width=\"1\",alignment=\"-1\",col_name=\"name\",colhdr=\"Name\"},{width=\"1\",alignment=\"-1\",col_name=\"address\",colhdr=\"Address\"}\\\],body=\\\[{name=\"const.aint_global_e\",address=\"$hex\"}\\\]}" \ + "-info-ada-exceptions global" + +mi_gdb_test "-info-ada-exceptions const.aint" \ + "\\^done,ada-exceptions={nr_rows=\"2\",nr_cols=\"2\",hdr=\\\[{width=\"1\",alignment=\"-1\",col_name=\"name\",colhdr=\"Name\"},{width=\"1\",alignment=\"-1\",col_name=\"address\",colhdr=\"Address\"}\\\],body=\\\[{name=\"constraint_error\",address=\"$hex\"},{name=\"const.aint_global_e\",address=\"$hex\"}\\\]}" \ + "-info-ada-exceptions const.aint" + diff --git a/gdb/testsuite/gdb.ada/mi_exc_info/const.ads b/gdb/testsuite/gdb.ada/mi_exc_info/const.ads new file mode 100644 index 0000000..753241e --- /dev/null +++ b/gdb/testsuite/gdb.ada/mi_exc_info/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 . + +package Const is + Aint_Global_E : exception; +end Const; diff --git a/gdb/testsuite/gdb.ada/mi_exc_info/foo.adb b/gdb/testsuite/gdb.ada/mi_exc_info/foo.adb new file mode 100644 index 0000000..e047db2 --- /dev/null +++ b/gdb/testsuite/gdb.ada/mi_exc_info/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 . + +with Const; use Const; +procedure Foo is +begin + raise Aint_Global_E; +end Foo; -- 1.8.1.2