c++valgrindcallgrind

attaching callgrind/valgrind to program in mid-way of its execution


I use Valgrind to detect issues by running a program from the beginning. Now I have memory/performance issues in a very specific moment in the program. Unfortunately there is no feasible way to make a shortcut to this place from the start.

Is there a way to instrument the c++ program ( Valgrind/Callgrind ) in its mid-way execution, like attaching to the process?

Already answered here: How use callgrind to profiling only a certain period of program execution?


Solution

  • Thanks all for help. Seems It's been already answered here: How use callgrind to profiling only a certain period of program execution? but not marked as answered for some reason.

    Summary: Starting callgrind with instrumentation off

    valgrind --tool=callgrind --instr-atstart=no <PROG>
    

    Controling instrumentation ( can be executed in other shell )

    callgrind_control -i on/off