core-lightning/lightningd/debug.c
Rusty Russell edc30b12ea lightningd: --dev-debugger=<subdaemon>
Or for blackbox tests --gdb1=<subdaemon> / --gdb2=<subdaemon>.

This makes the subdaemon wait as soon as it's execed, so we can attach
the debugger.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-24 16:22:56 +10:30

22 lines
428 B
C

#include <ccan/str/str.h>
#include <lightningd/debug.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
void subdaemon_debug(int argc, char *argv[])
{
int i;
bool printed = false;
/* From debugger, tell gdb "return". */
for (i = 1; i < argc; i++) {
while (streq(argv[i], "--debugger")) {
if (!printed)
fprintf(stderr, "gdb -ex 'attach %u' %s\n",
getpid(), argv[0]);
printed = true;
}
}
}