From patchwork Sat Apr 13 07:41:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Kaplun X-Patchwork-Id: 88452 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B04CA3858D3C for ; Sat, 13 Apr 2024 07:41:55 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [95.163.41.86]) by sourceware.org (Postfix) with ESMTPS id 0A6D3385842A for ; Sat, 13 Apr 2024 07:41:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0A6D3385842A Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=mail.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mail.ru ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0A6D3385842A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=95.163.41.86 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712994088; cv=none; b=l+v8IfzPOQbo16jSblO0B6f9hKyCKKpxWwqja5Pr6Lcv4LWEp4F53hgkR0vQRNp11WFx2uHwN42nDwAw0VAbYBFmrmDXcL03IYxaztdc+EwK1z7AEFaccBdsBJLdqSL3Nm/h+9CYw75xsk31WKBh6jpUxmWnOFI6MKjdo96AmFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712994088; c=relaxed/simple; bh=vYfbrupG6yvfuCLFSbLQDAlGGoc3bwW4z1I5xNLQLhk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=l6nJsKL5dLfMWjuwVIuNysvDFBx5Yu9A3yPaWZQrquZhoybbVSWMLGgkZTyoE1PPvqHoxVBFTt/e4kg49EHIS1MJtzWL8udAgUOogGjfsonOUrm9FGlBXTqXawDM3qlGftCdcfLqMpXb7FOQa6w+VY3cqoHLs10yKiB5DyqxAK8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail4; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:From:Date:From:Sender:Reply-To:To:Cc:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive: X-Cloud-Ids:Disposition-Notification-To; bh=1X1njjM6RBoA5Pvr0wgmFUk5p5A76FGDI22lmcZiZDI=; t=1712994085; x=1713084085; b=LB2BOZwiebSiDKrMTA8jI4Sp4duNTLpnOxQXzWJ5S7wEm77xaupR0BOMHc7N+lIw4XGnhogcU/L U47Qs1Pgqt8Ov9rcKypOQBLUXF9ikdaDIKM0wYwS0wWSBBlm8hUkKUgo3HGRCfDJL24gor6DocclJ 9Iy+wbTsm+ntx6GLsz1fqGF23Aw4oLd3x+AoUEbpiIs+xE91ITHIjJcKqxLlYP9pFquVSeWlvgGov /AVfBKgZ41btnudo26KrfONAtpjyUnDXnzgqfp6B2NFvJdWPaSrdePwBviUzEUAKH1eeA+Hu5DcUc 2cJq5VN/iTiY0VbdgsYQX3Y/tomCxJFYvCoQ==; Received: by smtp48.i.mail.ru with esmtpa (envelope-from ) id 1rvY0o-00000001cDN-0oF4 for gdb-patches@sourceware.org; Sat, 13 Apr 2024 10:41:22 +0300 Date: Sat, 13 Apr 2024 10:41:20 +0300 From: Sergey Kaplun To: gdb-patches@sourceware.org Subject: [PING] [PATCH v1 0/2] Fix the right shift of negative numbers Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Authentication-Results: smtp48.i.mail.ru; auth=pass smtp.auth=sergey_v_kaplun@mail.ru smtp.mailfrom=sergey_v_kaplun@mail.ru X-Mailru-Src: smtp X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D327C87852EB66D37A377202123D15E2522C17BB21D33F58182A05F538085040CF3EFC8C16201E039487ABAC94A94B54603B90F5E0B0EFA4EAC2C6C905A38352AF0056C46A67EA41 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70CF6737295EB4C15EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D58A1C8964E53F0E8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D87CDA8CAD99EB175EA736E8CB73A017D3FFD3AFC7BA05789620879F7C8C5043D14489FFFB0AA5F4BF176DF2183F8FC7C000E2D00546020E658941B15DA834481FA18204E546F3947C65B78C30F681404DF6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F7900637200F62B2C1E683AF389733CBF5DBD5E9B5C8C57E37DE458B9E9CE733340B9D5F3BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4931B544F03EFBC4D571D6A3D1828C12CDEC4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5661155B43A84E5E55002B1117B3ED696CDDA93704E3F172CE41E333F9D1358D5823CB91A9FED034534781492E4B8EEADC3194D76C41E9723C79554A2A72441328621D336A7BC284946AD531847A6065A17B107DEF921CE79BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF77DD89D51EBB7742D3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFA1947BAD1B6B130D2F1B4BA2E9A5EE72A18C7D38435ED5EA06AE34B409DCAFAC711F655CCE117FA31E5F415AA55898CCA5A8ADF8D2F04C6096B11D90C70994A85784AAEE8FF0390A383C93C5AD2DA449913E6812662D5F2AB9AF64DB468876803B9091C2F776607721F8114A732E981437E69C174A41D00C X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXhwSCSOI/ZezdGiEgrxx21X X-Mailru-Sender: 689FA8AB762F7393590D8C940224AE3313328ABB7187847F96EEBE670E5BC629821B968956CC46201CD6CF9A2A1E3F29C02EE44510EC069EDFF04496585778BA3C3E1DAAA4FD9C8420D68A02B3A7A3F5DF29DA55C944B5EC0D4ABDE8C577C2ED X-Mras: Ok X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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+patchwork=sourceware.org@sourceware.org Hi, folks! I am looking forward to your reply! Should I create an issue related to this patchset? Also, for these 2 weeks, I've dived a bit into the problems around OpenCL and CI failures (see links below) and need help with the following questions: Since commit 63c457b91104 ("gmp-utils: protect gdb_mpz exports against out-of-range values"), the subtest max-uint64 of the enabled test fails [1] on a 32-bit arm since "the 0xffffffffffffffff value cannot be represented as 32-bit unsigned integer". Should I disable this test for the 32-bit arm, or skip it somehow? Also, on the aarch64, the subtest "-1 >> 1" fails [2] before the fix in the second commit. Should I squash the commits to avoid regressions between commits? Plus, I've dived a bit into OpenCL failures. After the commit 55fc1623f942 ("Add name canonicalization for C") the corresponding OpenCL cast fails with the error: | gdb -ex 'set language opencl' -ex 'p (signed char) 1' -ex 'quit' | ... | No type named signed char. Since for OpenCL "signed char" is valid [3] and looks like it is the same type as just "char" [4], it should be fixed like the following: =================================================================== =================================================================== But even if I ran the executable from the directory with the datatypes.cl file, I got the following errors: | clBuildProgram failed with: | 1:116:16: error: double precision constant requires cl_khr_fp64, casting to single precision | half h = 1.0; | ^ | 1:117:25: error: double precision constant requires cl_khr_fp64, casting to single precision | half2 h2 = (half2) (1.0, 2.0); | ^ | ... If I remove the ".0" parts, then it runs OK, but I still can't set a breakpoint on the `testkernel`. I'm kind of stuck here and don't know what to do. [1]: https://ci.linaro.org/job/tcwg_gdb_check--master-arm-precommit/2073/artifact/artifacts/artifacts.precommit/notify/ [2]: https://ci.linaro.org/job/tcwg_gdb_check--master-aarch64-precommit/2072/artifact/artifacts/artifacts.precommit/notify/ [3]: https://godbolt.org/z/obPGdses6 [4]: https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html#built-in-scalar-data-types diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 1e1a7e9ce61..8dc1872849d 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1684,8 +1684,9 @@ lookup_unsigned_typename (const struct language_defn *language, struct type * lookup_signed_typename (const struct language_defn *language, const char *name) { - /* In C and C++, "char" and "signed char" are distinct types. */ - if (streq (name, "char")) + /* In C and C++, "char" and "signed char" are distinct types. + But not in OpenCL. */ + if (streq (name, "char") && language->la_language != language_opencl) name = "signed char"; return lookup_typename (language, name, NULL, 0); } diff --git a/gdb/testsuite/gdb.opencl/datatypes.cl b/gdb/testsuite/gdb.opencl/datatypes.cl index 999defa38b4..d390eb02b3f 100644 --- a/gdb/testsuite/gdb.opencl/datatypes.cl +++ b/gdb/testsuite/gdb.opencl/datatypes.cl @@ -46,6 +46,8 @@ __kernel void testkernel (__global int *data) char8 c8 = (char8) (1, 2, 3, 4, 5, 6, 7, 8); char16 c16 = (char16)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); + signed char c_signed = 1; + uchar uc = 1; uchar2 uc2 = (uchar2) (1, 2); #ifdef CL_VERSION_1_1 diff --git a/gdb/testsuite/gdb.opencl/datatypes.exp b/gdb/testsuite/gdb.opencl/datatypes.exp index 16243ad3cfb..c47c4873421 100644 --- a/gdb/testsuite/gdb.opencl/datatypes.exp +++ b/gdb/testsuite/gdb.opencl/datatypes.exp @@ -53,6 +53,9 @@ gdb_test "p sizeof(char8)" " = 8" gdb_test "whatis char16" "type = char16" gdb_test "p sizeof(char16)" " = 16" +gdb_test "whatis signed char" "type = char" +gdb_test "p sizeof(signed char)" " = 1" + gdb_test "whatis unsigned char" "type = unsigned char" gdb_test "p sizeof(unsigned char)" " = 1" gdb_test "whatis uchar" "type = uchar" @@ -247,6 +250,10 @@ gdb_test "whatis c16" "type = char16" gdb_test "p sizeof(c16)" " = 16" gdb_test "print c16" " = \\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16\\}" +gdb_test "whatis c_signed" "type = char" +gdb_test "p sizeof(c_signed)" " = 1" +gdb_test "print/d c_signed" " = 1" + gdb_test "whatis uc" "type = uchar" gdb_test "p sizeof(uc)" " = 1" gdb_test "print/d uc" " = 1" =================================================================== Also, locally, I've tracked down that the OpenCL tests are skipped due to the following warnings: | /home/burii/binutils-gdb-master/gdb/testsuite/lib/cl_util.c:371:70: warning: format '%d' expects argument of type 'int', but argument 2 has type 'size_t' {aka 'long unsigned int'} [-Wformat=] | 371 | printf (" CL_DEVICE_IMAGE3D_MAX_DEPTH: %d\n", sizet); | | ~^ ~~~~~ | | | | | | int size_t {aka long unsigned int} | | %ld | In file included from /usr/include/CL/cl.h:20, | from /home/burii/binutils-gdb-master/gdb/testsuite/lib/opencl_hostapp.c:28: | /usr/include/CL/cl_version.h:22:9: note: '#pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)' | 22 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)") | | ^~~~~~~ | /home/burii/binutils-gdb-master/gdb/testsuite/lib/opencl_hostapp.c: In function 'main': | /home/burii/binutils-gdb-master/gdb/testsuite/lib/opencl_hostapp.c:81:3: warning: 'clCreateCommandQueue' is deprecated [-Wdeprecated-declarations] | 81 | queue = clCreateCommandQueue (context, device, 0, &err); | | ^~~~~ | /usr/include/CL/cl.h:1920:1: note: declared here | 1920 | clCreateCommandQueue(cl_context context, | | ^~~~~~~~~~~~~~~~~~~~ Since the output of the CC command isn't empty, the OpenCL suite is declared unsupported. I added the following hotfix to run tests: =================================================================== diff --git a/gdb/testsuite/lib/opencl.exp b/gdb/testsuite/lib/opencl.exp index caa0e1e2911..7d2316edad7 100644 --- a/gdb/testsuite/lib/opencl.exp +++ b/gdb/testsuite/lib/opencl.exp @@ -23,6 +23,7 @@ proc gdb_compile_opencl_hostapp {clsource executable options} { set src "${srcdir}/lib/cl_util.c ${srcdir}/lib/opencl_hostapp.c" set binfile [standard_output_file ${executable}] set compile_flags [concat additional_flags=-I${srcdir}/lib/ additional_flags=-DCL_SOURCE=$clsource] + set compile_flags [concat $compile_flags additional_flags=-DCL_TARGET_OPENCL_VERSION=300 additional_flags=-w] set options_opencl [concat {debug} $compile_flags $options [list libs=-lOpenCL]] return [gdb_compile ${src} ${binfile} "executable" ${options_opencl}] } =================================================================== Then I run the testcase like the following, with the result: | make check TESTS="gdb.opencl/datatypes.exp" | grep FAIL | WARNING: Couldn't find the global config file. | FAIL: gdb.opencl/datatypes.exp: whatis char16 | FAIL: gdb.opencl/datatypes.exp: p sizeof(char16) | FAIL: gdb.opencl/datatypes.exp: whatis uchar16 | FAIL: gdb.opencl/datatypes.exp: p sizeof(uchar16) | ... all 16-bit values fail | ERROR: (datatypes) No such file or directory | FAIL: gdb.opencl/datatypes.exp: run | .. all after it fail To make this work, I've added the following fix: =================================================================== diff --git a/gdb/testsuite/gdb.opencl/datatypes.exp b/gdb/testsuite/gdb.opencl/datatypes.exp index 16243ad3cfb..539099d9c0f 100644 --- a/gdb/testsuite/gdb.opencl/datatypes.exp +++ b/gdb/testsuite/gdb.opencl/datatypes.exp @@ -22,10 +22,11 @@ load_lib opencl.exp require allow_opencl_tests set testfile "datatypes" -set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl] +set clsource ${srcdir}/${subdir}/${testfile}.cl +set clprogram [remote_download target ${clsource}] # Compile the generic OpenCL host app -if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } { +if { [gdb_compile_opencl_hostapp "${clsource}" "${testfile}" "" ] != "" } { untested "failed to compile" return -1 } @@ -197,7 +201,7 @@ gdb_test_no_output "set language auto" "no prompt when setting the language to a # Load the OpenCL app gdb_reinitialize_dir $srcdir/$subdir -gdb_load ${objdir}/${subdir}/${testfile} +gdb_load ${objdir}/outputs/${subdir}/${testfile}/${testfile} # Set breakpoint at the OpenCL kernel gdb_test "tbreak testkernel" \