By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,060 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

Debugging a server-client app

P: n/a
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

Apr 23 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.
Apr 23 '06 #2

P: n/a
bobrics wrote:

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/>
Apr 23 '06 #3

P: n/a
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!
Apr 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.