Chris, could you please repeat that step by step in more detail? I'm not sure I understand your suggestions. Christian Tismer wrote: > > Vladimir Marangozov wrote: > ... > > I wrote a very rough first implementation of this idea. The files are at: > > > > http://sirac.inrialpes.fr/~marangoz/python/lineno/ > > > > Basically, what I did is: > > > > 1) what I said :-) > > 2) No more SET_LINENO > > 3) In tracing mode, a copy of the original code is put in an additional > > slot (co_tracecode) of the code object. Then it's overwritten with > > CALL_TRACE opcodes at the locations returned by PyCode_Line2Addr. > > I'd rather keep the original code object as it is, create a copy > with inserted breakpoints and put that into the frame slot. You seem to suggest to duplicate the entire code object, right? And reference the modified duplicata from the current frame? I actually duplicate only the opcode string (that is, the co_code string object) and I don't see the point of duplicating the entire code object. Keeping a reference from the current frame makes sense, but won't it deallocate the modified version on every frame release (then redo all the code duplication work for every frame) ? > Pointing back to the original from there. I don't understand this. What points back where? > > Then I'd redirect the code from the CALL_TRACE opcode completely > to a user-defined function. What user-defined function? I don't understand that either... Except the sys_tracefunc, what other (user-defined) function do we have here? Is it a Python or a C function? > Getting rid of the extra code object would be done by this function > when tracing is off. How exactly? This seems to be obvious for you, but obviously, not for me ;-) > It also vanishes automatically when the frame is released. The function or the extra code object? > > > a) how to deallocate the modified code string when tracing is off > > By making the copy a frame property which is temporary, I think. I understood that the frame lifetime could be exploited "somehow"... > Or, if tracing should work for all frames, by pushing the original > in the back of the modified. Both works. Tracing is done for all frames, if sys_tracefunc is not NULL, which is a function that usually ends up in the f_trace slot. > > ciao - chris I'm confused. I didn't understand your idea. -- Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4