Open mahrud opened 1 month ago
Other observation: if I comment out these lines: https://github.com/Macaulay2/M2/blob/ec9e9ac60ed4a8e791448942202f077a88a87e15/M2/Macaulay2/m2/debugging.m2#L15-L18 then everything works fine:
i4 : blah 12
../../m2/debugging.m2:6:17:(1): error: debug me
../../m2/debugging.m2:6:17:(1): --entering debugger (type help to see debugger commands)
../../m2/debugging.m2:6:12-6:28: --source code:
blah = x -> error "debug me"
So maybe a naive solution is to move that segment to the interpreter.
Playing around with setting loadDepth
to something lower before that section and resetting it after doesn't seem to help either.
@pzinn my best guess is that the FilePosition of the error code is somehow involved, but I don't know where to look for more clues.
In #3431 I'm adding a new keyword breakpoint
which can be used to start the debugger in the correct location. e.g. instead of adding error "debug me"
you could add:
kernel Matrix := Module => opts -> (cacheValue symbol kernel) ((m) -> (
N := source m;
if m == 0 then return N;
P := target m;
if m.?RingMap then (
f := m.RingMap;
n := map(target m,f source m,raw m);
- p := pushNonLinear(options pushForward, f, coimage n);
+ p := breakpoint pushNonLinear(options pushForward, f, coimage n);
image p)
else (
m = matrix m;
if P.?generators then m = P.generators * m;
h := modulo(m, if P.?relations then P.relations);
if N.?generators then h = N.generators * h;
subquotient( h, if N.?relations then N.relations))))
Other observation: if I comment out these lines:
then everything works fine:
i4 : blah 12 ../../m2/debugging.m2:6:17:(1): error: debug me ../../m2/debugging.m2:6:17:(1): --entering debugger (type help to see debugger commands) ../../m2/debugging.m2:6:12-6:28: --source code: blah = x -> error "debug me"
So maybe a naive solution is to move that segment to the interpreter.
Playing around with setting
loadDepth
to something lower before that section and resetting it after doesn't seem to help either.@pzinn my best guess is that the FilePosition of the error code is somehow involved, but I don't know where to look for more clues.
definitely these lines should go at some point (and be moved to the interpreter).
Interestingly, the same test you propose at the top produces a quite different result on Macaulay2Web, which incorporates some major changes I made to the error workflow. I'll try to analyse where the difference is. Also, the interaction between TCO and debugging is messy, cf possibly related #3371 (on which I'm stuck).
Interestingly, the same test you propose at the top produces a quite different result on Macaulay2Web, which incorporates some major changes I made to the error workflow.
On the other hand, it used to work as late as version 1.21:
Macaulay2, version 1.21
i1 : debug Core
i2 : errorDepth=1
o2 = 1
i3 : blah()
M2/Macaulay2/m2/debugging.m2:6:13:(1):[1]: error: debug me
M2/Macaulay2/m2/debugging.m2:6:13:(1):[1]: --entering debugger (type help to see debugger commands)
M2/Macaulay2/m2/debugging.m2:6:13-6:13: --source code:
blah = x -> error "debug me"
So analyzing the differences since then could also work.
Very exiting realization: the breakpoint
keyword that I added in #3431 allows you to drop into a thread for debugging! This is currently not possible using error
, at least as far as I can tell.
@mikestillman pointed out something which I had also observed and noted on other issues here, which is that the debugger often doesn't end up in the right place in the Core.
Here is how to reproduce: insert
blah = x -> error "debug me"
somewhere in Core, then run it witherrorDepth
one or less. Here is the result for me:I don't seem to be able to get the original location in anyway.
One interesting factor is that avoiding tail-end optimization of
error
leads to the symbols remaining accessible. If I instead addblah = x -> (error "debug me";)
then I get:So far identical, but:
Note that if instead of
error "debug me"
I had put1/0
then location would have worked fine.Related to this, there are a number of tests for error messages here that weren't being tested manually. Perhaps they should be moved to a
manual
directory, with more documentation of expected behavior, or somehow made automatic.