From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by sourceware.org (Postfix) with ESMTPS id CB75B3857C4A for ; Sat, 15 Aug 2020 08:16:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CB75B3857C4A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wm1-x344.google.com with SMTP id x5so9231226wmi.2 for ; Sat, 15 Aug 2020 01:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=iL3UsLzV7ubEwuPqz2RM71IbQnFTNCV6yvpVZh5u524=; b=e4CnQXbTrR2+9b6ZMFNZlUaBWxSv2LSGLyWH1wXPhe3/nM0iTllVxgNJmmr+F9Bi3a 0+nqi8JGLYYUydzRuOPvW/NTZaymFvqai/OGHiob4w2+x+kHpxr4ltySSvunJTLJ8CpV QlXApWP+gZQ/zHcdJ9kppCvT9gZYlrQ9synITKoMsOAmhfTqy7ShC4NV0YeBY7NdwoOz KmiLahw3zpEkY15GgM+Zfur/uypfUi8EDZQp8WdfSZOhhpaieSHY6o6vKJSJ6RD5+oD4 hlcIun2vJ8OFr3Gwz+xVTSTCVq8z19XlsvwvEVG4UjpwmwzwEb33fFfc25IQ6jN+s2xi H2og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iL3UsLzV7ubEwuPqz2RM71IbQnFTNCV6yvpVZh5u524=; b=gix+j2cWUDE+AqhiiBQ98AjY6J51Cbwnyn7JzoGdwAn2HW9SAu+yvr72xE55f9Kg+4 pRLXa0IG/lhv2n6nsHxtdKIktUqWI/Q3gPsuWTfFgqQc4kL53s8xKPq532cgDtB2GRgj IrmYwFqDyWrz0NmQD79AMLPJvJfeqk5ZD+chhblQX1Ho4FL7YZzaILSHdmlYz+Kl/2Wj uBUO+MgNIuHQOROQgH9sJxbfYDrZHHdzYcrLa+T1L4fo/SroDfYCqzrJ7f1HRnPwgmHl 5urwvMfrIiEk0gjLCZQgKnDBtqkeEkoZqgfE207NjJ82Dnwgbt+UIgNy25S/D0J02kOK dHEg== X-Gm-Message-State: AOAM532qG6dIWcBdSBuyYbtS/1Et0jdSb/qOEFUaoujlpf7f92TbFcth YXLDqj6r6aKxP5Ho0F9BR8o+rA== X-Google-Smtp-Source: ABdhPJzHyo1cE49sEThBogxXtxAUBhUglC+CoRi0p1xypeuKgzD4RSpuxGxn6c2E5MKjyzAaJJ6Exg== X-Received: by 2002:a1c:c906:: with SMTP id f6mr6220228wmb.5.1597479364806; Sat, 15 Aug 2020 01:16:04 -0700 (PDT) Received: from localhost (host86-186-80-213.range86-186.btcentralplus.com. [86.186.80.213]) by smtp.gmail.com with ESMTPSA id v8sm20339326wmb.24.2020.08.15.01.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Aug 2020 01:16:04 -0700 (PDT) Date: Sat, 15 Aug 2020 09:16:02 +0100 From: Andrew Burgess To: Tom de Vries Cc: gdb-patches@sourceware.org Subject: Re: [PATCH][gdb/backtrace] Fix printing of fortran string args Message-ID: <20200815081602.GG853475@embecosm.com> References: <20200815055446.GA6668@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200815055446.GA6668@delia> X-Operating-System: Linux/5.6.15-200.fc31.x86_64 (x86_64) X-Uptime: 09:14:17 up 27 days, 17:28, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2020 08:16:07 -0000 * Tom de Vries [2020-08-15 07:54:48 +0200]: > Hi, > > When running test-case gdb.fortran/mixed-lang-stack.exp, it passes, but we > find in gdb.log: > ... > (gdb) bt^M > ... > #7 0x000000000040113c in mixed_func_1b (a=1, b=2, c=3, d=(4,5), \ > e= is more than max-value-size>, g=..., _e=6) at mixed-lang-stack.f90:87^M > ... > while a bit later in gdb.log, we have instead for the same frame (after > adding a gdb_test_no_output "set print frame-arguments all" to prevent > getting "e=..."): > ... > (gdb) up^M > #7 0x000000000040113c in mixed_func_1b (a=1, b=2, c=3, d=(4,5), \ > e='abcdef', g=( a = 1.5, b = 2.5 ), _e=6) at mixed-lang-stack.f90:87^M > ... > > The difference is that in the latter case, we print the frame while it's > selected, while in the former, it's not. > > The problem is that the while trying to resolve the dynamic type of e in > resolve_dynamic_type, we call dwarf2_evaluate_property with a frame == NULL > argument, and then use the selected frame as the context in which to evaluate > the dwarf property, effectively evaluating a DW_OP_fbreg operation in the > wrong frame context. > > Fix this by temporarily selecting the frame of which we're trying to print the > arguments in print_frame_args, borrowing code from print_frame_local_vars that > was added to fix a similar issue in commit 16c3b12f19 "error/internal-error > printing local variable during "bt full". > > Build and tested on x86_64-linux. > > Any comments? > > Thanks, > - Tom > > [gdb/backtrace] Fix printing of fortran string args > > gdb/ChangeLog: > > 2020-08-14 Tom de Vries > > PR backtrace/26390 > * stack.c (print_frame_args): Temporarily set the selected > frame to FRAME while printing the frame's arguments. > > gdb/testsuite/ChangeLog: > > 2020-08-14 Tom de Vries > > PR backtrace/26390 > * gdb.fortran/mixed-lang-stack.exp: Call bt with -frame-arguments all. > Update expected pattern. LGTM. Thanks, Andrew > > --- > gdb/stack.c | 6 ++++++ > gdb/testsuite/gdb.fortran/mixed-lang-stack.exp | 30 +++++++++++++++----------- > 2 files changed, 23 insertions(+), 13 deletions(-) > > diff --git a/gdb/stack.c b/gdb/stack.c > index 265e764dc2..616b629e20 100644 > --- a/gdb/stack.c > +++ b/gdb/stack.c > @@ -744,6 +744,12 @@ print_frame_args (const frame_print_options &fp_opts, > = (print_names > && fp_opts.print_frame_arguments != print_frame_arguments_none); > > + /* Temporarily change the selected frame to the given FRAME. > + This allows routines that rely on the selected frame instead > + of being given a frame as parameter to use the correct frame. */ > + scoped_restore_selected_frame restore_selected_frame; > + select_frame (frame); > + > if (func) > { > const struct block *b = SYMBOL_BLOCK_VALUE (func); > diff --git a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp > index 793318626d..edf2508537 100644 > --- a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp > +++ b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp > @@ -59,19 +59,23 @@ proc run_tests { lang } { > } > > # Check the backtrace. > - set bt_stack [multi_line \ > - "#0\\s+breakpt \\(\\) at \[^\r\n\]+" \ > - "#1\\s+$hex in mixed_func_1h \\(\\) at \[^\r\n\]+" \ > - "#2\\s+$hex in mixed_func_1g \\(obj=\\.\\.\\.\\) at \[^\r\n\]+" \ > - "#3\\s+$hex in mixed_func_1f \\(\\) at \[^\r\n\]+" \ > - "#4\\s+$hex in mixed_func_1e \\(\\) at \[^\r\n\]+" \ > - "#5\\s+$hex in mixed_func_1d \\(\[^\r\n\]+\\) at \[^\r\n\]+" \ > - "#6\\s+$hex in mixed_func_1c \\(\[^\r\n\]+\\) at \[^\r\n\]+" \ > - "#7\\s+$hex in mixed_func_1b \\(\[^\r\n\]+\\) at \[^\r\n\]+" \ > - "#8\\s+$hex in mixed_func_1a \\(\\) at \[^\r\n\]+" \ > - "#9\\s+$hex in mixed_stack_main \\(\\) at \[^\r\n\]+" \ > - "#10\\s+$hex in main \\(\[^\r\n\]+\\) at .*" ] > - gdb_test "bt" $bt_stack > + set e_arg "\['\"\]abcdef\['\"\]" > + set 1b_args "\[^\r\n\]+$e_arg\[^\r\n\]+" > + set 1g_args "obj=\[^\r\n\]+" > + set bt_stack \ > + [multi_line \ > + "#0\\s+breakpt \\(\\) at \[^\r\n\]+" \ > + "#1\\s+$hex in mixed_func_1h \\(\\) at \[^\r\n\]+" \ > + "#2\\s+$hex in mixed_func_1g \\($1g_args\\) at \[^\r\n\]+" \ > + "#3\\s+$hex in mixed_func_1f \\(\\) at \[^\r\n\]+" \ > + "#4\\s+$hex in mixed_func_1e \\(\\) at \[^\r\n\]+" \ > + "#5\\s+$hex in mixed_func_1d \\(\[^\r\n\]+\\) at \[^\r\n\]+" \ > + "#6\\s+$hex in mixed_func_1c \\(\[^\r\n\]+\\) at \[^\r\n\]+" \ > + "#7\\s+$hex in mixed_func_1b \\($1b_args\\) at \[^\r\n\]+" \ > + "#8\\s+$hex in mixed_func_1a \\(\\) at \[^\r\n\]+" \ > + "#9\\s+$hex in mixed_stack_main \\(\\) at \[^\r\n\]+" \ > + "#10\\s+$hex in main \\(\[^\r\n\]+\\) at .*" ] > + gdb_test "bt -frame-arguments all" $bt_stack > > # Check the language for frame #0. > gdb_test "info frame" "source language fortran\..*" \