From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 08574385C6C1 for ; Tue, 11 Jun 2024 08:50:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 08574385C6C1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 08574385C6C1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718095838; cv=none; b=w90ysMn9dHhIzIc+2/XonJwrB+M1FJ3PzMCEGNyZ8Nvf8D7Qmh3lPRIvxSPuF4xC4Sa/yqdxUxPe27NAfbFmb3angV5ZjiarzaBQ0TDdy6ipQPjdmwhxVQ7gH8KNAbmCMqAn9+8JmmjMiDSSWrZPzhJKG3WVrDFyc/txYAAtw/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718095838; c=relaxed/simple; bh=6wXaDmR8KnWW+odF6KsLAqbrCMif6TW2wEG7oszLjZ4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=ONQlHd+qxgA+4Nlbre789eW7qCqPqjUOkzJ4JbbJJlMpse/EbvuyU+dNS8QV8xv2H4oMzHugsRhaOlMy8cVUeEXFW5ROh3HU3BUP7xPA5nfwazvsYPijg/AI1lkyfsciWk88S4aq7SL4C5d2GMQ1xZioBGGzK5PemhcVZZoPhUQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DF87E20585 for ; Tue, 11 Jun 2024 08:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718095835; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+7TKMJpWUBWDsBHPKW3QdpIW1WNrFh9s5KMXmo7YlH8=; b=2KpvSQFCwtBa2V54Amzp4aM4pXE+k9L1NrE3opA1rKcSd30xTr0uglsPkuO4jOmUDyb25j HCnJ3SFHIp0LnB4B53Fy8vAiRFUOaVS6GoTyMHjVPFlY8FoNKZhf8XBvYi5eKd/gfN9U4M mVyRYSZeg6RRuI51Q6EXlM+KKXsU4SM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718095835; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+7TKMJpWUBWDsBHPKW3QdpIW1WNrFh9s5KMXmo7YlH8=; b=Foch0XvfRhKiaN6jWx5Qp58Ch4ZCBjph1qj73LUVDcB57trkLzTSOczJ8CpSbZKnhNCzpv ZC6BSVke5wOGvRCQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=sIF1TsKC; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=KIyPIQCT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718095834; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+7TKMJpWUBWDsBHPKW3QdpIW1WNrFh9s5KMXmo7YlH8=; b=sIF1TsKCijQrfz/8cWFYo1XGH0V55Cou5yAadmJr5tRf/3wB84dYImRpVnYST2wUJ7O1cq IImnuthuTXuuML1xFA9PzwUN948ZhuP2twQ7MgYZVODd7ARqj2qor7IrkNWOChhkNJ19l9 srAWlJwjzn8G0Vta0Tk0P769rg1RnsM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718095834; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+7TKMJpWUBWDsBHPKW3QdpIW1WNrFh9s5KMXmo7YlH8=; b=KIyPIQCTdOBEYWUhOVDSy5i/DD231pM9iuV2cLaER/AdswuwRFroXtoDs7TnZtxOpKR3eZ 5zRF3AEPuDxePaAQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CCE9D137DF for ; Tue, 11 Jun 2024 08:50:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id nt9gMNoPaGZBZgAAD6G6ig (envelope-from ) for ; Tue, 11 Jun 2024 08:50:34 +0000 Message-ID: <2e4a6e65-51af-4de3-a599-f8f39200e1b6@suse.de> Date: Tue, 11 Jun 2024 10:51:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] [gdb/exp] Fix gdb.fortran/intrinsics.exp fail on arm From: Tom de Vries To: gdb-patches@sourceware.org References: <20240527032944.19208-1-tdevries@suse.de> <20240527032944.19208-2-tdevries@suse.de> Content-Language: en-US In-Reply-To: <20240527032944.19208-2-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Level: X-Spamd-Result: default: False [-4.50 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_ONE(0.00)[1]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Action: no action X-Rspamd-Queue-Id: DF87E20585 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -4.50 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 5/27/24 05:29, Tom de Vries wrote: > When running test-case gdb.fortran/intrinsics.exp on arm-linux, I get: > ... > (gdb) p cmplx (4,4,16)^M > /home/linux/gdb/src/gdb/f-lang.c:1002: internal-error: eval_op_f_cmplx: \ > Assertion `kind_arg->code () == TYPE_CODE_COMPLEX' failed.^M > A problem internal to GDB has been detected,^M > further debugging may prove unreliable.^M > ----- Backtrace -----^M > FAIL: gdb.fortran/intrinsics.exp: p cmplx (4,4,16) (GDB internal error) > ... > > The problem is that 16-byte floats are unsupported: > ... > $ gfortran test.f90 > test.f90:2:17: > > 2 | REAL(kind=16) :: foo = 1 > | 1 > Error: Kind 16 not supported for type REAL at (1) > ... > and consequently we end up with a builtin_real_s16 and builtin_complex_s16 with > code TYPE_CODE_ERROR. > > Fix this by bailing out asap when encountering such a type. > > Without this patch we're able to do the rather useless: > ... > (gdb) ptype real*16 > type = real*16 > (gdb) ptype real_16 > type = real*16 > ... > but with this patch we get: > ... > (gdb) ptype real*16 > unsupported kind 16 for type real*4 > (gdb) ptype real_16 > unsupported type real*16 > ... > FWIW, a minimal approach would fix things like this: ... diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 58f35bf0f3f..236d092e142 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -998,6 +998,8 @@ value * eval_op_f_cmplx (type *expect_type, expression *exp, noside noside, exp_opcode opcode, value *arg1, value *arg2, type *kind_arg) { + if (kind_arg->code () == TYPE_CODE_ERROR) + error (_("unsupported kind")); gdb_assert (kind_arg->code () == TYPE_CODE_COMPLEX); if (arg1->type ()->code () == TYPE_CODE_COMPLEX || arg2->type ()->code () == TYPE_CODE_COMPLEX) ... but my fear is that this kind of fix is required in many other places, and we're just not hitting those in the test suite. The approach I've chose is more intrusive, but does try to catch as many cases as possible by bailing out asap. Thanks, - Tom > Tested on arm-linux. > > PR fortran/30537 > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30537 > --- > gdb/f-exp.y | 39 +++++++++++++++++------- > gdb/testsuite/gdb.fortran/intrinsics.exp | 8 +++-- > gdb/testsuite/gdb.fortran/type-kinds.exp | 22 ++++++++++--- > gdb/testsuite/gdb.fortran/types.exp | 19 +++++++++++- > 4 files changed, 70 insertions(+), 18 deletions(-) > > diff --git a/gdb/f-exp.y b/gdb/f-exp.y > index bdf9c32a81b..259f274d341 100644 > --- a/gdb/f-exp.y > +++ b/gdb/f-exp.y > @@ -754,7 +754,11 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */ > | REAL_S8_KEYWORD > { $$ = parse_f_type (pstate)->builtin_real_s8; } > | REAL_S16_KEYWORD > - { $$ = parse_f_type (pstate)->builtin_real_s16; } > + { $$ = parse_f_type (pstate)->builtin_real_s16; > + if ($$->code () == TYPE_CODE_ERROR) > + error (_("unsupported type %s"), > + TYPE_SAFE_NAME ($$)); > + } > | COMPLEX_KEYWORD > { $$ = parse_f_type (pstate)->builtin_complex; } > | COMPLEX_S4_KEYWORD > @@ -762,7 +766,11 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */ > | COMPLEX_S8_KEYWORD > { $$ = parse_f_type (pstate)->builtin_complex_s8; } > | COMPLEX_S16_KEYWORD > - { $$ = parse_f_type (pstate)->builtin_complex_s16; } > + { $$ = parse_f_type (pstate)->builtin_complex_s16; > + if ($$->code () == TYPE_CODE_ERROR) > + error (_("unsupported type %s"), > + TYPE_SAFE_NAME ($$)); > + } > | SINGLE PRECISION > { $$ = parse_f_type (pstate)->builtin_real;} > | DOUBLE PRECISION > @@ -1156,12 +1164,9 @@ push_kind_type (LONGEST val, struct type *type) > type_stack->push (tp_kind); > } > > -/* Called when a type has a '(kind=N)' modifier after it, for example > - 'character(kind=1)'. The BASETYPE is the type described by 'character' > - in our example, and KIND is the integer '1'. This function returns a > - new type that represents the basetype of a specific kind. */ > +/* Helper function for convert_to_kind_type. */ > static struct type * > -convert_to_kind_type (struct type *basetype, int kind) > +convert_to_kind_type_1 (struct type *basetype, int kind) > { > if (basetype == parse_f_type (pstate)->builtin_character) > { > @@ -1211,13 +1216,25 @@ convert_to_kind_type (struct type *basetype, int kind) > return parse_f_type (pstate)->builtin_integer_s8; > } > > - error (_("unsupported kind %d for type %s"), > - kind, TYPE_SAFE_NAME (basetype)); > - > - /* Should never get here. */ > return nullptr; > } > > +/* Called when a type has a '(kind=N)' modifier after it, for example > + 'character(kind=1)'. The BASETYPE is the type described by 'character' > + in our example, and KIND is the integer '1'. This function returns a > + new type that represents the basetype of a specific kind. */ > +static struct type * > +convert_to_kind_type (struct type *basetype, int kind) > +{ > + struct type *res = convert_to_kind_type_1 (basetype, kind); > + > + if (res == nullptr || res->code () == TYPE_CODE_ERROR) > + error (_("unsupported kind %d for type %s"), > + kind, TYPE_SAFE_NAME (basetype)); > + > + return res; > +} > + > struct f_token > { > /* The string to match against. */ > diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp > index 60c79f956dc..060bb53db97 100644 > --- a/gdb/testsuite/gdb.fortran/intrinsics.exp > +++ b/gdb/testsuite/gdb.fortran/intrinsics.exp > @@ -112,10 +112,14 @@ gdb_test "ptype cmplx (4,4)" "= complex\\*4" > gdb_test "p cmplx (-14,-4)" "= \\(-14,-4\\)" > gdb_test "p cmplx (4,4,4)" "\\(4,4\\)" > gdb_test "p cmplx (4,4,8)" "\\(4,4\\)" > -gdb_test "p cmplx (4,4,16)" "\\(4,4\\)" > +set re_unsupported_kind_16 \ > + [string_to_regexp "unsupported kind 16 for type complex*4"] > +gdb_test "p cmplx (4,4,16)" \ > + ([string_to_regexp " = (4,4)"]|$re_unsupported_kind_16) > gdb_test "ptype cmplx (4,4,4)" "= complex\\*4" > gdb_test "ptype cmplx (4,4,8)" "= complex\\*8" > -gdb_test "ptype cmplx (4,4,16)" "= complex\\*16" > +gdb_test "ptype cmplx (4,4,16)" \ > + ([string_to_regexp " = complex*16"]|$re_unsupported_kind_16) > > gdb_test "p cmplx (4,4,1)" "unsupported kind 1 for type complex\\*4" > gdb_test "p cmplx (4,4,-1)" "unsupported kind -1 for type complex\\*4" > diff --git a/gdb/testsuite/gdb.fortran/type-kinds.exp b/gdb/testsuite/gdb.fortran/type-kinds.exp > index ab5f19f97a4..a6f2aa4e870 100644 > --- a/gdb/testsuite/gdb.fortran/type-kinds.exp > +++ b/gdb/testsuite/gdb.fortran/type-kinds.exp > @@ -43,12 +43,20 @@ proc test_basic_parsing_of_type_kinds {} { > test_cast_1_to_type_kind "complex" "" "\\(1,0\\)" "8" > test_cast_1_to_type_kind "complex" "4" "\\(1,0\\)" "8" > test_cast_1_to_type_kind "complex" "8" "\\(1,0\\)" "16" > - test_cast_1_to_type_kind "complex" "16" "\\(1,0\\)" "32" > + set re_unsupported_kind \ > + [string_to_regexp "unsupported kind 16 for type complex*4"] > + test_cast_1_to_type_kind "complex" "16" \ > + [string_to_regexp (1,0)]|$re_unsupported_kind \ > + 32|$re_unsupported_kind > > test_cast_1_to_type_kind "real" "" "1" "4" > test_cast_1_to_type_kind "real" "4" "1" "4" > test_cast_1_to_type_kind "real" "8" "1" "8" > - test_cast_1_to_type_kind "real" "16" "1" "16" > + set re_unsupported_kind \ > + [string_to_regexp "unsupported kind 16 for type real*4"] > + test_cast_1_to_type_kind "real" "16" \ > + 1|$re_unsupported_kind \ > + 16|$re_unsupported_kind > > test_cast_1_to_type_kind "logical" "" "\\.TRUE\\." "4" > test_cast_1_to_type_kind "logical" "1" "\\.TRUE\\." "1" > @@ -83,11 +91,17 @@ proc test_old_star_type_sizes {} { > > gdb_test "p ((complex*4) 1)" " = \\(1,0\\)" > gdb_test "p ((complex*8) 1)" " = \\(1,0\\)" > - gdb_test "p ((complex*16) 1)" " = \\(1,0\\)" > + set re_unsupported_kind \ > + [string_to_regexp "unsupported kind 16 for type complex*4"] > + gdb_test "p ((complex*16) 1)" \ > + [string_to_regexp " = (1,0)"]|$re_unsupported_kind > > gdb_test "p ((real*4) 1)" " = 1" > gdb_test "p ((real*8) 1)" " = 1" > - gdb_test "p ((real*16) 1)" " = 1" > + set re_unsupported_kind \ > + [string_to_regexp "unsupported kind 16 for type real*4"] > + gdb_test "p ((real*16) 1)" \ > + "( = 1|$re_unsupported_kind)" > > gdb_test "p ((logical*1) 1)" " = \\.TRUE\\." > gdb_test "p ((logical*4) 1)" " = \\.TRUE\\." > diff --git a/gdb/testsuite/gdb.fortran/types.exp b/gdb/testsuite/gdb.fortran/types.exp > index 83b109869e6..edbf5abee97 100644 > --- a/gdb/testsuite/gdb.fortran/types.exp > +++ b/gdb/testsuite/gdb.fortran/types.exp > @@ -94,7 +94,24 @@ proc test_primitive_types_known {} { > # While TYPE_KIND is allowed as input, GDB will always return the > # Fortran notation TYPE*KIND > regsub -all "_" $type "\*" type_res > - gdb_test "ptype $type" [string_to_regexp "type = $type_res"] > + set re [string_to_regexp "type = $type_res"] > + switch $type { > + real*16 - complex*16 { > + regexp {^[^*_]*} $type base > + set re_unsupported \ > + [string_to_regexp \ > + "unsupported kind 16 for type $base*4"] > + set re ($re|$re_unsupported) > + } > + real_16 - complex_16 { > + set re_unsupported \ > + [string_to_regexp \ > + "unsupported type $type_res"] > + set re ($re|$re_unsupported) > + } > + } > + > + gdb_test "ptype $type" $re > } > } >