From 8fdde3c22ff981f0c41b78d3640e3249873e8495 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Fri, 17 May 2019 10:46:40 -0400 Subject: Add a debug-CLI leak-checker leak-check { } Hint: "set term history off" or you'll have to sort through a bunch of bogus leaks related to the debug cli history mechanism. Cleaned up a set of reported leaks in the "show interface" command. At some point, we thought about making a per-thread vlib_mains vector, but we never did that. Several interface-related CLI's maintained local static cache vectors. Not a bad idea, but not useful as things shook out. Removed the static vectors. Change-Id: I756bf2721a0d91993ecfded34c79da406f30a548 Signed-off-by: Dave Barach --- src/vlib/cli.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/vlib') diff --git a/src/vlib/cli.c b/src/vlib/cli.c index 835cb87d13d..6d83e2a3ce3 100644 --- a/src/vlib/cli.c +++ b/src/vlib/cli.c @@ -552,6 +552,31 @@ vlib_cli_dispatch_sub_commands (vlib_main_t * vm, parent_command_index); unformat_free (&sub_input); } + else if (unformat (input, "leak-check %U", + unformat_vlib_cli_sub_input, &sub_input)) + { + u8 *leak_report; + clib_mem_trace (1); + error = + vlib_cli_dispatch_sub_commands (vm, cm, &sub_input, + parent_command_index); + unformat_free (&sub_input); + + /* Otherwise, the clib_error_t shows up as a leak... */ + if (error) + { + vlib_cli_output (vm, "%v", error->what); + clib_error_free (error); + error = 0; + } + + (void) clib_mem_trace_enable_disable (0); + leak_report = format (0, "%U", format_mheap, clib_mem_get_heap (), + 1 /* verbose, i.e. print leaks */ ); + clib_mem_trace (0); + vlib_cli_output (vm, "%v", leak_report); + vec_free (leak_report); + } else if (unformat_user (input, unformat_vlib_cli_sub_command, vm, parent, &c)) -- cgit 1.2.3-korg