all repos — mgba @ 9088d8e6ef7eaa35bdd21268b3d8b86513156d42

mGBA Game Boy Advance Emulator

src/debugger/cli-debugger.h (view raw)

 1/* Copyright (c) 2013-2014 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef CLI_DEBUGGER_H
 7#define CLI_DEBUGGER_H
 8
 9#include "util/common.h"
10
11#include "debugger.h"
12
13#ifdef USE_CLI_DEBUGGER
14#include <histedit.h>
15
16struct CLIDebugger;
17
18struct CLIDebugVector {
19	struct CLIDebugVector* next;
20	enum CLIDVType {
21		CLIDV_ERROR_TYPE,
22		CLIDV_INT_TYPE,
23		CLIDV_CHAR_TYPE
24	} type;
25	union {
26		int32_t intValue;
27		char* charValue;
28	};
29};
30
31typedef void (*CLIDebuggerCommand)(struct CLIDebugger*, struct CLIDebugVector*);
32typedef struct CLIDebugVector* (*CLIDVParser)(struct CLIDebugger* debugger, const char* string, size_t length);
33
34struct CLIDebuggerCommandSummary {
35	const char* name;
36	CLIDebuggerCommand command;
37	CLIDVParser parser;
38	const char* summary;
39};
40
41struct CLIDebuggerSystem {
42	struct CLIDebugger* p;
43
44	void (*init)(struct CLIDebuggerSystem*);
45	void (*deinit)(struct CLIDebuggerSystem*);
46	bool (*custom)(struct CLIDebuggerSystem*);
47
48	void (*disassemble)(struct CLIDebuggerSystem*, struct CLIDebugVector* dv);
49	uint32_t (*lookupIdentifier)(struct CLIDebuggerSystem*, const char* name, struct CLIDebugVector* dv);
50	uint32_t (*lookupPlatformIdentifier)(struct CLIDebuggerSystem*, const char* name, struct CLIDebugVector* dv);
51	void (*printStatus)(struct CLIDebuggerSystem*);
52
53	struct CLIDebuggerCommandSummary* commands;
54	const char* name;
55	struct CLIDebuggerCommandSummary* platformCommands;
56	const char* platformName;
57};
58
59struct CLIDebugger {
60	struct mDebugger d;
61
62	struct CLIDebuggerSystem* system;
63
64	EditLine* elstate;
65	History* histate;
66};
67
68struct CLIDebugVector* CLIDVParse(struct CLIDebugger* debugger, const char* string, size_t length);
69struct CLIDebugVector* CLIDVStringParse(struct CLIDebugger* debugger, const char* string, size_t length);
70
71void CLIDebuggerCreate(struct CLIDebugger*);
72void CLIDebuggerAttachSystem(struct CLIDebugger*, struct CLIDebuggerSystem*);
73#endif
74
75#endif