mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 06:16:40 +02:00
Added "/debug buffer" command to see raw buffer content
This commit is contained in:
@@ -92,12 +92,13 @@ Nickname: Empf
|
||||
Datei: zu versendende (lokal vorliegende) Datei
|
||||
|
||||
</programlisting>
|
||||
<command>debug dump | windows</command>
|
||||
<command>debug dump | buffer | windows</command>
|
||||
<programlisting>
|
||||
Debugging-Nachricht ausgeben
|
||||
|
||||
dump: Speicherabbild im WeeChat-Logfile ablegen (wie nach einem Programmabsturz)
|
||||
windows: zeigt Fensterdaten an
|
||||
dump: save memory dump in WeeChat log file (same dump is written when WeeChat crashes)
|
||||
buffer: dump buffer content with hexadecimal values in log file
|
||||
windows: display windows tree
|
||||
|
||||
</programlisting>
|
||||
<command>help [Befehl]</command>
|
||||
|
||||
@@ -92,11 +92,12 @@ nickname: nickname to send file or chat
|
||||
file: filename (on local host)
|
||||
|
||||
</programlisting>
|
||||
<command>debug dump | windows</command>
|
||||
<command>debug dump | buffer | windows</command>
|
||||
<programlisting>
|
||||
print debug messages
|
||||
|
||||
dump: save memory dump in WeeChat log file (same dump is written when WeeChat crashes)
|
||||
buffer: dump buffer content with hexadecimal values in log file
|
||||
windows: display windows tree
|
||||
|
||||
</programlisting>
|
||||
|
||||
@@ -92,11 +92,12 @@ d
|
||||
fichier: nom du fichier (sur la machine locale)
|
||||
|
||||
</programlisting>
|
||||
<command>debug dump | windows</command>
|
||||
<command>debug dump | buffer | windows</command>
|
||||
<programlisting>
|
||||
affiche des messages de debogage
|
||||
|
||||
dump: affiche les variables mémoire WeeChat dans le fichier log (les mêmes messages sont affichés lorsque WeeChat plante)
|
||||
buffer: affiche le contenu du tampon en valeurs hexadécimales dans le fichier log
|
||||
windows: affiche l'arbre des fenêtres
|
||||
|
||||
</programlisting>
|
||||
|
||||
+244
-243
File diff suppressed because it is too large
Load Diff
+10
-2
@@ -119,10 +119,11 @@ t_weechat_command weechat_commands[] =
|
||||
" file: filename (on local host)"),
|
||||
"chat|send|close %n %f", 1, MAX_ARGS, 0, NULL, weechat_cmd_dcc },
|
||||
{ "debug", N_("print debug messages"),
|
||||
N_("dump | windows"),
|
||||
N_("dump | buffer | windows"),
|
||||
N_(" dump: save memory dump in WeeChat log file (same dump is written when WeeChat crashes)\n"
|
||||
" buffer: dump buffer content with hexadecimal values in log file\n"
|
||||
"windows: display windows tree"),
|
||||
"dump|windows", 1, 1, 0, weechat_cmd_debug, NULL },
|
||||
"dump|buffer|windows", 1, 1, 0, weechat_cmd_debug, NULL },
|
||||
{ "help", N_("display help about commands"),
|
||||
N_("[command]"),
|
||||
N_("command: name of a WeeChat or IRC command"),
|
||||
@@ -1899,12 +1900,15 @@ int
|
||||
weechat_cmd_debug (t_irc_server *server, t_irc_channel *channel,
|
||||
int argc, char **argv)
|
||||
{
|
||||
t_gui_buffer *buffer;
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) server;
|
||||
(void) channel;
|
||||
|
||||
gui_buffer_find_context (server, channel, NULL, &buffer);
|
||||
|
||||
if (argc != 1)
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_ERROR);
|
||||
@@ -1918,6 +1922,10 @@ weechat_cmd_debug (t_irc_server *server, t_irc_channel *channel,
|
||||
{
|
||||
weechat_dump (0);
|
||||
}
|
||||
else if (ascii_strcasecmp (argv[0], "buffer") == 0)
|
||||
{
|
||||
gui_buffer_dump_hexa (buffer);
|
||||
}
|
||||
else if (ascii_strcasecmp (argv[0], "windows") == 0)
|
||||
{
|
||||
gui_printf_nolog (NULL, "\n");
|
||||
|
||||
@@ -1409,6 +1409,68 @@ gui_buffer_scroll (t_gui_window *window, char *scroll)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_dump_hexa: dump content of buffer as hexa data in log file
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_dump_hexa (t_gui_buffer *buffer)
|
||||
{
|
||||
t_gui_line *ptr_line;
|
||||
int num_line, data_pos;
|
||||
char *data_without_colors;
|
||||
char hexa[(16 * 3) + 1], ascii[(16 * 2) + 1];
|
||||
int hexa_pos, ascii_pos;
|
||||
|
||||
weechat_log_printf ("[buffer dump hexa (addr:0x%X)]\n", buffer);
|
||||
num_line = 1;
|
||||
for (ptr_line = buffer->lines; ptr_line; ptr_line = ptr_line->next_line)
|
||||
{
|
||||
/* display line without colors */
|
||||
data_without_colors = (ptr_line->data) ?
|
||||
(char *)gui_color_decode ((unsigned char *)ptr_line->data, 0, 0) : NULL;
|
||||
weechat_log_printf ("\n");
|
||||
weechat_log_printf (" line %d: %s\n",
|
||||
num_line,
|
||||
(data_without_colors) ? data_without_colors : "(null)");
|
||||
if (data_without_colors)
|
||||
free (data_without_colors);
|
||||
|
||||
/* display raw data for line */
|
||||
if (ptr_line->data)
|
||||
{
|
||||
weechat_log_printf ("\n");
|
||||
weechat_log_printf (" raw data for line %d (with color codes):\n",
|
||||
num_line);
|
||||
data_pos = 0;
|
||||
hexa_pos = 0;
|
||||
ascii_pos = 0;
|
||||
while (ptr_line->data[data_pos])
|
||||
{
|
||||
snprintf (hexa + hexa_pos, 4, "%02X ",
|
||||
(unsigned char)(ptr_line->data[data_pos]));
|
||||
hexa_pos += 3;
|
||||
snprintf (ascii + ascii_pos, 3, "%c ",
|
||||
((((unsigned char)ptr_line->data[data_pos]) < 32)
|
||||
|| (((unsigned char)ptr_line->data[data_pos]) > 127)) ?
|
||||
'.' : (unsigned char)(ptr_line->data[data_pos]));
|
||||
ascii_pos += 2;
|
||||
if (ascii_pos == 32)
|
||||
{
|
||||
weechat_log_printf (" %-48s %s\n", hexa, ascii);
|
||||
hexa_pos = 0;
|
||||
ascii_pos = 0;
|
||||
}
|
||||
data_pos++;
|
||||
}
|
||||
if (ascii_pos > 0)
|
||||
weechat_log_printf (" %-48s %s\n", hexa, ascii);
|
||||
}
|
||||
|
||||
num_line++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_print_log: print buffer infos in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
@@ -109,6 +109,7 @@ extern void gui_buffer_search_restart (t_gui_window *);
|
||||
extern void gui_buffer_search_stop (t_gui_window *);
|
||||
extern int gui_buffer_search_text (t_gui_window *);
|
||||
extern void gui_buffer_scroll (t_gui_window *, char *);
|
||||
extern void gui_buffer_dump_hexa (t_gui_buffer *);
|
||||
extern void gui_buffer_print_log (t_gui_buffer *);
|
||||
|
||||
/* panel */
|
||||
|
||||
Reference in New Issue
Block a user