diff options
| author | rsc <devnull@localhost> | 2003-09-30 17:47:42 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2003-09-30 17:47:42 +0000 |
| commit | 76193d7cb0457807b2f0b95f909ab5de19480cd7 (patch) | |
| tree | 97e538c7e38181431e90289a0fe8b6b7ce1f8f3c /src/libthread/debug.c | |
| parent | ed7c8e8d02c02bdbff1e88a6d8d1419f39af48ad (diff) | |
| download | plan9port-76193d7cb0457807b2f0b95f909ab5de19480cd7.tar.gz plan9port-76193d7cb0457807b2f0b95f909ab5de19480cd7.zip | |
Initial revision
Diffstat (limited to 'src/libthread/debug.c')
| -rw-r--r-- | src/libthread/debug.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/libthread/debug.c b/src/libthread/debug.c new file mode 100644 index 00000000..63e2e1b5 --- /dev/null +++ b/src/libthread/debug.c @@ -0,0 +1,48 @@ +#include "threadimpl.h" + +int _threaddebuglevel; + +void +__threaddebug(ulong flag, char *fmt, ...) +{ + char buf[128]; + va_list arg; + Fmt f; + Proc *p; + + if((_threaddebuglevel&flag) == 0) + return; + + fmtfdinit(&f, 2, buf, sizeof buf); + + p = _threadgetproc(); + if(p==nil) + fmtprint(&f, "noproc "); + else if(p->thread) + fmtprint(&f, "%d.%d ", p->pid, p->thread->id); + else + fmtprint(&f, "%d._ ", p->pid); + + va_start(arg, fmt); + fmtvprint(&f, fmt, arg); + va_end(arg); + fmtprint(&f, "\n"); + fmtfdflush(&f); +} + +void +_threadassert(char *s) +{ + char buf[256]; + int n; + Proc *p; + + p = _threadgetproc(); + if(p && p->thread) + n = sprint(buf, "%d.%d ", p->pid, p->thread->id); + else + n = 0; + snprint(buf+n, sizeof(buf)-n, "%s: assertion failed\n", s); + write(2, buf, strlen(buf)); + abort(); +} |
