Message2961
I'm attaching a patch which I believe fixes (or at least greatly improves) problem 1757127 - Jython hangs under PyDev debugger
I'm attaching two versions: one for trunk, and one for Jython 2.2.1.
There seems to be some incompatibility between PyDev and the current Jython trunk version which causes an error when the interpreter is configured.
Description of change:
--------------------------------
PyDev was unable to debug using recent versions of Jython although it was fully capable of debugging
using recent versions of CPython.
The root of the problem appears to be that Jython has a single global trace-function hook whereas CPython maintains
a separate hook for each thread.
This patch changes Jython by moving the trace and profiling hooks from PySystemState.java (global) to ThreadState.java (thread-local)
and by adjusting other code to adapt to that change.
The source for CPython 2.4 was used for comparision to verify that this is an appropriate fix.
Details of changes:
----------------------------
[ ThreadState.java ]
1) Moved tracefunc and profilefunc here from PySystemState.java
[ PySystemState.java ]
1) Moved tracefunc and profilefunc from here to ThreadState.java
2) In settrace() and setprofile() set the trace and profile functions in the corresponding ThreadState object rather than globally (i.e. PySystemState).
[ PythonTraceFunction.java ]
1) On error, clear the tracefunc and profilefunc in the corresponding ThreadState object rather than globally (i.e. PySystemState).
[ PyTableCode.java ]
1) Use tracefunc and profilefunc from the corresponding ThreadState object rather than globally.
2) Set the line number in the frame before calling traceCall(). This seems to report the line number consistently with CPython.
3) Removed a large comment that appears to be outdated especially after the changes.
[ PyFrame.java ]
1) Add a comment for setline() since there is method in CPython that has a similar name but does something completely different.
[ InteractiveInterpreter.java ]
1) Use ThreadState rather that PySystemState
[ threading.py ]
1) Added setprofile() and settrace() from CPython 2.5
Testing done:
-------------------
A number of scripts were debugged using PyDev 1.3.8. The following features were tested:
Setting/clearing breakpoints
Stopping at breakpoints
Resuming from breakpoints
Stepping
Return from functions
Examining variables
Terminating a debug session
Some regression tests that use tracing/profiling were run:
test_trace.py - fails, is on the "failures" list.
Note: CPython 2.4 also fails this test.
test_scope - passes
test_profilehooks - fails, is on the "failures" list
Note: CPython 2.4 also fails this test
Testing not done:
-------------------------
Not tested with any other debugger. Are there any others that work with Jython?
Profiling - this fix involves profiling but no tests were done for that.
Other programs (besides debuggers) that rely on tracing - perhaps other programs depend upon the existing Jython implementation.
|
|
| Date |
User |
Action |
Args |
| 2008-02-20 17:18:53 | admin | link | issue1841378 messages |
| 2008-02-20 17:18:53 | admin | create | |
|