mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-09-26 17:07:55 +03:00
Add a new debugger interface using a simple command language. This is
less powerful than the scheme interface (which still exists) but more
ergonomic for interactive debugging.
This debugger has no external dependencies (it will however use readline
if available) and is included in builds by default.
A sample interaction might look like:
xsystem4 --debug /path/to/game
dbg(cmd)> breakpoint bar
Set breakpoint at function 'bar' (0x00001234)
dbg(cmd)> continue
Hit breakpoint at function 'bar' (0x00001234)
dbg(cmd)> backtrace
#0 0x00001234 in bar
#1 0x00002222 in foo
#2 0x00004444 in main
dbg(cmd)> locals
[0] i: 2
[1] s: "baz"
dbg(cmd)> locals 1
[0] j: 3
[1] obj: { m_i = 0; m_s = "" }
dbg(cmd)> quit
57 lines
1.7 KiB
C
57 lines
1.7 KiB
C
/* Copyright (C) 2019 Nunuhara Cabbage <nunuhara@haniwa.technology>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, see <http://gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef SYSTEM4_DEBUGGER_H
|
|
#define SYSTEM4_DEBUGGER_H
|
|
#ifdef DEBUGGER_ENABLED
|
|
|
|
#include <stdbool.h>
|
|
#include "system4/instructions.h"
|
|
#include "xsystem4.h"
|
|
|
|
#define DBG_ERROR(fmt, ...) sys_warning("ERROR: " fmt "\n", ##__VA_ARGS__)
|
|
|
|
struct breakpoint {
|
|
enum opcode restore_op;
|
|
void *data;
|
|
void (*cb)(struct breakpoint*);
|
|
char *message;
|
|
int count;
|
|
};
|
|
|
|
extern bool dbg_enabled;
|
|
|
|
void dbg_init(void);
|
|
void dbg_fini(void);
|
|
void dbg_repl(void);
|
|
|
|
void dbg_continue(void);
|
|
void dbg_quit(void);
|
|
void dbg_start(void(*fun)(void*), void *data);
|
|
void dbg_cmd_repl(void);
|
|
enum opcode dbg_handle_breakpoint(unsigned bp_no);
|
|
bool dbg_set_function_breakpoint(const char *_name, void(*cb)(struct breakpoint*), void *data);
|
|
bool dbg_set_address_breakpoint(uint32_t address, void(*cb)(struct breakpoint*), void *data);
|
|
void dbg_print_stack_trace(void);
|
|
|
|
#ifdef HAVE_SCHEME
|
|
void dbg_scm_init(void);
|
|
void dbg_scm_fini(void);
|
|
void dbg_scm_repl(void);
|
|
#endif /* HAVE_SCHEME */
|
|
#endif /* DEBUGGER_ENABLED */
|
|
#endif /* SYSTEM4_DEBUGGER_H */
|