Page 1 of 1

debugging/profiling NEURON execution

Posted: Thu Aug 29, 2019 9:06 am
by JimH
I'm interested in stepping through the execution of a NEURON program, line by line, to make sure that I fully understand how it's running. I'm assuming that would require compiling everything from source with debugging enabled.

Given the HOC interpreter, the dynamically loaded mechanisms, and my general inexperience debugging compiled programs, I'm not entirely sure where to start. Any guidance would be much appreciated.

Re: debugging/profiling NEURON execution

Posted: Thu Aug 29, 2019 10:15 am
by ramcdougal
Are you trying to debug NEURON itself or a NEURON simulation?

For debugging NEURON simulations written in Python, you can use pdb as with any other Python code. A quick search will lead you to many pdb tutorials.

For debugging NEURON simulations written in HOC... there's no equivalent. Going forward, you could write your new code in Python and then at least that part of the code would be easily debuggable. :) Other than that, general advice for debugging without a debugger include: (1) print statements (with printed labels), (2) making sure you understand expected values/properties and using assert statements to guarantee you have it, (3) testing each function separately as well as together, and (4) ask a friend to look at your code.

Compiling NEURON with debugging enabled is only necessary if you wanted to debug NEURON itself, not a NEURON model. This is almost certainly not what you need to do to solve your problem.

Re: debugging/profiling NEURON execution

Posted: Thu Aug 29, 2019 11:33 am
by ted
NEURON's standard run system is discussed in some detail in chapter 7 of The NEURON Book. Chapter 8 addresses simulation initialization. If you don't have the book, see these preprints:
https://www.neuron.yale.edu/ftp/ted/book/chap7.pdf
and
https://www.neuron.yale.edu/ftp/ted/book/chap8.pdf

Re: debugging/profiling NEURON execution

Posted: Thu Sep 05, 2019 2:33 pm
by JimH
The goal was to get a better understanding of how NEURON is running (so debugging NEURON itself), presumably by calling a NEURON simulation. The links Ted have provided are a start, although I was hoping to "see" that code in action. I was assuming this would mean compiling the source code with debugging enabled.

So for example, I'd like to have a breakpoint in fadvance() and step through line by line (in the C/C++? code) to see the integration occurring and how NEURON organizes calls to update channel dynamics, recording vectors, and the like.