From: David Malcolm <dmalcolm@redhat.com>
To: Eric Feng <ef2648@columbia.edu>
Cc: gcc@gcc.gnu.org
Subject: Re: [PATCH] WIP for dg-require-python-h [PR107646]
Date: Tue, 08 Aug 2023 14:08:34 -0400 [thread overview]
Message-ID: <3ffdcc3451ee475f8edd293e4f3a1875432e59b1.camel@redhat.com> (raw)
In-Reply-To: <20230808165159.80250-1-ef2648@columbia.edu>
[-- Attachment #1: Type: text/plain, Size: 4597 bytes --]
On Tue, 2023-08-08 at 12:51 -0400, Eric Feng wrote:
> Unfortunately, there doesn’t seem to be any ERRORs in the .log nor
> any of the debug print statements which I’ve scattered within proc
> dg-require-python-h when run. I’ve attached the WIP below; thank you!
> Please note that in this version of the patch, I’ve removed the other
> (non Python) test cases in plugin.exp for convenience.
>
> 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.
>
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 {
verbose "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=./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=./analyzer_cpython_plugin.so (test for warnings, line 17)
PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 18)
PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 21)
PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 31)
PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 32)
PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 35)
FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 45)
PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 55)
PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 63)
PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 66)
PASS: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 68)
FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 69)
FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for excess errors)
where the FAILs seem to be due to missing "leak of 'item'" messages,
which might be due to
- possibly 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
[-- Attachment #2: 0001-Fixup-Eric-s-WIP-for-dg-require-python-h.patch --]
[-- Type: text/x-patch, Size: 2548 bytes --]
From 16ca49cb40c3d34b3547b2e0834bb51ae26e2eb5 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 8 Aug 2023 13:53:39 -0400
Subject: [PATCH] Fixup Eric's WIP for dg-require-python-h
---
.../gcc.dg/plugin/cpython-plugin-test-2.c | 4 +--
gcc/testsuite/lib/target-supports.exp | 28 +++++++++----------
2 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-2.c b/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-2.c
index 9eb411316bd..19b5c17428a 100644
--- a/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-2.c
+++ b/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-2.c
@@ -1,7 +1,7 @@
/* { dg-do compile } */
-/* { dg-options "-fanalyzer" } */
-/* { dg-require-python-h } */
/* { dg-require-effective-target analyzer } */
+/* { dg-options "-fanalyzer" } */
+/* { dg-require-python-h "" } */
#define PY_SSIZE_T_CLEAN
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index a1d4f684f8e..99d62ab98ad 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -12560,27 +12560,25 @@ proc check_effective_target_const_volatile_readonly_section { } {
return 1
}
-proc dg-require-python-h { } {
- puts "ENTER dg-require-python-h" ;
+proc dg-require-python-h { args } {
+ upvar dg-extra-tool-flags extra-tool-flags
+
+ verbose "ENTER dg-require-python-h" 2
+
set result [remote_exec host "python3-config --cflags"]
set status [lindex $result 0]
if { $status == 0 } {
set python_flags [lindex $result 1]
} else {
- set python_flags "UNSUPPORTED"
+ verbose "Python.h not supported" 2
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ return
}
-
- puts "Python flags are: $python_flags" ;
- # Check if Python flags are unsupported
- if { $python_flags eq "UNSUPPORTED" } {
- puts "Python flags are unsupported" ;
- error "Python flags are unsupported"
- return
- }
+ verbose "Python flags are: $python_flags" 2
- upvar dg-extra-tool-flags extra-tool-flags
- puts "Before appending, extra-tool-flags: $extra-tool-flags" ;
+ verbose "Before appending, extra-tool-flags: ${extra-tool-flags}" 3
eval lappend extra-tool-flags $python_flags
- puts "After appending, extra-tool-flags: $extra-tool-flags" ;
-}
\ No newline at end of file
+ verbose "After appending, extra-tool-flags: ${extra-tool-flags}" 3
+}
--
2.26.3
next prev parent reply other threads:[~2023-08-08 18:08 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-25 4:49 Update and Questions on CPython Extension Module -fanalyzer plugin development Eric Feng
2023-07-25 14:41 ` David Malcolm
2023-07-27 22:13 ` Eric Feng
2023-07-27 22:35 ` David Malcolm
2023-07-30 17:52 ` Eric Feng
2023-07-30 23:44 ` David Malcolm
2023-08-01 13:57 ` Eric Feng
2023-08-01 17:06 ` David Malcolm
2023-08-04 15:02 ` Eric Feng
2023-08-04 15:39 ` David Malcolm
2023-08-04 20:48 ` Eric Feng
2023-08-04 22:42 ` David Malcolm
2023-08-04 22:46 ` David Malcolm
2023-08-07 18:31 ` Eric Feng
2023-08-07 23:16 ` David Malcolm
2023-08-08 16:51 ` [PATCH] WIP for dg-require-python-h [PR107646] Eric Feng
2023-08-08 18:08 ` David Malcolm [this message]
2023-08-08 18:51 ` David Malcolm
2023-08-09 19:22 ` [PATCH v2] analyzer: More features for CPython analyzer plugin [PR107646] Eric Feng
2023-08-09 21:36 ` David Malcolm
2023-08-11 17:47 ` [COMMITTED] " Eric Feng
2023-08-11 20:23 ` Eric Feng
2023-08-16 19:17 ` Update on CPython Extension Module -fanalyzer plugin development Eric Feng
2023-08-16 21:28 ` David Malcolm
2023-08-17 1:47 ` Eric Feng
2023-08-21 14:05 ` Eric Feng
2023-08-21 15:04 ` David Malcolm
2023-08-23 21:15 ` Eric Feng
2023-08-23 23:16 ` David Malcolm
2023-08-24 14:45 ` Eric Feng
2023-08-25 12:50 ` Eric Feng
2023-08-25 19:50 ` David Malcolm
2023-08-29 4:31 ` [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646] Eric Feng
2023-08-29 4:35 ` Eric Feng
2023-08-29 17:28 ` Eric Feng
2023-08-29 21:14 ` David Malcolm
2023-08-30 22:15 ` Eric Feng
2023-08-31 17:01 ` David Malcolm
2023-08-31 19:09 ` Eric Feng
2023-08-31 20:19 ` David Malcolm
2023-09-01 1:25 ` Eric Feng
2023-09-01 11:57 ` David Malcolm
2023-09-05 2:13 ` [PATCH] analyzer: implement symbolic value support for CPython plugin's refcnt checker [PR107646] Eric Feng
2023-09-07 17:28 ` David Malcolm
2023-09-11 2:12 ` Eric Feng
2023-09-11 19:00 ` David Malcolm
2023-08-29 21:08 ` [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646] David Malcolm
2023-09-01 2:49 ` Hans-Peter Nilsson
2023-09-01 14:51 ` David Malcolm
2023-09-01 21:07 ` Eric Feng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ffdcc3451ee475f8edd293e4f3a1875432e59b1.camel@redhat.com \
--to=dmalcolm@redhat.com \
--cc=ef2648@columbia.edu \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).