DGen/SDL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Macros | Functions | Variables
debug.cpp File Reference
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <assert.h>
#include "pd.h"
#include "md.h"
#include "system.h"
#include "debug.h"
#include "linenoise/linenoise.h"

Classes

class  md
 List of commands. More...

Macros

#define CURRENT_DEBUG_CONTEXT_NAME   debug_context_names[debug_context]
#define REG0(id, idx)
#define REG1(id)   { # id, offsetof(m68k_state_t, id), sizeof(m68k_state.id) }
#define REG2(id, idx, name)
#define REG3(id)   { # id, offsetof(z80_state_t, id), sizeof(z80_state.id) }
#define PRINT_Z80_FLAGS(x)
#define MAX_DISASM   128

Functions

void completion (const char *buf, linenoiseCompletions *lc)
 Linenoise completion callback.
static int debug_strtou32 (const char *str, uint32_t *ret)
 A simple wrapper around strtoul() with error check.
static void debug_print_hex_buf (unsigned char *buf, size_t len, size_t addr_label_start)
 Pretty prints hex dump.
static int debug_parse_cpu (char *arg)
 Convert a core name to a context ID.

Variables

static const char * debug_context_names []
const char * psg_aliases [] = { "sn", "sn76489", "psg", NULL }
 Aliases for the various cores.
const char * fm_aliases [] = { "fm", "ym", "ym2612", NULL }
 Aliases for YM2612 core.
const char * z80_aliases [] = { "z80", "z", NULL}
 Aliases for Z80 core.
const char * m68k_aliases [] = { "m68k", "m", "68000", "m68000", NULL}
 Aliases for M68K core.

Macro Definition Documentation

#define CURRENT_DEBUG_CONTEXT_NAME   debug_context_names[debug_context]
#define MAX_DISASM   128
#define PRINT_Z80_FLAGS (   x)
Value:
printf("\t <S=%u, Z= %u, H=%u, P/V=%u, N=%u, C=%u>\n", \
(x & Z80_SR_SIGN) ? 1 : 0, \
(x & Z80_SR_ZERO) ? 1 : 0, \
(x & Z80_SR_HALF_CARRY) ? 1 : 0, \
(x & Z80_SR_PARITY_OVERFLOW) ? 1 : 0, \
(x & Z80_SR_ADD_SUB) ? 1 : 0, \
(x & Z80_SR_CARRY) ? 1 : 0);
#define REG0 (   id,
  idx 
)
Value:
{ \
# id # idx, \
((uintptr_t)&m68k_state.id[idx] - (uintptr_t)&m68k_state), \
sizeof(m68k_state.id[idx]) \
}
#define REG1 (   id)    { # id, offsetof(m68k_state_t, id), sizeof(m68k_state.id) }
#define REG2 (   id,
  idx,
  name 
)
Value:
{ \
name, \
((uintptr_t)&z80_state.alt[idx].id - (uintptr_t)&z80_state), \
sizeof(z80_state.alt[idx].id) \
}
#define REG3 (   id)    { # id, offsetof(z80_state_t, id), sizeof(z80_state.id) }

Function Documentation

void completion ( const char *  buf,
linenoiseCompletions lc 
)

Linenoise completion callback.

Parameters:
bufString so far.
lcList of linenoise completions.
static int debug_parse_cpu ( char *  arg)
static

Convert a core name to a context ID.

Parameters:
[in]argNUL-terminated core name.
Returns:
Core context ID or -1 on error.
static void debug_print_hex_buf ( unsigned char *  buf,
size_t  len,
size_t  addr_label_start 
)
static

Pretty prints hex dump.

Parameters:
[in]bufBuffer to pretty print.
lenNumber of bytes to print.
addr_label_startThe address of the first byte.
static int debug_strtou32 ( const char *  str,
uint32_t *  ret 
)
static

A simple wrapper around strtoul() with error check.

Parameters:
[in]strString to convert to number.
[out]retNumber "str" represents.
Returns:
-1 on error.

Variable Documentation

const char* debug_context_names[]
static
Initial value:
{
"M68K", "Z80", "YM2612", "SN76489"
}
const char* fm_aliases[] = { "fm", "ym", "ym2612", NULL }

Aliases for YM2612 core.

const char* m68k_aliases[] = { "m68k", "m", "68000", "m68000", NULL}

Aliases for M68K core.

const char* psg_aliases[] = { "sn", "sn76489", "psg", NULL }

Aliases for the various cores.

Aliases for SN76489 core.

const char* z80_aliases[] = { "z80", "z", NULL}

Aliases for Z80 core.