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 char* charValue;
27 struct {
28 int32_t intValue;
29 int segmentValue;
30 };
31 };
32};
33
34typedef void (*CLIDebuggerCommand)(struct CLIDebugger*, struct CLIDebugVector*);
35typedef struct CLIDebugVector* (*CLIDVParser)(struct CLIDebugger* debugger, const char* string, size_t length);
36
37struct CLIDebuggerCommandSummary {
38 const char* name;
39 CLIDebuggerCommand command;
40 CLIDVParser parser;
41 const char* summary;
42};
43
44struct CLIDebuggerSystem {
45 struct CLIDebugger* p;
46
47 void (*init)(struct CLIDebuggerSystem*);
48 void (*deinit)(struct CLIDebuggerSystem*);
49 bool (*custom)(struct CLIDebuggerSystem*);
50
51 void (*disassemble)(struct CLIDebuggerSystem*, struct CLIDebugVector* dv);
52 uint32_t (*lookupIdentifier)(struct CLIDebuggerSystem*, const char* name, struct CLIDebugVector* dv);
53 uint32_t (*lookupPlatformIdentifier)(struct CLIDebuggerSystem*, const char* name, struct CLIDebugVector* dv);
54 void (*printStatus)(struct CLIDebuggerSystem*);
55
56 struct CLIDebuggerCommandSummary* commands;
57 const char* name;
58 struct CLIDebuggerCommandSummary* platformCommands;
59 const char* platformName;
60};
61
62struct CLIDebugger {
63 struct mDebugger d;
64
65 struct CLIDebuggerSystem* system;
66
67 EditLine* elstate;
68 History* histate;
69};
70
71struct CLIDebugVector* CLIDVParse(struct CLIDebugger* debugger, const char* string, size_t length);
72struct CLIDebugVector* CLIDVStringParse(struct CLIDebugger* debugger, const char* string, size_t length);
73
74void CLIDebuggerCreate(struct CLIDebugger*);
75void CLIDebuggerAttachSystem(struct CLIDebugger*, struct CLIDebuggerSystem*);
76#endif
77
78#endif