mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
lightningd: add code to search strmaps for memleak detection.
Didn't put this in common/memleak because only lightningd currently needs it (as of next patch). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
c506d42679
commit
e5c80f63d7
1
Makefile
1
Makefile
@ -96,6 +96,7 @@ CCAN_OBJS := \
|
||||
ccan-str-base32.o \
|
||||
ccan-str-hex.o \
|
||||
ccan-str.o \
|
||||
ccan-strmap.o \
|
||||
ccan-take.o \
|
||||
ccan-tal-grab_file.o \
|
||||
ccan-tal-link.o \
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "memdump.h"
|
||||
#if DEVELOPER
|
||||
#include <backtrace.h>
|
||||
#include <ccan/strmap/strmap.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
#include <common/daemon.h>
|
||||
#include <common/json_command.h>
|
||||
@ -120,6 +121,22 @@ static void json_add_backtrace(struct json_stream *response,
|
||||
json_array_end(response);
|
||||
}
|
||||
|
||||
static bool handle_strmap(const char *member, void *p, void *memtable_)
|
||||
{
|
||||
struct htable *memtable = memtable_;
|
||||
|
||||
memleak_scan_region(memtable, p, tal_bytelen(p));
|
||||
|
||||
/* Keep going */
|
||||
return true;
|
||||
}
|
||||
|
||||
/* FIXME: If strmap used tal, this wouldn't be necessary! */
|
||||
void memleak_remove_strmap_(struct htable *memtable, const struct strmap *m)
|
||||
{
|
||||
strmap_iterate_(m, handle_strmap, memtable);
|
||||
}
|
||||
|
||||
static void scan_mem(struct command *cmd,
|
||||
struct json_stream *response,
|
||||
struct lightningd *ld,
|
||||
|
@ -5,8 +5,16 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
struct command;
|
||||
struct htable;
|
||||
struct strmap;
|
||||
struct subd;
|
||||
|
||||
void opening_memleak_done(struct command *cmd, struct subd *leaker);
|
||||
void peer_memleak_done(struct command *cmd, struct subd *leaker);
|
||||
|
||||
/* Remove any pointers inside this strmap (which is opaque to memleak). */
|
||||
#define memleak_remove_strmap(memtable, strmap) \
|
||||
memleak_remove_strmap_((memtable), tcon_unwrap(strmap))
|
||||
void memleak_remove_strmap_(struct htable *memtable, const struct strmap *m);
|
||||
|
||||
#endif /* LIGHTNING_LIGHTNINGD_MEMDUMP_H */
|
||||
|
Loading…
Reference in New Issue
Block a user