wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 59bf7023dd327bdce8a20a363d3a1689782e7da1
parent 0e6b2f70256b4364c7aa38ec33c12197fa334cca
Author: Kris Maglione <kris@suckless.org>
Date:   Tue,  3 Nov 2009 20:48:55 -0500

Add 9p debugging.

Diffstat:
cmd/wmii/Makefile | 1+
cmd/wmii/dat.h | 15++++++++-------
cmd/wmii/fns.h | 3+++
cmd/wmii/main.c | 8++++++++
cmd/wmii/message.c | 1+
cmd/wmii/print.c | 124+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 145 insertions(+), 7 deletions(-)

diff --git a/cmd/wmii/Makefile b/cmd/wmii/Makefile @@ -30,6 +30,7 @@ OBJ = area \ map \ message \ mouse \ + print \ root \ rule \ printevent\ diff --git a/cmd/wmii/dat.h b/cmd/wmii/dat.h @@ -99,13 +99,14 @@ enum Protocols { }; enum DebugOpt { - DDnd = 1<<0, - DEvent = 1<<1, - DEwmh = 1<<2, - DFocus = 1<<3, - DGeneric= 1<<4, - DStack = 1<<5, - NDebugOpt = 6, + D9p = 1<<0, + DDnd = 1<<1, + DEvent = 1<<2, + DEwmh = 1<<3, + DFocus = 1<<4, + DGeneric= 1<<5, + DStack = 1<<6, + NDebugOpt = 7, }; /* Data Structures */ diff --git a/cmd/wmii/fns.h b/cmd/wmii/fns.h @@ -250,6 +250,9 @@ bool readmotion(Point*); int readmouse(Point*, uint*); Align snap_rect(const Rectangle *rects, int num, Rectangle *current, Align *mask, int snapw); +/* print.c */ +int Ffmt(Fmt*); + /* printevent.c */ void printevent(XEvent*); diff --git a/cmd/wmii/main.c b/cmd/wmii/main.c @@ -327,6 +327,11 @@ closedisplay(IxpConn *c) { XCloseDisplay(display); } +static void +printfcall(IxpFcall *f) { + Dprint(D9p, "%F\n", f); +} + int main(int argc, char *argv[]) { IxpMsg m; @@ -383,6 +388,9 @@ extern int fmtevent(Fmt*); init_environment(); + fmtinstall('F', Ffmt); + ixp_printfcall = printfcall; + sock = ixp_announce(address); if(sock < 0) fatal("Can't create socket '%s': %r", address); diff --git a/cmd/wmii/message.c b/cmd/wmii/message.c @@ -95,6 +95,7 @@ char *symtab[] = { }; char* debugtab[] = { + "9p", "dnd", "event", "ewmh", diff --git a/cmd/wmii/print.c b/cmd/wmii/print.c @@ -0,0 +1,124 @@ +#include "dat.h" +#include <fmt.h> +#include "fns.h" + +static char* fcnames[] = { + "TVersion", + "RVersion", + "TAuth", + "RAuth", + "TAttach", + "RAttach", + "TError", + "RError", + "TFlush", + "RFlush", + "TWalk", + "RWalk", + "TOpen", + "ROpen", + "TCreate", + "RCreate", + "TRead", + "RRead", + "TWrite", + "RWrite", + "TClunk", + "RClunk", + "TRemove", + "RRemove", + "TStat", + "RStat", + "TWStat", + "RWStat", +}; + +static int +qid(Fmt *f, Qid *q) { + return fmtprint(f, "(%uhd,%uld,%ullx)", q->type, q->version, q->path); +} + +int +Ffmt(Fmt *f) { + Fcall *fcall; + + fcall = va_arg(f->args, Fcall*); + fmtprint(f, "% 2d %s\t", fcall->hdr.tag, fcnames[fcall->hdr.type - TVersion]); + switch(fcall->hdr.type) { + case TVersion: + case RVersion: + fmtprint(f, " msize: %uld version: \"%s\"", (ulong)fcall->version.msize, fcall->version.version); + break; + case TAuth: + fmtprint(f, " afid: %uld uname: \"%s\" aname: \"%s\"", (ulong)fcall->tauth.afid, fcall->tauth.uname, fcall->tauth.aname); + break; + case RAuth: + fmtprint(f, " aqid: "); + qid(f, &fcall->rauth.aqid); + break; + case RAttach: + fmtprint(f, " qid: "); + qid(f, &fcall->rattach.qid); + break; + case TAttach: + fmtprint(f, " fid: %uld afid: %uld uname: \"%s\" aname: \"%s\"", (ulong)fcall->hdr.fid, (ulong)fcall->tattach.afid, fcall->tattach.uname, fcall->tattach.aname); + break; + case RError: + fmtprint(f, " \"%s\"", fcall->error.ename); + break; + case TFlush: + fmtprint(f, " oldtag: %uld", (ulong)fcall->tflush.oldtag); + break; + case TWalk: + fmtprint(f, " newfid: %uld wname: {", (ulong)fcall->twalk.newfid); + for(int i=0; i<fcall->twalk.nwname; i++) { + if(i > 0) fmtprint(f, ", "); + fmtprint(f, "\"%s\"", fcall->twalk.wname[i]); + } + fmtprint(f, "}"); + break; + case RWalk: + fmtprint(f, " wqid: {"); + for(int i=0; i<fcall->rwalk.nwqid; i++) { + if(i > 0) fmtprint(f, ", "); + qid(f, &fcall->rwalk.wqid[i]); + } + fmtprint(f, "}"); + break; + case TOpen: + fmtprint(f, " fid: %uld mode: %ulo", (ulong)fcall->hdr.fid, (ulong)fcall->topen.mode); + break; + case ROpen: + case RCreate: + fmtprint(f, " qid: "); + qid(f, &fcall->ropen.qid); + fmtprint(f, " %uld", (ulong)fcall->ropen.iounit); + break; + case TCreate: + fmtprint(f, " fid: %uld name: \"%s\" perm: %ulo mode: %ulo", (ulong)fcall->hdr.fid, fcall->tcreate.name, (ulong)fcall->tcreate.perm, (ulong)fcall->tcreate.mode); + break; + case TRead: + fmtprint(f, " fid: %uld offset: %ulld count: %uld", (ulong)fcall->hdr.fid, fcall->tread.offset, (ulong)fcall->tread.count); + break; + case RRead: + fmtprint(f, " data: {data: %uld}", fcall->rread.count); + break; + case TWrite: + fmtprint(f, " fid: %uld offset: %ulld data: {data: %uld}", (ulong)fcall->hdr.fid, fcall->twrite.offset, fcall->twrite.count); + break; + case RWrite: + fmtprint(f, " count: %uld", (ulong)fcall->rwrite.count); + break; + case TClunk: + case TRemove: + case TStat: + fmtprint(f, " fid: %uld", (ulong)fcall->hdr.fid); + break; + case RStat: + fmtprint(f, " stat: {data: %uld}", fcall->rstat.nstat); + break; + } + + return 0; +} +