Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Dynamic tracing of C code execution

Reply
Thread Tools

Dynamic tracing of C code execution

 
 
Nikhil
Guest
Posts: n/a
 
      05-12-2006
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

 
Reply With Quote
 
 
 
 
Vladimir Oka
Guest
Posts: n/a
 
      05-12-2006
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 http://www.velocityreviews.com/forums/(E-Mail Removed), Christopher Browne)

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

 
Reply With Quote
 
 
 
 
Michael Mair
Guest
Posts: n/a
 
      05-12-2006
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.
 
Reply With Quote
 
Walter Bright
Guest
Posts: n/a
 
      05-13-2006
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
 
Reply With Quote
 
Ira Baxter
Guest
Posts: n/a
 
      05-15-2006

"Nikhil" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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


 
Reply With Quote
 
Frank Pittel
Guest
Posts: n/a
 
      05-16-2006
Nikhil <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question: Dynamic code execution Thorsten Hater Ruby 4 03-29-2010 07:55 PM
private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack sndive@gmail.com Python 9 11-14-2007 10:31 PM
Tracing the execution of scripts? Michael B. Trausch Python 10 10-28-2006 12:51 AM
Code execution Tracing Sabiyur C++ 1 08-17-2006 10:49 PM
Tracing Execution in Class Library Graham Cottle ASP .Net 1 01-21-2004 04:07 PM



Advertisments