From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id B4F843858D20 for ; Tue, 8 Aug 2023 18:08:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4F843858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691518119; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PyKDUZ3cOJsF8pKhaY6+IIlo8rCNFZqRJ8qOH3p/FMU=; b=OLGtwb0Gn1p8PHbVAqNezZyNv0MuPSvhLP3DeGKYn7lQfDrrX7U76MrY3jX9eAQdKH1UrP /wkfzCiX6SpwTWmyC/Z7gClYDLvbzggnSU+XxZIDbut/HrMtVhnxLI9nj9Q9plofLL70eN 6IPxeg1Rs+0NM+0w8CYY6LP7M45uz3E= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-534-t5jJODJXOVmh9wUE1b2WEA-1; Tue, 08 Aug 2023 14:08:37 -0400 X-MC-Unique: t5jJODJXOVmh9wUE1b2WEA-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7656c94fc4eso788056085a.2 for ; Tue, 08 Aug 2023 11:08:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691518117; x=1692122917; h=mime-version:user-agent:references:in-reply-to:date:cc:to:from :subject:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=3TEs4/yhNl8e3iWCtUVmZ2SbqEwhYzs4cf2jgbdQECo=; b=TJTJkcKilZn+pe7IOtbtTBKRXLBYgMjAha3CenXYEYbto1OP/KI2tJyghHnFwoMhF1 fKiitIpG1Br9qXvhbpB4n3jfFIs0DDQxyUMz6Ryoem6i30zkGwOzPrzO19eMIpGB1uF4 n0wZtrfWHGMrL5FMbvN2yJ/qhXOTEsG5oP+50rDGenjzeOojcN1F6ACyMReb2+AkYs4I 3JU1XJ5L3au96oB93NXec6/cniiq3q0ogX4r3zsp0b0vKHR6M9cCqNNZCWQqUPWJh7YR p3pIf+XaCRpUtdOhvO72IS6bt7+nED7sYJ4j0j9RDKhqqUYxr7Xk3t1Z+RCjzyzUfoGk UI2w== X-Gm-Message-State: AOJu0YzBXqX3CMqWlTEVT7NMSFwDbijohaC7nqqzKiVCkWYjpMYkfMJq 2FCqj298g1WMxZSiuOEHSk9Kfi7+5NrHzmriEqXKVN5Epyk3PNHzMzHagcuK7bt2a/RVZX+xqHs HeRGGQFrdj/7OS1M= X-Received: by 2002:a05:620a:22a8:b0:76c:b7f0:2b98 with SMTP id p8-20020a05620a22a800b0076cb7f02b98mr381928qkh.63.1691518116960; Tue, 08 Aug 2023 11:08:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8sooBaHM4W7cR8yUxQkWKr9oq/e8BGnRd9VjWZj/dVDoFePlWSLvu7O9yF/L4wPlYVZJCkg== X-Received: by 2002:a05:620a:22a8:b0:76c:b7f0:2b98 with SMTP id p8-20020a05620a22a800b0076cb7f02b98mr381913qkh.63.1691518116631; Tue, 08 Aug 2023 11:08:36 -0700 (PDT) Received: from t14s.localdomain (c-76-28-97-5.hsd1.ma.comcast.net. [76.28.97.5]) by smtp.gmail.com with ESMTPSA id s1-20020a05620a16a100b007676f3859fasm3471982qkj.30.2023.08.08.11.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 11:08:36 -0700 (PDT) Message-ID: <3ffdcc3451ee475f8edd293e4f3a1875432e59b1.camel@redhat.com> Subject: Re: [PATCH] WIP for dg-require-python-h [PR107646] From: David Malcolm To: Eric Feng Cc: gcc@gcc.gnu.org Date: Tue, 08 Aug 2023 14:08:34 -0400 In-Reply-To: <20230808165159.80250-1-ef2648@columbia.edu> References: <925a3480a840b43634c303d508ec2f908c92edff.camel@redhat.com> <20230808165159.80250-1-ef2648@columbia.edu> User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="=-6N0dFHy/gAz9N5dFwFPB" X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 List-Id: --=-6N0dFHy/gAz9N5dFwFPB Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2023-08-08 at 12:51 -0400, Eric Feng wrote: > Unfortunately, there doesn=E2=80=99t seem to be any ERRORs in the .log no= r > any of the debug print statements which I=E2=80=99ve scattered within pro= c > dg-require-python-h when run. I=E2=80=99ve attached the WIP below; thank = you! > Please note that in this version of the patch, I=E2=80=99ve removed the o= ther > (non Python) test cases in plugin.exp for convenience.=20 >=20 > Aside from issues with dg-require-python-h, everything works as > expected (when using /* { dg-options "-fanalyzer - > I/usr/include/python3.9" }. The patch includes support for > PyList_New, PyLong_FromLong, PyList_Append and also the optional > parameters for get_or_create_region_for_heap_alloc as we previously > discussed. I will submit the version of the patch sans dg-require- > python-h to gcc-patches for review as soon as I confirm regtests pass > as expected; perhaps we can first push these changes to trunk and > later push a separate patch for dg-require-python-h.=20 >=20 Hi Eric. I got dg-require-python-h working; I'm attaching a patch that seems to fix it (on top of your WIP patch). Looking in dg.exp, dg-test has a: set tmp [dg-get-options $prog] foreach op $tmp { =09verbose "Processing option: $op" 3 on the dg directives it finds, and at verbosity level 3 that wasn't firing. The issue turned out to be that the grep in dg.exp's dg-get-options for dg- directives requires them to have an argument. So fixing it from: /* { dg-require-python-h } */ to: /* { dg-require-python-h "" } */ gets it to recognize it as a directive and calls the new code. Some other fixes: - I put the /* { dg-require-effective-target analyzer } */ above the /* { dg-options "-fanalyzer" } */, since it seems to make more logical sense - within the new .exp code: - the new function needs to takes "args" (but will happily ignore them) - I put the upvar at the top of the function, as that what's everyone else seems to do. This may be "cargo cult programming" though. - I used verbose rather than "puts" for the debugging code - I reworked how the "unsupported" case works, copying what other target-supports code does. With this, hacking up the script invocation to be "not-python-3-config" so that it fails makes the test gracefully with UNSUPPORTED in the gcc.sum - As written the puts of $extra-tool-flags fails with: ERROR: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_= plugin.so: can't read "extra": no such variable for " dg-require-python-h 3= " since AIUI it looks for a variable names "extra" and tries to subtract from it. Putting the full variable name in {}, as ${extra-tool-flags} fixes that. With this, I get this for -test-2.c: PASS: gcc.dg/plugin/analyzer_cpython_plugin.c compilation PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for warnings, line 17) PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for warnings, line 18) PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for warnings, line 21) PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for warnings, line 31) PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for warnings, line 32) PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for warnings, line 35) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for warnings, line 45) PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for warnings, line 55) PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for warnings, line 63) PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for warnings, line 66) PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for warnings, line 68) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for warnings, line 69) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=3D./analyzer_cpython_p= lugin.so (test for excess errors) where the FAILs seem to be due to missing "leak of 'item'" messages, which might be due to -=C2=A0possibly not having all of the patch? - differences between python 3.8 and python 3.9 - differences between the --cflags affecting the gimple seen by the analyzer Anyway, hope this gets you unstuck. Dave --=-6N0dFHy/gAz9N5dFwFPB Content-Disposition: attachment; filename="0001-Fixup-Eric-s-WIP-for-dg-require-python-h.patch" Content-Type: text/x-patch; name="0001-Fixup-Eric-s-WIP-for-dg-require-python-h.patch"; charset="UTF-8" Content-Transfer-Encoding: base64 RnJvbSAxNmNhNDljYjQwYzNkMzRiMzU0N2IyZTA4MzRiYjUxYWUyNmUyZWI1IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBEYXZpZCBNYWxjb2xtIDxkbWFsY29sbUByZWRoYXQuY29tPgpE YXRlOiBUdWUsIDggQXVnIDIwMjMgMTM6NTM6MzkgLTA0MDAKU3ViamVjdDogW1BBVENIXSBGaXh1 cCBFcmljJ3MgV0lQIGZvciBkZy1yZXF1aXJlLXB5dGhvbi1oCgotL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