![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Timer | aekaramg20 | Shell Programming and Scripting | 6 | 08-21-2008 09:47 AM |
| Timer for VNC | foweja | UNIX for Advanced & Expert Users | 1 | 07-14-2005 10:31 AM |
| VNC Timer | foweja | Shell Programming and Scripting | 0 | 07-13-2005 12:25 PM |
| timer | k_oops9 | Shell Programming and Scripting | 3 | 11-08-2004 11:33 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I'm trying generate an interrupt every 1 seconds using itimer and My clock is not running. This is what i did :
printf("about to sleep for 1 second \n"); signal(SIGALRM, wakeup); //myTimer.it_interval.tv_sec=0; //myTimer.it_interval.tv_usec =0; myTimer.it_value.tv_sec = delay; myTimer.it_value.tv_usec =0; setitimer(ITIMER_REAL, &myTimer, ); Can anyone give me some idea how to debug my program ? and are there any good reference book i can read. Thanks |
|
||||
|
timer/alarm
Heres a good reference on alarms and timers using interrupts:
http://www.gnu.org/manual/glibc-2.0..../libc_306.html |
|
||||
|
Further to what Perderabo said, I use a form of printf to debug my programs.
Rather than displaying messages to screen, I would write those same messages to a log file. This could obviously mean a very large file, which will mean a performance degredation, so the logging (or tracing) is conditional on a configuration setting being activiated e.g. an environment variable or in an configuration (or ini) file or a flag on a database table. A trace level could also be defined e.g. 9 for most detailed to 1 for the least detail. Although creating a mechanism to log to a file will require more programming effort, it will be invaluable to you if you have developed your program and delivered it to a 'live' system where your development tools won't be available. You may not be able to predict when your fault is going to happen either, especially with background or daemon processes. After you have put in the effort to create your new logging functions, you may want to encapsulate them into a library for use in future projects. To this end I believe many Unix systems will provide standard functions to allow you to write messages to the system log if you prefer. Whether you are logging to a file or the screen or even using a debugger I would recommend you track the following features of your program: 1. When a function is called 2. When a function exits. 3. The input values, or paramters to functions 4. The return values, or parameters of functions 5. When a variable is first assigned. 6 When a variable changes (Be sure to display all strings within quotes so you can see any whitespace in the string) This should allow you to tackle most faults in your program. MBB |
|
||||
|
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|