summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-find.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2018-05-04 08:21:43 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2018-05-04 08:21:43 +0000
commitec5654b6197c25438f6d2d94a70b9956c3d83c7f (patch)
treecae4f7ea43ef8d9e93fe0171946f2780f405b83e /usr.bin/tmux/cmd-find.c
parent2d49bbb16b3a48bdd9e442875b2b917a97f0ee82 (diff)
Improve logging of sessions.
Diffstat (limited to 'usr.bin/tmux/cmd-find.c')
-rw-r--r--usr.bin/tmux/cmd-find.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c
index fe90a822adf..c93f8e46f62 100644
--- a/usr.bin/tmux/cmd-find.c
+++ b/usr.bin/tmux/cmd-find.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-find.c,v 1.62 2018/05/03 16:56:59 nicm Exp $ */
+/* $OpenBSD: cmd-find.c,v 1.63 2018/05/04 08:21:42 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -83,6 +83,7 @@ cmd_find_try_TMUX(struct client *c)
char tmp[256];
long long pid;
u_int session;
+ struct session *s;
envent = environ_find(c->environ, "TMUX");
if (envent == NULL)
@@ -92,8 +93,13 @@ cmd_find_try_TMUX(struct client *c)
return (NULL);
if (pid != getpid())
return (NULL);
- log_debug("client %p TMUX %s (session @%u)", c, envent->value, session);
- return (session_find_by_id(session));
+ log_debug("%s: client %p TMUX %s (session $%u)", __func__, c,
+ envent->value, session);
+
+ s = session_find_by_id(session);
+ if (s != NULL)
+ log_debug("%s: session $%u still exists", __func__, s->id);
+ return (s);
}
/* Find pane containing client if any. */
@@ -109,6 +115,8 @@ cmd_find_inside_pane(struct client *c)
if (strcmp(wp->tty, c->ttyname) == 0)
break;
}
+ if (wp != NULL)
+ log_debug("%s: got pane %%%u (%s)", __func__, wp->id, wp->tty);
return (wp);
}
@@ -167,6 +175,8 @@ cmd_find_best_session(struct session **slist, u_int ssize, int flags)
struct session *s_loop, *s;
u_int i;
+ log_debug("%s: %u sessions to try", __func__, ssize);
+
s = NULL;
if (slist != NULL) {
for (i = 0; i < ssize; i++) {
@@ -190,6 +200,8 @@ cmd_find_best_session_with_window(struct cmd_find_state *fs)
u_int ssize;
struct session *s;
+ log_debug("%s: window is @%u", __func__, fs->w->id);
+
ssize = 0;
RB_FOREACH(s, sessions, &sessions) {
if (!session_has(s, fs->w))
@@ -219,6 +231,8 @@ cmd_find_best_winlink_with_window(struct cmd_find_state *fs)
{
struct winlink *wl, *wl_loop;
+ log_debug("%s: window is @%u", __func__, fs->w->id);
+
wl = NULL;
if (fs->s->curw != NULL && fs->s->curw->window == fs->w)
wl = fs->s->curw;
@@ -706,7 +720,7 @@ void
cmd_find_log_state(const char *prefix, struct cmd_find_state *fs)
{
if (fs->s != NULL)
- log_debug("%s: s=$%u", prefix, fs->s->id);
+ log_debug("%s: s=$%u %s", prefix, fs->s->id, fs->s->name);
else
log_debug("%s: s=none", prefix);
if (fs->wl != NULL) {
@@ -895,6 +909,9 @@ cmd_find_from_client(struct cmd_find_state *fs, struct client *c, int flags)
break;
}
if (wl != NULL) {
+ log_debug("%s: session $%u has pane %%%u", __func__,
+ s->id, wp->id);
+
fs->s = s;
fs->wl = s->curw; /* use current session */
fs->w = fs->wl->window;