View topic - Hanging of program

Hanging of program

anything that doesn't fit to other groups.

Hanging of program

Postby rldchua » Fri Dec 19, 2003 4:36 am

I'm tryin out a self written program but everytime i run the program it seems to stop at a certain location without proceeding. I've put several printf statements to check where is the latest part of the program it had proceeded but it can't seems to "go pass" a certain "mark". Are there any way i can overcome this problem?
rldchua
New Member
 
Posts: 7
Joined: Thu Dec 11, 2003 5:48 am

Postby vishwa2000 » Fri Dec 19, 2003 6:55 am

Compile the program with -g option and use gdb rather that putting printfs. Ex. gcc -g test.c -o test. Please note that you may not get the exact point of trouble just by using printfs.
vishwa2000
Active Member
 
Posts: 25
Joined: Thu Jun 26, 2003 6:49 am
Location: Bangalore, INDIA

Postby thegman » Fri Dec 19, 2003 10:35 am

IF that does not help, post the source.
thegman
Senior Member
 
Posts: 439
Joined: Sun Jun 15, 2003 8:10 pm

Postby rick » Fri Dec 19, 2003 2:20 pm

Also the output of pidin at the point your program hangs will show what you are blocked on - which will explain by it is blocked (or that it is running ready).
rick
QNX Master
 
Posts: 500
Joined: Wed Nov 13, 2002 3:59 am

Postby mario » Mon Dec 22, 2003 11:47 pm

vishwa2000; what's wrong then printfs ;-)

rldchua you will have to give more information, this is way to vague.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Postby vishwa2000 » Tue Dec 23, 2003 3:02 am

mario wrote:vishwa2000; what's wrong then printfs ;-)

rldchua you will have to give more information, this is way to vague.
I have a very bad experience when I used printfs for debugging. I have no much idea but as printfs are buffered, it may give some incorrect results.
vishwa2000
Active Member
 
Posts: 25
Joined: Thu Jun 26, 2003 6:49 am
Location: Bangalore, INDIA

Postby cdm » Tue Dec 23, 2003 6:19 am

vishwa2000 wrote:
mario wrote:vishwa2000; what's wrong then printfs ;-)

rldchua you will have to give more information, this is way to vague.
I have a very bad experience when I used printfs for debugging. I have no much idea but as printfs are buffered, it may give some incorrect results.


Only stdout is buffered, stderr is not.

fprintf(stderr, "....");
cdm
QNX Master
 
Posts: 789
Joined: Fri Jul 05, 2002 9:38 am

Postby mario » Tue Dec 23, 2003 3:31 pm

It's buffered but a /n at the end of the line will flush it.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Postby ed1k » Tue Dec 23, 2003 8:31 pm

vishwa2000 wrote:Compile the program with -g option and use gdb rather that putting printfs. Ex. gcc -g test.c -o test...


Please do not use name "test" and do not advise other people to use name "test" in un*x environment.
ed1k
QNX Master
 
Posts: 96
Joined: Tue Jul 23, 2002 10:52 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron