From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by sourceware.org (Postfix) with ESMTPS id 8D8D83834426 for ; Thu, 4 Mar 2021 09:51:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8D8D83834426 IronPort-SDR: +6AvWSmWSyjb0KU1nUe5NtBI758F9UjkX5Nfrbpj8hR4ns5vCyjsobJytsUvO24pOp+i/LY8vE dhHzMNJa+kWA== X-IronPort-AV: E=McAfee;i="6000,8403,9912"; a="175015911" X-IronPort-AV: E=Sophos;i="5.81,222,1610438400"; d="scan'208";a="175015911" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2021 01:51:28 -0800 IronPort-SDR: DBjB9oOQIiXmfUQ7aNPIQIff4qIq5VsaOj5vfnqpvgOQgktzU4tE5oEFn7g71Re5xO9MC3g0jy KPRZmnQTh8sA== X-IronPort-AV: E=Sophos;i="5.81,222,1610438400"; d="scan'208";a="407705703" Received: from mulvlfelix.iul.intel.com (HELO localhost) ([172.28.48.31]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2021 01:51:27 -0800 From: Felix Willgerodt To: felix.willgerodt@intel.com, gdb-patches@sourceware.org Subject: [PATCH] gdb/fortran: Add 'LOC' intrinsic support. Date: Thu, 4 Mar 2021 10:50:44 +0100 Message-Id: <20210304095044.3017369-1-felix.willgerodt@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, 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: Thu, 04 Mar 2021 09:51:34 -0000 LOC(X) returns the address of X as an integer: https://gcc.gnu.org/onlinedocs/gfortran/LOC.html Before: (gdb) p LOC(l) No symbol "LOC" in current context. After: (gdb) p LOC(l) $1 = (PTR TO -> ( logical(kind=4) )) 0x7fffffffccfc gdb/ChangeLog: 2021-03-04 Felix Willgerodt Abhishek Aggarwal * ax-gdb.c (gen_expr): Add case for UNOP_LOC. * eval.c (evaluate_subexp_standard): Add case for UNOP_LOC. * expprint.c (dump_subexp_body_standard): Add case for UNOP_LOC. * f-exp.y (exp): Add LOC. (pytpe): Same. (f77_keywords): Same. * std-operator.def (OP): Same. gdb/testsuite/ChangeLog: 2020-07-04 Felix Willgerodt * gdb.fortran/intrinsics.exp: Add LOC test. --- gdb/ax-gdb.c | 1 + gdb/eval.c | 8 ++++++++ gdb/expprint.c | 1 + gdb/f-exp.y | 7 ++++++- gdb/std-operator.def | 1 + gdb/testsuite/gdb.fortran/intrinsics.exp | 4 ++++ 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index fa777281c1e..3596f856c73 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -2185,6 +2185,7 @@ gen_expr (struct expression *exp, union exp_element **pc, gen_deref (value); break; + case UNOP_LOC: case UNOP_ADDR: (*pc)++; gen_expr (exp, pc, ax, value); diff --git a/gdb/eval.c b/gdb/eval.c index 7ba3ee59522..fffb409f6e5 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2490,6 +2490,14 @@ evaluate_subexp_standard (struct type *expect_type, return value_from_longest (size_type, align); } + case UNOP_LOC: + if (noside == EVAL_SKIP) + { + evaluate_subexp (nullptr, exp, pos, EVAL_SKIP); + return eval_skip_value (exp); + } + return evaluate_subexp_for_address (exp, pos, noside); + case UNOP_CAST: (*pos) += 2; type = exp->elts[pc + 1].type; diff --git a/gdb/expprint.c b/gdb/expprint.c index d95835fc47d..ae66eceff30 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -866,6 +866,7 @@ dump_subexp_body_standard (struct expression *exp, case UNOP_POSTDECREMENT: case UNOP_SIZEOF: case UNOP_ALIGNOF: + case UNOP_LOC: case UNOP_PLUS: case UNOP_CAP: case UNOP_CHR: diff --git a/gdb/f-exp.y b/gdb/f-exp.y index f5360c10ef6..3d0dd2de93b 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -160,7 +160,7 @@ static int parse_number (struct parser_state *, const char *, int, %token NAME_OR_INT -%token SIZEOF KIND +%token SIZEOF KIND LOC %token ERROR /* Special type cases, put in to allow the parser to distinguish different @@ -243,6 +243,10 @@ exp : SIZEOF exp %prec UNARY { write_exp_elt_opcode (pstate, UNOP_SIZEOF); } ; +exp : LOC exp %prec UNARY + { write_exp_elt_opcode (pstate, UNOP_LOC); } + ; + exp : KIND '(' exp ')' %prec UNARY { write_exp_elt_opcode (pstate, UNOP_FORTRAN_KIND); } ; @@ -1038,6 +1042,7 @@ static const struct token f77_keywords[] = { "precision", PRECISION, BINOP_END, true }, /* The following correspond to actual functions in Fortran and are case insensitive. */ + { "loc", LOC, BINOP_END, false }, { "kind", KIND, BINOP_END, false }, { "abs", UNOP_INTRINSIC, UNOP_ABS, false }, { "mod", BINOP_INTRINSIC, BINOP_MOD, false }, diff --git a/gdb/std-operator.def b/gdb/std-operator.def index 99b5d90381a..afd3dbc1598 100644 --- a/gdb/std-operator.def +++ b/gdb/std-operator.def @@ -227,6 +227,7 @@ OP (UNOP_PREDECREMENT) /* -- before an expression */ OP (UNOP_POSTDECREMENT) /* -- after an expression */ OP (UNOP_SIZEOF) /* Unary sizeof (followed by expression) */ OP (UNOP_ALIGNOF) /* Unary alignof (followed by expression) */ +OP (UNOP_LOC) /* Unary loc (followed by expression) */ OP (UNOP_PLUS) /* Unary plus */ diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp index d0ac1944aab..1d426e3dfb6 100644 --- a/gdb/testsuite/gdb.fortran/intrinsics.exp +++ b/gdb/testsuite/gdb.fortran/intrinsics.exp @@ -84,3 +84,7 @@ gdb_test "ptype MODULO (3.0,2.0)" "type = real\\*8" # Test CMPLX gdb_test "p CMPLX (4.1, 2.0)" " = \\(4.$decimal,2\\)" + +# Test LOC + +gdb_test "p LOC(l)" "(logical|LOGICAL).*$hex" -- 2.25.4 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928