From patchwork Thu Jul 19 15:27:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 28484 Received: (qmail 116672 invoked by alias); 19 Jul 2018 15:27:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 116659 invoked by uid 89); 19 Jul 2018 15:27:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Jul 2018 15:27:49 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1E5D4AD71; Thu, 19 Jul 2018 15:27:47 +0000 (UTC) Date: Thu, 19 Jul 2018 17:27:59 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH][gdb/exp] Fix exception when printing optimized out vla Message-ID: <20180719152758.24vnhbekc4hdlwax@delia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170912 (1.9.0) X-IsSubscribed: yes Hi, when compiling vla-optimized-out.c with -O3 and a recent gcc, and trying to print the vla a in f1, we run into this gdb exception: ... Cannot find matching parameter at DW_TAG_call_site 0x4003be at main ... This is a regression introduced by 42dc7699a2 "[gdb/exp] Fix printing of type of optimized out vla". This patch fixes the regression by wrapping the ctx.eval call in dwarf2_locexpr_baton_eval in try/catch, similar to what is done in dwarf2_evaluate_loc_desc_full. Build and reg-tested on x86_64-linux. OK for trunk? Thanks, - Tom [gdb/exp] Fix exception when printing optimized out vla 2018-07-19 Tom de Vries * dwarf2loc.c (dwarf2_locexpr_baton_eval): Wrap ctx.eval call in try/catch. * gdb.base/vla-optimized-out.c: Make noclone attribute conditional on NOCLONE macro. * gdb.base/vla-optimized-out.exp: Use additional_flags -DNOCLONE. * gdb.base/vla-optimized-out-o3.exp: New file. Reuse vla-optimized-out.c. --- gdb/dwarf2loc.c | 21 ++++++++++++++- gdb/testsuite/gdb.base/vla-optimized-out-o3.exp | 36 +++++++++++++++++++++++++ gdb/testsuite/gdb.base/vla-optimized-out.c | 7 ++++- gdb/testsuite/gdb.base/vla-optimized-out.exp | 2 +- 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 730934fe6e..a98b676b30 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -2573,7 +2573,26 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, ctx.ref_addr_size = dwarf2_per_cu_ref_addr_size (dlbaton->per_cu); ctx.offset = dwarf2_per_cu_text_offset (dlbaton->per_cu); - ctx.eval (dlbaton->data, dlbaton->size); + TRY + { + ctx.eval (dlbaton->data, dlbaton->size); + } + CATCH (ex, RETURN_MASK_ERROR) + { + if (ex.error == NOT_AVAILABLE_ERROR) + { + return 0; + } + else if (ex.error == NO_ENTRY_VALUE_ERROR) + { + if (entry_values_debug) + exception_print (gdb_stdout, ex); + return 0; + } + else + throw_exception (ex); + } + END_CATCH switch (ctx.location) { diff --git a/gdb/testsuite/gdb.base/vla-optimized-out-o3.exp b/gdb/testsuite/gdb.base/vla-optimized-out-o3.exp new file mode 100644 index 0000000000..60707e7aff --- /dev/null +++ b/gdb/testsuite/gdb.base/vla-optimized-out-o3.exp @@ -0,0 +1,36 @@ +# Copyright 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 . + +# Check whether we can print an optimized-out vla. + +standard_testfile + +if { [prepare_for_testing "failed to prepare" $testfile "vla-optimized-out.c" \ + {debug optimize=-O3}] } { + return -1 +} + +proc vla_optimized_out { } { + if ![runto f1] { + fail "can't run to f1" + return + } + + gdb_test "p a" \ + { = } \ + "printed optimized out vla" +} + +vla_optimized_out diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.c b/gdb/testsuite/gdb.base/vla-optimized-out.c index 913e8ea867..ec0a6fdd80 100644 --- a/gdb/testsuite/gdb.base/vla-optimized-out.c +++ b/gdb/testsuite/gdb.base/vla-optimized-out.c @@ -15,7 +15,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -int __attribute__((noinline, noclone)) +int +#ifdef NOCLONE +__attribute__((noinline, noclone)) +#else +__attribute__((noinline)) +#endif f1 (int i) { char a[i + 1]; diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.exp b/gdb/testsuite/gdb.base/vla-optimized-out.exp index 39abb795c8..b27569ed1e 100644 --- a/gdb/testsuite/gdb.base/vla-optimized-out.exp +++ b/gdb/testsuite/gdb.base/vla-optimized-out.exp @@ -18,7 +18,7 @@ standard_testfile if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ - {debug optimize=-O1}] } { + {debug optimize=-O1 additional_flags=-DNOCLONE}] } { return -1 }