mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 00:33:13 +02:00
Add option "memory" to command /debug
This commit is contained in:
@@ -61,6 +61,7 @@ CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
|
||||
CHECK_FUNCTION_EXISTS(strpbrk HAVE_STRPBRK)
|
||||
CHECK_FUNCTION_EXISTS(strrchr HAVE_STRRCHR)
|
||||
CHECK_FUNCTION_EXISTS(strstr HAVE_STRSTR)
|
||||
CHECK_FUNCTION_EXISTS(mallinfo HAVE_MALLINFO)
|
||||
|
||||
CHECK_INCLUDE_FILES("regex.h" HAVE_REGEX_H)
|
||||
CHECK_FUNCTION_EXISTS(regexec HAVE_REGEXEC)
|
||||
|
||||
+15
-9
@@ -1125,17 +1125,21 @@ COMMAND_CALLBACK(debug)
|
||||
_("Raw content of buffers has been written in log "
|
||||
"file"));
|
||||
}
|
||||
else if (string_strcasecmp (argv[1], "windows") == 0)
|
||||
else if (string_strcasecmp (argv[1], "color") == 0)
|
||||
{
|
||||
debug_windows_tree ();
|
||||
gui_color_dump (buffer);
|
||||
}
|
||||
else if (string_strcasecmp (argv[1], "memory") == 0)
|
||||
{
|
||||
debug_memory ();
|
||||
}
|
||||
else if (string_strcasecmp (argv[1], "term") == 0)
|
||||
{
|
||||
gui_window_term_display_infos ();
|
||||
}
|
||||
else if (string_strcasecmp (argv[1], "color") == 0)
|
||||
else if (string_strcasecmp (argv[1], "windows") == 0)
|
||||
{
|
||||
gui_color_dump (buffer);
|
||||
debug_windows_tree ();
|
||||
}
|
||||
else if (string_strcasecmp (argv[1], "set") == 0)
|
||||
{
|
||||
@@ -4718,7 +4722,7 @@ command_init ()
|
||||
N_("list"
|
||||
" || set <plugin> <level>"
|
||||
" || dump [<plugin>]"
|
||||
" || buffer|windows|term|color"),
|
||||
" || buffer|color|memory|term|windows"),
|
||||
N_(" list: list plugins with debug levels\n"
|
||||
" set: set debug level for plugin\n"
|
||||
" plugin: name of plugin (\"core\" for WeeChat core)\n"
|
||||
@@ -4727,16 +4731,18 @@ command_init ()
|
||||
"dump is written when WeeChat crashes)\n"
|
||||
" buffer: dump buffer content with hexadecimal values "
|
||||
"in log file\n"
|
||||
"windows: display windows tree\n"
|
||||
" color: display infos about current color pairs\n"
|
||||
" memory: display infos about memory usage\n"
|
||||
" term: display infos about terminal\n"
|
||||
" color: display infos about current color pairs"),
|
||||
"windows: display windows tree"),
|
||||
"list"
|
||||
" || set %(plugins_names)|core"
|
||||
" || dump %(plugins_names)|core"
|
||||
" || buffer"
|
||||
" || windows"
|
||||
" || color"
|
||||
" || memory"
|
||||
" || term"
|
||||
" || color",
|
||||
" || windows",
|
||||
&command_debug, NULL);
|
||||
hook_command (NULL, "filter",
|
||||
N_("filter messages in buffers, to hide/show them according "
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_MALLINFO
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include "weechat.h"
|
||||
#include "wee-backtrace.h"
|
||||
@@ -256,6 +259,37 @@ debug_windows_cb (void *data, const char *signal, const char *type_data,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* debug_memory: display information about dynamic memory allocation
|
||||
*/
|
||||
|
||||
void
|
||||
debug_memory ()
|
||||
{
|
||||
#ifdef HAVE_MALLINFO
|
||||
struct mallinfo info;
|
||||
|
||||
info = mallinfo ();
|
||||
|
||||
gui_chat_printf (NULL, "");
|
||||
gui_chat_printf (NULL, _("Memory usage (see \"man mallinfo\" for help):"));
|
||||
gui_chat_printf (NULL, " arena :%10d", info.arena);
|
||||
gui_chat_printf (NULL, " ordblks :%10d", info.ordblks);
|
||||
gui_chat_printf (NULL, " smblks :%10d", info.smblks);
|
||||
gui_chat_printf (NULL, " hblks :%10d", info.hblks);
|
||||
gui_chat_printf (NULL, " hblkhd :%10d", info.hblkhd);
|
||||
gui_chat_printf (NULL, " usmblks :%10d", info.usmblks);
|
||||
gui_chat_printf (NULL, " fsmblks :%10d", info.fsmblks);
|
||||
gui_chat_printf (NULL, " uordblks:%10d", info.uordblks);
|
||||
gui_chat_printf (NULL, " fordblks:%10d", info.fordblks);
|
||||
gui_chat_printf (NULL, " keepcost:%10d", info.keepcost);
|
||||
#else
|
||||
gui_chat_printf (NULL,
|
||||
_("Memory usage not available (function \"mallinfo\" not "
|
||||
"found)"));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* debug_init: hook signals for debug
|
||||
*/
|
||||
|
||||
@@ -24,6 +24,7 @@ struct t_gui_window_tree;
|
||||
|
||||
extern void debug_sigsegv ();
|
||||
extern void debug_windows_tree ();
|
||||
extern void debug_memory ();
|
||||
extern void debug_init ();
|
||||
|
||||
#endif /* __WEECHAT_DEBUG_H */
|
||||
|
||||
Reference in New Issue
Block a user