Attach valgrind with daemon and collect logs for each daemon call
I have a client server system written entirely in C ++. the server works as /etc/init.d/serverd
with the start / stop parameters. Client.exe
runs any command like client.exe --options
. The daemon is removed with each client call. I want to attach valgrind
using /etc/init.d/serverd
for leak detection. I tried below options but couldn't.
/usr/local/bin/valgrind --log-file=valgrind_1.log -v --trace-children=yes --leak-check=full --tool=memcheck --vgdb=yes --vgdb-error=0 /etc/init.d/ serverd start
Every time he doesn't connect to the daemon.
We want to attach valgrind
using the daemon at startup [ the exact point is , I will stop daemon , attach valgrind with it and then start it again ]
so that every time it is executed client.exe --options
, logs must be generated for the daemon in--log-file=valgrind_1.log
Does anyone have an idea on how to do the same?
source to share
It seems impossible to attach valgrind to an existing process: http://valgrind.org/docs/manual/faq.html#faq.attach
It seems to me that your best bet is to kill the daemon process and run the executable itself in valgrind.
source to share
For a system managed daemon, you can change ExecStart=
to run valgrind like this:
ExecStart = {valgrind-command-with-flags} / usr / sbin / foo-daemon
Make sure to redirect the output to a well-defined location.
Caveat : The valgrind daemon can be very slow and potentially not work as expected
source to share