plan9port

[fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port # fast
git clone https://src.adamsgaard.dk/plan9port.git # slow
Log | Files | Refs | README | LICENSE Back to index

commit af89fc108d61625959704a08ffdd44adfd86a9d4
parent 9b4de09d413c43059afcd75ceba4d2adcdc0a0a8
Author: rsc <devnull@localhost>
Date:   Thu,  6 Jan 2005 23:07:19 +0000

more debugging

Diffstat:
Msrc/libthread/ioproc.c | 2+-
Msrc/libthread/iorw.c | 3++-
Msrc/libthread/thread.c | 20++++++++++++++++----
3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/libthread/ioproc.c b/src/libthread/ioproc.c @@ -13,7 +13,7 @@ iointerrupt(Ioproc *io) { if(!io->inuse) return; - fprint(2, "bug: cannot iointerrupt yet\n"); + fprint(2, "bug: cannot iointerrupt %p yet\n", io); } static void diff --git a/src/libthread/iorw.c b/src/libthread/iorw.c @@ -123,7 +123,8 @@ _iowrite(va_list *arg) long iowrite(Ioproc *io, int fd, void *a, long n) { - return iocall(io, _iowrite, fd, a, n); + n = iocall(io, _iowrite, fd, a, n); + return n; } static long diff --git a/src/libthread/thread.c b/src/libthread/thread.c @@ -23,17 +23,29 @@ _threaddebug(char *fmt, ...) va_list arg; char buf[128]; _Thread *t; - - return; + char *p; + static int fd = -1; + +return; + if(fd < 0){ + p = strrchr(argv0, '/'); + if(p) + p++; + else + p = argv0; + snprint(buf, sizeof buf, "/tmp/%s.tlog", p); + if((fd = create(buf, OWRITE, 0666)) < 0) + fd = open("/dev/null", OWRITE); + } va_start(arg, fmt); vsnprint(buf, sizeof buf, fmt, arg); va_end(arg); t = proc()->thread; if(t) - fprint(2, "%d.%d: %s\n", getpid(), t->id, buf); + fprint(fd, "%d.%d: %s\n", getpid(), t->id, buf); else - fprint(2, "%d._: %s\n", getpid(), buf); + fprint(fd, "%d._: %s\n", getpid(), buf); } static _Thread*