Patricia said:
Sounds like a very different approach to debug from mine.
>
Maybe not that different. I suspect that an OO purist could easily throw
rocks at my class decomposition, but one result is that most of my
methods are fairly small and linear. If a method is becoming large and
complex it gets refactored into a set of private methods and the
hierarchic tracing levels adjusted so that higher debug levels will
cause the private methods to be traced. This way I don't get deluged
with low level tracing detail if I don't need to see it.
I tend to
collect information not just for a specific problem, but to answer a
specific question about the problem. It is possible that all exits from
some method would be the key information, but just as likely that I
would need to know about uses of a particular path inside the method.
The way that I use debugging levels more or less maps onto this.
Another neat idea that I first saw in the depths of George 3 is to
continually generate tracing, but put the result into a circular buffer.
If a fatal error occurs the buffer gets dumped in trace event sequence.
Its useful for solving problems in long running processes without
burying yourself in debugging output, but is only suitable for processes
that don't carry much context over from one logical piece of input to
the next.
I do sometimes want access to data from a normally running program,
without having a specific problem to debug. For example, one of my
programs uses a hill climbing heuristic that can reach a local optimum.
I often want to review its behavior. I supported that with logging calls
at points in the code where the information I need is most conveniently
available. I don't think any of them are method exits.
Yes, I do that too when needed. In addition, when performance and/or
memory use is critical I'll instrument the programs in the system so
that its easy to follow performance over time. Performance data might
get written to a database, if the system uses one, or to a log file.
Either way the system would almost certainly include a performance
analysis program.
A good (non-Java) example of this occurred a while back when I was away
from home and paying for my phone usage. I made sure ppp was logging
session stats and wrote a pair of gawk programs to extract ppp session
details from the log and consolidate them into a session diary so they
could be easily reconciled with the phone bill.