Hi,
I've created a module to dump function trace during execution of Python
script. You can see session example in attachment. The format is of PHP
Xdebug tool [2] just because I had some scripts from the past to analyze it.
The module uses sys.settrace() to analyse frames in 'call' events with
callback(frame, event, arg).
Recently I've got an anonymous report that some frame misses filename
information when run under IDE:
https://bitbucket.org/techtonik/xtrace/issue/2/use-of-xtrace-module-within-ide-causes
There is unlikely to be any more feedback from the user to make me
understand and reproduce the behavior, nor there is a sufficient
documentation in sys.trace description [1]. So I am on my own. But I can
not read C code the CPython is written in, so I ask here.
What are possible execution contexts for Python?
How each execution context affects data structure that is passed to trace
function (frame and arg)?
Please, CC. Thanks.
1.
http://docs.python.org/3/library/sys.html?highlight=sys.settrace#sys.settrace
2. Example of PHP function trace: http://xdebug.org/docs/execution_trace
--
anatoly t.
> cat a.py
from ctypes import wintypes
print wintypes.LONG
> python2 xtrace.py a.py
TRACE START [2013-03-20 15:38:43]
-> <>(a.py) xtrace.py:1
-> <ctypes>(C:\Python27\lib\ctypes\__init__.py) a.py:4
-> <struct>(C:\Python27\lib\struct.py)
C:\Python27\lib\ctypes\__init__.py:1
-> py_object() C:\Python27\lib\ctypes\__init__.py:159
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_short() C:\Python27\lib\ctypes\__init__.py:168
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_ushort() C:\Python27\lib\ctypes\__init__.py:172
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_long() C:\Python27\lib\ctypes\__init__.py:176
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_ulong() C:\Python27\lib\ctypes\__init__.py:180
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_float() C:\Python27\lib\ctypes\__init__.py:197
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_double() C:\Python27\lib\ctypes\__init__.py:201
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_longdouble() C:\Python27\lib\ctypes\__init__.py:205
-> c_longlong() C:\Python27\lib\ctypes\__init__.py:215
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_ulonglong() C:\Python27\lib\ctypes\__init__.py:219
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_ubyte() C:\Python27\lib\ctypes\__init__.py:226
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_byte() C:\Python27\lib\ctypes\__init__.py:233
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_char() C:\Python27\lib\ctypes\__init__.py:238
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_char_p() C:\Python27\lib\ctypes\__init__.py:243
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_void_p() C:\Python27\lib\ctypes\__init__.py:255
-> _check_size() C:\Python27\lib\ctypes\__init__.py:147
-> c_bool() C:\Python27\lib\ctypes\__init__.py:260
-> c_wchar_p() C:\Python27\lib\ctypes\__init__.py:291
-> c_wchar() C:\Python27\lib\ctypes\__init__.py:294
-> CDLL() C:\Python27\lib\ctypes\__init__.py:332
-> PyDLL() C:\Python27\lib\ctypes\__init__.py:388
-> WinDLL() C:\Python27\lib\ctypes\__init__.py:397
-> HRESULT() C:\Python27\lib\ctypes\__init__.py:406
-> OleDLL() C:\Python27\lib\ctypes\__init__.py:419
-> LibraryLoader() C:\Python27\lib\ctypes\__init__.py:428
-> __init__() C:\Python27\lib\ctypes\__init__.py:429
-> __init__() C:\Python27\lib\ctypes\__init__.py:429
-> __init__() C:\Python27\lib\ctypes\__init__.py:349
-> _FuncPtr() C:\Python27\lib\ctypes\__init__.py:359
-> __init__() C:\Python27\lib\ctypes\__init__.py:429
-> __init__() C:\Python27\lib\ctypes\__init__.py:429
-> __getattr__() C:\Python27\lib\ctypes\__init__.py:432
-> __init__() C:\Python27\lib\ctypes\__init__.py:349
-> _FuncPtr() C:\Python27\lib\ctypes\__init__.py:359
-> __getattr__() C:\Python27\lib\ctypes\__init__.py:375
-> __getitem__() C:\Python27\lib\ctypes\__init__.py:382
-> CFUNCTYPE() C:\Python27\lib\ctypes\__init__.py:78
-> CFunctionType() C:\Python27\lib\ctypes\__init__.py:104
-> CFUNCTYPE() C:\Python27\lib\ctypes\__init__.py:78
-> CFunctionType() C:\Python27\lib\ctypes\__init__.py:104
-> PYFUNCTYPE() C:\Python27\lib\ctypes\__init__.py:493
-> CFunctionType() C:\Python27\lib\ctypes\__init__.py:494
-> PYFUNCTYPE() C:\Python27\lib\ctypes\__init__.py:493
-> CFunctionType() C:\Python27\lib\ctypes\__init__.py:494
-> PYFUNCTYPE() C:\Python27\lib\ctypes\__init__.py:493
-> CFunctionType() C:\Python27\lib\ctypes\__init__.py:494
-> <ctypes._endian>(C:\Python27\lib\ctypes\_endian.py)
C:\Python27\lib\ctypes\__init__.py:4
-> _swapped_meta() C:\Python27\lib\ctypes\_endian.py:26
-> BigEndianStructure() C:\Python27\lib\ctypes\_endian.py:49
-> _reset_cache() C:\Python27\lib\ctypes\__init__.py:265
-> CFUNCTYPE() C:\Python27\lib\ctypes\__init__.py:78
-> CFunctionType() C:\Python27\lib\ctypes\__init__.py:104
-> <ctypes.wintypes>(C:\Python27\lib\ctypes\wintypes.py) a.py:6
-> VARIANT_BOOL() C:\Python27\lib\ctypes\wintypes.py:23
-> RECT() C:\Python27\lib\ctypes\wintypes.py:100
-> _SMALL_RECT() C:\Python27\lib\ctypes\wintypes.py:107
-> _COORD() C:\Python27\lib\ctypes\wintypes.py:114
-> POINT() C:\Python27\lib\ctypes\wintypes.py:118
-> SIZE() C:\Python27\lib\ctypes\wintypes.py:123
-> FILETIME() C:\Python27\lib\ctypes\wintypes.py:131
-> MSG() C:\Python27\lib\ctypes\wintypes.py:136
-> WIN32_FIND_DATAA() C:\Python27\lib\ctypes\wintypes.py:146
-> WIN32_FIND_DATAW() C:\Python27\lib\ctypes\wintypes.py:158
<class 'ctypes.c_long'>
-> stop() xtrace.py:84
-> stop() xtrace.py:36
TRACE END [2013-03-20 15:38:43]
_______________________________________________
pypy-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-dev