Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Octave debug info randomly displayed

  1. May 19, 2015 #1
    Okay, I'm not sure if one of the Octave settings got messed up or something, but all of a sudden, in the middle of my run, the Octave console displays a message and all of the debug commands, but doesn't throw an error:

    'debug' is a function from the file C:\[path to debug.m]

    -- Function file: debug ()
    Summary of debugging commands. For more information on each command and available options use 'help CMD'.

    The debugging commands available in Octave are

    Add a breakpoint.
    Remove a breakpoint.
    List all breakpoints.

    And it goes on to list all the debugging functions with brief descriptions, etc......It does not enter debug mode.

    Anybody know how to suppress this, or what might be causing it? As I remember, my code was working perfectly, but on one run it just starting doing this, and I can't remember what I changed or how I caused it. In any case, my code goes through thousands of iterations, and this is going to keep the code from being able to be completed. Again, no error or warning is officially identified, the display is exactly as described.

    Any help is appreciated.

    -Jeremy LeFevre
  2. jcsd
  3. May 19, 2015 #2


    Staff: Mentor

  4. May 19, 2015 #3
    Yes, but it doesn't say there's a warning, error, or anything else that would require it to enter debug mode, it just starts randomly (as far as I can tell) spitting out information on debug mode.

    As for having created a breakpoint, that could be the case, but since Octave does not come with a GUI (at least I am not using one), I have no way of determining where it would be (if I inadvertently created one).

    So, I have no idea what is causing it or why it is giving output on debug mode, and not indicating a warning, interruption, error, or problem of some kind.
  5. May 19, 2015 #4


    Staff: Mentor

    You have to determine at what line the debug kicks in if it is indeed program dependent. Also if you have the source you could search for dbstop or any of the other names used in the link I gave you earlier. It could be that some option or function argument has turned it on as a feature of the library code you're using...
  6. May 19, 2015 #5


    Staff: Mentor

  7. May 19, 2015 #6
    That's just it, I have tried it with debug mode on and off (and nothing changed at all). Maybe I haven't described what is happening well enough. It displays the said text, then continues to execute the program. The problem becomes the fact that displaying so much text without clearing causes Octave to crash after only a few iterations (I assume). When I say crash, I mean crash, as it Octave closes itself. No stopping of the program, this weird text displays information about debug mode (which hadn't been activated in the first place), does not stop the code from executing, and then Octave crashes, I can only guess why. So, in other words, it never even enters debug mode, it just displays the said text and continues to execute until it crashes!!! I cannot see anything in the code that would be causing it to crash (like a divide by zero, a growing array, or anything weird like that). I can only figure that displaying so much unnecessary text it is somehow causing it to crash, but I don't know this for certain.

    By the way, it is calling a function, named wedgeRT.m, a code I wrote. There is no reference to debugging anything in the code, not that I'm aware of (and I wrote it, so you'd think I would remember if I had :P ). Thanks for the ideas though.
  8. May 19, 2015 #7


    Staff: Mentor

    Okay so maybe there is a referencing error. In C code for example, if you forgot to place a null byte at the end of a string and then printed that string it would keep printing forever until it found a null byte.

    Since this is showing the text of the debug help then perhaps its a similar kind of situation. If so these kinds of problems are very hard to debug.

    One trick might be to try running in debug mode and then see if debug detects something and causes it to stop.

    Another trick is to add print statements to it so you can see how far it got before the error occurs and then keep refininf the prints to isolate the offending line if thats the case. This trick doesn't always work if something earlier in your code has corrupted somethings.

    Are you sure you haven't exceeded your array indexes? Are you sure you have enough memory on your system and haven't exhausted it during your program run? Do you have enough disk space for caching if Octave is using caching?

    The printing of the debug help and then the crash is indicative of a bad pointer somewhere and so the print statements may help you isolate it.

    Last trick is to selectively comment out parts of your code to see if the error still exists. As an example, commenting out a for loop or code inside it...
  9. May 19, 2015 #8


    Staff: Mentor

  10. May 19, 2015 #9


    Staff: Mentor

    If your code isn't too large, you could consider switching to Julia. Its syntax is very similar to MATLAB and Octave and it has better support and is more performant than either one. THe synatx is similar but not the same and there may be a learning curve to go thru to get your program to work.



    There are some good tutorials on it on Youtube by Dave Sanders and by the original developers.
  11. May 19, 2015 #10
    Ok, thanks. That gives me a few ideas of some things I can try (some of them I already have without success).

    LOLZ!!! I just found it.....

    So, one of the times I was using debug mode to fix my code, I must have accidentally types the word 'debug' at the end of one of the lines. It looked something like this:

    some assignment or function line;debug

    Result was, a short tutorial on how to use the debug function printed in my code for no reason and confused me thoroughly...

    As a side note, come to think of it, when it first started doing that, I think I was debugging some kind of an overflow of an array or something like that. I think something was gobbling up the memory and causing the crash, so the crash is probably not related to the text after all.
  12. May 19, 2015 #11


    Staff: Mentor

    Great catch!

    In post #4, I suggested searching your code for debug keywords which might have found it sooner.

    Also one other trick, is usually when a working program that you have made recent changes too fails then it's a good idea to review those areas for odd things and always try to remember what you changed.

    At work, I added a shell script to vim to always save the file I'm editing and then on exit it deletes the original if no changes were made. This allows me to use vim -d old.file new.file to see side by side differences in vim.

    It's helped me a lot during a debugging session where I may be messing with many parts of the code to be able to compare it to the original.
  13. May 19, 2015 #12


    Staff: Mentor

    Anyway if you get the chance check out Julia. It may ruboff on you and convince you to drop Octave.
  14. May 19, 2015 #13
    Yes, indeed you mentioned it to me that I should search for that...and, thinking that there was no way I could have possibly written anything like that in my code, I ignored your sage advice. I have never heard of Julia, but I might check it out sometime. I guess for the time being, I will finish up with Octave the project I having going right now. In the long run a lot of people have told me I should change to Python. I kind of wanted to refresh my skills in C. Of course, what language I learn will probably depend most likely on where I end up job-wise, and what my boss says to learn. It could be a while until that happens.
  15. May 20, 2015 #14


    Staff: Mentor

    There's an interesting website that covers both and uses the IPython/IJulia workbench for both Julia nd Python development. The Dave Sanders videos on Youtube utilize it for teaching. The website is:

    http://quant-econ.net/python_or_julia.html [Broken]

    With respect to Julia it interoperates well with Python and with Fortran and there's some work to allow it to work with Java and Matlab but they aren't as complete.

    There's also the Pyzo.org website that has collected the various scientific python packages together as a one-stop shop for numerical computing in python.
    Last edited by a moderator: May 7, 2017
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook