From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id A989538708E8 for ; Tue, 9 Mar 2021 10:00:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A989538708E8 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-x32f.google.com with SMTP id b2-20020a7bc2420000b029010be1081172so5576454wmj.1 for ; Tue, 09 Mar 2021 02:00:33 -0800 (PST) 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=XrgaErV/P/59A+0TKlmrc065Iy1AlukOm/1gMtcdebc=; b=XEcdsgViVSa4jHh14Aph2OF9AysDwj3ct5Sc4Dmihp/hUrKKE1OHPRh6TVJoC3/wAN G0I3qJiVvR53lCC+S6Mjm8kwd3TFamH1aNFjCI3EAN/GMgBLNgYUJJVXxHetTz9tIXZx 978Um3avM421JKAGiCCEyWKfoLiHscszPbdlZrI4Q/UmyNv8IbNgTZ1ZpEM9yxgJ4Mhy eop1iF1kd4oOxb+N9dO3WCS5/fvsBBDTuyhW8FHxq2cXxbx+BxBiM+9lIX3TOqNHZOMg lCVwslOp/ieKudFCeLI46tpWHfUMJ4LPfbZX47Vmep0Tl21V06SgpLb/ZMuU2i2gAGUF vPFg== 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=XrgaErV/P/59A+0TKlmrc065Iy1AlukOm/1gMtcdebc=; b=bwGxsZf7+oFp1VJxXxqsWo62ByfUIsV3lzgiTIG1iAgKVZGb/QgIgDlGqTBjpSipbX WT6qDlFzNzTjp6VlOtRdWaY4HblnaM1oJTR1pGie34KfSzA/HdpJgDflTXOrzUbwOJMU LZ37CJ1IvcMSJrO71qWNpHbYBhnwvu8jdm2MOtUy7qOGxE4ZqmQBiaLyWSaLdKg+fz03 EMGd3Y3szvI77Z1y3NhAi5RSgxIPUfVlKXycB6Wn94VGfEVGm1sfGLNEHkAwJRz6eM0p R+4S0FpPbUKWmYsy78qfep7vtnaJlxnxABMOvW+dnNSncXhXlzXwXcaHowAzmU0bR5mx Fc+Q== X-Gm-Message-State: AOAM530Bak3OXr4a/H8G86w1UHCVZzpNebO1FjhC7wO8mAZmyC/vF8Ha OhW7eOSjFICj+HOrAvAatbt5J2qZPcIo3g== X-Google-Smtp-Source: ABdhPJxb5tc8OnFn39REmpvmDybv1ubVSFMBG1lZu/aadZpRxsxAdQl3ZmrqTtLrICUE2RYrfLwq8g== X-Received: by 2002:a1c:5584:: with SMTP id j126mr3198210wmb.153.1615284032169; Tue, 09 Mar 2021 02:00:32 -0800 (PST) Received: from localhost (host86-134-238-232.range86-134.btcentralplus.com. [86.134.238.232]) by smtp.gmail.com with ESMTPSA id i17sm11502255wrp.77.2021.03.09.02.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 02:00:31 -0800 (PST) Date: Tue, 9 Mar 2021 10:00:30 +0000 From: Andrew Burgess To: Felix Willgerodt Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v4] gdb/fortran: Add 'LOC' intrinsic support. Message-ID: <20210309100030.GP1720904@embecosm.com> References: <20210309084221.263485-1-felix.willgerodt@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210309084221.263485-1-felix.willgerodt@intel.com> X-Operating-System: Linux/5.8.13-100.fc31.x86_64 (x86_64) X-Uptime: 09:59:14 up 90 days, 14:43, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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: Tue, 09 Mar 2021 10:00:36 -0000 * Felix Willgerodt via Gdb-patches [2021-03-09 09:42:21 +0100]: > LOC(X) returns the address of X as an integer: > https://gcc.gnu.org/onlinedocs/gfortran/LOC.html > > Before: > (gdb) p LOC(r) > No symbol "LOC" in current context. > > After: > (gdb) p LOC(r) > $1 = 0xffffdf48 > > gdb/ChangeLog: > 2021-03-04 Felix Willgerodt > > * f-exp.y (f77_keywords): Add LOC. > * f-lang.c (evaluate_subexp_f): Handle UNOP_FORTRAN_LOC. > (operator_length_f): Likewise. > (print_subexp_f): Likewise. > (dump_subexp_body_f): Likewise. > (operator_check_f): Likewise. > * std-operator.def (UNOP_FORTRAN_LOC): New operator. Remember to update your ChangeLog. Otherwise, this looks good. You can push this once the ChangeLog has been updated. Thanks, Andrew > > gdb/testsuite/ChangeLog: > 2020-03-04 Felix Willgerodt > > * gdb.fortran/intrinsics.exp: Add LOC test. > --- > gdb/f-exp.h | 7 +++++++ > gdb/f-exp.y | 4 ++++ > gdb/f-lang.c | 19 +++++++++++++++++++ > gdb/std-operator.def | 1 + > gdb/testsuite/gdb.fortran/intrinsics.exp | 5 +++++ > 5 files changed, 36 insertions(+) > > diff --git a/gdb/f-exp.h b/gdb/f-exp.h > index 81cf3412ee2..a2e5b332b40 100644 > --- a/gdb/f-exp.h > +++ b/gdb/f-exp.h > @@ -73,6 +73,11 @@ extern struct value * eval_op_f_allocated (struct type *expect_type, > enum noside noside, > enum exp_opcode op, > struct value *arg1); > +extern struct value * eval_op_f_loc (struct type *expect_type, > + struct expression *exp, > + enum noside noside, > + enum exp_opcode op, > + struct value *arg1); > > namespace expr > { > @@ -86,6 +91,8 @@ using fortran_kind_operation = unop_operation eval_op_f_kind>; > using fortran_allocated_operation = unop_operation eval_op_f_allocated>; > +using fortran_loc_operation = unop_operation + eval_op_f_loc>; > > using fortran_mod_operation = binop_operation; > using fortran_modulo_operation = binop_operation diff --git a/gdb/f-exp.y b/gdb/f-exp.y > index c33b5079158..0c2a5be7a06 100644 > --- a/gdb/f-exp.y > +++ b/gdb/f-exp.y > @@ -319,6 +319,9 @@ exp : UNOP_INTRINSIC '(' exp ')' > break; > case UNOP_FORTRAN_ALLOCATED: > pstate->wrap (); > + break; > + case UNOP_FORTRAN_LOC: > + pstate->wrap (); > break; > default: > gdb_assert_not_reached ("unhandled intrinsic"); > @@ -1139,6 +1142,7 @@ static const struct token f77_keywords[] = > { "ubound", UNOP_OR_BINOP_INTRINSIC, FORTRAN_UBOUND, false }, > { "allocated", UNOP_INTRINSIC, UNOP_FORTRAN_ALLOCATED, false }, > { "associated", UNOP_OR_BINOP_INTRINSIC, FORTRAN_ASSOCIATED, false }, > + { "loc", UNOP_INTRINSIC, UNOP_FORTRAN_LOC, false }, > }; > > /* Implementation of a dynamically expandable buffer for processing input > diff --git a/gdb/f-lang.c b/gdb/f-lang.c > index 1b66ae34159..833b151449a 100644 > --- a/gdb/f-lang.c > +++ b/gdb/f-lang.c > @@ -773,6 +773,25 @@ eval_op_f_allocated (struct type *expect_type, struct expression *exp, > return value_from_longest (result_type, result_value); > } > > +/* A helper function for UNOP_FORTRAN_LOC. */ > + > +struct value * > +eval_op_f_loc (struct type *expect_type, struct expression *exp, > + enum noside noside, enum exp_opcode op, > + struct value *arg1) > +{ > + struct type *result_type; > + if (gdbarch_ptr_bit (exp->gdbarch) == 16) > + result_type = builtin_f_type (exp->gdbarch)->builtin_integer_s2; > + else if (gdbarch_ptr_bit (exp->gdbarch) == 32) > + result_type = builtin_f_type (exp->gdbarch)->builtin_integer; > + else > + result_type = builtin_f_type (exp->gdbarch)->builtin_integer_s8; > + > + LONGEST result_value = value_address (arg1); > + return value_from_longest (result_type, result_value); > +} > + > namespace expr > { > > diff --git a/gdb/std-operator.def b/gdb/std-operator.def > index b0c6beb4628..5d29305d47b 100644 > --- a/gdb/std-operator.def > +++ b/gdb/std-operator.def > @@ -378,6 +378,7 @@ OP (UNOP_FORTRAN_KIND) > OP (UNOP_FORTRAN_FLOOR) > OP (UNOP_FORTRAN_CEILING) > OP (UNOP_FORTRAN_ALLOCATED) > +OP (UNOP_FORTRAN_LOC) > > /* Two operand builtins. */ > OP (BINOP_FORTRAN_CMPLX) > diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp > index d0ac1944aab..84f486f4d7b 100644 > --- a/gdb/testsuite/gdb.fortran/intrinsics.exp > +++ b/gdb/testsuite/gdb.fortran/intrinsics.exp > @@ -84,3 +84,8 @@ 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/x LOC(l)" "= $hex" > +gdb_test "ptype loc(l)" "type = integer(\\*$decimal)?" > -- > 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 >