bugGNU Octave - Bugs: bug #65330, dblist should print out lines...

 
 

bug #65330: dblist should print out lines around current point in the stack, not just bottom of stack

Submitter:  Richard <crobar>
Submitted:  Mon 19 Feb 2024 12:53:53 PM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  10.1.0 (current default)
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 23 Feb 2024 01:33:21 AM UTC, comment #15: 

I can still get the numbering to default to 1 after an "error", but I'm also not that bothered by it.  It resets itself to the correct value after one dbnext step.  And for normal debugging it works completely as intended.

Rik <rik5>
Group administrator
Thu 22 Feb 2024 06:29:12 PM UTC, comment #14: 
John W. Eaton <jwe>
Group administrator
Thu 22 Feb 2024 10:45:08 AM UTC, comment #13: 

Happy to test things on Matlab here.

Richard <crobar>
Thu 22 Feb 2024 01:02:21 AM UTC, comment #12: 

Maybe this change instead?



(file #55733)

John W. Eaton <jwe>
Group administrator
Wed 21 Feb 2024 11:15:47 PM UTC, comment #11: 

Maybe we could get someone to test recursive debugging on Matlab?  I agree that it is starting to feel esoteric.  I'm sure 99% of problems can be debugged in a forward mode without needing recursion.

Rik <rik5>
Group administrator
Wed 21 Feb 2024 10:47:54 PM UTC, comment #10: 

Yeah, I'll try to do something here.

The whole recursive debugging levels thing is weird, but I thought we determined some time ago that it is also the behavior of Matlab's debugger and decided to play along.

John W. Eaton <jwe>
Group administrator
Wed 21 Feb 2024 10:16:02 PM UTC, comment #9: 

The patch restores the functionality of dbnext and doesn't have problems with the example session from comment #5.  But, I did find a new sequence of commands which causes the line numbering to be reset to the first line of the file.  I don't know whether the cause is using three stack levels, or whether it is the mixture of "dbstep out", "dbstep", and "dbcont".


octave:3> dbstop ls_command
ans = 35
octave:4> ls abc
debug> ls def
[1]debug> ls ghi
[2]debug> dbstack
stopped in:

  --> ls_command at line 35 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls_command.m]
              ls at line 67 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls.m]
      ls_command at line 35 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls_command.m]
              ls at line 67 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls.m]
      ls_command at line 35 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls_command.m]
              ls at line 67 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls.m]
[2]debug> dbcont
error: ls: command exited abnormally with status 2
[1]debug> dbstack
stopped in:

  --> ls_command at line 35 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls_command.m]
              ls at line 67 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls.m]
      ls_command at line 35 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls_command.m]
              ls at line 67 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls.m]
[1]debug> dbnext
[1]debug> dbstep out
[1]debug> dbstack
stopped in:

  -->         ls at line 69 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls.m]
      ls_command at line 35 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls_command.m]
              ls at line 67 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls.m]
[1]debug> dbcont
error: ls: command exited abnormally with status 2
debug> dbstack
stopped in:

  --> ls_command at line 1 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls_command.m]
              ls at line 67 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls.m]
debug> dbwhere
stopped in ls_command at line 1 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls_command.m]
debug> dbcont
error: ls: command exited abnormally with status 2
octave:5> diary off


If this is too time-consuming to debug you could just check in this additional patch as an improvement over the status quo ante.

Rik <rik5>
Group administrator
Wed 21 Feb 2024 07:57:29 PM UTC, comment #8: 

"Unfortunately, I seem to have the magic touch for finding problems."

No problem.  Also unfortunately, I don't know how to write tests for these operations so it's difficult to know whether a fix for one problem breaks some other case.

The current state of the debugger seems to be "I'm surprised it works at all".  I'm attaching an additional patch that appears to fix the second problem you reported, but it looks like another band-aid on top of other bandages and it makes me think that I don't really understand the overall problem (much less the solution) and that there must be a better way.


