On 2006-04-23, bobrics <bo*****@gmail.com> wrote:
Greetings,
I am debugging client-server single threaded code and would like to
hear some suggestions regarding being able to make debugger to detect a
certain condition and from that point to allow step by step debugging.
The reason for that is because I need to see what is arriving at a
certain packet, not necessary the first one.
In fact, I was thinking to start server in debugging mode to wait for a
trap, where I'll put a bookmark (location to stop a debugger at), and
run the client, which will send packets. I am not sure how to do that.
Is it possible? Are there any other suggestions?
Currently, I am using Eclipse for C on Linux.
Thank you
Most debuggers have conditional breakpoints : since you dont mention
your platform I can't really confirm this : but most debuggers
understand (in C environment) C conditions to force the break
point. Failing that you can add a line to your code (assuming you have
ability to check it out and compile locally which I assume you do)
where you can set the breakpoint : although be very careful that the
"if" statement is bugfree : adding "debug" code can and frequently
does affect the application being debugged - see
http://heather.cs.ucdavis.edu/~matlo...tml#tth_sEc3.1
It discusses why using debug specific code is not a good idea, but
often it is convenient and certainly has its place in small systems
where its easy to add/remove/compile small code bases:
eg.
if (myBreakCondition(a,b,c,d)){
logBreakCondition("Here!"); /* set breakpoint here */
}
Using printfs on their own without a breakpoint has its place but is
limited and requires recompilations and code removal as well as
possibly causing heisenbugs : in addition, they tell you nothing at
all about the call stack which might have contributed to the break condition.
Good luck!