Hi, On Sun, Apr 26 2020, 易会战 via Gcc wrote: > I am working a instrumentation tool based on gcc. I insert some > intrumentation code into each function, including destructor > functions. A finalize function will free memory resources after all > work done. But I cannot find proper loacation calling my finalizing > function since the destructor functions will called finally after the > program exit.
IIUC you need to execute your "finalize function" from a "static destructor" - nothing to do with C++ destructors, these are just functions executed before the program exits. Look for places in the code which call cgraph_build_static_cdtor with 'D' as the first parameter. Good luck, Martin