(I am the author of the debug package in which mtrace lives)
If the definition of "Subfunction" lives outside of "MyFunction", you can simply mtrace "SubFunction" and do not need mtrace "MyFunction". And functions run faster if they are not "mtrace'd", so itโs good to use mtrace only as you need. (But you probably already know that!)
If "MyFunction" is defined only inside "SubFunction", one trick that might help is to use a conditional breakpoint in "MyFunction". You will need "mtrace (MyFunction)", then run it, and when the debug window appears, find out which line "MyFunction" is defined. Say line 17. Then the following should work:
D (n)> bp (1, F) # no need to show the window again for MyFunction D (n)> bp (18, {mtrace (SubFunction), FALSE}) D (n)> go ()
It should be clear what this does (or it will if you try).
The only disadvantages are: the need to do this again when you change the code "MyFunction" and; the slowdown that can occur with the help of the "MyFunction" itself performed by mtraced.
You can also experiment by adding the argument 'debug.sub' to 'MyFunction', which defaults to FALSE. In the "MyFunction" code, add this line immediately after the definition of "SubFunction":
if (debug.sub) mtrace (SubFunction)
This avoids the need for mtrace 'MyFunction', but requires you to change your code.
Mark bravington
source share