<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hy Olaf, <BR>
 <BR>
Thank u for your response ! <BR>
Ok maybe i don't have to change New operator Comportement, but supposed that i need to find a number line and the file name of a method X, how can i do it with Aspect ??<BR>
Because i'm developing a memory debugger and i need this kind of informations ..<BR><BR>
maybe the problem is a litlle bit dificult, but i find the solution without aspect..we have just to modle it with aspect no ?<BR>
 <BR>
i want just change a comportement of new/X/Y.. and add him in a new definition tow news arguments (__LINE__//__FILE__)<BR>
 <BR>
ok i can ask my problem in the ather form:<BR>
 <BR>
If i want detect the number LINE and name FILE of the method main , how can i do ?<BR>
 <BR>
thak u for your time, Heni  <BR>
<BR> <BR>> Date: Wed, 16 Dec 2009 12:00:04 +0100<BR>> From: aspectc-user-request@aspectc.org<BR>> Subject: aspectc-user Digest, Vol 4, Issue 4<BR>> To: aspectc-user@aspectc.org<BR>> <BR>> Send aspectc-user mailing list submissions to<BR>> aspectc-user@aspectc.org<BR>> <BR>> To subscribe or unsubscribe via the World Wide Web, visit<BR>> http://www.aspectc.org/mailman/listinfo/aspectc-user<BR>> or, via email, send a message with subject or body 'help' to<BR>> aspectc-user-request@aspectc.org<BR>> <BR>> You can reach the person managing the list at<BR>> aspectc-user-owner@aspectc.org<BR>> <BR>> When replying, please edit your Subject line so it is more specific<BR>> than "Re: Contents of aspectc-user digest..."<BR>> <BR>> <BR>> Today's Topics:<BR>> <BR>> 1. Re: do an aspect for detect line/file of an execution of new<BR>> operator ?? (Olaf Spinczyk)<BR>> 2. Help about detcting new operator and the line and fle name<BR>> where it is executed ? (Heni Dhiab)<BR>> <BR>> <BR>> ----------------------------------------------------------------------<BR>> <BR>> Message: 1<BR>> Date: Tue, 15 Dec 2009 15:38:39 +0100<BR>> From: Olaf Spinczyk <os@aspectc.org><BR>> Subject: Re: [aspectc-user] do an aspect for detect line/file of an<BR>> execution of new operator ??<BR>> To: aspectc-user@aspectc.org<BR>> Message-ID: <4B279F6F.6040905@aspectc.org><BR>> Content-Type: text/plain; charset=windows-1256; format=flowed<BR>> <BR>> Dear Heni,<BR>> <BR>> redefining the meaning of the token 'new' is rather dangerous. The C <BR>> prepropressor is very simple and replaces 'new' wherever it appears. <BR>> Also note that the code, which is transformed by a++, will once again be <BR>> preprocessed by the C++ compiler.<BR>> <BR>> The root of the problem ist that call-advice for the new operator is not <BR>> supported by ac++, yet. If you could use cal- advice, the joinpoint-API <BR>> w
ould allow you to access the filename and line number easily in your <BR>> advice code. This would be the best solution.<BR>> <BR>> If you can't wait until this feature is implemented, I would recommend a <BR>> workaround like this: Implement a kind of tracing aspect for the <BR>> execution of all functions. Use a global 'function_name' variable and a <BR>> global 'new_count' variable. Whenever a function is being executed <BR>> (before-execution-advice) set the 'function_name' to <BR>> JoinPoint::signature() and 'new_count' to 0. Additionally, define advice <BR>> for the execution of the new operator. There you can use the current <BR>> 'function_name' and 'new_count' as context information. Also increment <BR>> 'new_count'. If your program is multi-threaded make sure the two globals <BR>> are allocated in thread-local storage. With this workaround you don't <BR>> get the file and line, but with the function name and the invocation <BR>> counter you should normally be able to identify the right new-call.<BR>> <BR>> So much about my two cents,<BR>> <BR>> Olaf<BR>> <BR>> Heni Dhiab wrote:<BR>> ><BR>> > I'm developing a debugger for C++ dynamicly memory allocated with <BR>> > aspectC++. So i have to detect each execution of NEW and NEW [] <BR>> > opertors. For this, i did the 'NewDetectionAspect' aspect.<BR>> ><BR>> > <BR>> ><BR>> > The aspect working well, but i want to change the comportment of New <BR>> > operator for return two arguments, the first is the line where New/New <BR>> > [] operator was executed, and the second is the file where it is executed.<BR>> ><BR>> > <BR>> ><BR>> > I did an sample but not with an spectC++ aspect, it is just with a <BR>> > normal C++ class and a header file. it s working well..i can detect <BR>> > each execution line and file of new[]/new operator. The pricipe is <BR>> > like this :<BR>> ><BR>> > <BR>>
 ><BR>> > <BR>> ><BR>> > change New operator Prototype by adding two arguments for line and <BR>> > file in a header file "halloc.h":<BR>> ><BR>> > <BR>> ><BR>> > <BR>> ><BR>> > # include <string.h><BR>> ><BR>> > # include <new><BR>> ><BR>> > <BR>> ><BR>> > <BR>> ><BR>> > void* operator new (size_t size, const char* nom_fich, const <BR>> > unsigned long num_ligne)<BR>> ><BR>> > throw (std::bad_alloc);<BR>> ><BR>> > #define new new (__FILE__, __LINE__)<BR>> ><BR>> > <BR>> ><BR>> > <BR>> ><BR>> > <BR>> ><BR>> > And develop it in hello.cpp:<BR>> ><BR>> > <BR>> ><BR>> > #include "halloc.h"<BR>> ><BR>> > #undef new<BR>> ><BR>> > <BR>> ><BR>> > void* operator new (size_t size, const char* nom, const unsigned long <BR>> > ligne)<BR>> ><BR>> > throw (std::bad_alloc)<BR>> ><BR>> > {<BR>> ><BR>> > void*ptr= new char;<BR>> ><BR>> > <BR>> ><BR>> > printf ("%s:%lu - ",nom, ligne);<BR>> ><BR>> > return ptr;// MallocSecurise (size, nom, ligne);<BR>> ><BR>> > }<BR>> ><BR>> > <BR>> ><BR>> > When I integrate this sample in an aspect, like this <BR>> > ‘NewDetectionAspectLineFile.ah’ :<BR>> ><BR>> > <BR>> ><BR>> > <BR>> ><BR>> > #ifndef FIRSTASPECT<BR>> ><BR>> > #define FIRSTASPECT<BR>> ><BR>> > <BR>> ><BR>> > <BR>> ><BR>> > <BR>> ><BR>> > <BR>> ><BR>> > #include <stdio.h><BR>> ><BR>> > #include <iostream><BR>> ><BR>> > #include <string.h><BR>> ><BR>> > #include <stdlib.h><BR>> ><BR>> > #include <stdarg.h><BR>> ><BR>> > # include <new><BR>> ><BR>> 
> <BR>> ><BR>> > <BR>> ><BR>> > # include <string.h><BR>> ><BR>> > # include <new><BR>> ><BR>> > <BR>> ><BR>> > void* operator new (size_t size, const char* nom_fich, const unsigned <BR>> > long num_ligne)<BR>> ><BR>> > throw (std::bad_alloc);<BR>> ><BR>> > <BR>> ><BR>> > <BR>> ><BR>> > <BR>> ><BR>> > void* operator new (size_t size, const char* nom, const unsigned long <BR>> > ligne)<BR>> ><BR>> > throw (std::bad_alloc)<BR>> ><BR>> > {<BR>> ><BR>> > void*ptr= new char;<BR>> ><BR>> > printf ("%s:%lu - ",nom, ligne);<BR>> ><BR>> > return ptr;// MallocSecurise (size, nom, ligne);<BR>> ><BR>> > }<BR>> ><BR>> > #undef new<BR>> ><BR>> > #define new new (__FILE__, __LINE__)<BR>> ><BR>> > <BR>> ><BR>> > <BR>> ><BR>> > //-----------------------------------------------------------------------------<BR>> ><BR>> > aspect FirstAspect<BR>> ><BR>> > { <BR>> ><BR>> > void * ptr;<BR>> ><BR>> > int d;<BR>> ><BR>> > FILE *F3;<BR>> ><BR>> > <BR>> ><BR>> > public :<BR>> ><BR>> > advice classes("%")://securise la gestion de memoire afin de <BR>> > s'assurer qu'aucune autre gestion n'est en place (eviter les conflits)<BR>> ><BR>> > slice class newdelete<BR>> ><BR>> > {<BR>> ><BR>> > <BR>> ><BR>> > public:<BR>> ><BR>> > <BR>> ><BR>> > //Assure que loperateur new n'a pas ete redefinit sinon le <BR>> > garbage collection ne peu fonctionner<BR>> ><BR>> > void* operator new (size_t size, const char* nom, const unsigned <BR>> > long ligne)<BR>> ><BR>> > throw (std::bad_alloc)<BR>> ><BR>> > {<BR>> ><BR>> > void*ptr= new char;<BR>> &gt
;<BR>> > printf ("%s:%lu - ",nom, ligne);<BR>> ><BR>> > return ptr;// MallocSecurise (size, nom, ligne);<BR>> ><BR>> > }<BR>> ><BR>> > };<BR>> ><BR>> > <BR>> ><BR>> > <BR>> ><BR>> > advice (execution("% ...::operator new(...)") )<BR>> ><BR>> > && !within("Pointer") && !within("Pointers"): after ()<BR>> ><BR>> > { printf ("executing heap operation \"%s\"\n", <BR>> > JoinPoint::signature ());}<BR>> ><BR>> > };<BR>> ><BR>> > #endif //FIRSTASPECT<BR>> ><BR>> > <BR>> ><BR>> > This error is occurred:<BR>> ><BR>> > <BR>> ><BR>> > Error 6 error C2660: 'simple::operator new' : function <BR>> > does not take 1 arguments <BR>> ><BR>> > <BR>> ><BR>> > Some one can help me for resolve this problem, and made an <BR>> > aspect/advice/slice for detect the line and the file for a new operator ??<BR>> ><BR>> > Thank u very much, Heni.<BR>> ><BR>> ><BR>> > ------------------------------------------------------------------------<BR>> > Windows Live: Keep your friends up to date with what you do online. <BR>> > <http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010> <BR>> ><BR>> > ------------------------------------------------------------------------<BR>> ><BR>> > _______________________________________________<BR>> > aspectc-user mailing list<BR>> > aspectc-user@aspectc.org<BR>> > http://www.aspectc.org/mailman/listinfo/aspectc-user<BR>> <BR>> <BR>> <BR>> ------------------------------<BR>> <BR>> Message: 2<BR>> Date: Tue, 15 Dec 2009 21:55:05 +0100<BR>> From: Heni Dhiab <hdhiab@gmail.com><BR>> Subject: [aspectc-user] Help about detcting new operator and the line<BR>> and fle name w
here it is executed ?<BR>> To: aspectc-user@aspectc.org<BR>> Message-ID:<BR>> <f5e1fc4f0912151255y60e0ec00h4106a1102403e7a2@mail.gmail.com><BR>> Content-Type: text/plain; charset="iso-8859-1"<BR>> <BR>> Hello every body ..<BR>> <BR>> I'm developing a debugger for C++ dynamicly memory allocated with aspectC++.<BR>> So i have to detect each execution of NEW and NEW [] opertors. For this, i<BR>> did the 'NewDetectionAspect' aspect.<BR>> The aspect working well, but i want to change the comportment of New<BR>> operator for return two arguments, the first is the line where New/New []<BR>> operator was executed, and the second is the file where it is executed.<BR>> <BR>> I did an sample but without an aspect, it's just with basic C++ lass and a<BR>> header, some one can help me for integrate this changement in an aspect ??<BR>> <BR>> <BR>> change New operator Prototype by adding two arguments for line and file in<BR>> a header file *"halloc.h": *<BR>> <BR>> # include <string.h><BR>> <BR>> # include <new><BR>> <BR>> <BR>> <BR>> void* operator new (size_t size, const char* nom_fich, const unsigned<BR>> long num_ligne)<BR>> <BR>> throw (std::bad_alloc);<BR>> <BR>> #define new new (__FILE__, __LINE__)<BR>> <BR>> And develop it in *hello.cpp:*<BR>> <BR>> #include "halloc.h"<BR>> <BR>> #undef new<BR>> <BR>> void* operator new (size_t size, const char* nom, const unsigned longligne)<BR>> <BR>> throw (std::bad_alloc)<BR>> <BR>> {<BR>> <BR>> void*ptr= new char;<BR>> <BR>> printf ("%s:%lu - ",nom, ligne);<BR>> <BR>> return ptr;// MallocSecurise (size, nom, ligne);<BR>> <BR>> }<BR>> <BR>> Some one can help me for resolve this problem, and made an<BR>> aspect/advice/slice for detect the line and the file for a new operator ??<BR>> <BR>> Thank u very much, Heni.<BR>> -------------- next part --------------<BR>> An HTML attachment was sc
rubbed...<BR>> URL: http://p15111082.pureserver.info/pipermail/aspectc-user/attachments/20091215/5ab0c44d/attachment-0001.html<BR>> <BR>> ------------------------------<BR>> <BR>> _______________________________________________<BR>> aspectc-user mailing list<BR>> aspectc-user@aspectc.org<BR>> http://www.aspectc.org/mailman/listinfo/aspectc-user<BR>> <BR>> <BR>> End of aspectc-user Digest, Vol 4, Issue 4<BR>> ******************************************<BR>                                      <br /><hr />Windows Live Hotmail:  <a href='http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009' target='_new'>Your friends can get your Facebook updates, right from Hotmail®.</a></body>
</html>