From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27943 invoked by alias); 21 Nov 2017 17:29:54 -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 27827 invoked by uid 89); 21 Nov 2017 17:29:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_STOCKGEN,KB_WAM_FROM_NAME_SINGLEWORD,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Nov 2017 17:29:51 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9CE68A58B7; Tue, 21 Nov 2017 17:29:50 +0000 (UTC) Received: from localhost (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 748C55C883; Tue, 21 Nov 2017 17:29:50 +0000 (UTC) From: Sergio Durigan Junior To: Pedro Alves Cc: gdb-patches@sourceware.org, Joel Brobecker Subject: Re: [PATCH v2] Don't lose language determined from the "main" name (fix gdb.ada/minsyms.exp) References: <1511284814-25508-1-git-send-email-palves@redhat.com> Date: Tue, 21 Nov 2017 17:29:00 -0000 In-Reply-To: <1511284814-25508-1-git-send-email-palves@redhat.com> (Pedro Alves's message of "Tue, 21 Nov 2017 17:20:14 +0000") Message-ID: <87k1yjmtf6.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2017-11/txt/msg00454.txt.bz2 On Tuesday, November 21 2017, Pedro Alves wrote: > New in v2: > - completely different solution/implementation. avoids selecting a > frame in the first place. For the record: this LGTM. Thanks, > gdb.ada/minsyms.exp fails like this here: > > FAIL: gdb.ada/minsyms.exp: print integer(some_minsym) > FAIL: gdb.ada/minsyms.exp: print /x integer(&some_minsym) > > The problem is that if you have debug info for glibc, GDB switches the > current language to C before it reaches the program's entry point, and > then Ada's cast syntax doesn't work when the current language is C: > > print integer(some_minsym) > A syntax error in expression, near `some_minsym)'. > (gdb) FAIL: gdb.ada/minsyms.exp: print integer(some_minsym) > > I first thought of doing "set language ada" in the testcase, but > looking deeper, I realized that before running to main, GDB knows the > program is Ada, determined by reading __gnat_ada_main_program_name, > via set_initial_language->main_language->find_main_name-> > ada_main_name, and loses that when it is handling a shared library > event that in turn evaluates probe arguments. That looks like a bug > to me. > > Fix that by avoiding selecting a frame if one isn't set yet in > expression evaluation, which is what switches to the frame's language > as side effect. > > (There are a couple calls to get_selected_block in the file that > should probably get a similar treatment, but I'm leaving those as is > for now.) > > gdb/testsuite/ChangeLog: > 2017-11-21 Pedro Alves > > * eval.c (evaluate_subexp_standard): Use > get_selected_frame_if_set+get_current_frame instead of > get_selected_frame. > --- > gdb/eval.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/gdb/eval.c b/gdb/eval.c > index 14a3e05..b789982 100644 > --- a/gdb/eval.c > +++ b/gdb/eval.c > @@ -1319,7 +1319,6 @@ evaluate_subexp_standard (struct type *expect_type, > > { > struct symbol *sym = exp->elts[pc + 1].symbol; > - struct frame_info *frame; > > if (noside == EVAL_AVOID_SIDE_EFFECTS) > return value_zero (SYMBOL_TYPE (sym), not_lval); > @@ -1329,7 +1328,11 @@ evaluate_subexp_standard (struct type *expect_type, > error (_("Symbol \"%s\" does not have any specific entry value"), > SYMBOL_PRINT_NAME (sym)); > > - frame = get_selected_frame (NULL); > + /* Avoid get_selected_frame because that selects the frame's > + language as side effect. */ > + frame_info *frame = get_selected_frame_if_set (); > + if (frame == NULL) > + frame = get_current_frame (); > return SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry (sym, frame); > } > > @@ -1381,7 +1384,14 @@ evaluate_subexp_standard (struct type *expect_type, > + gdbarch_num_pseudo_regs (exp->gdbarch)) > val = value_zero (register_type (exp->gdbarch, regno), not_lval); > else > - val = value_of_register (regno, get_selected_frame (NULL)); > + { > + /* Avoid get_selected_frame because that selects the > + frame's language as side effect. */ > + frame_info *frame = get_selected_frame_if_set (); > + if (frame == NULL) > + frame = get_current_frame (); > + val = value_of_register (regno, frame); > + } > if (val == NULL) > error (_("Value of register %s not available."), name); > else > -- > 2.5.5 -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/