Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/articles/c-tutorials/)
-   -   C Tools To Peek Inside A Process (http://www.go4expert.com/articles/c-tools-peek-inside-process-t23447/)

techexplorer 29Sep2010 23:51

C Tools To Peek Inside A Process
List of helpful C tools that will help you peek inside a process or an a.out file. Some are specific to Sun OS. I have compiled it into an easy-to-read summary of what each one does, and where to find them. Going through the man pages for each, and try running each on a couple of different a.outs - the "hello world" program and a "big program".

Tools To Examine Source

Tool --> Where To Find It --> What it Does
  1. cb --> Comes with the Compiler --> C program beautifier. Run your source through this filter to put it in a standard layout and indentation.
  2. Indent --> comes with AT&T --> Does same as cb.
  3. cdecl --> _______ --> Unscrambles C declarations.
  4. cflow- --> Comes with the Compiler --> An interactive ASCII based C program browser. We can use it in the OS group to check the impact of changes to header files. It provides quick answers to questions like: "How many commands use libthread?" or "Who are all the kmem readers".
  5. ctags --> /usr/bin --> Creates a tag file for use in vi editor. Tags file speeds up examining program source by maintaining a table of where most objects are located.
  6. lint --> Comes with the Compiler --> A C program checker.
  7. sccs --> /usr/ccs/bin --> A source code version control system.
  8. vgrind --> /usr/bin --> A formatter for printing nice C listings.
Doctors can use x-rays, sonograms, arthroscopes, and exploratory operations to look inside their patients. These tools are the x-rays of the Software world.

Tools To Examine Executable

Tool --> Where To Find It --> What it Does
  1. dis --> /ur/ccs/bin --> Object code disassemble.
  2. dump Lv --> /usr/ccs/bin - --> Prints dynamic linking of information.
  3. ldd --> /usr/bin --> Prints the dynamic libraries the file needs.
  4. nm --> /usr/ccs/bin --> Prints the symbol table information of an object file.
  5. strings --> /usr/bin --> Looks at the strings embedded in a library. Useful for looking at error messages a binary can generate, built-in file names, and sometimes symbol names or version and copyright information.
  6. sum --> /usr/bin --> Prints checksum and block count for a file. Answer the questions like: "Are two executables the same version?" "Did transmission go OK?"

Tools To Help With Debugging

Tool --> Where To Find It --> What it Does
  1. truss --> /usr/bin --> The SVr4 version of trace. This tool prints out the system calls that an executable makes. Use it to see what a binary is doing, and why its stuck or failing. This is a great help!.
  2. ps --> /usr/bin --> Displays process characteristics.
  3. ctrace --> Comes with the Compiler --> Interactive debugger.
  4. debugger --> Comes with the Compiler --> Modifies your source to print lines as they are executed. A great tool for small programs.
  5. file --> /usr/bin --> Tells you what a file contains (Ex:executable, data, ASCII, shell script, archive, etc...).

Tools To Perform Performance Tuning

Tool --> Where To Find It --> What it Does
  1. collector --> Comes with debugger --> (Sun OS only)Collects runtime performance data under the control of debugger.
  2. analyzer --> Comes with debugger --> (Sun OS only) Analyses collected performance data.
  3. gprof --> /usr/ccs/bin --> Displays the Call-graph profile data (identifies the compute intensive functions).
  4. prof --> /usr/ccs/bin --> Displays the percentage of time spent in each routine.
  5. tcov --> Comes with compiler --> Displays a count of how often each statement is executed(identifies the compute-intensive loops within a function).
  6. time --> /usr/bin/time --> Displays the total real and CPU time used by a program.
If you are working on the OS Kernel, most of the runtime tools are not available to you, because the kernel does not run as a user process. The compile time tools, like lint, work but otherwise we have to use stone knives and flint axes: putting non random patters in memory to see when they are over written, using printfs or their equivalents and logging trace information.

Tools To Help Identify Your Hardware

What It identifies --> Typical Output --> How to Invoke It
  1. Kernel Architecture --> sun4c --> /usr/kvm/arch k
  2. Any OS patches applied --> no patches are installed --> /usr/bin/showrev p
  3. Various hardware things --> lots --> /usr/sbin/prtconf
  4. CPU clock rate --> 40MHz processor --> /usr/sbin/psrinfo v
  5. hosted --> 55417fe --> /usr/ucb/hosted
  6. memory --> 32Mb --> Displays on power up
  7. Serial number --> 4290302 --> Displays on power up
  8. ROM Version --> 2.4.1 --> Displayed on power up
  9. Mounted disk --> 198Mb disk --> /usr/bin/df F ufs k
  10. Swap space --> 40 Mb --> /etc/swap s
  11. Ethernet addresss --> 9:0:6:6:6 --> /usr/sbin/ifconfig a The Ethernet address is built into the machine
  12. IP address --> le0= --> /usr/sbin/ifconfig a The IP address is built into the network
  13. Floating-point hardware --> FPUs frequency appears to be 38.2 MHz --> fpversion comes with compiler.


  1. Stephen C. Tweedie (February 17 1999). Re: fsync on large files. Linux kernel mailing list.
  2. M. Bach. The Design of the UNIX Operating System. Prentice Hall, 1986 .

coderzone 30Sep2010 20:54

Re: C Tools To Peak Inside A Process
Is the spelling of peak correct in the context?

shabbir 30Sep2010 21:03

Re: C Tools To Peek Inside A Process
Changed. :D

shabbir 4Oct2010 10:21

Re: C Tools To Peek Inside A Process
If you liked this article do nominate this article for Article of the month - Sep 2010 Before 15th of October 2010.

dorramide7 8Oct2010 16:12

Re: C Tools To Peek Inside A Process
wamly welcome

Sure all pro gamer are most welcome... if you can reach out to them it would be great!! Thanks a lot

Ya it will be great if they both get active on this forum...
and share their exp. with gaming...

shabbir 17Oct2010 12:54

Re: C Tools To Peek Inside A Process
Article selected for voting for Article of the month - Sep 2010. Cast your vote now before October 27th, 2010

All times are GMT +5.5. The time now is 17:49.