473,503 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4853
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
6275
by: Ford Desperado | last post by:
there is an application which issues a lot of simple dynamic queries against an Oracle database. If CURSOR_SHARING is set to FORCE, Oracle treats dynamic queries as static ones, for instance...
6
2658
by: MattC | last post by:
Hi, I'm implementing a new Business Layer in one of our applications. I'm toying with the idea of placing all the Create, Read, Update and Delete SQL in the object in question and build a...
5
1816
by: Patrick | last post by:
I understand it is built in behaviour that if an ASP.NET's web.config is set to: <customErrors mode="RemoteOnly" /> then I only get a detailed error message on screen when the ASP.NET...
2
1748
by: deepukutty | last post by:
Hi all, I know tht we can do tracing in two ways.one in application level and the other is at Page level. I am able to see the details of trace either on the page itself or .../trace.axd page....
0
2055
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab,...
1
2102
by: Sabiyur | last post by:
Hi All, I don't know whether this is the right forum to post this question. If not, Please forgive me. I want to write my own tool which can trace the code execution (print the sequence of...
10
2422
by: Michael B. Trausch | last post by:
Alright, I seem to be at a loss for what I am looking for, and I am not even really all that sure if it is possible or not. I found the 'pdb' debugger, but I was wondering if there was something...
7
3013
by: Ronald S. Cook | last post by:
I've always been taught that stored procedures are better than writing SQL in client code for a number of reasons: - runs faster as is compiled and lives on the database server - is the more...
4
1713
by: Michel Esber | last post by:
Environment: DB2 v8 LUW FP 15 running on Linux. For some reason that I can´t explain, a simple insert statement on a table may run very quickly, or may take forever (20-30mins) to finish....
0
7076
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5005
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1507
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.