473,466 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Need help building a software profiler.

78 New Member
Hi guys. i'm trying to build a software profiler in C++. What i want for now is to get a C code as input to my program, and produce a that code but added to it some stuff.
An example is getting input "x;" and putting output "x; stmt[0]++;"
This allows me to know how many times a statement in this code as been executed.
The strategy is to insert a stmt[i]++; anywhere i see a ';', but i'm afraid it won't work if i encounter a ';' found in the for loop parameters. And if i want to solve this and check if this statement ends with a new line, then place a "stmt[i]++", i'll be missing out on lines which include more than one statement such as "x; y;" (on the same line).

Can anyone suggest a possible solution? I've been thinking about it for hours, but i'm unable to solve this problem.

Thank you.
Apr 15 '07 #1
4 1546
Savage
1,764 Recognized Expert Top Contributor
Hi guys. i'm trying to build a software profiler in C++. What i want for now is to get a C code as input to my program, and produce a that code but added to it some stuff.
An example is getting input "x;" and putting output "x; stmt[0]++;"
This allows me to know how many times a statement in this code as been executed.
The strategy is to insert a stmt[i]++; anywhere i see a ';', but i'm afraid it won't work if i encounter a ';' found in the for loop parameters. And if i want to solve this and check if this statement ends with a new line, then place a "stmt[i]++", i'll be missing out on lines which include more than one statement such as "x; y;" (on the same line).

Can anyone suggest a possible solution? I've been thinking about it for hours, but i'm unable to solve this problem.

Thank you.
Hi,

if it contains more than one statement in one line then how about to search the line for:
Expand|Select|Wrap|Line Numbers
  1. for(
and if it contains it you will need to skip all ';' until you get to ;).
and then after every ';' add a stmt[i]++;

Savage
Apr 15 '07 #2
JosAH
11,448 Recognized Expert MVP
Hi,

if it contains more than one statement in one line then how about to search the line for:
Expand|Select|Wrap|Line Numbers
  1. for(
and if it contains it you will need to skip all ';' until you get to ;).
and then after every ';' add a stmt[i]++;

Savage
At least you have to do that after preprocessing; have a look at this sick little puppy:
Expand|Select|Wrap|Line Numbers
  1. #define for(x) while(1)
  2. ...
  3. for (ever;and;ever)
  4. ...
Note that the preprocessor doesn't know about reserved words nor anything
at all about the C (or C++) language.

kind regards,

Jos
Apr 15 '07 #3
Sebouh
78 New Member
Hi,

if it contains more than one statement in one line then how about to search the line for:
Expand|Select|Wrap|Line Numbers
  1. for(
and if it contains it you will need to skip all ';' until you get to ;).
and then after every ';' add a stmt[i]++;

Savage
Yeh i think that would work.
Thanks mate. Now to deal with adding { for every 1 lined for loop.
Apr 15 '07 #4
JosAH
11,448 Recognized Expert MVP
Yeh i think that would work.
Thanks mate. Now to deal with adding { for every 1 lined for loop.
Note my reply just above yours though ... If you want a bullet proof profiler better
start reading about coff and elf object file formats then which contain statement
and line information for compiled C (or C++) code. The compiler itself has done
its evil deeds and optimization tricks then already so it can't fool you anymore.

kind regards,

Jos
Apr 15 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: PatchFactory Support | last post by:
Description: Professional and easy-to-use patch building environment that can help you to create instant patch packages for software and file updating. Generated patch packages are small size...
3
by: jw56578 | last post by:
Where is the information coming from that is displayed in query profiler. Is it the command that is retrieved before it is processed, or is it what is actually processed.
22
by: Rafia Tapia | last post by:
Hi all This is what I have in mind and I will appreciate any suggestions. I am trying to create a xml help system for my application. The schema of the xml file will be <helpsystem> <help...
3
by: Maansi Gupta | last post by:
Platform - Windows 2000 Professional , VC .NET 7.1 Hello, I have recently ported my source code from Visual Studio 6.0 to .NET 7.1 Previously with Visual Studio 6.0 I was using the profiler...
5
by: HotRod | last post by:
I am new to this so please go easy. We currently have some students doing some work on some web based tracking documents for us. They are currently using VB .net to develop what we requested....
3
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
0
by: anweshadash | last post by:
Using SQL Profiler: (Ref: http://msdn2.microsoft.com/en-us/library/ms181091.aspx) Sometimes it’s very beneficial to use sql profiler. Let’s have an idea about that and how to use that by...
3
by: Gordon | last post by:
Has anybody had any success compiling a PHP build for Leopard, specifically for Leopard running on a 64 bit Intel architecture? I have been using the Entropy builds up to now but there has been a...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
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
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...
0
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.