Add vargs to panic

上级 aa9350de
...@@ -192,16 +192,19 @@ kerneltrap(struct trapframe *tf) ...@@ -192,16 +192,19 @@ kerneltrap(struct trapframe *tf)
; ;
} }
void __noret__ void
panic(const char *s) panic(const char *fmt, ...)
{ {
extern void sys_halt(); extern void sys_halt();
va_list ap;
cli(); cli();
acquire(&cons.lock); acquire(&cons.lock);
__cprintf("cpu%d: panic: ", mycpu()->id); __cprintf("cpu%d: panic: ", mycpu()->id);
__cprintf(s); va_start(ap, fmt);
vprintfmt(writecons, 0, fmt, ap);
va_end(ap);
__cprintf("\n"); __cprintf("\n");
stacktrace(); stacktrace();
......
...@@ -45,7 +45,8 @@ void cv_tick(void); ...@@ -45,7 +45,8 @@ void cv_tick(void);
// console.c // console.c
void cprintf(const char*, ...) __attribute__((format(printf, 1, 2))); void cprintf(const char*, ...) __attribute__((format(printf, 1, 2)));
void panic(const char*) __noret__; void panic(const char*, ...)
__noret__ __attribute__((format(printf, 1, 2)));
void kerneltrap(struct trapframe *tf) __noret__; void kerneltrap(struct trapframe *tf) __noret__;
void snprintf(char *buf, u32 n, char *fmt, ...); void snprintf(char *buf, u32 n, char *fmt, ...);
void consoleintr(int(*)(void)); void consoleintr(int(*)(void));
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论