From patchwork Thu Nov 9 01:25:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 24172 Received: (qmail 56713 invoked by alias); 9 Nov 2017 01:25:47 -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 56700 invoked by uid 89); 9 Nov 2017 01:25:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=fear, Attached X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Nov 2017 01:25:44 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B800456213; Wed, 8 Nov 2017 20:25:42 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jMa11X5HQDay; Wed, 8 Nov 2017 20:25:42 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 8E0DC56153; Wed, 8 Nov 2017 20:25:42 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id B63F683060; Wed, 8 Nov 2017 17:25:40 -0800 (PST) Date: Wed, 8 Nov 2017 17:25:40 -0800 From: Joel Brobecker To: Pedro Alves , gdb-patches@sourceware.org Subject: RFC: problems with minimal symbols (without a type) Message-ID: <20171109012540.ds5ixw4pq6rclhgc@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi Pedro, You recently made a change to require that minimal symbols be cast in order to be printed. This is causing some unexpected side-effects in Ada. The most visible is with exception catchpoints. Consider any Ada program, trying to insert a catchpoint on a specific exception now fails: $ (gdb) catch exception constraint_error warning: failed to reevaluate internal exception condition for catchpoint 0: 'constraint_error' has unknown type; cast it to its declared type I suspect people using the version of GNAT produced by distribution makes such as RedHat probably cannot reproduce the issue, as I understand the compiler is built with a runtime with full debugging information, whereas the version AdaCore distributes only provides debugging info for the few units where we need it. Another way to show the same issue is to just print constraint_error: (gdb) p constraint_error 'constraint_error' has unknown type; cast it to its declared type And unfortunately, the Ada equivalent of casting does not work either: (gdb) print integer(constraint_error) 'constraint_error' has unknown type; cast it to its declared type But even if casting were working, should we really also require a case in a situation like this? (gdb) p constraint_error'address $2 = (system.address) 0x62c960 Unlike C, 'address returns an object of type system.address, which is the equivalent of "void *" in C. For minimal symbols other that integers, the way people typically dump them is by doing something like that: (gdb) print {my_type} minsym'address I looked at the patch series that introduced that change, and I see where you are coming from, but I am wondering if we should be doing the same for Ada or not. I think Ada users are a lot less used to casting (case in point, it took quite a while, even for myself, to remember what the syntax was), and I fear this is not going to be well received by the users. What do you think? Attached is a prototype patch which implements the original behavior for Ada expressions. It fixes the failures in exception catchpoints without introducing any regresssion (x86_64-linux). Thanks! From acf78c27f8652e2bb2c35fc488766312bccc3487 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Wed, 8 Nov 2017 19:32:14 -0500 Subject: [PATCH] WIP: Treat minimal symbol as integers when in Ada --- gdb/ada-lang.c | 15 +++++++++++++++ gdb/eval.c | 2 +- gdb/value.h | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 40213b5..8d987a1 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10355,6 +10355,21 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, return arg1; + case OP_VAR_MSYM_VALUE: + { + (*pos) += 3; + + minimal_symbol *msymbol = exp->elts[pc + 2].msymbol; + arg1 = evaluate_var_msym_value (noside, exp->elts[pc + 1].objfile, + msymbol); + if (noside != EVAL_AVOID_SIDE_EFFECTS + && TYPE_CODE (value_type (arg1)) == TYPE_CODE_ERROR) + arg1 = ada_value_cast (builtin_type (exp->gdbarch)->builtin_int, + arg1, noside); + + return arg1; + } + case OP_STRING: { struct value *result; diff --git a/gdb/eval.c b/gdb/eval.c index 94ddfdb..eca4643 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -738,7 +738,7 @@ evaluate_var_value (enum noside noside, const block *blk, symbol *var) /* Helper for evaluating an OP_VAR_MSYM_VALUE. */ -static value * +value * evaluate_var_msym_value (enum noside noside, struct objfile *objfile, minimal_symbol *msymbol) { diff --git a/gdb/value.h b/gdb/value.h index b1b8c6d..64556c5 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -885,6 +885,10 @@ extern char *extract_field_op (struct expression *exp, int *subexp); extern struct value *evaluate_subexp_with_coercion (struct expression *, int *, enum noside); +extern struct value *evaluate_var_msym_value (enum noside noside, + struct objfile *objfile, + minimal_symbol *msymbol); + extern struct value *parse_and_eval (const char *exp); extern struct value *parse_to_comma_and_eval (const char **expp); -- 2.1.4