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

 
 

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

Submitted by:  Richard <crobar>
Submitted on:  Thu 25 Jun 2015 10:40:14 AM UTC  
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  In Progress Assigned to:  None
Originator Name:  Richard Crozier Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

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>
Project 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>
Project 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.

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>
Project 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>
Project 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>
Project 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>
Project Administrator
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 siko1056 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by crobar (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    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.4