bugGNU Octave - Bugs: bug #48082, Cannot set breakpoint on files...

 
 

bug #48082: Cannot set breakpoint on files that have invalid identifiers as names

Submitter:  Emma Ainge <kusuri>
Submitted:  Wed 01 Jun 2016 11:29:39 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  3 - Low Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  kusuri Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 04 Mar 2019 12:56:33 AM UTC, comment #7: 

This bug is still present in Octave 5.1 and on the development branch.

Mike Miller <mtmiller>
Group Member
Fri 29 Jul 2016 07:37:26 PM UTC, comment #6: 

Yes, the problem is that files executed by run (or source) are not necessarily entered into the symbol table.  So there is currently no way to attach the breakpoint to the parse tree since that is done by looking up the function in the symbol table.

We either need some way to store the parse trees for scripts executed this way so that dbstop can find them, or a way to store the breakpoint info for a file even if it is not currently in the symbol table, or if it can't be loaded due to syntax errors.  Then when the file is loaded, the breakpoint info could be attached to the parse tree.

Maintaining breakpoint info separately actually seems like the right thing to do anyway as that would also allow a clean way to restore breakpoints for functions that have been cleared.  I think there have been bug reports about those kinds of issues as well.

John W. Eaton <jwe>
Group administrator
Sat 04 Jun 2016 01:05:52 PM UTC, comment #5: 

I don't think there is a way to remove the comment, but even if there were, I'd leave it because it raises a good point.  I spent a few hours trying to track down a way to give a more informative syntax error, but I don't understand that section of the code well enough.

Lachlan Andrew <lachlan>
Fri 03 Jun 2016 06:49:45 PM UTC, comment #4: 

Lachlan,

Thanks for the response. I had forgotten that Octave (and MATLAB) will catch a syntax error before running, and so Octave's behavior here is normal and also is nothing to do with this bug report.

Is there any way to remove my last comment and this one to keep this bug report clean and focused on the original invalid identifiers as names issue? If not, then the comments should just be disregarded.

Emma Ainge <kusuri>
Fri 03 Jun 2016 01:46:18 AM UTC, comment #3: 

Thanks for the update, Emma.

Breakpoints wouldn't have helped here, because they are only encountered when the code executes.  It doesn't execute at all if there is a syntax error, because the whole file is parsed once when it starts running.

The current message isn't the clearest of errors, but it shows roughly the offending line. It is one line off, because Octave allows a (...) expression to span multiple lines, and it doesn't realise there was an error until it has read "location" instead of ")", or perhaps "*" or something else that could form part of an expression.

That off-by-one issue is one of the reasons why it says "near line ..." instead of "in line ...".  I know gcc always used to report errors on the line following a line with a missing ';', so this isn't unique to Octave.

Given that

  for n=1:length(TC(:,1)
                 * ones (1,1000))
      disp (n)
  end

is valid code, can you suggest a better error message?  Perhaps it could mention how many levels of brackets are open, and where the most recent one started.  I'm not sure how technically feasible that is.

Lachlan Andrew <lachlan>
Thu 02 Jun 2016 10:08:16 PM UTC, comment #2: 

Update:

I thought I had narrowed the bug down to being a problem with naming conventions. However, I now am having trouble putting breakpoints in normally named files as well. I am still seeing the error - "error: add_breakpoint: unable to find the requested function".

I renamed all the files to be names like getdata.m or DataProcessing.m . I'm not able to put breakpoints in these. I also started fresh with a new script, pasted in my code, and tried to then add a breakpoint.

If I start fresh with a new file, named foo.m with a few simple lines of code, I'm able to place breakpoints without issue. Stumped by this, I attempted to find where the trouble lies. I started with a fresh file, and bit by bit added in sections of code. I was able to add breakpoints up until the point when I added in the following:



%%Thermocouples

for n=1:length(TC(:,1)
    location = find(strcmpi(TC{n,1},TestDataHeaders(1,:)),1);
    eval([TC{n,1} '= TestData(1:end,location);']);
end

%Time


This was the code I originally was trying to use breakpoints to debug. Octave kept giving me the syntax error for the line that starts with "location = ...". After manually debugging this section of code (without breakpoints), I found my error is that I need an extra ) on the first line, so that it reads "
for n=1:length(TC(:,1))". This fixed my code and also resolved the breakpoint issue. This seems like a bug to me as well, as breakpoints would have helped me resolve this issue quicker.

Please advise. Is this a bug? Should I create a separate bug report for this or leave it here?

Emma Ainge <kusuri>
Thu 02 Jun 2016 12:24:20 AM UTC, comment #1: 

Thanks for the report, Emma.

A breakpoint is set by placing a note in the parse tree of the function, and so the function must be syntactically correct, which by default includes having a valid name.

Matlab is also unable to place breakpoints in invalid functions, although trying to set a breakpoint in the GUI causes it to remember the line of the request and place the breakpoint once the syntax errors are fixed.


However, if the only syntax error is the name, then I think it is possible to make the breakpoint work by explicitly loading the file into the symbol table.  If the more senior developers thing that that is the right approach, I'm happy to take a go at implementing it.

Lachlan Andrew <lachlan>
Wed 01 Jun 2016 11:29:39 PM UTC, original submission:  

When I try to set a breakpoint using the GUI or dbstop with a script that has a name starting with a number, Octave outputs the error: error: add_breakpoint: unable to find the requested function

For example, I created a script named 1_Test.m , detailed below.



# Name the file 1_Test.m
disp hello
disp goodbye
# Use mouse to select line 1
# Use "Toggle Breakpoint" from menu bar
error: add_breakpoint: unable to find the requested function


Octave is able to execute scripts with invalid identifier names. For example, I could use "run 1_Test.m" without trouble.

I see that when I create a file through Octave and name it starting with a number, Octave gives me a friendly warning that I may run into issues. I normally name my files outside of Octave, so I was stumped on this for awhile.

Could either this be fixed so that dbstop accepts invalid identifier names, or could the error that Octave displays let the user know that its their naming convention that they need to look at?

Thank you!

Emma Ainge <kusuri>

 

(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 jwe (Posted a comment)
  • -email is unavailable- added by lachlan (Posted a comment)
  • -email is unavailable- added by kusuri (Submitted the item)
  • -email is unavailable- added by kusuri
  •  

    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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-04 mtmiller Priority5 - Normal 3 - Low
        Release4.0.2 dev
    2016-07-29 jwe CategoryNone Interpreter
    2016-06-02 lachlan StatusNone Confirmed
        Operating SystemMicrosoft Windows Any
    2016-06-01 kusuri Carbon-Copy- Added kusuri

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code