summaryrefslogtreecommitdiff
path: root/sys/src/libthread/debug.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2021-10-13 17:08:26 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2021-10-13 17:08:26 +0000
commit5a807265a819206f8342ab3a23b940a0c75049fc (patch)
treea84effb4eb8852b1346259b98772c5c269f91e09 /sys/src/libthread/debug.c
parent3fe3e370e3bcad21b61aec6cbf5d11a9398e805b (diff)
libthread: fix debug prints, simplify
Do the debuglevel check before calling the print function for _threaddebug, by making it a macro. Do not waste cycles passing arguments. Generalize the _threaddebug function into _threadprint() and add a varargcheck pragma. This function can also be used from _threadassert(). Fix missing arguments in one case, fix trailing newlines in _threaddebug(). Make _threadgetproc()/_threadsetproc() a macro, just dereferencing Proc**_threadprocp. Simplify the mainjump, just call _threadsetproc() directly without that mainp dance. Remove the _schedinit() argument, it uses _threadgetproc() now. Get rid of Mainarg struct, just have a global variable for argc.
Diffstat (limited to 'sys/src/libthread/debug.c')
-rw-r--r--sys/src/libthread/debug.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/sys/src/libthread/debug.c b/sys/src/libthread/debug.c
index 183869d18..cab101ca6 100644
--- a/sys/src/libthread/debug.c
+++ b/sys/src/libthread/debug.c
@@ -6,16 +6,13 @@
int _threaddebuglevel;
void
-_threaddebug(ulong flag, char *fmt, ...)
+_threadprint(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();
@@ -36,16 +33,6 @@ _threaddebug(ulong flag, char *fmt, ...)
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));
+ _threadprint("%s: assertion failed", s);
abort();
}