2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-02-28 22:14:45 +01:00
|
|
|
/*
|
|
|
|
* Debugging utilities.
|
|
|
|
* Copyright (C) 2018 Cumulus Networks, Inc.
|
|
|
|
* Quentin Young
|
|
|
|
*/
|
|
|
|
#include <zebra.h>
|
2019-05-25 02:09:01 +02:00
|
|
|
#include "typesafe.h"
|
2018-02-28 22:14:45 +01:00
|
|
|
#include "debug.h"
|
|
|
|
#include "command.h"
|
|
|
|
|
2024-03-26 15:54:54 +01:00
|
|
|
static struct debug_list_head debug_head;
|
2019-05-25 02:09:01 +02:00
|
|
|
|
2024-03-26 15:54:54 +01:00
|
|
|
DECLARE_LIST(debug_list, struct debug, item);
|
2018-02-28 22:14:45 +01:00
|
|
|
|
|
|
|
/* All code in this section should be reentrant and MT-safe */
|
|
|
|
|
2024-03-26 15:54:54 +01:00
|
|
|
DEFUN_NOSH (debug_all,
|
|
|
|
debug_all_cmd,
|
|
|
|
"[no] debug all",
|
|
|
|
NO_STR DEBUG_STR
|
|
|
|
"Toggle all debugging output\n")
|
2018-02-28 22:14:45 +01:00
|
|
|
{
|
2024-03-26 15:54:54 +01:00
|
|
|
struct debug *debug;
|
2019-04-12 23:00:05 +02:00
|
|
|
bool set = !strmatch(argv[0]->text, "no");
|
2018-02-28 22:14:45 +01:00
|
|
|
uint32_t mode = DEBUG_NODE2MODE(vty->node);
|
|
|
|
|
2024-03-26 15:54:54 +01:00
|
|
|
frr_each (debug_list, &debug_head, debug) {
|
|
|
|
DEBUG_MODE_SET(debug, mode, set);
|
|
|
|
|
|
|
|
/* If all modes have been turned off, don't preserve options. */
|
|
|
|
if (!DEBUG_MODE_CHECK(debug, DEBUG_MODE_ALL))
|
|
|
|
DEBUG_CLEAR(debug);
|
|
|
|
}
|
2019-05-25 02:09:01 +02:00
|
|
|
|
2018-02-28 22:14:45 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2024-03-26 15:54:54 +01:00
|
|
|
void debug_install(struct debug *debug)
|
2018-02-28 22:14:45 +01:00
|
|
|
{
|
2024-03-26 15:54:54 +01:00
|
|
|
debug_list_add_tail(&debug_head, debug);
|
2019-05-25 02:15:31 +02:00
|
|
|
}
|
2019-05-25 02:09:01 +02:00
|
|
|
|
2024-03-26 15:54:54 +01:00
|
|
|
void debug_init(void)
|
2019-05-25 02:15:31 +02:00
|
|
|
{
|
2024-03-26 15:54:54 +01:00
|
|
|
debug_list_init(&debug_head);
|
|
|
|
|
2018-02-28 22:14:45 +01:00
|
|
|
install_element(ENABLE_NODE, &debug_all_cmd);
|
|
|
|
install_element(CONFIG_NODE, &debug_all_cmd);
|
|
|
|
}
|