[aspectc-user] Help about detcting new operator and the line and fle name where it is executed ?

Heni Dhiab hdhiab at gmail.com
Tue Dec 15 21:55:05 CET 2009

Hello every body ..

I'm developing a debugger for C++ dynamicly memory allocated with aspectC++.
So i have to detect each execution of NEW and NEW [] opertors. For this, i
did the 'NewDetectionAspect' aspect.
The aspect working well, but i want to change the comportment of New
operator for return two arguments, the first is the line where New/New []
operator was executed, and the second is the file where it is executed.

I did an sample but without an aspect, it's just with basic C++ lass and a
header, some one can help me for integrate this changement in an aspect ??

change New operator Prototype  by adding two arguments for line and file in
a header file *"halloc.h": *

#  include <string.h>

#    include <new>

      void* operator new (size_t size, const char* nom_fich, const unsigned
long num_ligne)

       throw (std::bad_alloc);

       #define new new (__FILE__, __LINE__)

And develop it in *hello.cpp:*

 #include "halloc.h"

#undef new

 void* operator new (size_t size, const char* nom, const unsigned longligne)

  throw (std::bad_alloc)


  void*ptr= new char;

  printf ("%s:%lu - ",nom, ligne);

    return ptr;// MallocSecurise (size, nom, ligne);


Some one can help me for resolve this problem, and made an
aspect/advice/slice for detect the line and the file for a new operator ??

Thank u very much, Heni.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.aspectc.org/pipermail/aspectc-user/attachments/20091215/5ab0c44d/attachment.html>

More information about the aspectc-user mailing list