Professional Web Applications Themes

tracing through C function calls - UNIX Programming

Hi, All Comments appreciated. I have the source-code (in C) for a sufficiently huge program. What tools are available that can be used to trace through the program, so that I can get a decent understanding of how it works.. I can't use gdb as i think it will be complicated. (especially since it involves networking and threads) I have read on previos posts about ptrace, strace, gprof and truss.. Ihave never used them, and would like to know how effective they are, Thanks in advance to any comments. Shashank...

  1. #1

    Default tracing through C function calls

    Hi,
    All Comments appreciated.

    I have the source-code (in C) for a sufficiently huge program. What
    tools are available that can be used to trace through the program, so
    that I can get a decent understanding of how it works..

    I can't use gdb as i think it will be complicated. (especially since it
    involves networking and threads)

    I have read on previos posts about ptrace, strace, gprof and truss..
    Ihave never used them, and would like to know how effective they are,

    Thanks in advance to any comments.
    Shashank



    Shashank Guest

  2. #2

    Default Re: tracing through C function calls

    Shashank Khanvilkar wrote: 

    strace, ptrace and truss trace *system* calls, not application calls.

    gdb *is* one way, if you can put break points at interesting places, it
    does give you an idea.

    A good "logging" API can help and it's usually the way I find problems
    with MT code.

    Gianni Guest

  3. #3

    Default Re: tracing through C function calls

    Gianni Mariani <ws> writes:
     [/ref]

    [snip]
     

    Not strictly true. At least truss can be used to trace library calls as
    well (check -u switch). Example 9 from truss man page on Solaris 8 givesL


    Example 9: Tracing any user-level function call

    This example traces every user-level function call from any-
    where to anywhere:

    example$ truss -u a.out -u ld:: -u :: ...

    Don't know about strace, ptrace and the others. On Linux you can use ltrace
    for library calls traces.

    HTH, Dragan

    --
    Dragan Cvetkovic,

    To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer

    !!! Sender/From address is bogus. Use reply-to one !!!
    Dragan Guest

  4. #4

    Default Re: tracing through C function calls

    Shashank Khanvilkar wrote: 
    Try DDD (Data Display Debugger). It is frontend for gdb. But it
    simplifies many of the intricacies of gdb.

    I personally use it for debugging my complex unix code.

    Cheers,

    Tejas Kokje
    University of Southern California
    Los Angeles.
    http://www-scf.usc.edu/~kokje
    Tejas Guest

  5. #5

    Default Re: tracing through C function calls

    On Tue, 10 Feb 2004 12:28:31 -0600, Shashank Khanvilkar wrote:
     

    Since you mention gdb, I am going to assume that you use gcc.
    The -finstrument-functions option for gcc may help.

    --
    mail1dotstofanetdotdk

    Bjorn Guest

  6. #6

    Default Re: tracing through C function calls

    Shashank Khanvilkar wrote: 

    strace is a cool tool, and one you should be familiar with for debugging
    your own progs. it is very useful, especiallly if you read the man
    pages and see you can easily trace child process's system calls. iirc,
    attaching to child gdb processes takes a 'hack' of some sort. strace
    can be a really valuable tool. there is also 'ltrace', it will trace
    all libc calls and it is also helpful.

    inf Guest

Similar Threads

  1. way to dispatch strings to function calls
    By mrfrazzlebottom in forum PHP Development
    Replies: 2
    Last Post: January 24th, 04:58 PM
  2. duplicateMovieClip function calls (Asynchronous)
    By irraticFlash in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: March 2nd, 04:29 PM
  3. Function Calls not working
    By Johnny in forum ASP Database
    Replies: 2
    Last Post: March 2nd, 05:38 AM
  4. Function calls and strings
    By Ney andré de mello zunino in forum PHP Development
    Replies: 1
    Last Post: September 14th, 03:08 PM
  5. [PHP-DEV] New extension; nested function calls failing
    By Bob Glamm in forum PHP Development
    Replies: 1
    Last Post: August 13th, 05:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139