[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: Debugging tool

From   "Martin Weiss" <>
To   <>
Subject   st: AW: Debugging tool
Date   Thu, 20 Aug 2009 16:15:48 +0200


I do recall hearing this item at a "wishes and grumbles" last year. Many of
the other grumbles are gone (think pdf manuals...), so I think it would be
worthwhile to devote developer time to the issue. I also recall complaints
about -mata- being even harder to debug. Given that I anticipate that -mata-
will acquire even more importance than it already has, it should be part of
this future debugging tool...


-----Ursprüngliche Nachricht-----
[] Im Auftrag von WLJ van Putten
Gesendet: Donnerstag, 20. August 2009 16:11
Betreff: st: Debugging tool

Debugging of Stata programs  can be a very tedious and complicated 
process, especially in case of long and/or nested programs.

Where is the bug? In the main program or in a subroutine or a program 
somewhere down the line? Is there a bug in program code itself or is it 
due to wrong or missing content of certain macros in specific situations 
when the program is applied?

There are a number of approaches that one can follow and combine for 
debugging. E.g.:

- set trace on before starting the program or add a set trace on line to 
the program at a point before where an error occurs.
- add noisily display "text... "   lines  to an ado file to find out 
where the error occurs
- or add "global X<i> ...." lines to the program and later inspect the 
content of these global macros
- set pause on and add pause commands to the ado file
- set a log on before setting trace on and use an editor to go through 
the lines of code in the resulting log file
- close the result window first when logging the output to speed up the 

But still it can be very time consuming to just locate the point where 
the error occurs.

I would like to have a tool (say with set debug on)  that shows (without 
set trace on) after a command that ends in an error

(1) the final command line  [c1] that produced the error  without and 
with macro substitution - just like after set trace on, followed by

(2) the command line  [c2] that called c1 without and with macro 
substitution of that line, followed by

(3) the command line  [c3] that called c2 without and with macro 
substitution, followed by

.... etcetera till the inital command given.

Such a tool can be used as the first step to locate the error. The  
macro substituted lines may already give sufficient clues to solve the 
problem. Otherwise one could set a trace on at a suitable point in the 
program or one of the called programs for further detection.

To write such a tool is beyond the powers of a simple mortal user of 
Stata, and can only be done by StataCorp.

I had proposed this to Stata and received some useful comments from 
Kerry Kammire from Stata Technical Support. He has passed on my request 
to Stata Development. He told me that the development of such a tool 
gets a higher vpriority if it is supported by many users of Stata.

If any of you support my request for such a debugging tool (or a smarter 
one!) please let this be known to StataCorp (or)  through Statalist.

Wim van Putten

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index