Dynamic tracing of C code execution

Discussion in 'C Programming' started by Nikhil, May 12, 2006.

  1. Nikhil

    Nikhil Guest

    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
    Nikhil, May 12, 2006
    #1
    1. Advertising

  2. Nikhil

    Vladimir Oka Guest

    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 , Christopher Browne)

    <http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>
    Vladimir Oka, May 12, 2006
    #2
    1. Advertising

  3. Nikhil

    Michael Mair Guest

    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.
    Michael Mair, May 12, 2006
    #3
  4. 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
    Walter Bright, May 13, 2006
    #4
  5. Nikhil

    Ira Baxter Guest

    "Nikhil" <> wrote in message
    news:...
    > 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
    Ira Baxter, May 16, 2006
    #5
  6. Nikhil

    Frank Pittel Guest

    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.

    : Thanks,

    : Nikhil

    Use truss.
    --




    -------------------
    Keep working millions on welfare depend on you
    Frank Pittel, May 16, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Graham Cottle

    Tracing Execution in Class Library

    Graham Cottle, Jan 21, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    369
    Daniel Bass
    Jan 21, 2004
  2. Michael B. Trausch

    Tracing the execution of scripts?

    Michael B. Trausch, Oct 27, 2006, in forum: Python
    Replies:
    10
    Views:
    457
    Ben Finney
    Oct 28, 2006
  3. Sabiyur

    Code execution Tracing

    Sabiyur, Aug 16, 2006, in forum: C++
    Replies:
    1
    Views:
    330
    Jim Langston
    Aug 17, 2006
  4. Thorsten Hater

    Question: Dynamic code execution

    Thorsten Hater, Mar 29, 2010, in forum: Ruby
    Replies:
    4
    Views:
    181
    Matthew K. Williams
    Mar 29, 2010
  5. Jarek Blakarz

    tracing code line executions

    Jarek Blakarz, Sep 26, 2013, in forum: C++
    Replies:
    3
    Views:
    381
    Öö Tiib
    Sep 27, 2013
Loading...

Share This Page