From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 38603 invoked by alias); 3 Jan 2018 16:30:56 -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 37775 invoked by uid 89); 3 Jan 2018 16:30:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT autolearn=ham version=3.3.2 spammy=actions X-HELO: sessmg23.ericsson.net Received: from sessmg23.ericsson.net (HELO sessmg23.ericsson.net) (193.180.251.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 03 Jan 2018 16:30:52 +0000 Received: from ESESSHC020.ericsson.se (Unknown_Domain [153.88.183.78]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id 4C.D3.31026.9350D4A5; Wed, 3 Jan 2018 17:30:49 +0100 (CET) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.78) with Microsoft SMTP Server (TLS) id 14.3.352.0; Wed, 3 Jan 2018 17:30:48 +0100 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from [142.133.60.216] (192.75.88.130) by DBXPR07MB320.eurprd07.prod.outlook.com (2a01:111:e400:941d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.4; Wed, 3 Jan 2018 16:30:46 +0000 Subject: Re: [RFA] (Ada) Add gdb-mi support for stopping at start of exception handler. To: Xavier Roirand , CC: References: <1514977774-30677-1-git-send-email-roirand@adacore.com> From: Simon Marchi Message-ID: <0050dd92-343b-0b77-04ea-c98dd8f9f246@ericsson.com> Date: Wed, 03 Jan 2018 16:30:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1514977774-30677-1-git-send-email-roirand@adacore.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MWHPR2201CA0053.namprd22.prod.outlook.com (2603:10b6:301:16::27) To DBXPR07MB320.eurprd07.prod.outlook.com (2a01:111:e400:941d::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0a4e7a89-03bd-454f-a494-08d552c7580b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060);SRVR:DBXPR07MB320; X-Microsoft-Exchange-Diagnostics: 1;DBXPR07MB320;3:0Xbbi0+svn8HHqPWKgx7UDOT3mBdmbIFTa0oeadELT55TEZTGfbxKgTCEIQmCgFUaHQcehKaT9yRBeN+Qw4V8cWj+Yyu2NKHB22KDTVccl6wuU/Ll7L7cfYkUEyH6wC9NC88RzTZ1K+8r3dq46/sc7Ll+E2orijBRfAUtmc1sOM9GUoyrqtinmvbMcjE5uZvjliY4gPtnRn3njion5zIFzPaxijF7Cvt0fX1mXmC7+Ap0Kegz3yI6+grud4ajiAG;25:DZQNQFFLcnDmwgGjUDqhTSrcYmW3ifoNY1o8Nj0A9eZ26jIUwukQn+eRZbrCMtedC34sRq2XFGB7vfEPNHcud1mSTpaLDkLG7firp+Wj5D2QMIHtK016mCk9Ay4EijPBk0iYFbdv0cwAskCKJuvHLbJ4KzInQGOJrMoFnN2ZrTrPRegPPYVmyFsqQgHRBkQUKQbeKjQ1lnIXDQS0CnR57gP/66KBQCENxc16c0VzUzJPmn/crDWxeD0zsMY9UROIZL/nOD09Whiq3eqFXxjU78ObsrUsGsVuQLCR2lmlLyo2i1H3eaXZdWBgCKkGM2saMdKQpT5tuVa4R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K3raqqChAywcZ9IBZGn3oUl5IujU9fKXJp9g8Kvt9Yv4U5OCZEbXT9d0yx0pc16v/s9Z/8//MRMpB5PxfdxP+atxvfLvWe0V5d8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(3231023)(944501075)(10201501046)(93006095)(93001095)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011);SRVR:DBXPR07MB320;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:DBXPR07MB320; X-Forefront-PRVS: 0541031FF6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(979002)(6049001)(366004)(396003)(39380400002)(346002)(39860400002)(376002)(377424004)(199004)(189003)(24454002)(54534003)(105586002)(31686004)(106356001)(49976008)(65806001)(66066001)(2486003)(76176011)(31696002)(23676004)(59450400001)(36756003)(25786009)(4326008)(52146003)(52116002)(305945005)(53546011)(478600001)(386003)(58126008)(47776003)(6246003)(8936002)(65956001)(7736002)(16526018)(81166006)(6306002)(64126003)(16576012)(68736007)(81156014)(97736004)(316002)(53936002)(230700001)(2950100002)(83506002)(65826007)(8676002)(50466002)(6486002)(6666003)(575784001)(86362001)(2906002)(229853002)(5660300001)(3846002)(6116002)(78286006)(2004002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:DBXPR07MB320;H:[142.133.60.216];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQlhQUjA3TUIzMjA7MjM6SFN0bWhramJjZUdKZzhVOU1ZY2FKaDlXYVFm?= =?utf-8?B?ekttdnBRdTV6M1N1TEdx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tO+RIja2Uk5S4+vvxBr+70BJO88a+KLJRMPQ86pecVHZ86TfIjvuzND8DwbNfVH4yx0XsBEUZTA3R5t/yWY6hVXR1EDqUQUt2mJupjIuznoFlGKKSHkwOAGzYDjc7v00/Z1dJtOAYUcf+DJvfPsmKVanTsxDF999HWiT3F46V28AadY9s/EsD/c5Oe9ls3sBZcm6nwG2+Y2quppB7V9es SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2018 16:30:46.1139 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a4e7a89-03bd-454f-a494-08d552c7580b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR07MB320 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg00031.txt.bz2 On 2018-01-03 06:09 AM, Xavier Roirand wrote: > Following my previous commit which add support for stopping at start of > exception handler, this commit adds required gdb-mi support for this > feature. Hi Xavier, This patch would need to update the documentation, and probably add a NEWS entry (I always forget those too). I would like to try running the test, but I am not able to catch handlers with my setup, I get the "Your Ada runtime appears to be missing some debugging information" message. I am on Ubuntu 16.04, do you know how to set up the environment on that distro to get it working, is it just a matter of installing the right package? Right now I have the gnat-5 package installed, from the xenial-updates official repository. I have a few comments below, nothing big. > gdb/ChangeLog: > > * mi-cmd-catch.c (mi_cmd_catch_handlers): New function. > * mi-cmds.c (struct mi_cmds): Add catch-handlers command. > * mi-cmds.h (mi_cmd_catch_handlers): Add external declaration. > > gdb/testsuite/ChangeLog: > * gdb.ada/mi_catch_ex_hand.exp: New testcase. There's a new .adb file too, you should mention it. > > Tested on x86_64-linux. > --- > gdb/mi/mi-cmd-catch.c | 73 +++++++++++++ > gdb/mi/mi-cmds.c | 2 + > gdb/mi/mi-cmds.h | 1 + > gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp | 141 +++++++++++++++++++++++++ > gdb/testsuite/gdb.ada/mi_catch_ex_hand/foo.adb | 33 ++++++ > 5 files changed, 250 insertions(+) > create mode 100644 gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp > create mode 100644 gdb/testsuite/gdb.ada/mi_catch_ex_hand/foo.adb > > diff --git a/gdb/mi/mi-cmd-catch.c b/gdb/mi/mi-cmd-catch.c > index 9c103d2..964b1a8 100644 > --- a/gdb/mi/mi-cmd-catch.c > +++ b/gdb/mi/mi-cmd-catch.c > @@ -167,6 +167,79 @@ mi_cmd_catch_exception (const char *cmd, char *argv[], int argc) > temp, enabled, 0); > } > > +/* Handler for the -catch-handlers command. */ > + > +void > +mi_cmd_catch_handlers (const char *cmd, char *argv[], int argc) > +{ > + struct gdbarch *gdbarch = get_current_arch(); Space before (). > + char *condition = NULL; > + int enabled = 1; > + char *exception_name = NULL; > + int temp = 0; > + enum ada_exception_catchpoint_kind ex_kind = ada_catch_handlers; > + > + int oind = 0; > + char *oarg; > + > + enum opt > + { > + OPT_CONDITION, OPT_DISABLED, OPT_EXCEPTION_NAME, OPT_TEMP, > + OPT_UNHANDLED, I think unhandled is unused in the context of this function. > + }; > + static const struct mi_opt opts[] = > + { > + { "c", OPT_CONDITION, 1}, > + { "d", OPT_DISABLED, 0 }, > + { "e", OPT_EXCEPTION_NAME, 1 }, > + { "t", OPT_TEMP, 0 }, > + { "u", OPT_UNHANDLED, 0},> + { 0, 0, 0 } > + }; > + > + for (;;) > + { > + int opt = mi_getopt ("-catch-handlers", argc, argv, opts, > + &oind, &oarg); > + > + if (opt < 0) > + break; > + > + switch ((enum opt) opt) > + { > + case OPT_CONDITION: > + condition = oarg; > + break; > + case OPT_DISABLED: > + enabled = 0; > + break; > + case OPT_EXCEPTION_NAME: > + exception_name = oarg; > + break; > + case OPT_TEMP: > + temp = 1; > + break; > + } > + } > + > + /* This command does not accept any argument. Make sure the user > + did not provide any. */ > + if (oind != argc) > + error (_("Invalid argument: %s"), argv[oind]); > + > + scoped_restore restore_breakpoint_reporting > + = setup_breakpoint_reporting (); > + /* create_ada_exception_catchpoint needs EXCEPTION_NAME and CONDITION > + to be xstrdup'ed, and will assume control of their lifetime. */ > + if (exception_name != NULL) > + exception_name = xstrdup (exception_name); > + if (condition != NULL) > + condition = xstrdup (condition); > + create_ada_exception_catchpoint (gdbarch, ex_kind, > + exception_name, condition, > + temp, enabled, 0); > +} > + > /* Common path for the -catch-load and -catch-unload. */ > > static void > diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c > index 18f6653..310be51 100644 > --- a/gdb/mi/mi-cmds.c > +++ b/gdb/mi/mi-cmds.c > @@ -69,6 +69,8 @@ static struct mi_cmd mi_cmds[] = > &mi_suppress_notification.breakpoint), > DEF_MI_CMD_MI_1 ("catch-exception", mi_cmd_catch_exception, > &mi_suppress_notification.breakpoint), > + DEF_MI_CMD_MI_1 ("catch-handlers", mi_cmd_catch_handlers, > + &mi_suppress_notification.breakpoint), > DEF_MI_CMD_MI_1 ("catch-load", mi_cmd_catch_load, > &mi_suppress_notification.breakpoint), > DEF_MI_CMD_MI_1 ("catch-unload", mi_cmd_catch_unload, > diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h > index 03a11c0..52785e9 100644 > --- a/gdb/mi/mi-cmds.h > +++ b/gdb/mi/mi-cmds.h > @@ -41,6 +41,7 @@ extern mi_cmd_argv_ftype mi_cmd_break_passcount; > extern mi_cmd_argv_ftype mi_cmd_break_watch; > extern mi_cmd_argv_ftype mi_cmd_catch_assert; > extern mi_cmd_argv_ftype mi_cmd_catch_exception; > +extern mi_cmd_argv_ftype mi_cmd_catch_handlers; > extern mi_cmd_argv_ftype mi_cmd_catch_load; > extern mi_cmd_argv_ftype mi_cmd_catch_unload; > extern mi_cmd_argv_ftype mi_cmd_disassemble; > diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp b/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp > new file mode 100644 > index 0000000..544e0d8 > --- /dev/null > +++ b/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp > @@ -0,0 +1,141 @@ > +# Copyright 2011-2018 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 additional_flags=-gnata ]] != "" } { > + return -1 > +} > + > +# Some global variables used to simplify the maintenance of some of > +# the regular expressions below. > +set any_nb "\[0-9\]+" There is $decimal that is defined to the same thing as any_nb by Dejagnu. I would suggest using that instead (especially since you already use it in this test). > +set eol "\[\r\n\]+" > + > +# Before going any further, verify that we can insert exception > +# handlers catchpoints... That way, we won't have to do this while > +# doing the actual GDB/MI testing. > + > +clean_restart ${testfile} > + > +if ![runto_main] then { > + fail "cannot run to main, testcase aborted" > + return 0 > +} > + > +set msg "insert catchpoint on all Ada exceptions handlers" > +gdb_test_multiple "catch handlers" $msg { > + -re "Catchpoint $any_nb: all Ada exceptions handlers$eol$gdb_prompt $" { > + pass $msg > + } > + -re "Your Ada runtime appears to be missing some debugging information.*\[\r\n\]+$gdb_prompt $" { > + # If the runtime was not built with enough debug information, > + # or if it was stripped, we can not test exception > + # catchpoints. > + unsupported $msg > + return -1 > + } > +} > + > +# Now, we can start the GDB/MI testing itself... > + > +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} These last three actions are done in mi_run_to_main, so you can remove them. > + > +############################################# > +# 1. Try catching all exceptions handlers. # > +############################################# > + > +if ![mi_run_to_main] then { > + fail "cannot run to main, testcase aborted" > + return 0 > +} > + > +mi_gdb_test "-catch-handlers" \ > + "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",addr=\"$hex\",what=\"all Ada exceptions handlers\",.*}" \ > + "catch all exceptions handlers" > + > +# Continue to exception handler. > + > +proc continue_to_exception_handler { test line } { > + global hex any_nb > + > + mi_send_resuming_command "exec-continue" "$test" > + > + # Now MI stream output. > + mi_expect_stop \ > + "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"exception\"?" \ > + "foo" "" ".*" "$line" \ > + ".*" \ > + $test > +} > + > +# We don't have the exception name info when stopping at the exception handlers > +# breakpoint so we use source line to check if the inferior stops at the > +# right location. > + > +set bp_ce_location [gdb_get_line_number "BREAK1" ${testdir}/foo.adb] > +continue_to_exception_handler \ > + "continue until CE handling caught by all-exceptions handlers catchpoint" \ > + "$bp_ce_location" > + > +set bp_pe_location [gdb_get_line_number "BREAK2" ${testdir}/foo.adb] > +continue_to_exception_handler \ > + "continue until PE handling caught by all-exceptions handlers catchpoint" \ > + "$bp_pe_location" > + > +########################################################## > +# 2. Try catching only some of the exceptions handlers. # > +########################################################## > + > +# Here is the scenario: > +# - Restart the debugger from scratch, runto_main > +# - We'll catch only "Constraint_Error handlers" > +# - continue, we should stop at the Constraint_Error exception handler > +# - continue, we should not stop at the Program_Error exception handler > +# but exits instead. exits -> exit > + > +if ![mi_run_to_main] then { > + fail "cannot run to main, testcase aborted" > + return 0 > +} > + > +mi_gdb_test "-catch-handlers -e Constraint_Error" \ > + "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",addr=\"$hex\",what=\"`Constraint_Error' Ada exception handlers\",.*}" \ > + "catch Constraint_Error" > + > +mi_execute_to "exec-continue" \ > + "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"exception\"?" \ > + "foo" "" ".*" "$bp_ce_location" \ > + ".*" \ > + "continue to exception catchpoint hit" > + > +# Exit the inferior. > +mi_send_resuming_command "exec-continue" "continuing to inferior exit" > +mi_expect_stop "exited-normally" "" "" "" "" "" "exit normally" > + > +mi_gdb_exit > +return 0 > diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex_hand/foo.adb b/gdb/testsuite/gdb.ada/mi_catch_ex_hand/foo.adb > new file mode 100644 > index 0000000..da701a3 > --- /dev/null > +++ b/gdb/testsuite/gdb.ada/mi_catch_ex_hand/foo.adb > @@ -0,0 +1,33 @@ > +-- Copyright 2007-2018 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 . > + > +procedure Foo is > +begin > + > + begin > + raise Constraint_Error; > + exception > + when Constraint_Error => -- BREAK1 > + null; > + end; > + > + begin > + raise Program_Error; > + exception > + when Program_Error => -- BREAK2 > + null; > + end; > + > +end Foo; > Thanks, Simon