Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

re: Version 9. I typically write concise code and make a real effort to refactor. As such debugging has tended to take care of itself.

Recently, I've needed to assemble applications of more complexity, in that it they have deeper hierarchies of functions, lots of them, and often from multiple packages. So I've started to want just a bit more debugging help.

I prefer as simple development environment as possible, so I'd like to focus on debugging with native functionality of Breakpoints, rather than debugging functions from third parties or Workbench.

I just need to see what goes on in the code.

While, several questions on the site explore strategies and tactics for debugging. I have not found a concise description of how to effectively use the Breakpoints debugging functionality accessible from the menu items:

Evaluation > Debugger Controls > Show Breakpoints Window

either on this site, on Wolfram's site, or in the Mathematica documentation.

Opening the Breakpoints debugging window doesn't tell one much.

enter image description here

One would expect a clear way to set up breaks and variables to watch, and a way to run code to the specified point. In particular can and how can one:

  • set a series of breakpoints both at a functional level and within a function and
  • step through processing, point to point?

Some examples or mini-overview?

Thx.

share|improve this question
4  
if anyone can figure how to use the above evaluation->debugger then they should get 10,000 voting points added. The above tool is the most convoluted software tool I have ever seen. I really have no idea why is it even there as it is impossible to figure out and use in any practical way. Matlab debugger is the best and easiest debugger I've seen so far. I am hoping Mathematica will one day have such an easy to use debugger integrated in it, but I am not holding my breath for that. –  Nasser Aug 24 '13 at 21:15
    
@Nasser -- Comforting to know, I haven't gone completely daft. Thx. –  Jagra Aug 24 '13 at 21:41
2  
@Nasser if you highlight some part of the code (eg with ctrl-.), set a breakpoint, and evaluate the code, doesn't it then break there and display the state? –  acl Aug 24 '13 at 22:25
2  
I commiserate. For laughs there is this page extolling the power and glory of the debugger. –  m_goldberg Aug 25 '13 at 23:14
    
You can fight it all you want (I surely did), but in the end Workbench is the best solution. I'm only sorry I didn't switch to WB sooner. –  Ajasja Nov 10 '13 at 21:21

2 Answers 2

up vote 6 down vote accepted

The debugger in Mathematica is, in fact, a bit hard to use. However, it is functional. To create a breakpoint, one must select the WHOLE command. Just double clicking on the command name will do. Then you press the "Break at Selection" button in the debugger control panel. I still have no clear understanding what is considered a whole command from the Mathematica point of view. If the breakpoint doesn't work, I'll select the expression around it and try to make that a breakpoint.

In the example attached, selecting the "Print[...]" statement worked as a breakpoint, while selection only a "ToString[...]" command didn't stop the execution.

Mathematica Debugger

share|improve this answer

I never managed to use the built-in debugger. However if you are willing to use another IDE, the Wolfram Workbench 2.0 is a Mathematica IDE based on eclipse. It provides great debugging capabilities: step by step execution, breakpoints, variable watch, Mathematica front-end integration...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.