From patchwork Tue Nov 21 17:20:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 24415 Received: (qmail 71234 invoked by alias); 21 Nov 2017 17:20:21 -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 71211 invoked by uid 89); 21 Nov 2017 17:20:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, 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:20:19 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 271814A6EB; Tue, 21 Nov 2017 17:20:18 +0000 (UTC) Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E3FF61F32; Tue, 21 Nov 2017 17:20:15 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org, Joel Brobecker Cc: Sergio Durigan Junior Subject: [PATCH v2] Don't lose language determined from the "main" name (fix gdb.ada/minsyms.exp) Date: Tue, 21 Nov 2017 17:20:14 +0000 Message-Id: <1511284814-25508-1-git-send-email-palves@redhat.com> New in v2: - completely different solution/implementation. avoids selecting a frame in the first place. 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