2023-06-09 11:44:57 +00:00
|
|
|
#pragma once
|
2023-06-03 19:37:42 +00:00
|
|
|
#ifndef GB_DISABLE_DEBUGGER
|
2017-04-17 17:16:17 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2021-11-07 11:39:18 +00:00
|
|
|
#include "defs.h"
|
2017-04-17 17:16:17 +00:00
|
|
|
#include "symbol_hash.h"
|
2016-03-30 20:07:55 +00:00
|
|
|
|
2024-11-16 18:25:36 +00:00
|
|
|
typedef void (*GB_debugger_reload_callback_t)(GB_gameboy_t *gb);
|
|
|
|
|
2023-05-09 21:54:34 +00:00
|
|
|
void GB_debugger_break(GB_gameboy_t *gb);
|
2017-04-17 17:16:17 +00:00
|
|
|
#ifdef GB_INTERNAL
|
2023-06-03 19:37:42 +00:00
|
|
|
bool /* Returns true if debugger waits for more commands. Not relevant for non-GB_INTERNAL */
|
2017-10-12 16:05:27 +00:00
|
|
|
#else
|
2023-06-03 19:37:42 +00:00
|
|
|
void
|
|
|
|
#endif
|
|
|
|
GB_debugger_execute_command(GB_gameboy_t *gb, char *input); /* Destroys input. */
|
|
|
|
char *GB_debugger_complete_substring(GB_gameboy_t *gb, char *input, uintptr_t *context); /* Destroys input, result requires free */
|
|
|
|
void GB_debugger_load_symbol_file(GB_gameboy_t *gb, const char *path);
|
|
|
|
const char *GB_debugger_name_for_address(GB_gameboy_t *gb, uint16_t addr);
|
2023-07-30 15:54:49 +00:00
|
|
|
/* Use -1 for bank to use the currently mapped bank */
|
|
|
|
const char *GB_debugger_describe_address(GB_gameboy_t *gb, uint16_t addr, uint16_t bank, bool exact_match, bool prefer_local);
|
2023-06-03 19:37:42 +00:00
|
|
|
bool GB_debugger_evaluate(GB_gameboy_t *gb, const char *string, uint16_t *result, uint16_t *result_bank); /* result_bank is -1 if unused. */
|
|
|
|
bool GB_debugger_is_stopped(GB_gameboy_t *gb);
|
|
|
|
void GB_debugger_set_disabled(GB_gameboy_t *gb, bool disabled);
|
|
|
|
void GB_debugger_clear_symbols(GB_gameboy_t *gb);
|
2024-11-16 18:25:36 +00:00
|
|
|
void GB_debugger_set_reload_callback(GB_gameboy_t *gb, GB_debugger_reload_callback_t callback);
|
2023-06-03 19:37:42 +00:00
|
|
|
|
|
|
|
#ifdef GB_INTERNAL
|
2021-11-07 12:13:52 +00:00
|
|
|
internal void GB_debugger_run(GB_gameboy_t *gb);
|
|
|
|
internal void GB_debugger_handle_async_commands(GB_gameboy_t *gb);
|
|
|
|
internal void GB_debugger_call_hook(GB_gameboy_t *gb, uint16_t call_addr);
|
|
|
|
internal void GB_debugger_ret_hook(GB_gameboy_t *gb);
|
|
|
|
internal void GB_debugger_test_write_watchpoint(GB_gameboy_t *gb, uint16_t addr, uint8_t value);
|
|
|
|
internal void GB_debugger_test_read_watchpoint(GB_gameboy_t *gb, uint16_t addr);
|
2023-07-29 11:51:31 +00:00
|
|
|
internal const GB_bank_symbol_t *GB_debugger_find_symbol(GB_gameboy_t *gb, uint16_t addr, bool prefer_local);
|
2021-11-07 12:13:52 +00:00
|
|
|
internal void GB_debugger_add_symbol(GB_gameboy_t *gb, uint16_t bank, uint16_t address, const char *symbol);
|
2024-08-28 22:11:47 +00:00
|
|
|
#ifndef GB_DISABLE_CHEAT_SEARCH
|
|
|
|
internal bool GB_debugger_evaluate_cheat_filter(GB_gameboy_t *gb, const char *string, bool *result, uint16_t old, uint16_t new);
|
|
|
|
#endif
|
2017-04-17 17:16:17 +00:00
|
|
|
#endif
|
|
|
|
|
2023-06-03 19:37:42 +00:00
|
|
|
#else // GB_DISABLE_DEBUGGER
|
2017-05-26 17:16:19 +00:00
|
|
|
#ifdef GB_INTERNAL
|
2023-06-03 19:37:42 +00:00
|
|
|
#define GB_debugger_run(gb) (void)0
|
|
|
|
#define GB_debugger_handle_async_commands(gb) (void)0
|
|
|
|
#define GB_debugger_ret_hook(gb) (void)0
|
|
|
|
#define GB_debugger_call_hook(gb, addr) (void)addr
|
|
|
|
#define GB_debugger_test_write_watchpoint(gb, addr, value) ((void)addr, (void)value)
|
|
|
|
#define GB_debugger_test_read_watchpoint(gb, addr) (void)addr
|
|
|
|
#define GB_debugger_add_symbol(gb, bank, address, symbol) ((void)bank, (void)address, (void)symbol)
|
|
|
|
#define GB_debugger_break(gb) (void)0
|
|
|
|
#endif // GB_INTERNAL
|
|
|
|
|
|
|
|
#endif // GB_DISABLE_DEBUGGER
|