I am the maintainer of a tracing profiler written in C called yappi (sumerc/yappi/) and
Blackfire. I have been using some weird ways/undocumented structures/APIs and somehow maintaining it for 10 years, but this
3.11 version was really, REALLY hard to support. Any help is really appreciated.
The version I am using is
3.11.0b5. My current problems is as following:
I have been using
frame->f_statestructure to check its generator state to detect if there is a coroutine running on it.Yappi supports asyncio wall-time profiling, thus I am using these states to measure coroutine enter/yield/exit.
See: yappi/_yappi.c at 58c876b52740aa7120daa7446543d2f0928b9623 · sumerc/yappi · GitHub.
I was using following code:
return (frame->f_state == FRAME_SUSPENDED);
Now thinking to use something like following:
But not sure if this is the correct way to do it.
I have been using:
const char *firstarg = PyStr_AS_CSTRING(PyTuple_GET_ITEM(cobj->co_varnames, 0));
co_varnamesis gone. I have read some suggestions on this:
either: (this seems to be slow)
PyObject *co_varnames = PyObject_GetAttrString((PyObject *)cobj, "co_varnames");
or I think Guido suggested to use below internal API for this:
But, when I compile the extension, with the including the header, I get symbol errors. How can I link these internal APIs in the extension? Any help on this?
This is the most problematic for me as it is causing a SIGSEGV without any clue. I have been calling Python function from C code to retrieve some metadata depending on the library used (asyncio, greenlet, threading…etc)
An example usage:
And I am calling these callbacks via following from C side:
Now, this type of calling currently throws seg. fault and I don’t have any clue on why. Here is a traceback:
(gdb) bt #0 _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:3873 #1 0x00005555557de1ea in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fed808, tstate=0x555555d1d1c8 <_PyRuntime+166312>) at ./Include/internal/pycore_ceval.h:73 #2 _PyEval_Vector (tstate=0x555555d1d1c8 <_PyRuntime+166312>, func=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>, kwnames=<optimized out>) at Python/ceval.c:6424 #3 0x00005555556b8184 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=0, args=0x7fffffffc230, callable=0x7ffff61649a0, tstate=0x555555d1d1c8 <_PyRuntime+166312>) at ./Include/internal/pycore_call.h:92 #4 object_vacall (tstate=0x555555d1d1c8 <_PyRuntime+166312>, base=base@entry=0x0, callable=0x7ffff61649a0, vargs=vargs@entry=0x7fffffffc290) at Objects/call.c:819 #5 0x00005555556bcf38 in PyObject_CallFunctionObjArgs (callable=<optimized out>) at Objects/call.c:925 #6 0x00007ffff6432fab in _call_funcobjargs (func=<optimized out>, args=args@entry=0x0) at yappi/_yappi.c:342 #7 0x00007ffff64342d3 in _current_context_name () at yappi/_yappi.c:358 #8 _yapp_callback (self=<optimized out>, frame=0x7ffff61c4e10, what=<optimized out>, arg=0x0) at yappi/_yappi.c:1212
Any help is really appreaciated!
Thanks in advance,