MCPcopy Create free account
hub / github.com/ElementsProject/lightning / add_memdump

Function add_memdump

lightningd/memdump.c:31–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31static size_t add_memdump(struct json_stream *response,
32 const char *fieldname, const tal_t *root,
33 struct command *cmd)
34{
35 size_t cumulative_size = 0;
36
37 json_array_start(response, fieldname);
38 for (const tal_t *i = tal_first(root); i; i = tal_next(i)) {
39 const char *name = tal_name(i);
40 size_t size = tal_bytelen(i);
41
42 /* Don't try to dump this command! */
43 if (i == cmd || i == cmd->jcon)
44 continue;
45
46 /* Don't dump logs, we know they grow. */
47 if (name && streq(name, "struct log_book"))
48 continue;
49
50 json_object_start(response, NULL);
51 json_add_ptr(response, "parent", tal_parent(i));
52 json_add_ptr(response, "value", i);
53 json_add_u64(response, "size", size);
54 if (name)
55 json_add_string(response, "label", name);
56
57 if (tal_first(i))
58 size += add_memdump(response, "children", i, cmd);
59 json_add_u64(response, "cumulative_size", size);
60 json_object_end(response);
61 cumulative_size += size;
62 }
63 json_array_end(response);
64 return cumulative_size;
65}
66
67static struct command_result *json_memdump(struct command *cmd,
68 const char *buffer,

Callers 1

json_memdumpFunction · 0.85

Calls 12

tal_firstFunction · 0.85
tal_nextFunction · 0.85
tal_nameFunction · 0.85
tal_bytelenFunction · 0.85
json_add_ptrFunction · 0.85
tal_parentFunction · 0.85
json_array_startFunction · 0.50
json_object_startFunction · 0.50
json_add_u64Function · 0.50
json_add_stringFunction · 0.50
json_object_endFunction · 0.50
json_array_endFunction · 0.50

Tested by

no test coverage detected