Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to trace function calls?

5 views
Skip to first unread message

nospam

unread,
May 29, 2008, 10:54:54 PM5/29/08
to
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

unread,
May 29, 2008, 11:37:16 PM5/29/08
to

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
eso...@ieee-dot-org.invalid

user923005

unread,
May 29, 2008, 11:54:50 PM5/29/08
to

This is C++ code, but you can probably translate the idea to C:
http://www.codeproject.com/KB/cpp/cmtrace.aspx

I guess that for your environment, this is what you want:
http://www.tlug.org.za/wiki/index.php/Obtaining_a_stack_trace_in_C_upon_SIGSEGV

Keith Thompson

unread,
May 30, 2008, 12:02:30 AM5/30/08
to

The C language doesn't define any way to do this. Try asking in
comp.sys.hp.hpux, comp.unix.programmer, or one of the Linux groups.

--
Keith Thompson (The_Other_Keith) ks...@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"

CBFalconer

unread,
May 30, 2008, 1:27:04 AM5/30/08
to

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 **

Richard Tobin

unread,
May 30, 2008, 4:29:44 AM5/30/08
to
In article <oPSdnRSGRavj8aLV...@comcast.com>,
nospam <n...@spam.com> 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.

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)

Kenny McCormack

unread,
May 30, 2008, 10:19:24 AM5/30/08
to
In article <g1odto$l6r$2...@pc-news.cogsci.ed.ac.uk>,

Richard Tobin <ric...@cogsci.ed.ac.uk> wrote:
>In article <oPSdnRSGRavj8aLV...@comcast.com>,
>nospam <n...@spam.com> 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.
>
>If all else fails, you can run it under a debugger.

Excuse me. Noone here uses debuggers.

Richard

unread,
May 31, 2008, 12:35:50 PM5/31/08
to
user923005 <dco...@connx.com> writes:

Just FYI also see "strace".

Herbert Rosenau

unread,
Jun 2, 2008, 4:06:05 PM6/2/08
to

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!

0 new messages