bugGNU Octave - Bugs: bug #45404, Breakpoints cannot be set in...

 
 

bug #45404: Breakpoints cannot be set in classdef methods or +package function files

Submitter:  Richard <crobar>
Submitted:  Thu 25 Jun 2015 10:40:14 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Richard Crozier Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  9.1.0 Planned Release:  9.1.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 04 Oct 2023 05:38:09 PM UTC, comment #22: 

Just adding that @mmuetzel noted the remaining method issue in the open report over at bug #46451, so probably best to move any further comments over there where we can hopefully get it cleaned up before the v9 release.

Nicholas Jankowski <nrjank>
Group Member
Wed 04 Oct 2023 04:02:46 PM UTC, comment #21: 

I can confirm that with Octave 8.3.0.
In Octave 9, setting break points in classdef classes is working correctly using the built-in editor or from the command line using method names or line numbers.
Clearing break points in classdef classes is working correctly using the built-in editor or from the command line using line numbers. It's not working using method names though.

Markus Mützel <mmuetzel>
Group administrator
Wed 04 Oct 2023 12:44:33 PM UTC, comment #20: 

Thanks. 

FYI only. 

As I wrote in my prior note, I can set break point.  However I have not figured out the correct syntax to remove the class m file break point in command window.  Replacing dbstop with dbclear results in the same file-not-found message as gui. 

Limited by what I know, the only way that I can clear a class m file break point is "clear all", i.e., clear all the break points together with everything else.

Liang Tang <lt1234>
Wed 04 Oct 2023 07:41:16 AM UTC, comment #19: 

@lt1234: See bug #46451.

Markus Mützel <mmuetzel>
Group administrator
Tue 03 Oct 2023 10:44:45 PM UTC, comment #18: 

Hi,

I briefly read through the bug report.  I have a question.  I am on 8.1.0 Win 64. Is what below expected and will be fixed in 9? Thanks. 

(1) 'dbstop in CLASS at METHOD' works in 8.1.0. 

(2) But in gui editor, I keep getting an error message regardless I am setting a break point in class or method.  In the same time, 'which' in the command window indicates the missing m file is in the search path.

error: add_breakpoints_in_function: unable to find function 'name_of_class_m_file'

Liang Tang <lt1234>
Mon 28 Aug 2023 02:21:37 AM UTC, comment #17: 

seems no other issues in the last 2 years. a patch for the Octave 9 dev branch was recently pushed in bug #46451 to address the classdef issue. Closing report as fixed. Further issues with classdef would be better brought up on the other report.

Nicholas Jankowski <nrjank>
Group Member
Fri 12 Nov 2021 04:38:59 AM UTC, comment #16: 

2 years without comment.  seems this fixed the package part of the report, leaving the classdef issues? Probably can close this one and use bug #46451 for the classdef breakpoint issue?

Nicholas Jankowski <nrjank>
Group Member
Tue 26 Mar 2019 03:21:21 AM UTC, comment #15: 

At some point, setting breakpoints for functions in packages seems to have been fixed.  I'm now able to set breakpoints using


dbstop pkga.pkgb.fcn


After changeset

http://hg.savannah.gnu.org/hgweb/octave/rev/de826e69a5ea

setting breakpoints in classdef methods using dbstop commands like


dbstop in MYCLASS at MYMETHOD


should work.

Some additional changes will be needed to accept filenames in addition to class names and to support parsing class names or methods names when they are prefixed by package names and to also allow breakpoints in classdef methods to be set from inside the GUI editor. But this change is a good start.

See also bug #46451.

Maybe we should close one of these bug reports?  Or maybe it would be best to close them both and open another one (or more) reports about specific dbstop syntax that does not work?

John W. Eaton <jwe>
Group administrator
Wed 20 Mar 2019 07:05:07 PM UTC, comment #14: 

The following changeset attempts to fix the dbstop command to accept the syntax


dbstop in CLASS at METHOD


It doesn't currently look up the method and properly set the breakpoint, but it's a step in that direction.

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

John W. Eaton <jwe>
Group administrator
Thu 14 Feb 2019 10:41:58 AM UTC, comment #13: 

