summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2016-10-18 08:46:44 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2016-10-18 08:46:44 +0000
commite14d2f533608140329a8c502a1378c59edf0396f (patch)
treee59636821b9ef11abfd130d794d215786d49a267 /usr.bin
parentbf606e345ea5c42317d748407876697d1d2d981e (diff)
Give each item on queue a name for better logging.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-queue.c20
-rw-r--r--usr.bin/tmux/tmux.h6
2 files changed, 20 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c
index 6db90945bb8..d0db1942a25 100644
--- a/usr.bin/tmux/cmd-queue.c
+++ b/usr.bin/tmux/cmd-queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-queue.c,v 1.45 2016/10/16 19:36:37 nicm Exp $ */
+/* $OpenBSD: cmd-queue.c,v 1.46 2016/10/18 08:46:43 nicm Exp $ */
/*
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -112,6 +112,8 @@ cmdq_remove(struct cmdq_item *item)
cmd_list_free(item->cmdlist);
TAILQ_REMOVE(item->queue, item, entry);
+
+ free((void *)item->name);
free(item);
}
@@ -147,10 +149,15 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
struct cmdq_item *item, *first = NULL, *last = NULL;
struct cmd *cmd;
u_int group = cmdq_next_group();
+ char *tmp;
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
+ xasprintf(&tmp, "command[%s]", cmd->entry->name);
+
item = xcalloc(1, sizeof *item);
+ item->name = tmp;
item->type = CMDQ_COMMAND;
+
item->group = group;
item->flags = flags;
@@ -220,12 +227,17 @@ out:
/* Get a callback for the command queue. */
struct cmdq_item *
-cmdq_get_callback(cmdq_cb cb, void *data)
+cmdq_get_callback1(const char *name, cmdq_cb cb, void *data)
{
struct cmdq_item *item;
+ char *tmp;
+
+ xasprintf(&tmp, "callback[%s]", name);
item = xcalloc(1, sizeof *item);
+ item->name = tmp;
item->type = CMDQ_CALLBACK;
+
item->group = 0;
item->flags = 0;
@@ -289,8 +301,8 @@ cmdq_next(struct client *c)
item = TAILQ_FIRST(queue);
if (item == NULL)
break;
- log_debug("%s %s: type %d, flags %x", __func__, name,
- item->type, item->flags);
+ log_debug("%s %s: %s (%d), flags %x", __func__, name,
+ item->name, item->type, item->flags);
/*
* Any item with the waiting flag set waits until an external
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index d153881036a..3ce34e8fe49 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.672 2016/10/16 22:18:04 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.673 2016/10/18 08:46:43 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1239,6 +1239,7 @@ enum cmdq_type {
/* Command queue item. */
typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *);
struct cmdq_item {
+ const char *name;
struct cmdq_list *queue;
struct cmdq_item *next;
@@ -1779,7 +1780,8 @@ char *cmd_list_print(struct cmd_list *);
/* cmd-queue.c */
struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmd_find_state *,
struct mouse_event *, int);
-struct cmdq_item *cmdq_get_callback(cmdq_cb, void *);
+#define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data)
+struct cmdq_item *cmdq_get_callback1(const char *, cmdq_cb, void *);
void cmdq_insert_after(struct cmdq_item *, struct cmdq_item *);
void cmdq_append(struct client *, struct cmdq_item *);
void printflike(3, 4) cmdq_format(struct cmdq_item *, const char *,