libc8
CHIP-8 utility library
debug.h File Reference
#include "../chip8.h"

Go to the source code of this file.

Macros

#define DEBUG_QUIT   1
 
#define DEBUG_CONTINUE   2
 
#define DEBUG_STEP   3
 
#define DEBUG_HELP_STRING   "Available commands:\n\break [ADDRESS]: Add breakpoint to PC or ADDRESS, if given\n\rmbreak [ADDRESS]: Remove breakpoint at PC or ADDRESS, if given\n\continue: Exit debug mode until next breakpoint or completion\n\help: Print this help string\n\load PATH: Load program state from PATH\n\next: Step to the next instruction\n\print [ATTRIBUTE]: Print current value of ATTRIBUTE\n\save PATH: Save program state to the given file\n\set ATTRIBUTE VALUE: Set the given attribute to the given value\n\quit: Terminate the program\n\\n\Available attributes to print:\n\PC: Program counter\n\SP: Stack pointer\n\DT: Delay timer\n\ST: Sound timer\n\I: I address\n\K: Register to store next keypress\n\V[x]: All register values or value of Vx, if given\n\stack: All stack values\n\$[address]: Value at given address\n\\n\If no argument is given to print, it will print all of the above attributes\n\except for address values.\n"
 

Functions

int debug_repl (c8_t *)
 Debug command line loop. More...
 
int has_breakpoint (c8_t *, uint16_t)
 Check if breakpoint exists at address pc. More...
 

Detailed Description

Note
NOT EXPORTED

Stuff related to debug mode.

Macro Definition Documentation

◆ DEBUG_CONTINUE

#define DEBUG_CONTINUE   2

◆ DEBUG_HELP_STRING

#define DEBUG_HELP_STRING   "Available commands:\n\break [ADDRESS]: Add breakpoint to PC or ADDRESS, if given\n\rmbreak [ADDRESS]: Remove breakpoint at PC or ADDRESS, if given\n\continue: Exit debug mode until next breakpoint or completion\n\help: Print this help string\n\load PATH: Load program state from PATH\n\next: Step to the next instruction\n\print [ATTRIBUTE]: Print current value of ATTRIBUTE\n\save PATH: Save program state to the given file\n\set ATTRIBUTE VALUE: Set the given attribute to the given value\n\quit: Terminate the program\n\\n\Available attributes to print:\n\PC: Program counter\n\SP: Stack pointer\n\DT: Delay timer\n\ST: Sound timer\n\I: I address\n\K: Register to store next keypress\n\V[x]: All register values or value of Vx, if given\n\stack: All stack values\n\$[address]: Value at given address\n\\n\If no argument is given to print, it will print all of the above attributes\n\except for address values.\n"

◆ DEBUG_QUIT

#define DEBUG_QUIT   1

◆ DEBUG_STEP

#define DEBUG_STEP   3

Function Documentation

◆ debug_repl()

int debug_repl ( c8_t c8)

Debug command line loop.

This function parses user commands from stdin and prints the result until one of the following conditions is met:

  • continue command is evaluated (return DEBUG_CONTINUE)
  • quit command is evaluated (return DEBUG_QUIT)
  • next command is evaluated (return DEBUG_STEP)
Parameters
c8the current CHIP-8 state
Returns
DEBUG_CONTINUE, DEBUG_STEP, or DEBUG_QUIT

◆ has_breakpoint()

int has_breakpoint ( c8_t c8,
uint16_t  pc 
)

Check if breakpoint exists at address pc.

Parameters
c8c8_t to check breakpoints of
pcaddress to check for breakpoint at
Returns
1 if yes, 0 if no