468,746 Members | 1,866 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,746 developers. It's quick & easy.

Dynamic tracing of C code execution

Hi,

I have a set of C source files and I need a tool which can add probes
and then dynamically trace the execution and print the results (The C
source code does not have any printf statements).

The purpose of the tool is to add test cases for unit testing and then
see the statement/branch coverage for them.

Thanks,

Nikhil

May 12 '06 #1
5 4615
Nikhil opined:
Hi,

I have a set of C source files and I need a tool which can add probes
and then dynamically trace the execution and print the results (The C
source code does not have any printf statements).

The purpose of the tool is to add test cases for unit testing and
then see the statement/branch coverage for them.


I can't think of such a tool right now, but I do wonder how would it
know where to put "print" statements, and what to print out, without
heavy input from you? While specifying that, you might as well add
your own debug "print" statements, and guard them with `#ifdef`s so
they're only compiled in for debug/test purposes. As a bonus, you
won't be relying on a tool still being available (and supporting
whatever next platform you port to) sometime in the future.

--
Fatal Error: Found [MS-Windows] System -> Repartitioning Disk for
Linux...
(By cb*****@io.org, Christopher Browne)

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>

May 12 '06 #2
Vladimir Oka schrieb:
Nikhil opined:
Hi,

I have a set of C source files and I need a tool which can add probes
and then dynamically trace the execution and print the results (The C
source code does not have any printf statements).

The purpose of the tool is to add test cases for unit testing and
then see the statement/branch coverage for them.


I can't think of such a tool right now, but I do wonder how would it
know where to put "print" statements, and what to print out, without
heavy input from you? While specifying that, you might as well add
your own debug "print" statements, and guard them with `#ifdef`s so
they're only compiled in for debug/test purposes. As a bonus, you
won't be relying on a tool still being available (and supporting
whatever next platform you port to) sometime in the future.


You even can go one step further and
#ifdef TRACE_ON
# define TRACE_PRINT(a) fputs(a, TRACE_FILE)
#else
# define TRACE_PRINT(a)
#endif
There is also the ((....)) trick
#ifdef TRACE_ON
# define TRACE_PRINTF(a) fprintf a
#else
# define TRACE_PRINTF(a)
#endif
"called" via
TRACE_PRINTF((TRACE_FILE, formatstring, ....))
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
May 12 '06 #3
Nikhil wrote:
Hi,

I have a set of C source files and I need a tool which can add probes
and then dynamically trace the execution and print the results (The C
source code does not have any printf statements).

The purpose of the tool is to add test cases for unit testing and then
see the statement/branch coverage for them.


Here's a tool that will get you started:

http://www.digitalmars.com/ctg/trace.html

-Walter Bright
www.digitalmars.com C, C++, D programming language compilers
May 13 '06 #4

"Nikhil" <n.********@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
Hi,

I have a set of C source files and I need a tool which can add probes
and then dynamically trace the execution and print the results (The C
source code does not have any printf statements).

The purpose of the tool is to add test cases for unit testing and then
see the statement/branch coverage for them.


See the white paper, "TestCoverage.pdf" at
http://www.semanticdesigns.com/Products/TestCoverage
It explains how to use a program transformation tool
to insert probes in source code. The paper is focused
on probes for test coverage, but the ideas work for
any kind of probe.
--
Ira Baxter, CTO
www.semanticdesigns.com
May 15 '06 #5
Nikhil <n.********@gmail.com> wrote:
: Hi,

: I have a set of C source files and I need a tool which can add probes
: and then dynamically trace the execution and print the results (The C
: source code does not have any printf statements).

: The purpose of the tool is to add test cases for unit testing and then
: see the statement/branch coverage for them.

: Thanks,

: Nikhil

Use truss.
--


-------------------
Keep working millions on welfare depend on you
May 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Ford Desperado | last post: by
6 posts views Thread by MattC | last post: by
5 posts views Thread by Patrick | last post: by
2 posts views Thread by deepukutty | last post: by
reply views Thread by Pascal Costanza | last post: by
1 post views Thread by Sabiyur | last post: by
10 posts views Thread by Michael B. Trausch | last post: by
7 posts views Thread by Ronald S. Cook | last post: by
4 posts views Thread by Michel Esber | last post: by
1 post views Thread by CARIGAR | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.