CS318 - Pintos
Pintos source browser for JHU CS318 course
debug.c
Go to the documentation of this file.
1 #include <debug.h>
2 #include <stdarg.h>
3 #include <stdbool.h>
4 #include <stdio.h>
5 #include <syscall.h>
6 
7 /** Aborts the user program, printing the source file name, line
8  number, and function name, plus a user-specific message. */
9 void
10 debug_panic (const char *file, int line, const char *function,
11  const char *message, ...)
12 {
13  va_list args;
14 
15  printf ("User process ABORT at %s:%d in %s(): ", file, line, function);
16 
17  va_start (args, message);
18  vprintf (message, args);
19  printf ("\n");
20  va_end (args);
21 
22  debug_backtrace ();
23 
24  exit (1);
25 }
va_end
#define va_end(LIST)
Definition: stdarg.h:10
va_start
#define va_start(LIST, ARG)
Definition: stdarg.h:9
file
An open file.
Definition: file.c:7
debug_backtrace
void debug_backtrace(void)
Prints the call stack, that is, a list of addresses, one in each of the functions we are nested withi...
Definition: debug.c:13
stdbool.h
debug_panic
void debug_panic(const char *file, int line, const char *function, const char *message,...)
Halts the OS, printing the source file name, line number, and function name, plus a user-specific mes...
Definition: debug.c:19
stdarg.h
printf
int printf(const char *format,...)
Writes formatted output to the console.
Definition: stdio.c:79
vprintf
int vprintf(const char *format, va_list args)
The standard vprintf() function, which is like printf() but uses a va_list.
Definition: console.c:126
va_list
__builtin_va_list va_list
GCC has <stdarg.h> functionality as built-ins, so all we need is to use it.
Definition: stdarg.h:7
exit
void exit(int status)
Definition: syscall.c:72
syscall.h
stdio.h
debug.h