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

Function add_memdump

lightningd/memdump.c:34–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

json_memdumpFunction · 0.85

Calls 12

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

Tested by

no test coverage detected