CS350 COS
COS
Loading...
Searching...
No Matches
kassert.h File Reference
#include <sys/cdefs.h>
#include <sys/sysctl.h>
Include dependency graph for kassert.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ASSERT(_x)
 
#define NOT_IMPLEMENTED()
 
#define PANIC   Panic
 
#define static_assert   _Static_assert
 
#define Alert(_module, _format, ...)   kprintf(#_module ": " _format, ##__VA_ARGS__)
 
#define Warning(_module, _format, ...)   kprintf(#_module ": " _format, ##__VA_ARGS__)
 
#define Log(_module, _format, ...)
 
#define DLOG(_module, _format, ...)
 
#define VLOG(_module, _format, ...)
 

Functions

NO_RETURN void Panic (const char *str)
 
int kprintf (const char *fmt,...)
 
NO_RETURN void Debug_Assert (const char *fmt,...)
 

Macro Definition Documentation

◆ Alert

#define Alert (   _module,
  _format,
  ... 
)    kprintf(#_module ": " _format, ##__VA_ARGS__)

Definition at line 28 of file kassert.h.

◆ ASSERT

#define ASSERT (   _x)
Value:
if (!(_x)) { \
Debug_Assert("ASSERT("#_x"): %s %s:%d\n", \
__FUNCTION__, __FILE__, __LINE__); \
}

Definition at line 8 of file kassert.h.

◆ DLOG

#define DLOG (   _module,
  _format,
  ... 
)
Value:
if (SYSCTL_GETINT(log_##_module) >= 5) { \
kprintf(#_module ": " _format, ##__VA_ARGS__); \
}
#define SYSCTL_GETINT(_PATH)
Definition: sysctl.h:63

Definition at line 37 of file kassert.h.

◆ Log

#define Log (   _module,
  _format,
  ... 
)
Value:
if (SYSCTL_GETINT(log_##_module) >= 1) { \
kprintf(#_module ": " _format, ##__VA_ARGS__); \
}

Definition at line 32 of file kassert.h.

◆ NOT_IMPLEMENTED

#define NOT_IMPLEMENTED ( )
Value:
if (1) { \
Debug_Assert("NOT_IMPLEMENTED(): %s %s:%d\n", \
__FUNCTION__, __FILE__, __LINE__); \
}

Definition at line 13 of file kassert.h.

◆ PANIC

#define PANIC   Panic

Definition at line 18 of file kassert.h.

◆ static_assert

#define static_assert   _Static_assert

Definition at line 25 of file kassert.h.

◆ VLOG

#define VLOG (   _module,
  _format,
  ... 
)
Value:
if (SYSCTL_GETINT(log_##_module) >= 10) { \
kprintf(#_module ": " _format, ##__VA_ARGS__); \
}

Definition at line 42 of file kassert.h.

◆ Warning

#define Warning (   _module,
  _format,
  ... 
)    kprintf(#_module ": " _format, ##__VA_ARGS__)

Definition at line 30 of file kassert.h.

Function Documentation

◆ Debug_Assert()

NO_RETURN void Debug_Assert ( const char *  fmt,
  ... 
)

Definition at line 222 of file printf.c.

223{
224 va_list ap;
225
226 va_start(ap, fmt);
227 kvprintf(fmt, consoleputc, 0, ap);
228 va_end(ap);
229
230#if 0
231 kprintf("PC %lx FP %lx\n", __builtin_return_address(0), __builtin_frame_address(0));
232 kprintf("PC %lx FP %lx\n", __builtin_return_address(1), __builtin_frame_address(1));
233 kprintf("PC %lx FP %lx\n", __builtin_return_address(2), __builtin_frame_address(2));
234 kprintf("PC %lx FP %lx\n", __builtin_return_address(3), __builtin_frame_address(3));
235 kprintf("PC %lx FP %lx\n", __builtin_return_address(4), __builtin_frame_address(4));
236 kprintf("PC %lx FP %lx\n", __builtin_return_address(5), __builtin_frame_address(5));
237#endif
238
239 Panic("");
240}
static int kvprintf(char const *fmt, void(*func)(int, void *), void *handle, va_list ap)
Definition: printf.c:75
#define va_end(ap)
Definition: stdarg.h:21
#define va_start(ap, last)
Definition: stdarg.h:9
__builtin_va_list va_list
Definition: stdarg.h:6
int kprintf(const char *fmt,...)
Definition: printf.c:210
void consoleputc(int c, void *handle)
Definition: printf.c:202
void Panic(const char *str)
Definition: vgacons.c:164
Here is the call graph for this function:

◆ kprintf()

int kprintf ( const char *  fmt,
  ... 
)

Definition at line 210 of file printf.c.

211{
212 int ret;
213 va_list ap;
214
215 va_start(ap, fmt);
216 ret = kvprintf(fmt, consoleputc, 0, ap);
217 va_end(ap);
218
219 return ret;
220}
Here is the call graph for this function:

◆ Panic()

NO_RETURN void Panic ( const char *  str)

Definition at line 164 of file vgacons.c.

165{
166 VGA_Puts(str);
167 __asm__("int3");
168 while (1)
169 {
170 __asm__("hlt");
171 }
172}
void VGA_Puts(const char *str)
Definition: vgacons.c:157
Here is the call graph for this function:
Here is the caller graph for this function: