Jython fully supports the standard tracing/profiling API (sys.settrace, sys.setprofile). In addition, a subset of debugging (pdb) is supported, namely we don't allow for setting jumps. However, we don't support returning exactly the same sequence of events. You can see this in the 2.5 tests, test_trace and test_profile, as well as run standard profiling. (Note we only support profile, not cProfile.)

Standard attributes are available on the frame, including f_lineno. You can access directly or use inspect, the latter works in 2.5, and perhaps earlier. Generated Java bytecode sets this attribute in the PyFrame object, as well as emitting the corresponding JVM metadata. This allows for debugging either by pdb type debuggers or by standard Java source debuggers. We need both because we cannot introspect running Java bytecode in process without using an agent, that's a (security) restriction of the JVM.

co_lnotab is therefore an implementation detail that supports this functionality for CPython bytecode.

Jython 2.5.0 supports the execution of CPython bytecode, although this feature must be considered experimental at this point. A future release (likely 2.5.1) will enable the compilation of CPython bytecode, until then you need a separate compiler. (CPython is a good choice, although it doesn't support quite the same grammar, eg no direct usage of class, in, and other attributes that are normally keywords in Python - Jython of course relaxes this restriction.) For these code objects, the stdlib dis seems to work just fine. You can see an example of how to work with this in test_pbcvm.py. Certainly feel free to contact me for more details or better yet discuss on #jython.

I don't know the specifics of Coverage or figleaf, and how much they depend on the CPython bytecode format, but hopefully they don't rely too much on the CPython bytecode format. Alternatively, you could try our CPython bytecode support, most of the regrtest passes it, with failures only occurring for code object introspection and slightly different float formats (for NaN, that sort of thing) when marshaled.

- Jim

On Mon, May 11, 2009 at 7:05 AM, Chris Burroughs <chris.burroughs@gmail.com> wrote:
Most python coverage tools depend on the CPython co_lnotab
implementation.  For example, both Coverage and figleaf use code like
this modeled on the stdlib dis and trace modules:
byte_increments = [ord(c) for c in code.co_lnotab[0::2]]
line_increments = [ord(c) for c in code.co_lnotab[1::2]]

The jython differences page
<http://jython.sourceforge.net/docs/differences.html>  says that this
co_lnotab will probably never be supported.  What is the recommended
way for developers to determine which lines of jython code were
executed?  Have the co_lnotab support plans changed,  or should the
.class files be examined, or is there an alternative approach?

Thank you.

The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
Jython-dev mailing list

Jim Baker