diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-02-28 22:14:45 +0100 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-03-01 21:01:25 +0100 |
commit | aea03ad6e8198a91578f550cb0c835020e673031 (patch) | |
tree | 3001ba2843d2eb31973f0bccddee51595fb565a0 /vtysh | |
parent | lib: add atomic bitwise OR, AND (diff) | |
download | frr-aea03ad6e8198a91578f550cb0c835020e673031.tar.xz frr-aea03ad6e8198a91578f550cb0c835020e673031.zip |
lib: add mt-safe debugging facilities
The current strategy for fine-grained debugging across FRR is to use
static long int bitfields, in combination with helper macros that are
copy-pasted between daemons, to hold state on what debugging information
should be collected at any given time. This has a couple of problems:
* These bitfields are generally extern'd and accessed everywhere, so
they are not MT-safe or easy to make MT-safe
* Lots of code duplication from copy-pasting the DEBUG_* macros...
* Code duplication because of the "term" vs "conf" debugging concept
This patch aims to remedy that by providing some infrastructure to work
with debugs. The core concept of using bitfields has been retained, but
the number of these for each debug has been reduced to 1. This allows
easy use of lock-free methods for synchronizing access to debugging
info.
The helper macros have also been retained but they are now collected in
one place and perform exclusively atomic operations.
Finally there is a bit of code that allows daemons to register
callbacks, which I used to implement a command that will toggle all
debugging for any daemons that use these facilities.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'vtysh')
-rw-r--r-- | vtysh/vtysh.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 871922628..23df78f23 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1971,14 +1971,24 @@ static int show_per_daemon(const char *line, const char *headline) return ret; } +DEFUNSH_HIDDEN (0x00, + vtysh_debug_all, + vtysh_debug_all_cmd, + "[no] debug all", + NO_STR + DEBUG_STR + "Toggle all debugs on or off\n") +{ + return CMD_SUCCESS; +} + DEFUN (vtysh_show_debugging, vtysh_show_debugging_cmd, "show debugging", SHOW_STR DEBUG_STR) { - return show_per_daemon("do show debugging\n", - ""); + return show_per_daemon("do show debugging\n", ""); } DEFUN (vtysh_show_debugging_hashtable, @@ -3368,14 +3378,17 @@ void vtysh_init_vty(void) install_element(ENABLE_NODE, &vtysh_start_zsh_cmd); #endif + /* debugging */ install_element(VIEW_NODE, &vtysh_show_debugging_cmd); install_element(VIEW_NODE, &vtysh_show_debugging_hashtable_cmd); + install_element(VIEW_NODE, &vtysh_debug_all_cmd); + install_element(CONFIG_NODE, &vtysh_debug_all_cmd); + + /* misc lib show commands */ install_element(VIEW_NODE, &vtysh_show_memory_cmd); install_element(VIEW_NODE, &vtysh_show_modules_cmd); - install_element(VIEW_NODE, &vtysh_show_work_queues_cmd); install_element(VIEW_NODE, &vtysh_show_work_queues_daemon_cmd); - install_element(VIEW_NODE, &vtysh_show_thread_cmd); /* Logging */ |