aboutsummaryrefslogtreecommitdiff
path: root/src/lib/libc/debug.c
blob: 29820ac2ca5d549f893c83e5e50103ba67d2e666 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdbool.h>
#include <stdlib.h>

#include <kogata/syscall.h>
#include <kogata/debug.h>
#include <kogata/printf.h>
#include <kogata/mutex.h>

void sys_panic(const char* msg, const char* file, int line) {
	dbg_printf("PANIC in user process\n  %s\n  at %s:%d\n", msg, file, line);
	*((uint32_t*)NULL) = 1;		//provoke segfault
	exit(-1);
	while(true);
}

void sys_panic_assert(const char* assert, const char* file, int line) {
	dbg_printf("ASSERT FAILED in user process\n  %s\n   at %s:%d\n", assert, file, line);
	*((uint32_t*)NULL) = 1;		//provoke segfault
	exit(-1);
	while(true);
}

void dbg_print(const char* s) {
	sc_dbg_print(s);
}

void dbg_printf(const char* fmt, ...) {
	va_list ap;
	char buffer[256];

	va_start(ap, fmt);
	vsnprintf(buffer, 256, fmt, ap);
	va_end(ap);

	dbg_print(buffer);
}

void yield() {
	sc_yield();
}

/* vim: set ts=4 sw=4 tw=0 noet :*/