(file #55732)

John W. Eaton <jwe>
Group administrator
Wed 21 Feb 2024 05:02:02 PM UTC, comment #7: 

Unfortunately, I seem to have the magic touch for finding problems.  With the latest changeset, "dbnext" is behaving like "dbcont".  See diary below.


octave:2> dbstop ls_command
ans = 35
octave:3> ls abc
debug> dbnext
error: ls: command exited abnormally with status 2
octave:4> diary off


Rik <rik5>
Group administrator
Wed 21 Feb 2024 06:03:23 AM UTC, comment #6: 

Thanks for testing.

It took a while for me to figure out why the call stack location was mangled but the fix turned out to be easy.

http://hg.savannah.gnu.org/hgweb/octave/rev/6fa52e36a8f2

John W. Eaton <jwe>
Group administrator
Tue 20 Feb 2024 09:32:06 PM UTC, comment #5: 

I tested with dblist.  It seems to work well unless there is an error, in which case line numbering gets reset.  However, a subsequent dbnext will re-initialize the line in the file and then dblist goes back to working correctly.  See the attached sequence which uses 'ls' with a non-existent file to throw an error.


octave:2> dbstop ls_command
ans = 35
octave:3> ls abc
debug> ls def
[1]debug> dbstack
stopped in:

  --> ls_command at line 35 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls_command.m]
              ls at line 67 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls.m]
      ls_command at line 35 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls_command.m]
              ls at line 67 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls.m]
[1]debug> dbcont
error: ls: command exited abnormally with status 2
debug> dbstack
stopped in:

  --> ls_command at line 1 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls_command.m]
              ls at line 67 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls.m]
debug> dbnext
debug> dbstack
stopped in:

  --> ls_command at line 37 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls_command.m]
              ls at line 67 [/home/rik/wip/Projects_Mine/octave-dev/scripts/miscellaneous/ls.m]


Rik <rik5>
Group administrator
Tue 20 Feb 2024 08:09:58 PM UTC, comment #4: 

I pushed the following changeset to improve the behavior of both dblist and dbtype.  Marking as ready for test.

http://hg.savannah.gnu.org/hgweb/octave/rev/50e19b01e111

John W. Eaton <jwe>
Group administrator
Tue 20 Feb 2024 04:52:16 AM UTC, comment #3: 

Try the attached change for dblist.

Something similar should probably be done for dbtype.


(file #55721)

John W. Eaton <jwe>
Group administrator
Mon 19 Feb 2024 11:17:14 PM UTC, comment #2: 

It looks like dbtype has similar issues but dbwhere gets the correct location by asking the current stack frame to display the location.  It seems like the fix might be to do something similar for dbtype and dbwhere.  I can try to take a look at that unless someone else is interested.

John W. Eaton <jwe>
Group administrator
Mon 19 Feb 2024 10:58:40 PM UTC, comment #1: 

The current behavior isn't optimal, and has been that way from the start.  I have wanted this behavior as well for quite some time.

Rik <rik5>
Group administrator
Mon 19 Feb 2024 12:53:53 PM UTC, original submission:  

The dblist command is useful for investigating issues in debug mode. However, it always prints out the lines around where the debugger is stopped at the bottom of the stack, even if the user has used dbup (or dbdown) to navigate the stack.

It would be more useful if dblist printed out the lines around the current point in the stack.

It would also be nice if you could navigate the stack in the same way in the GUI, but that's another feature request.

Richard <crobar>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #55733:  dbstep-patch-2.txt added by jwe (544B - text/plain)
file #55732:  dbstep-patch-1.txt added by jwe (2KiB - text/plain)
file #55721:  dblist-diff.txt added by jwe (4KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by crobar (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-03-03 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2024-02-22 jwe Attached File- Added dbstep-patch-2.txt, #55733
    2024-02-21 jwe Attached File- Added dbstep-patch-1.txt, #55732
    2024-02-20 jwe StatusConfirmed Ready For Test
        Planned ReleaseNone 10.1.0 (current default)
    2024-02-20 jwe Attached File- Added dblist-diff.txt, #55721
    2024-02-19 rik5 Severity3 - Normal 1 - Wish
        StatusNone Confirmed
        Releasestable dev

    Back to the top

    Powered by Savane 3.13-0329.
    Corresponding source code