libdragon
Macros | Functions
debug.c File Reference

Debugging Support. More...

Macros

#define ISVIEWER_WRITE_LEN   ((volatile uint32_t *)0xB3FF0014)
 
#define ISVIEWER_BUFFER   ((volatile uint32_t *)0xB3FF0020)
 
#define ISVIEWER_BUFFER_LEN   0x00000200
 
#define MAX_FAT_FILES   4
 

Functions

void __debug_backtrace (FILE *out, bool skip_exception)
 internal backtrace printing function
 
bool debug_init_usblog (void)
 Initialize USB logging.
 
bool debug_init_isviewer (void)
 Initialize ISViewer logging.
 
bool debug_init_sdlog (const char *fn, const char *openfmt)
 Initialize SD logging.
 
bool debug_init_sdfs (const char *prefix, int npart)
 Initialize SD filesystem.
 
void debug_close_sdfs (void)
 Shutdown SD filesystem.
 
void debug_assert_func_f (const char *file, int line, const char *func, const char *failedexpr, const char *msg,...)
 Underlying implementation function for assert() and assertf.
 
void debug_assert_func (const char *file, int line, const char *func, const char *failedexpr)
 Assertion function that is registered into system.c at startup.
 
void debug_hexdump (const void *vbuf, int size)
 Do a hexdump of the specified buffer via debugf. More...
 
void debug_backtrace (void)
 Dump a backtrace (call stack) via debugf. More...
 

Detailed Description

Debugging Support.

Macro Definition Documentation

◆ ISVIEWER_WRITE_LEN

#define ISVIEWER_WRITE_LEN   ((volatile uint32_t *)0xB3FF0014)

ISViewer register for buffer write length

◆ ISVIEWER_BUFFER

#define ISVIEWER_BUFFER   ((volatile uint32_t *)0xB3FF0020)

ISViewer buffer

◆ ISVIEWER_BUFFER_LEN

#define ISVIEWER_BUFFER_LEN   0x00000200

ISViewer buffer length

◆ MAX_FAT_FILES

#define MAX_FAT_FILES   4

Maximum number of FAT files that can be concurrently opened

Function Documentation

◆ debug_hexdump()

void debug_hexdump ( const void *  buffer,
int  size 
)

Do a hexdump of the specified buffer via debugf.

This is useful to dump a binary buffer for debugging purposes. The hexdump shown contains both the hexadecimal and ASCII values, similar to what hex editors do.

Sample output:

0000  80 80 80 80 80 80 80 80  80 80 80 80 80 80 80 80   |................|
0010  45 67 cd ef aa aa aa aa  aa aa aa aa aa aa aa aa   |Eg..............| 
0020  9a bc 12 34 80 80 80 80  80 80 80 80 80 80 80 80   |...4............|
0030  aa aa aa aa aa aa aa aa  ef 01 67 89 aa aa aa aa   |..........g.....|
0040  80 80 80 80 80 80 80 80  00 00 00 00 80 80 80 80   |................|
Parameters
[in]bufferBuffer to dump
[in]sizeSize of the buffer in bytes

◆ debug_backtrace()

void debug_backtrace ( void  )

Dump a backtrace (call stack) via debugf.

This function will dump the current call stack to the debugging channel. It is useful to understand where the program is currently executing, and to understand the context of an error.

The implementation of this function relies on the lower level backtrace and backtrace_symbols functions, which are implemented in libdragon itself via a symbol table embedded in the ROM. See backtrace_symbols for more information.

See also
backtrace
backtrace_symbols