C++ to C++ transformer

G

Guest

Hello,
I 'm trying to convert my C++ sources by inserting something just at the
beginning and in the end of each function/method.

Do anyone know a way/tool how to do it efficiently. The preffered
environment is Linux.

Thanx in advance

Michal Blaszak
 
T

Thomas Matthews

Micha? B?aszak said:
Hello,
I 'm trying to convert my C++ sources by inserting something just at the
beginning and in the end of each function/method.
What are you converting to?
Your subject line implies there is no transformation, or perhaps
a redundant transformation.

Do anyone know a way/tool how to do it efficiently. The preffered
environment is Linux.
Have you tried sed or awk, python or perl?
Thanx in advance

Michal Blaszak
Perhaps if you give more details, we can give better
responses.


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
J

Jacek Dziedzic

Thomas said:
What are you converting to?
Your subject line implies there is no transformation, or perhaps
a redundant transformation.

I believe he means that a C++ source is to be transformed by
inserting a bit of code or perhaps a comment into the body all
functions, producing a C++ output.

- J.
 
G

Guest

Jacek said:
I believe he means that a C++ source is to be transformed by
inserting a bit of code or perhaps a comment into the body all
functions, producing a C++ output.

- J.

That's right. I have a C++ source in the input and want to produce another
C++ changed a little bit. The goal is to insert a piece of code just at the
beginning and at the end of each function. Unfortunately it is advanced C++
source (classes, templates, macros, ... everything) so solving the problem
is as complicated as parsing sources against the full C++ syntax. This is
why I look for a tool which is capable of doing the task for me. Doing it
manually requires to much effort.

Thanx for your help

Michal Blaszak
 
J

Jacek Dziedzic

Micha³ B³aszak said:
That's right. I have a C++ source in the input and want to produce another
C++ changed a little bit. The goal is to insert a piece of code just atthe
beginning and at the end of each function. Unfortunately it is advancedC++
source (classes, templates, macros, ... everything) so solving the problem
is as complicated as parsing sources against the full C++ syntax. This is
why I look for a tool which is capable of doing the task for me. Doing it
manually requires to much effort.

I think you'd have more luck in a different newsgroup (unfortunately
I can't recommend you any), because people around here discuss only
the C++ as in "C++ standard" and are quite strict about doing this
and only this. I also don't know how to solve your problem.

- J.
 
I

Ira Baxter

That's right. I have a C++ source in the input and want to produce another
C++ changed a little bit. The goal is to insert a piece of code just at the
beginning and at the end of each function. Unfortunately it is advanced C++
source (classes, templates, macros, ... everything) so solving the problem
is as complicated as parsing sources against the full C++ syntax. This is
why I look for a tool which is capable of doing the task for me. Doing it
manually requires to much effort.

Yes, you need to parse the full C++ syntax.
You also need to be able to write rules stating what you want done.
The DMS Software Reengineering toolkit is a source-to-source
transformation tool that can do this, and has a full
C++ front end parser to support it.
See http://www.semanticdesigns.com/Products/CppFrontEnd.html
and follow the link there to read about DMS.

A white paper showing how to instrument code using DMS,
e.g., something almost exactly like you requested, can be found the the web
page
www.semanticdesigns.com/Products/TestCoverage
 
C

Cedric LEMAIRE

Ira Baxter said:
Yes, you need to parse the full C++ syntax.
I don't agree. You can recognize function definitions without having
to parse the full C++ syntax.

I have an example here:
http://www.codeworker.org/ScriptsRepository.html#Program_transformation

You need to use CodeWorker (http://www.codeworker.org, distributed
under LGPL), a parsing tool and a universal source code generation,
which notably allows the transformation of source files.

It is an old script. I'm not sure whether it works on template or not.
If you try it and if it doesn't work on a function, tell me and I'll
correct it.
 
L

Lothar Werzinger

Michał Błaszak said:
Hello,
I 'm trying to convert my C++ sources by inserting something just at the
beginning and in the end of each function/method.

Do anyone know a way/tool how to do it efficiently. The preffered
environment is Linux.

Thanx in advance

Michal Blaszak

If you only want to execute a special peace of code at the entry and exit of
your function/method then the gcc option -finstrument-functions may be of
interest.

Lothar
 
O

Oliver Brandt

Michał Błaszak said:
Hello,
I 'm trying to convert my C++ sources by inserting something just at the
beginning and in the end of each function/method.

Do anyone know a way/tool how to do it efficiently. The preffered
environment is Linux.
Perhaps www.aspectc.org comes close to what you want....

HTH,
Oliver
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,183
Messages
2,570,967
Members
47,517
Latest member
Andres38A1

Latest Threads

Top