Skip to main content

Questions tagged [debugging]

Questions about debugging techniques, using the built-in debugger, and/or the Wolfram Workbench debugger.

Filter by
Sorted by
Tagged with
62 votes
2 answers
4k views

Mathematica Debuggability

One of the things that I really dislike about Mathematica is its lack of debuggability compared to many other programming languages. Some of the problems arises from the functional nature of ...
Helium's user avatar
  • 4,059
42 votes
4 answers
3k views

Interrogating a running evaluation

Is it possible to find the values of variables of a running Mathematica evaluation, without interrupting it? For example, suppose I do: Do[Pause[1]; a++, {50}] ...
Carl Woll's user avatar
  • 131k
38 votes
4 answers
8k views

Debugging with Breakpoints

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 ...
Jagra's user avatar
  • 14.4k
38 votes
2 answers
5k views

Debugging memory leaks

I've written my incredibly complex, incredibly elegant analysis function, that works great on small test data. But when I run it on my real (bigger) data set it keeps running out of memory. It turns ...
36 votes
2 answers
1k views

How do I disable the stack tracing feature in Mathematica 11?

Bug was introduced in 11.0 and persisting through 11.1 It looks like the Mathematica 11 stack tracing feature (see red ellipsis in front of any warning message) prevents the garbage collector from ...
Ray Shadow's user avatar
  • 7,836
35 votes
8 answers
6k views

Wolfram Workbench - Mathematica Development Alternatives

Are there any alternatives (IDE or other workflow) to Wolfram Workbench for development and debugging? Elaboration: An open source alternative.
EmpireJones's user avatar
34 votes
1 answer
1k views

which is better, using Assert[] or manual checks on arguments and other computations?

I never used Asserts in Mathematica, but trying to see what advantage they have over just argument check and additional definitions of the function to capture unwanted input. For example, which one ...
Nasser's user avatar
  • 145k
31 votes
5 answers
59k views

How do I identify the source of a "Tag times protected" error?

I have some code that looks like Table[ a = 1; b = {2, 3} c = i;, {i, 2} ] which gives an error: Set::write: Tag Times in c {2,3} is Protected....
dearN's user avatar
  • 5,351
31 votes
3 answers
1k views

Prepend Information to Warning Messages

I have a function running within a Do loop that sometimes issues a warning. I'd like to prepend the warning with the loop ctr so that I can go back and debug that instance later. Basically, I would ...
Chris Roth's user avatar
25 votes
1 answer
3k views

How to report a bug in Mathematica

I found two bugs in Mathematica (10.3 and 10.1) and I need to report it. Is there any tools to do that or section on Wolfram website?
BetterEnglish's user avatar
25 votes
1 answer
1k views

A debug utility to print or extract intermediate data from a program

Is there a way to print variables using their names, or to extract the corresponding information for later analysis ?
faysou's user avatar
  • 11k
25 votes
1 answer
924 views

How can I trace a functional expression's evaluation visually?

Ok, so the goal is to visualize the execution of this expression foo /@ {3 + 1, bar /@ {1 + 2, {4 + 7}}} in the following fashion using nested rectangles with ...
M.R.'s user avatar
  • 31.6k
23 votes
3 answers
2k views

How to find the name of the current function?

I would like to know the name of the current function from within that function. For example, consider the following code ...
Ian Hinder's user avatar
  • 2,125
22 votes
2 answers
5k views

Debugging Mathematica Code

In various integrated development environments, such as Microsoft Visual Studio, there is an integrated debugger where you can step through code sections, examine the state of variables and figure out ...
s0rce's user avatar
  • 9,632
21 votes
2 answers
608 views

Where is the old option TraceInternal->True?

Already at least in version 2 (I think), the function Solve calls the function Roots. At that time, I had a rather dirty trick, that still works, to verify this: ...
Fred Simons's user avatar
  • 10.2k
21 votes
5 answers
1k views

Is it possible to Print expressions in reverse order?

Let's say I'm debugging a program step by step and want to Print some expressions (using ShowIt, for example). Is there a way to output the result of ...
21 votes
1 answer
262 views

Why Trace[] shows some internal warnings on a standard Plot command in V9?

For fun, I like to use Trace with option TraceInternal->True to see if I figure how some of the commands work internally. I ...
Nasser's user avatar
  • 145k
