Debugging a server-client app

B

bobrics

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
 
J

jacob navia

bobrics a écrit :
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

If your debugger is not sophisticated to handle conditional breakpoints
just add a line to your application (in the critical problem section)


void CallDebugger(void);

if (condition) {
CallDebugger();
}


Now, CallDebugger() could be some system specific code to attach the
debugger to your application or, if you run in an x86 system just

void CallDebugger(void)
{
_asm("int $3");
}

This will call the debugger in all linux x86 systems.
 
C

CBFalconer

bobrics said:
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.

This is off-topic for c.l.c. Which means, among other things, that
any answers you get are very likely to be meaningless blather from
people who cannot stay on topic, and who will certainly not get
corrected as to facts. Look for a newsgroup with 'thread' in its
name, or one that deals with your particular system.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
 
R

Richard G. Riley

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/~matloff/UnixAndC/CLanguage/Debug.html#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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,800
Messages
2,569,656
Members
45,399
Latest member
JettTancre
Top