swarm-support
[Top][All Lists]
Advanced

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

Re: How to debug java? (was Re: SimpleObserverSwarm in Java again... :-{


From: jones . peter
Subject: Re: How to debug java? (was Re: SimpleObserverSwarm in Java again... :-{
Date: Sat, 26 May 2001 17:11:31 -0400 (EDT)

> So I go digging in your code and I am distracted by many many
> System.out.println statements.  I don't know if these things are helping
> in java, but I think Marcus Daniels told me that in C they are not
> helpful because some printf statements get swallowed or lost when
> programs crash, so prints like this don't necessarily tell you where a
> job crashes. Although it seems like they ought to. 
> 
Presumably the prinln's are an attempt to trace the program. I'll suggest
one trick I have used when it's not clear where a program is crashing:
deliberately code a statement that creates a non-ambiguous crash,
such as a divide by zero (if that causes such a crash in java) so as to
occur a few lines before the suspected crash site, recompile and run. If this
telltale crash occurs, move the telltale to occur a line later and repeat.
It would be wise to make sure the breakpoint is determinate: i.e. the
hardware won't try to execute any instructions following the crashing
instruction. Also, the data stream the program will read on each test run
has to result in the same flow of control as the one in which the crash
occurred. It is also assumed the program is crashing on the first time
through the suspect code.

This approach, minimizes dependence on deguggers and their possible side
effects, and the time and effort to learn a debugger. It can also be used
when no debugger is available, or memory is too tight to allow compilation
with debugging, or compiling with the debugger makes the bug seem to evaporate.

Peter Jones

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]