ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi there,
I am quite new to c programming. I wrote a program to measure some values with a a/d converter connected to the parport. The program is timer interrupt driven and runs OK for a few hours (6-26). After that it takes 98% of CPU time and does not react to input.
How can I see where it is so busy with? there are some while loops in the program but all of them have a timer-time-out built in.
The idea was that it runs as a daemon and interfacing should go through a web-page.
Program is developed on suse 7.0 and run on redhat with the same kernel (a smoothwall 0.9.9-18). The runtime machine has no X.
Any help would be appreciated. And I have no experience with gdb (but it is never too late to start ;-) )
Unless you can run the application in a debug mode which generates a lot of extra output. Your best option would probably be to start debugging it with gdb.
Once it starts taking up 98% of the processor load if it's still possible to start up gdb then you can attach gdb to the running process by doing something like: gdb program pid
If it takes up too much load you might want to try getting the file to generate a core file which you can later debug, possibly even on a different computer if needed. You can make the program stop and generate a core file by giving the command: kill -ABRT pid
Debugging will work best if you have built a debug version of the program so make sure you compile with the -g switch.
Another thing you might want to look at is memory usage of the application. You could write a script which logs the output of ps aux every x minutes to see if there are possible memory leaks. This can really slow down a process. Something like this will show the 10 processes which use the most memory:
ps aux | awk '{print $6,$0}' | sort -gr | head -n 10
The Linux that is running doesnt understand kill -ABRT but does understand kill -6. I think it is kill -INT or so. I changed a routine where an array pointer got out of bounds, but it is still running wild, only after a shorter period of time.
I started dbg and it reads symbols from libc.so.6 and .4 and then comes with: no such file or dir in ../sysdeps/generic/strcpy.c .
Is this an error generated by gdb or an error from my program?
-jpf-
btw where must Gprof be run?
-leuk nederlands onderonsje ;-)
Last edited by jpflathead; 10-23-2002 at 02:53 AM.
It's an error from gdb. It's looking for the source code files. Having the source code files makes it easier to debug so you can see where it went wrong? You should make sure you debug in the right directory so it can find the source files.
There are several steps to running gprof. The man page explains it all in detail.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.