summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/debug/debugcmd.h
blob: b65b49b68eae3747168c87afbb5d384ba18561b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// license:BSD-3-Clause
// copyright-holders:Aaron Giles,Ryan Holtz
/*********************************************************************

    debugcmd.h

    Debugger command interface engine.

*********************************************************************/

#pragma once

#ifndef __DEBUGCMD_H__
#define __DEBUGCMD_H__

#include "emu.h"
#include "debugcpu.h"
#include "debugcon.h"

class parsed_expression;
class symbol_table;

class debugger_commands
{
public:
	debugger_commands(running_machine& machine, debugger_cpu& cpu, debugger_console& console);

	/* validates a parameter as a boolean value */
	bool validate_boolean_parameter(const char *param, bool *result);

	/* validates a parameter as a numeric value */
	bool validate_number_parameter(const char *param, uint64_t *result);

	/* validates a parameter as a cpu */
	bool validate_cpu_parameter(const char *param, device_t **result);

	/* validates a parameter as a cpu and retrieves the given address space */
	bool validate_cpu_space_parameter(const char *param, int spacenum, address_space *&result);

private:
	struct global_entry
	{
		void *      base;
		uint32_t      size;
	};


	struct cheat_map
	{
		uint64_t      offset;
		uint64_t      first_value;
		uint64_t      previous_value;
		uint8_t       state:1;
		uint8_t       undo:7;
	};

	// TODO [RH 31 May 2016]: Move this cheat stuff into its own class
	struct cheat_system
	{
		char        cpu[2];
		uint8_t       width;
		std::vector<cheat_map> cheatmap;
		uint8_t       undo;
		uint8_t       signed_cheat;
		uint8_t       swapped_cheat;
	};


	struct cheat_region_map
	{
		uint64_t      offset;
		uint64_t      endoffset;
		const char *share;
		uint8_t       disabled;
	};

	bool debug_command_parameter_expression(const char *param, parsed_expression &result);
	bool debug_command_parameter_command(const char *param);

	bool cheat_address_is_valid(address_space &space, offs_t address);
	uint64_t cheat_sign_extend(const cheat_system *cheatsys, uint64_t value);
	uint64_t cheat_byte_swap(const cheat_system *cheatsys, uint64_t value);
	uint64_t cheat_read_extended(const cheat_system *cheatsys, address_space &space, offs_t address);

	uint64_t execute_min(symbol_table &table, void *ref, int params, const uint64_t *param);
	uint64_t execute_max(symbol_table &table, void *ref, int params, const uint64_t *param);
	uint64_t execute_if(symbol_table &table, void *ref, int params, const uint64_t *param);

	uint64_t global_get(symbol_table &table, void *ref);
	void global_set(symbol_table &table, void *ref, uint64_t value);

	int mini_printf(char *buffer, const char *format, int params, uint64_t *param);

	void execute_trace_internal(int ref, int params, const char *param[], bool trace_over);

	void execute_help(int ref, int params, const char **param);
	void execute_print(int ref, int params, const char **param);
	void execute_printf(int ref, int params, const char **param);
	void execute_logerror(int ref, int params, const char **param);
	void execute_tracelog(int ref, int params, const char **param);
	void execute_quit(int ref, int params, const char **param);
	void execute_do(int ref, int params, const char **param);
	void execute_step(int ref, int params, const char **param);
	void execute_over(int ref, int params, const char **param);
	void execute_out(int ref, int params, const char **param);
	void execute_go(int ref, int params, const char **param);
	void execute_go_vblank(int ref, int params, const char **param);
	void execute_go_interrupt(int ref, int params, const char **param);
	void execute_go_time(int ref, int params, const char *param[]);
	void execute_focus(int ref, int params, const char **param);
	void execute_ignore(int ref, int params, const char **param);
	void execute_observe(int ref, int params, const char **param);
	void execute_next(int ref, int params, const char **param);
	void execute_comment_add(int ref, int params, const char **param);
	void execute_comment_del(int ref, int params, const char **param);
	void execute_comment_save(int ref, int params, const char **param);
	void execute_comment_list(int ref, int params, const char **param);
	void execute_comment_commit(int ref, int params, const char **param);
	void execute_bpset(int ref, int params, const char **param);
	void execute_bpclear(int ref, int params, const char **param);
	void execute_bpdisenable(int ref, int params, const char **param);
	void execute_bplist(int ref, int params, const char **param);
	void execute_wpset(int ref, int params, const char **param);
	void execute_wpclear(int ref, int params, const char **param);
	void execute_wpdisenable(int ref, int params, const char **param);
	void execute_wplist(int ref, int params, const char **param);
	void execute_rpset(int ref, int params, const char **param);
	void execute_rpclear(int ref, int params, const char **param);
	void execute_rpdisenable(int ref, int params, const char **param);
	void execute_rplist(int ref, int params, const char **param);
	void execute_hotspot(int ref, int params, const char **param);
	void execute_statesave(int ref, int params, const char **param);
	void execute_stateload(int ref, int params, const char **param);
	void execute_save(int ref, int params, const char **param);
	void execute_load(int ref, int params, const char **param);
	void execute_dump(int ref, int params, const char **param);
	void execute_cheatinit(int ref, int params, const char **param);
	void execute_cheatnext(int ref, int params, const char **param);
	void execute_cheatlist(int ref, int params, const char **param);
	void execute_cheatundo(int ref, int params, const char **param);
	void execute_dasm(int ref, int params, const char **param);
	void execute_find(int ref, int params, const char **param);
	void execute_trace(int ref, int params, const char **param);
	void execute_traceover(int ref, int params, const char **param);
	void execute_traceflush(int ref, int params, const char **param);
	void execute_history(int ref, int params, const char **param);
	void execute_trackpc(int ref, int params, const char **param);
	void execute_trackmem(int ref, int params, const char **param);
	void execute_pcatmem(int ref, int params, const char **param);
	void execute_snap(int ref, int params, const char **param);
	void execute_source(int ref, int params, const char **param);
	void execute_map(int ref, int params, const char **param);
	void execute_memdump(int ref, int params, const char **param);
	void execute_symlist(int ref, int params, const char **param);
	void execute_softreset(int ref, int params, const char **param);
	void execute_hardreset(int ref, int params, const char **param);
	void execute_images(int ref, int params, const char **param);
	void execute_mount(int ref, int params, const char **param);
	void execute_unmount(int ref, int params, const char **param);
	void execute_input(int ref, int params, const char **param);
	void execute_dumpkbd(int ref, int params, const char **param);

	running_machine&    m_machine;
	debugger_cpu& m_cpu;
	debugger_console& m_console;

	global_entry *m_global_array;
	cheat_system m_cheat;

	static const size_t MAX_GLOBALS;
};

#endif