20 votes
1 answer
634 views

How does the built-in debugger decide what to highlight?

How does the built-in debugger decide which definition to highlight in the notebook when Break on messages" is enabled? Here's an example to illustrate what I mean. First, enable the debugger (...
Szabolcs's user avatar
  • 235k
16 votes
1 answer
1k views

How can I interrupt a calculation without aborting it?

Before version 10.0, there was a menu item, Evaluation → Interrupt Evaluation..., which could be used to interrupt a calculation without aborting it. It would bring up this window: It was possible ...
Szabolcs's user avatar
  • 235k
16 votes
4 answers
1k views

How to make a custom Echo

I usually check my intermediate variable by Echo.Like Table[Echo@x, {x, 10}] But when the intermediate variable have too much ...
yode's user avatar
  • 26.8k
15 votes
1 answer
2k views

Finding a Specific Line in a Package

In a package I am developing, I accidentally left this line Protect[ uncompleted prior to running the package. Mathematica produced this error message ...
rcollyer's user avatar
  • 34k
15 votes
1 answer
377 views

Profiling a package

I have some code that I want to profile to see how much time each step takes, for instance: ...
Jansen's user avatar
  • 1,223
14 votes
2 answers
2k views

How to find out where an error occurs?

I got this error when using Mathematica: ...
Alex's user avatar
  • 345
14 votes
1 answer
326 views

Inspecting non-variable state from a breakpoint in Workbench

Suppose I'm stopped at a breakpoint in Workbench, say at one of the y = ... lines in: ...
Brett Champion's user avatar
13 votes
1 answer
194 views

Is there a way to find out who is importing a package?

After calling some functions, if I look into $ContextPath, I can see that JLink` is in there. Is there a way to find out what ...
Meh's user avatar
  • 1,637
12 votes
3 answers
1k views

How to debug the C code for LibraryLink?

Recently, I use the C to rewrite a Mathematica function NonzeroBasis[], please see here for fully descriptions. Here, ...
xyz's user avatar
  • 625
12 votes
1 answer
493 views

Easy printing of executable code

I'm working on a package that has functions that call other existing and packaged functions. I'd like a way to output what some of those key calls are, so users can see what's happening under the ...
Chris K's user avatar
  • 20.3k
12 votes
2 answers
280 views

How to globally disable and re-enable Echo?

I have Echo's buried in code all over my notebook, I'd like a flag to turn them all on or off globally. Sure Unprotect[Echo];Echo=Identity would disable them, but ...
M.R.'s user avatar
  • 31.6k
12 votes
0 answers
254 views

RuntimeTools insight?

Does anyone happen to have some more complete insight into the RuntimeTools package that is used by Debug and Workbench? I ask ...
flip's user avatar
  • 1,800
11 votes
1 answer
225 views

Why does Unevaluated applied (@@) to a held expression not work?

I do not understand why Unevaluated sometimes does not work. Consider this expression: expr = Hold[a - a] Now let's say I ...
QuantumDot's user avatar
  • 19.7k
11 votes
3 answers
2k views

How can one debug a module more elegant than just with Print?

This question is interesting mainly for beginners, but the answer i wrote to my own question could be also interesting for advanced users. Introduction: While writing huge blocks of code, especially ...
sacratus's user avatar
  • 1,566
10 votes
0 answers
127 views

How to setup logging levels?

I was wondering what tools exist out there for doing logging in Mathematica? The Echo functions is nice, but I'd like to set various severity levels and other ...
user5601's user avatar
  • 3,655
9 votes
3 answers
202 views

Metaquestion: how to find out why (e.g.) MatchQ[42, _?Function[x, True]] is False?

Suppose you run into a bewildering Mathematica result (which happens to me several times per Mathematica session, even after a 20-year acquaintance), such as, for example: ...
kjo's user avatar
  • 11.7k
9 votes
2 answers
516 views

Can Trace[] output during evaluation (and not only after)?

I'm trying to debug a function that goes into an endless loop. I tried to Trace[] some expressions inside the the function, but apparently Trace[] outputs its information only after the expression has ...
yippy_yay's user avatar
  • 243
9 votes
1 answer
1k views

Debugging a $RecursionLimit error?

I sometimes encounter bugs that involve a recursion limit. It's often very hard to find the origin of the problem. Would there be a way to copy the stack somewhere and abort the evaluation in order ...
faysou's user avatar
  • 11k
9 votes
0 answers
187 views

A bug in Derivative?

Update This is a bug in v11.3 or earlier and is fixed in v12. Original Post Check this out: ...
luyuwuli's user avatar
  • 2,814
9 votes
0 answers
97 views

How to capture implicit fails in Plot or Show? [duplicate]

How can I make a construct similar to C++ functions: try{} catch{} I want to use it to avoid showing a lot of errors in the plot area when for example one of the ...
Misery's user avatar
  • 2,650
8 votes
3 answers
363 views

How to get frame around every function without any evaluation?

Is there a good universal method that allows the making of a frame around every function. In the output, functions should remain unchanged (no evaluation, or any other changes) and each function ...
vasili111's user avatar
  • 1,225
8 votes
2 answers
240 views

Is there a way to accelerate buffering to the screen?

I have an application that does a bunch of small computations, mostly Table management, and logic around loops. It takes seconds to execute. However, when I turn on debug (a variable I set for ...
Rick R's user avatar
  • 407
8 votes
1 answer
569 views

What is missing in this Mathematica Journal Article?

So I had been looking to solve a little tiling problem and Google turned up this Mathematica Journal Article and I noticed the code was both incomplete and incorrect, so... My Question is, What is ...
Nothingtoseehere's user avatar
8 votes
1 answer
134 views

How can I get TracePrint to treat certain functions as atomic?

Consider the following example: ...
celtschk's user avatar
  • 19.1k
8 votes
1 answer
306 views

How to debug this failing pattern-matching expression?

NB: this question is primarily about troubleshooting and debugging, and only secondarily about pattern-matching. IOW, I'm far less interested in getting an explanation for the situation described ...
kjo's user avatar
  • 11.7k
8 votes
0 answers
298 views

Is there a way to update Workbench 2.0 to recognize Mathematica 9, 10 and 10.1 functions?

Is there a way to add newer functions to a configuration file so that Workbench 2.0 is useable for development with 10.1? Also, are there changes that can be made so that Workbench 2.0 can be used to ...
Doug Kimzey's user avatar
  • 2,279
7 votes
2 answers
255 views

Trace works differently with different right-hand-side rules—bug?

Bug introduced in 2.1 or earlier and persisting through 13.2 UPDATE: Wolfram Support has confirmed that this is a bug. I noticed that Trace does the following ...
thorimur's user avatar
  • 9,020
7 votes
3 answers
576 views

Avoiding the suppression of messages by NIntegrate

Consider the following code: test[x_] := If[1 < x < 2, Message[Test::message]; x^2, x]; NIntegrate[test[x], {x, 0, 3}] 5.33333333333334 I.e. it gives me ...
Ruslan's user avatar
  • 7,172
7 votes
2 answers
300 views

Is it possible to attach a debugger to a dynamically linked library on the supported OS?

Recently, I discovered that LibraryLink technique is a very useful tool to improve the performance of function. Firstly, I need to use LibraryLink template to write C/C++ program. Then compiling the ...
xyz's user avatar
  • 625
7 votes
2 answers
359 views

Strange bug with "MessageName[a,b] is not of the form symbol::name ", Debugger & cursor location

Can someone confirm/disconfirm this? Start Mathematica 11, blank notebook, blank init.m Start the Debugger/make sure it is running. It doesn't seem to matter whether you have the Stack and ...
masterxilo's user avatar
  • 5,739
7 votes
1 answer
640 views

How to Debug Missing[NotAvailable] error for Social Media Data

I get a Missing[NotAvailable] error message when trying to access Social Media Data using SocialMediaData["Facebook", "Friends"] ...
Igor's user avatar
  • 171
7 votes
0 answers
120 views

Understanding the profiler: Is pattern matching/de-structuring expensive?

I was profiling some code and I am trying to understand what the results mean. Suppose we have the very idiomatic, ...
ITA's user avatar
  • 393
7 votes
0 answers
93 views

Logging modules in Mathematica?

Is there any logging module or functions or scripts that one can use to store all the information of what happens during executing mathematica program in Wolfram? For example, one might look up log....
Xuemei's user avatar
  • 1,616