summaryrefslogtreecommitdiff
path: root/src/core/wee-command.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-08-25 13:35:50 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-08-25 13:35:50 +0200
commitff4596e45ca9bff5995f912efb1f49d22823c82f (patch)
tree8f0b81ed60016c5a98a3ce51058a09b588e78976 /src/core/wee-command.c
parentcc2bb4b8cf36c7b454f5219cff5a6113e3a02cd4 (diff)
downloadweechat-ff4596e45ca9bff5995f912efb1f49d22823c82f.zip
core: add option `callbacks` in command `/debug`
Diffstat (limited to 'src/core/wee-command.c')
-rw-r--r--src/core/wee-command.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 09e1b0001..58fc83c9d 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -1988,7 +1988,8 @@ COMMAND_CALLBACK(debug)
struct t_config_option *ptr_option;
struct t_weechat_plugin *ptr_plugin;
struct timeval time_start, time_end;
- char *result;
+ char *result, *str_threshold;
+ long long threshold;
int debug;
/* make C compiler happy */
@@ -2023,6 +2024,28 @@ COMMAND_CALLBACK(debug)
return WEECHAT_RC_OK;
}
+ if (string_strcmp (argv[1], "callbacks") == 0)
+ {
+ COMMAND_MIN_ARGS(3, "callbacks");
+ threshold = util_parse_delay (argv[2], 1);
+ if (threshold > 0)
+ {
+ str_threshold = util_get_microseconds_string (threshold);
+ debug_long_callbacks = threshold;
+ gui_chat_printf (NULL,
+ _("Debug enabled for callbacks (threshold: %s)"),
+ (str_threshold) ? str_threshold : "?");
+ if (str_threshold)
+ free (str_threshold);
+ }
+ else
+ {
+ debug_long_callbacks = 0;
+ gui_chat_printf (NULL, _("Debug disabled for callbacks"));
+ }
+ return WEECHAT_RC_OK;
+ }
+
if (string_strcmp (argv[1], "certs") == 0)
{
gui_chat_printf (NULL,
@@ -8024,6 +8047,7 @@ command_init ()
" || dump|hooks [<plugin>]"
" || buffer|certs|color|dirs|infolists|libs|memory|tags|"
"term|windows"
+ " || callbacks <duration>[<unit>]"
" || mouse|cursor [verbose]"
" || hdata [free]"
" || time <command>"
@@ -8036,7 +8060,16 @@ command_init ()
"written when WeeChat crashes)\n"
" hooks: display infos about hooks (with a plugin: display "
"detailed info about hooks created by the plugin)\n"
- " buffer: dump buffer content with hexadecimal values in log file\n"
+ " buffer: dump buffer content with hexadecimal values in WeeChat "
+ "log file\n"
+ "callbacks: write hook and bar item callbacks that took more than "
+ "\"duration\" in the WeeChat log file (0 = disable), where optional "
+ "unit is one of:\n"
+ " us: microseconds (default)\n"
+ " ms: milliseconds\n"
+ " s: seconds\n"
+ " m: minutes\n"
+ " h: hours\n"
" certs: display number of loaded trusted certificate authorities\n"
" color: display infos about current color pairs\n"
" cursor: toggle debug for cursor mode\n"
@@ -8066,6 +8099,7 @@ command_init ()
" || set %(plugins_names)|" PLUGIN_CORE
" || dump %(plugins_names)|" PLUGIN_CORE
" || buffer"
+ " || callbacks"
" || certs"
" || color"
" || cursor verbose"