Incidentally, the last example differs from the edit command, i.e.


>> dbstop in wsim.waveSettings at wsim.waveSettings.plotEta
Error using dbstop
Cannot find function "wsim.waveSettings.plotEta" within "waveSettings".


but


>> edit wsim.waveSettings.plotEta % works
>> edit waveSettings.plotEta % obviously doesn't work


to me, this is inconsistent, dbstop should let you specify the package name, especially if the docs state that any edit input syntax is allowed.

Richard <crobar>
Thu 14 Feb 2019 10:40:21 AM UTC, comment #12: 

Incidentally, the last example differs from the edit command, i.e.


>> dbstop in wsim.waveSettings at wsim.waveSettings.plotEta
Error using dbstop
Cannot find function "wsim.waveSettings.plotEta" within "waveSettings".
+verbatim+

but

+verbatim+
>> edit wsim.waveSettings.plotEta % works
>> edit waveSettings.plotEta % obviously doesn't work


to me, this is inconsistent, dbstop should let you specify the package name, especially if the docs state that any edit input syntax is allowed.

Richard <crobar>
Thu 14 Feb 2019 10:29:22 AM UTC, comment #11: 

The ML docs here:

https://uk.mathworks.com/help/matlab/matlab_oop/using-the-editor-and-debugger-with-classes.html

state that dbstop accepts and file specification accepted by the edit command, but this doesn't seem to work for class methods, e.g. for a class waveClass on my path:


>> edit  waveClass.plotEta % works, opens at the plotEta method

>> dbstop waveClass.plotEta
Error using dbstop
Cannot find function "waveClass.plotEta".


However, the following stackoverflow question

https://stackoverflow.com/questions/19523965/how-to-place-a-breakpoint-at-the-start-of-a-method-programmatically

reveals that both of the following works:


dbstop in waveClass at waveClass.plotEta
dbstop waveClass at waveClass.plotEta

 
I suppose technically this agrees with the matlab doc.

For another class, waveSettings, on my path which is in a package directory (+wsim), the following  is the syntax:


>> dbstop in wsim.waveSettings at waveSettings.plotEta % works
>> dbstop in wsim.waveSettings at wsim.waveSettings.plotEta
Error using dbstop
Cannot find function "wsim.waveSettings.plotEta" within "waveSettings".


Richard <crobar>
Thu 14 Feb 2019 10:10:14 AM UTC, comment #10: 


Well, that specific example doesn't work

>> dbstop slmengine.m>slmengine_constant % works
>> dbstop slmengine.m>slmengine_constant at 5
Error using dbstop
Invalid option combination.  Specify the line number or specify the local or nested function.


Richard <crobar>
Tue 12 Feb 2019 05:27:41 PM UTC, comment #9: 

Thanks.

I meant to be asking about the syntax of the dbstop command.  For example


dbstop file.m>method
dbstop file.m>method at 5  ## Does this work?


etc.

I assume it should be possible to set a breakpoint at any executable statement, but I'm not sure how that works when there are multiple statements on a single line in a file.

John W. Eaton <jwe>
Group administrator
Tue 12 Feb 2019 04:31:57 PM UTC, comment #8: 

Hmm, I am afraid it is easier to ask where it is not possible in Matlab to set a breakpoint:

- class methods: yes
- local functions in classdef files: yes
- class methods in pkg dirs: yes
- local functions in classdef files in pkg dirs: yes

As one can see from this demo

https://www.mathworks.com/help/matlab/matlab_prog/set-breakpoints.html

It is for example not possible to set a breakpoint at a function or method header, only inside the body.

Another exception is, you cannot set a breakpoint within "properties" blocks.

Kai Torben Ohlhus <siko1056>
Group Member
Tue 12 Feb 2019 03:02:54 PM UTC, comment #7: 

I'm looking at this bug and bug #46451.  What are all the ways that work in Matlab to set breakpoints in class methods or local functions in classdef files?  Also functions (including class methods) in package directories?

John W. Eaton <jwe>
Group administrator
Wed 16 May 2018 07:55:05 AM UTC, comment #6: 

