From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MZUXHhOzVmpEfwgAWB0awg (envelope-from ) for ; Tue, 14 Jul 2026 18:07:15 -0400 Received: by simark.ca (Postfix, from userid 112) id 783141E033; Tue, 14 Jul 2026 18:07:15 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D5CBF1E033 for ; Tue, 14 Jul 2026 18:07:14 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 747AE4BA23D2 for ; Tue, 14 Jul 2026 22:07:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 747AE4BA23D2 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by sourceware.org (Postfix) with ESMTPS id 18E924BA2E25 for ; Tue, 14 Jul 2026 22:06:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 18E924BA2E25 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 18E924BA2E25 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784066810; cv=none; b=XxnTPdtvuoi7mu6SvRpz9i0Bxn0PMCXpqx9+D8U1sMgXDqwbKzlIBLr0sdOJLsce2kG0IktJlN+QA5oI19I32fyQKxQ+ugJINIyu9PCNY6xfM8Vo5bOYfamX4HV9GnNSj3lBaSOjae+aeOIvvNJwoZarxQOtGNhcCnnIYs3BiXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784066810; c=relaxed/simple; bh=nDflnRiBCcHzHYkoI4DksAdhErKYzjSqVVSYLckdtoA=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=rRoXw5qnbQUr8UmyKd36vPbE0x4IrKw+99CY1LZLiU9kHTjvPFwoSvYXfeBX/cHCCQMV6KnPExs7GdlbHwFkOQcSoJQQCRGPDJk5p+bmnL3meBRWMBs+O6V/hg7kHUkelcbpSb3ysIVTfuQyYShzngIWwjezx2c4518RGRPHiaM= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 18E924BA2E25 Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-c167aa9500dso6196666b.3 for ; Tue, 14 Jul 2026 15:06:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784066809; x=1784671609; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=t6hw14EbGwL724FzulwpbpWIq2xPcTTR2wQK7aq8w1o=; b=gBSuI2P8TsTT4AaK3863MZ/xq4rdKha0ZiPx0aky2I3KtzWO9gNI+mM9Km664D6YzN anAtSC6q9kJpIyMX3My9w7tC3zA1cQvyigEj1YlRlWQi2fgVhoGWtf4JSSTnyb6G44tK wCifHgw/23MFV9nzfDAWWXJ7K5ZkuIM25+OXddwICLScYxH6yldO2/X3K69lLPV2Ye0V VtQAHF/LjEgT+zm8Qu2urWZTVmh+oBvpaWxn1fBCONArP1Ly/H580QaqVzFHQMZw971V vfvKk3molKgB/QpoYeXVU322fQtXEWb5Let1BXriWOjqSyvvcRo9bL443k3K1oXQ2gK6 dCmw== X-Gm-Message-State: AOJu0Yw0+I6TUTZtvoOemMMtDu5Rgr1SRxH/COW6i8QwTAfCIgqdhg/a 8x90Uec0qhZLXc037XxhTJsK6UgnV448sW6FquDFNTSNJoVzOTonqu78VCwE+gmO X-Gm-Gg: AfdE7ck9kLAkhObH80uMXO6XPzXTYk3vwF/M20mvnJ76t5iS9pADFxoFARvV4xxH/wC Ule90mWUXMEtxoQ3zfKHS28Ze71AVrS2lQxIA2UjEslbNVumWFyWTeLnBvKIt++RNCCoLk4Jum4 MB3f1RRAof7QWUC5lJXHKncp+rPqLSSwyTwNsZ6Kn1NANjU1rVcvoqiVJ2tXe0UHitvxCRfkY+R TCWOOUFp1bPnuaRDZONHAXNGpKlGTKJSNhJFkEwi+hwRsGRzq3PoMNgclvFNPHOejOcdTr6f6PD mj+WAj0bcK+Vde53cQNXcEtu8TsLF8TRd6b1/hBYTLpbUrOFe9SlQQeP4isZotcEnEeRtU/bSZb +q/zi/4TYCaj/9tBF3IF+Hm186ZOucjDWIAjdgrAUkmY4UtmkJ+mkJzUgu93GbI6803ywsut2i9 r4PEBDVO++fRk= X-Received: by 2002:a17:907:7b82:b0:c0e:883e:93fd with SMTP id a640c23a62f3a-c16619189d8mr307370966b.48.1784066808748; Tue, 14 Jul 2026 15:06:48 -0700 (PDT) Received: from localhost ([2001:8a0:fae3:3700:4d25:7ae8:520f:e7a8]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-c15adb488desm1229465666b.63.2026.07.14.15.06.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jul 2026 15:06:48 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 4/4] gdb.base/callfuncs.exp: Exercise "long double" Date: Tue, 14 Jul 2026 23:06:31 +0100 Message-ID: <20260714220631.1499846-5-pedro@palves.net> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260714220631.1499846-1-pedro@palves.net> References: <20260714220631.1499846-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org gdb.base/callfuncs.exp tests calling functions that take and return floating point arguments, but only for float and double. Add long double too, so that GDB's handling of the type in inferior function calls is exercised. On x86_64-pc-windows-msvc, without the fix that teaches GDB about the correct size of "long double", we get: $ grep FAIL gdb.sum FAIL: gdb.base/callfuncs.exp: noproto: p ((int (*) ()) t_long_double_values)(45.654L,-67.66L) FAIL: gdb.base/callfuncs.exp: p ((int (*) (long double, long double)) t_long_double_values)(45.654,-67.66) These two tests go through GDB's expression parser for the long double type. Without the long double fix, GDB is passing 128-bit (amd64 default) but on the MSVC ABI, it should be passing 64-bit. The other tests pass even without the fix, as those are direct calls that get the parameter type from DWARF, which has the correct long double size. Change-Id: Ibcc3590753d08ece4fbf03c5d890872197047fff --- gdb/testsuite/gdb.base/callfuncs.c | 58 ++++++++++++++++++++-------- gdb/testsuite/gdb.base/callfuncs.exp | 26 +++++++++++++ 2 files changed, 67 insertions(+), 17 deletions(-) diff --git a/gdb/testsuite/gdb.base/callfuncs.c b/gdb/testsuite/gdb.base/callfuncs.c index 0e6d9dcdd71..918e8d6f97d 100644 --- a/gdb/testsuite/gdb.base/callfuncs.c +++ b/gdb/testsuite/gdb.base/callfuncs.c @@ -72,6 +72,24 @@ double double_val13 = 10.25; double double_val14 = 11.25; double double_val15 = 12.25; +/* "long double" cannot be pasted into a "long_double_val1" + identifier, so the long double globals use an "ldouble" prefix. */ +long double ldouble_val1 = 45.654; +long double ldouble_val2 = -67.66; +long double ldouble_val3 = 0.25; +long double ldouble_val4 = 1.25; +long double ldouble_val5 = 2.25; +long double ldouble_val6 = 3.25; +long double ldouble_val7 = 4.25; +long double ldouble_val8 = 5.25; +long double ldouble_val9 = 6.25; +long double ldouble_val10 = 7.25; +long double ldouble_val11 = 8.25; +long double ldouble_val12 = 9.25; +long double ldouble_val13 = 10.25; +long double ldouble_val14 = 11.25; +long double ldouble_val15 = 12.25; + #ifdef TEST_COMPLEX extern float crealf (float _Complex); extern float cimagf (float _Complex); @@ -359,20 +377,23 @@ float float_arg1, float_arg2; #endif /* Define a function NAME comparing its two TYPE arguments against the - TYPE_val1 and TYPE_val2 globals. */ + TYPE_val1 and TYPE_val2 globals. PREFIX is passed separately + because "long double" cannot be pasted into a "long_double_val1" + identifier. */ -#define DEFINE_T_FLOAT_VALUES(TYPE, NAME) \ +#define DEFINE_T_FLOAT_VALUES(TYPE, NAME, PREFIX) \ int \ NAME T_VALUES_PARAMS (TYPE) \ { \ - return ((arg1 - TYPE##_val1) < DELTA \ - && (arg1 - TYPE##_val1) > -DELTA \ - && (arg2 - TYPE##_val2) < DELTA \ - && (arg2 - TYPE##_val2) > -DELTA); \ + return ((arg1 - PREFIX##_val1) < DELTA \ + && (arg1 - PREFIX##_val1) > -DELTA \ + && (arg2 - PREFIX##_val2) < DELTA \ + && (arg2 - PREFIX##_val2) > -DELTA); \ } -DEFINE_T_FLOAT_VALUES (float, t_float_values2) -DEFINE_T_FLOAT_VALUES (double, t_double_values) +DEFINE_T_FLOAT_VALUES (float, t_float_values2, float) +DEFINE_T_FLOAT_VALUES (double, t_double_values, double) +DEFINE_T_FLOAT_VALUES (long double, t_long_double_values, ldouble) /* The parameter list of a t_TYPE_many_args function. Split out into prototyped vs non-prototyped variants because a macro body cannot @@ -394,9 +415,11 @@ DEFINE_T_FLOAT_VALUES (double, t_double_values) test that GDB can construct the parameter save area correctly. Note that Linux/ppc32 has 8 float registers to use for float parameter passing and Linux/ppc64 has 13, so the number of - arguments has to be at least 14 to contemplate these platforms. */ + arguments has to be at least 14 to contemplate these platforms. + PREFIX is passed separately because "long double" cannot be pasted + into a "long_double_val1" identifier. */ -#define DEFINE_T_MANY_ARGS(TYPE, NAME) \ +#define DEFINE_T_MANY_ARGS(TYPE, NAME, PREFIX) \ TYPE \ NAME T_MANY_ARGS_PARAMS (TYPE) \ { \ @@ -405,18 +428,19 @@ NAME T_MANY_ARGS_PARAMS (TYPE) \ \ sum_args = (f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 \ + f12 + f13 + f14 + f15); \ - sum_values = (TYPE##_val1 + TYPE##_val2 + TYPE##_val3 \ - + TYPE##_val4 + TYPE##_val5 + TYPE##_val6 \ - + TYPE##_val7 + TYPE##_val8 + TYPE##_val9 \ - + TYPE##_val10 + TYPE##_val11 + TYPE##_val12 \ - + TYPE##_val13 + TYPE##_val14 + TYPE##_val15); \ + sum_values = (PREFIX##_val1 + PREFIX##_val2 + PREFIX##_val3 \ + + PREFIX##_val4 + PREFIX##_val5 + PREFIX##_val6 \ + + PREFIX##_val7 + PREFIX##_val8 + PREFIX##_val9 \ + + PREFIX##_val10 + PREFIX##_val11 + PREFIX##_val12 \ + + PREFIX##_val13 + PREFIX##_val14 + PREFIX##_val15); \ \ return ((sum_args - sum_values) < DELTA \ && (sum_args - sum_values) > -DELTA); \ } -DEFINE_T_MANY_ARGS (float, t_float_many_args) -DEFINE_T_MANY_ARGS (double, t_double_many_args) +DEFINE_T_MANY_ARGS (float, t_float_many_args, float) +DEFINE_T_MANY_ARGS (double, t_double_many_args, double) +DEFINE_T_MANY_ARGS (long double, t_long_double_many_args, ldouble) /* Various functions for _Complex types. */ diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp index f020100ce8b..ebc389c6b03 100644 --- a/gdb/testsuite/gdb.base/callfuncs.exp +++ b/gdb/testsuite/gdb.base/callfuncs.exp @@ -136,6 +136,32 @@ proc do_function_calls {prototypes} { gdb_test "p t_double_many_args (double_val1, double_val2, double_val3, double_val4, double_val5, double_val6, double_val7, double_val8, double_val9, double_val10, double_val11, double_val12, double_val13, double_val14, double_val15)" " = 1" "call function with many double arguments." + gdb_test "p t_long_double_values(0.0,0.0)" " = 0" + # Same, via function pointer. When the pointer type is + # unprototyped, GDB has no parameter type to coerce the + # arguments to, so the literals must carry the "L" suffix to + # be passed as long double rather than double. + if {$prototypes} { + gdb_test "p ((int (*) (long double, long double)) t_long_double_values)(0.0,0.0)" " = 0" + } else { + gdb_test "p ((int (*) ()) t_long_double_values)(0.0L,0.0L)" " = 0" + } + + gdb_test "p t_long_double_values(45.654,-67.66)" " = 1" + if {$prototypes} { + gdb_test "p ((int (*) (long double, long double)) t_long_double_values)(45.654,-67.66)" " = 1" + } else { + gdb_test "p ((int (*) ()) t_long_double_values)(45.654L,-67.66L)" " = 1" + } + + gdb_test "p t_long_double_values(ldouble_val1,ldouble_val2)" " = 1" + gdb_test "p t_long_double_values(45.654,ldouble_val2)" " = 1" + gdb_test "p t_long_double_values(ldouble_val1,-67.66)" " = 1" + + gdb_test "p t_long_double_many_args (ldouble_val1, ldouble_val2, ldouble_val3, ldouble_val4, ldouble_val5, ldouble_val6, ldouble_val7, ldouble_val8, ldouble_val9, ldouble_val10, ldouble_val11, ldouble_val12, ldouble_val13, ldouble_val14, ldouble_val15)" \ + " = 1" \ + "call function with many long double arguments" + gdb_test "p t_double_int(99.0, 1)" " = 0" gdb_test "p t_double_int(99.0, 99)" " = 1" gdb_test "p t_int_double(99, 1.0)" " = 0" -- 2.54.0