0

There is a c++ program running as daemon on linux in production environment. It keeps on restarting after some unpredictable time. Since it is in production environment it has no debug info. It does not log errors in any file. There is no liberty to attach gdb to the running process as it may affect production. But the fix is to be provided.

How to collect info or dump in such a case? How to debug such a scenario?

RKum
  • 758
  • 2
  • 12
  • 33

1 Answers1

1

How to debug such a scenario?

Enable core dump saving on production environment. See how to do it on linux: How to enable core dump in my Linux C++ program.

Copy core dump on development environment and debug it with debug info loaded in gdb.

ks1322
  • 33,961
  • 14
  • 109
  • 164
  • Dumps will be created when an application crashes. But here the daemon is restarting. Does restarting means it might have had crashed? – RKum Jan 25 '18 at 15:17
  • Yes, daemon can be configured to restart after crash with systemd or [daemontools](http://cr.yp.to/daemontools.html). I don't know any other reason why daemon would want to restart itself. – ks1322 Jan 25 '18 at 15:32
  • @ks1322 "I don't know any other reason why daemon would want to restart itself." -- it could be that there is some other program that periodically `kill`s it. Or does `service stop`, or ... any number of other reasons. – Employed Russian Jan 26 '18 at 03:14