[aspectc-user] AspectC++ with MSVC++ 6.0

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Mon Feb 9 17:22:57 CET 2004


Hello,

Chalapathi Rao Kotnana wrote:
> We have VC++ (MFC) based GUI application. We need to write a
> function\method exit to log files. Our application freezes once in a
> while at users desktop. We don't know why it freezes and what is
> causing this problem. So, we would like to log every method exit to a
> log file. So, that if application freezes, we can go through log
> files and see why it freezes. Ours is big application. Adding one
> line of code to write to log file is very big task.
> 
> I guess Aspects can help me. Let me know if I am wrong. My guess is
> with aspectC++, with few lines of code changes we can write to log
> files. Ours is VC++ application and I don't see much help for VC++. I
> greatly appreciate, of anybody can help us.
> 
> Regards,
> KC

a task like this is a good example what AspectC++ can be used for. From 
the language point fo view this is very simple: just define an aspect 
with "after-advice" for the relevant "execution join points".

However, I'm not sure whether the ac++ compiler is already useful in 
your case (a "big application" and ac++ still has version number 0.x). 
It mostly depends on your code. The following problems might arise:

1. parse errors by ac++
    If your code uses complicated templates or libraries which contain
    code that is hard to parse, ac++ wouldn't start any transformations

2. no weaving in templates
    The current version of ac++ can not weave advice for template
    functions or members of template classes. If your application is full
    of templates there might be the problem that the interesting
    functions cannot be instrumented, because of this limitation.

3. no weaving in macro generated code
    If a function is generated by a macro ac++ is not able to perform
    the code transformation.

4. very long compile time
    This might be no problem in your case.

5. VC++ 6 is unable to parse the ac++ output
    The Visual C++ compiler does not conform to the C++ standard very
    well (VC++ 7 is much better). Thus, in some case VC++ 6 doesn't
    compile the generated code. In your case with simple execution
    advice it should work, I think.

If you want to experiment with ac++ start to compile your code without 
writing any aspects. This shows if there are any parse problems. When 
you write aspects, don't start with a pointcut expression that matches 
all functions of your system. You might run into problem 2 or 3. If you 
can weave your aspect (no problem 6) you can extend the pointcut step by 
step.

Please note, it is a little bit complicated to use the Visual Studio 
Add-In for AspectC++ from www.pure-systems.com with VC++ 6. You should 
contact them if you want to do this in advance.

Please keep me informed,

Olaf Spinczyk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3142 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://www.aspectc.org/pipermail/aspectc-user/attachments/20040209/5b310e7a/attachment.bin>


More information about the aspectc-user mailing list