MentOS  0.8.0
The Mentoring Operating System
Macros | Functions | Variables
debug.c File Reference

Debugging primitives. More...

Macros

#define SERIAL_COM1   (0x03F8)
 Serial port for QEMU.
 

Functions

void dbg_putchar (char c)
 Prints the given character to debug output. More...
 
void dbg_puts (const char *s)
 Prints the given string to debug output. More...
 
static void __debug_print_header (const char *file, const char *fun, int line, short log_level, char *header)
 Prints the correct header for the given debug level. More...
 
void set_log_level (int level)
 Sets the loglevel. More...
 
int get_log_level (void)
 Returns the current loglevel. More...
 
void dbg_printf (const char *file, const char *fun, int line, char *header, short log_level, const char *format,...)
 Prints the given string to the debug output. More...
 
const char * to_human_size (unsigned long bytes)
 Transforms the given amount of bytes to a readable string. More...
 
const char * dec_to_binary (unsigned long value, unsigned length)
 Transforms the given value to a binary string. More...
 
void dbg_print_regs (pt_regs *frame)
 Prints the registers. More...
 

Variables

static int max_log_level = LOGLEVEL_DEBUG
 Determines the log level.
 

Detailed Description

Debugging primitives.

Function Documentation

◆ __debug_print_header()

static void __debug_print_header ( const char *  file,
const char *  fun,
int  line,
short  log_level,
char *  header 
)
inlinestatic

Prints the correct header for the given debug level.

Parameters
filethe file origin of the debug message.
funthe function where the debug message was called.
linethe line in the file where debug message was called.
log_levelthe log level.
headerthe header we want to show.

◆ dbg_print_regs()

void dbg_print_regs ( pt_regs frame)

Prints the registers.

Parameters
framethe registers to print.

◆ dbg_printf()

void dbg_printf ( const char *  file,
const char *  fun,
int  line,
char *  header,
short  log_level,
const char *  format,
  ... 
)

Prints the given string to the debug output.

Parameters
filethe name of the file.
funthe name of the function.
linethe line inside the file.
headerthe header to print.
log_levelthe log level.
formatthe format to used, see printf.
...the list of arguments.

◆ dbg_putchar()

void dbg_putchar ( char  c)

Prints the given character to debug output.

Parameters
cThe character to print.

◆ dbg_puts()

void dbg_puts ( const char *  s)

Prints the given string to debug output.

Parameters
sThe string to print.

◆ dec_to_binary()

const char* dec_to_binary ( unsigned long  value,
unsigned  length 
)

Transforms the given value to a binary string.

Parameters
valueto print.
lengthof the binary output.
Returns
String representing the binary value.

◆ get_log_level()

int get_log_level ( void  )

Returns the current loglevel.

Returns
The current loglevel

◆ set_log_level()

void set_log_level ( int  level)

Sets the loglevel.

Parameters
levelThe new loglevel.

◆ to_human_size()

const char* to_human_size ( unsigned long  bytes)

Transforms the given amount of bytes to a readable string.

Parameters
bytesThe bytes to turn to string.
Returns
String representing the bytes in human readable form.