[hackers] [wmii] Add 9p debugging. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Wed, 4 Nov 2009 01:51:33 +0000 (UTC)

changeset: 2584:b5707c828c91
user: Kris Maglione <kris_AT_suckless.org>
date: Tue Nov 03 20:48:55 2009 -0500
files: cmd/wmii/Makefile cmd/wmii/dat.h cmd/wmii/fns.h cmd/wmii/main.c cmd/wmii/message.c cmd/wmii/print.c
description:
Add 9p debugging.

diff -r ce1fb5650d77 -r b5707c828c91 cmd/wmii/Makefile
--- a/cmd/wmii/Makefile Fri Oct 30 17:32:33 2009 -0400
+++ b/cmd/wmii/Makefile Tue Nov 03 20:48:55 2009 -0500
@@ -30,6 +30,7 @@
         map \
         message \
         mouse \
+ print \
         root \
         rule \
         printevent\
diff -r ce1fb5650d77 -r b5707c828c91 cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Fri Oct 30 17:32:33 2009 -0400
+++ b/cmd/wmii/dat.h Tue Nov 03 20:48:55 2009 -0500
@@ -99,13 +99,14 @@
 };
 
 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 -r ce1fb5650d77 -r b5707c828c91 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Fri Oct 30 17:32:33 2009 -0400
+++ b/cmd/wmii/fns.h Tue Nov 03 20:48:55 2009 -0500
@@ -250,6 +250,9 @@
 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 -r ce1fb5650d77 -r b5707c828c91 cmd/wmii/main.c
--- a/cmd/wmii/main.c Fri Oct 30 17:32:33 2009 -0400
+++ b/cmd/wmii/main.c Tue Nov 03 20:48:55 2009 -0500
@@ -327,6 +327,11 @@
         XCloseDisplay(display);
 }
 
+static void
+printfcall(IxpFcall *f) {
+ Dprint(D9p, "%F\n", f);
+}
+
 int
 main(int argc, char *argv[]) {
         IxpMsg m;
@@ -383,6 +388,9 @@
 
         init_environment();
 
+ fmtinstall('F', Ffmt);
+ ixp_printfcall = printfcall;
+
         sock = ixp_announce(address);
         if(sock < 0)
                 fatal("Can't create socket '%s': %r", address);
diff -r ce1fb5650d77 -r b5707c828c91 cmd/wmii/message.c
--- a/cmd/wmii/message.c Fri Oct 30 17:32:33 2009 -0400
+++ b/cmd/wmii/message.c Tue Nov 03 20:48:55 2009 -0500
@@ -95,6 +95,7 @@
 };
 
 char* debugtab[] = {
+ "9p",
         "dnd",
         "event",
         "ewmh",
diff -r ce1fb5650d77 -r b5707c828c91 cmd/wmii/print.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cmd/wmii/print.c Tue Nov 03 20:48:55 2009 -0500
@@ -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;
+}
+
Received on Wed Nov 04 2009 - 01:51:33 UTC

This archive was generated by hypermail 2.2.0 : Wed Nov 04 2009 - 02:00:08 UTC