Browse Source

dev: option not to do backtracing.

It crashes under valgrind, causing a valgrind error: valgrind gives us a
backtrace anyway, so we don't need it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
bc9918ad46
  1. 15
      lightningd/log.c
  2. 4
      lightningd/log.h
  3. 3
      lightningd/options.c
  4. 2
      tests/test_lightningd.py

15
lightningd/log.c

@ -18,6 +18,10 @@
#include <sys/types.h>
#include <unistd.h>
#if DEVELOPER
bool dev_no_backtrace;
#endif
static struct backtrace_state *backtrace_state;
struct log_entry {
@ -432,8 +436,9 @@ static void log_crash(int sig)
if (sig) {
log_broken(crashlog, "FATAL SIGNAL %i RECEIVED", sig);
backtrace_full(backtrace_state, 0, log_backtrace, NULL,
crashlog);
if (backtrace_state)
backtrace_full(backtrace_state, 0, log_backtrace, NULL,
crashlog);
}
if (crashlog->lr->print == log_default_print) {
@ -457,7 +462,8 @@ static void log_crash(int sig)
if (sig) {
fprintf(stderr, "Fatal signal %u. ", sig);
backtrace_print(backtrace_state, 0, stderr);
if (backtrace_state)
backtrace_print(backtrace_state, 0, stderr);
}
if (logfile)
fprintf(stderr, "Log dumped in %s", logfile);
@ -469,6 +475,9 @@ void crashlog_activate(const char *argv0, struct log *log)
struct sigaction sa;
crashlog = log;
#if DEVELOPER
if (!dev_no_backtrace)
#endif
backtrace_state = backtrace_create_state(argv0, 0, NULL, NULL);
sa.sa_handler = log_crash;
sigemptyset(&sa.sa_mask);

4
lightningd/log.h

@ -94,4 +94,8 @@ const tal_t *ltmp;
/* Before the crashlog is activated, just prints to stderr. */
void NORETURN PRINTF_FMT(1,2) fatal(const char *fmt, ...);
#if DEVELOPER
extern bool dev_no_backtrace;
#endif
#endif /* LIGHTNING_LIGHTNINGD_LOG_H */

3
lightningd/options.c

@ -288,6 +288,9 @@ static void dev_register_opts(struct lightningd *ld)
NULL, ld, "File containing disconnection points");
opt_register_arg("--dev-hsm-seed=<seed>", opt_set_hsm_seed,
NULL, ld, "Hex-encoded seed for HSM");
opt_register_noarg("--dev-no-backtrace", opt_set_bool,
&dev_no_backtrace,
"Disable backtrace (crashes under valgrind)");
}
#endif

2
tests/test_lightningd.py

@ -107,6 +107,8 @@ class NodeFactory(object):
daemon.cmd_line.append("--dev-disconnect=dev_disconnect")
if DEVELOPER:
daemon.cmd_line.append("--dev-fail-on-subdaemon-fail")
if VALGRIND:
daemon.cmd_line.append("--dev-no-backtrace")
opts = [] if options is None else options
for opt in opts:
daemon.cmd_line.append(opt)

Loading…
Cancel
Save