PKUOS - Pintos
Pintos source browser for PKU Operating System course
Macros | Functions | Variables
debug.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define UNUSED   __attribute__ ((unused))
 GCC lets us add "attributes" to functions, function parameters, etc. More...
 
#define NO_RETURN   __attribute__ ((noreturn))
 
#define NO_INLINE   __attribute__ ((noinline))
 
#define PRINTF_FORMAT(FMT, FIRST)   __attribute__ ((format (printf, FMT, FIRST)))
 
#define PANIC(...)   debug_panic (__FILE__, __LINE__, __func__, __VA_ARGS__)
 Halts the OS, printing the source file name, line number, and function name, plus a user-specific message. More...
 
#define ASSERT(CONDITION)
 This is outside the header guard so that debug.h may be included multiple times with different settings of NDEBUG. More...
 
#define NOT_REACHED()   PANIC ("executed an unreachable statement");
 lib/debug.h More...
 

Functions

void debug_panic (const char *file, int line, const char *function, const char *message,...) PRINTF_FORMAT(4
 
void debug_backtrace (void)
 Prints the call stack, that is, a list of addresses, one in each of the functions we are nested within. More...
 
void debug_backtrace_all (void)
 Prints call stack of all threads. More...
 

Variables

void NO_RETURN
 

Macro Definition Documentation

◆ ASSERT

#define ASSERT (   CONDITION)
Value:
if (CONDITION) { } else { \
PANIC ("assertion `%s' failed.", #CONDITION); \
}

This is outside the header guard so that debug.h may be included multiple times with different settings of NDEBUG.

Definition at line 31 of file debug.h.

◆ NO_INLINE

#define NO_INLINE   __attribute__ ((noinline))

Definition at line 9 of file debug.h.

◆ NO_RETURN

#define NO_RETURN   __attribute__ ((noreturn))

Definition at line 8 of file debug.h.

◆ NOT_REACHED

#define NOT_REACHED ( )    PANIC ("executed an unreachable statement");

lib/debug.h

Definition at line 43 of file debug.h.

◆ PANIC

#define PANIC (   ...)    debug_panic (__FILE__, __LINE__, __func__, __VA_ARGS__)

Halts the OS, printing the source file name, line number, and function name, plus a user-specific message.

Definition at line 14 of file debug.h.

◆ PRINTF_FORMAT

#define PRINTF_FORMAT (   FMT,
  FIRST 
)    __attribute__ ((format (printf, FMT, FIRST)))

Definition at line 10 of file debug.h.

◆ UNUSED

#define UNUSED   __attribute__ ((unused))

GCC lets us add "attributes" to functions, function parameters, etc.

to indicate their properties. See the GCC manual for details.

Definition at line 7 of file debug.h.

Function Documentation

◆ 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 within.

gdb or addr2line may be applied to kernel.o to translate these into file names, line numbers, and function names.

Definition at line 13 of file debug.c.

References NULL, and printf().

Referenced by debug_panic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ debug_backtrace_all()

void debug_backtrace_all ( void  )

Prints call stack of all threads.

Definition at line 117 of file debug.c.

References intr_disable(), intr_set_level(), print_stacktrace(), and thread_foreach().

Here is the call graph for this function:

◆ debug_panic()

void debug_panic ( const char *  file,
int  line,
const char *  function,
const char *  message,
  ... 
)

Variable Documentation

◆ NO_RETURN

void NO_RETURN

Definition at line 17 of file debug.h.