Actually, I haven't tested this, but the code in comment #4 probably doesn't handle the case of a method in a @class folder which is in a +package directory correctly, but it is an improvement.

Richard <crobar>
Tue 15 May 2018 09:56:03 AM UTC, comment #5: 

To clarify, this fixes the bug for function files in packages. I've no idea how to get the correct method name for methods in classdef classes, which is what I think what should be in 'function_name'. Probably need to query the octave parser or something.

Richard <crobar>
Tue 15 May 2018 09:35:35 AM UTC, comment #4: 

If you replace file_editor_tab::bp_info::bp_info with the following if fixes the bug


  file_editor_tab::bp_info::bp_info (const QString& fname, int l,
                                     const QString& cond)
    : line (l), file (fname.toStdString ()), condition (cond.toStdString ())
  {
    QFileInfo file_info (fname);

    QString q_dir = file_info.absolutePath ();
    QString q_function_name = file_info.fileName ();

    // We have to cut off the suffix, because octave appends it.
    q_function_name.chop (file_info.suffix ().length () + 1);

    dir = q_dir.toStdString ();
    function_name = q_function_name.toStdString ();

    // Check if we are in a class directory or a package namespace
    size_t pos = dir.rfind (sys::file_ops::dir_sep_chars ());

    if (pos != std::string::npos && pos < dir.length () - 1)
      {
        if (dir[pos+1] == '@')
          {
            // If the last component of DIR is @foo strip it and prepend it
            // to the name of the function.

            function_name = sys::file_ops::concat (dir.substr (pos+1), function_name);

            dir = dir.substr (0, pos);
          }
        else if (dir[pos+1] == '+')
          {
              // If the last component of DIR is +foo the file is in a package
              // namespace, we need to build the whole package tree (packages
              // can be nested)
              function_name = dir.substr (pos+2) + "." + function_name;

              dir = dir.substr (0, pos);

              // search backwards for the next directory level
              pos = dir.rfind (sys::file_ops::dir_sep_chars (), pos-1);

              size_t last_pos = pos;

              while (pos != std::string::npos)
                {
                  if (dir[pos+1] == '+')
                    {
                      // add this package to the full function name
                      function_name = dir.substr (pos+2, last_pos-1) + "." + function_name;

                      dir = dir.substr (0, pos);

                      pos = dir.rfind (sys::file_ops::dir_sep_chars (), pos-1);
                    }
                  else
                    {
                      // finish the search
                      pos = std::string::npos;
                    }
                }
          }
      }
  }


Richard <crobar>
Thu 25 Jun 2015 04:55:38 PM UTC, comment #3: 

No, bug #41514 is about the GUI not being able to set breakpoints in legacy @-classes, which the interpreter can. This bug is about not being able to set breakpoints in classdef classes or namespaced functions at all.

Mike Miller <mtmiller>
Group Member
Thu 25 Jun 2015 01:55:21 PM UTC, comment #2: 

Yep, obviously my searching wasn't that good, sorry. However, this one doesn't mention the packages issue. You also can't set breakpoints in functions in package folders using the gui, but can using the command line:

dbstop mypackage.foofcn

You also can't remove breakpoints set this way using the gui.

Richard <crobar>
Thu 25 Jun 2015 01:05:42 PM UTC, comment #1: 
Anonymous
Thu 25 Jun 2015 10:40:14 AM UTC, original submission:  

I haven't seen this elsewhere on the bug tracker, but I think it's pretty important.

It is currently impossible to set a break point in a classdef method, or in functions in +package directories. This makes debugging other aspects of classdef quite difficult.


Richard <crobar>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by lt1234 (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by jwe (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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-08-28 nrjank StatusNeed Info Fixed
        Open/ClosedOpen Closed
        Fixed ReleaseNone 9.1.0
        Planned ReleaseNone 9.1.0
    2021-11-12 nrjank StatusIn Progress Need Info
    2019-03-26 jwe StatusNone In Progress
    2019-02-12 mtmiller Carbon-CopyRemoved 80942 -
    2015-06-25 mtmiller Release4.0.0 dev

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code