mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 14:54:26 +01:00
memleak: add backtrace to allocations.
We use the tal notifiers to attach a `backtrace` object on every allocation. This also means moving backtrace_state from log.c into lightningd.c, so we can hand it to memleak_init(). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
c956d9f5eb
commit
dfc132b2fe
@@ -3,6 +3,7 @@
|
||||
#include "lightningd.h"
|
||||
#include "peer_control.h"
|
||||
#include "subd.h"
|
||||
#include <backtrace.h>
|
||||
#include <ccan/array_size/array_size.h>
|
||||
#include <ccan/cast/cast.h>
|
||||
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
|
||||
@@ -33,6 +34,12 @@
|
||||
|
||||
char *bitcoin_datadir;
|
||||
|
||||
#if DEVELOPER
|
||||
bool dev_no_backtrace;
|
||||
#endif
|
||||
|
||||
struct backtrace_state *backtrace_state;
|
||||
|
||||
void db_resolve_invoice(struct lightningd *ld,
|
||||
const char *label);
|
||||
void db_resolve_invoice(struct lightningd *ld,
|
||||
@@ -71,7 +78,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx,
|
||||
ld->dev_disconnect_fd = -1;
|
||||
ld->dev_hsm_seed = NULL;
|
||||
ld->dev_subdaemon_fail = false;
|
||||
memleak_init(ld);
|
||||
memleak_init(ld, backtrace_state);
|
||||
#endif
|
||||
|
||||
list_head_init(&ld->peers);
|
||||
@@ -237,6 +244,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
err_set_progname(argv[0]);
|
||||
|
||||
#if DEVELOPER
|
||||
if (!dev_no_backtrace)
|
||||
#endif
|
||||
backtrace_state = backtrace_create_state(argv[0], 0, NULL, NULL);
|
||||
|
||||
/* Things log on shutdown, so we need this to outlive lightningd */
|
||||
log_book = new_log_book(NULL, 20*1024*1024, LOG_INFORM);
|
||||
ld = new_lightningd(NULL, log_book);
|
||||
|
||||
Reference in New Issue
Block a user