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