How to trace function calls?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nospam

    How to trace function calls?

    I have a C binary which is built from numerous .c and .h source files.
    How can I trace through which functions are being called when I execute
    the binary? Ideally I'd like to just see the function names accessed.
    This is on an HP-UX system, but I'm curious as far as Linux is concerned.


    -Thanks

  • Eric Sosman

    #2
    Re: How to trace function calls?

    nospam wrote:
    I have a C binary which is built from numerous .c and .h source files.
    How can I trace through which functions are being called when I execute
    the binary? Ideally I'd like to just see the function names accessed.
    This is on an HP-UX system, but I'm curious as far as Linux is concerned.
    There's no built-into-C facility to do this, but perhaps
    you can find "test coverage" tools that run on the systems
    that concern you. (Questions about how to use the tools should
    be directed to forums about them or about their host systems;
    they're not questions about the C language.)

    --
    Eric Sosman
    esosman@ieee-dot-org.invalid

    Comment

    • user923005

      #3
      Re: How to trace function calls?

      On May 29, 7:54 pm, nospam <n...@spam.comw rote:
      I have a C binary which is built from numerous .c and .h source files.
      How can I trace through which functions are being called when I execute
      the binary?  Ideally I'd like to just see the function names accessed.
      This is on an HP-UX system, but I'm curious as far as Linux is concerned.
      This is C++ code, but you can probably translate the idea to C:


      I guess that for your environment, this is what you want:

      Comment

      • Keith Thompson

        #4
        Re: How to trace function calls?

        nospam <no@spam.comwri tes:
        I have a C binary which is built from numerous .c and .h source files.
        How can I trace through which functions are being called when I execute
        the binary? Ideally I'd like to just see the function names accessed.
        This is on an HP-UX system, but I'm curious as far as Linux is concerned.
        The C language doesn't define any way to do this. Try asking in
        comp.sys.hp.hpu x, comp.unix.progr ammer, or one of the Linux groups.

        --
        Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
        Nokia
        "We must do something. This is something. Therefore, we must do this."
        -- Antony Jay and Jonathan Lynn, "Yes Minister"

        Comment

        • CBFalconer

          #5
          Re: How to trace function calls?

          nospam wrote:
          >
          I have a C binary which is built from numerous .c and .h source
          files. How can I trace through which functions are being called
          when I execute the binary? Ideally I'd like to just see the
          function names accessed. This is on an HP-UX system, but I'm
          curious as far as Linux is concerned.
          If you are using gcc, look up the -p (and -pg) options. For other
          systems see if there are useful profiling commands. This is all
          system specific, and thus off-topic here.

          --
          [mail]: Chuck F (cbfalconer at maineline dot net)
          [page]: <http://cbfalconer.home .att.net>
          Try the download section.


          ** Posted from http://www.teranews.com **

          Comment

          • Richard Tobin

            #6
            Re: How to trace function calls?

            In article <oPSdnRSGRavj8a LVnZ2dnUVZ_qTin Z2d@comcast.com >,
            nospam <no@spam.comwro te:
            >I have a C binary which is built from numerous .c and .h source files.
            >How can I trace through which functions are being called when I execute
            >the binary? Ideally I'd like to just see the function names accessed.
            If all else fails, you can run it under a debugger.

            -- Richard

            --
            In the selection of the two characters immediately succeeding the numeral 9,
            consideration shall be given to their replacement by the graphics 10 and 11 to
            facilitate the adoption of the code in the sterling monetary area. (X3.4-1963)

            Comment

            • Kenny McCormack

              #7
              Re: How to trace function calls?

              In article <g1odto$l6r$2@p c-news.cogsci.ed. ac.uk>,
              Richard Tobin <richard@cogsci .ed.ac.ukwrote:
              >In article <oPSdnRSGRavj8a LVnZ2dnUVZ_qTin Z2d@comcast.com >,
              >nospam <no@spam.comwro te:
              >
              >>I have a C binary which is built from numerous .c and .h source files.
              >>How can I trace through which functions are being called when I execute
              >>the binary? Ideally I'd like to just see the function names accessed.
              >
              >If all else fails, you can run it under a debugger.
              Excuse me. Noone here uses debuggers.

              Comment

              • Richard

                #8
                Re: How to trace function calls?

                user923005 <dcorbit@connx. comwrites:
                On May 29, 7:54 pm, nospam <n...@spam.comw rote:
                >I have a C binary which is built from numerous .c and .h source files.
                >How can I trace through which functions are being called when I execute
                >the binary?  Ideally I'd like to just see the function names accessed.
                >This is on an HP-UX system, but I'm curious as far as Linux is concerned.
                >
                This is C++ code, but you can probably translate the idea to C:

                >
                I guess that for your environment, this is what you want:
                http://www.tlug.org.za/wiki/index.ph...C_upon_SIGSEGV
                Just FYI also see "strace".

                Comment

                • Herbert Rosenau

                  #9
                  Re: How to trace function calls?

                  On Fri, 30 May 2008 02:54:54 UTC, nospam <no@spam.comwro te:
                  I have a C binary which is built from numerous .c and .h source files.
                  How can I trace through which functions are being called when I execute
                  the binary? Ideally I'd like to just see the function names accessed.
                  This is on an HP-UX system, but I'm curious as far as Linux is concerned.
                  It's simple. You'll needs 2 steps.

                  1. step:

                  tell the compiler to compile and bind the sources with bouded debug
                  information.

                  2. step:

                  You just starts the program under the control of a debug and tells the
                  debug what you want from it.

                  You can do much more now.

                  You can hold the program at each source line where an executeable
                  statement is.
                  You can let the debug show you the value of each variable in sight
                  when the execution of the debugee is frozen.
                  You can change the value of each variable in sight at this point too.
                  And many, many other things too.

                  The only hurde is: you have to learn how to control the debug.

                  --
                  Tschau/Bye
                  Herbert

                  Visit http://www.ecomstation.de the home of german eComStation
                  eComStation 1.2R Deutsch ist da!

                  Comment

                  Working...