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
47 uint32_t (*lookupIdentifier)(struct CLIDebuggerSystem*, const char* name, struct CLIDebugVector* dv);
48
49 struct CLIDebuggerCommandSummary* commands;
50 const char* name;
51};
52
53struct CLIDebugger {
54 struct ARMDebugger d;
55
56 struct CLIDebuggerSystem* system;
57
58 EditLine* elstate;
59 History* histate;
60};
61
62struct CLIDebugVector* CLIDVParse(struct CLIDebugger* debugger, const char* string, size_t length);
63struct CLIDebugVector* CLIDVStringParse(struct CLIDebugger* debugger, const char* string, size_t length);
64
65void CLIDebuggerCreate(struct CLIDebugger*);
66void CLIDebuggerAttachSystem(struct CLIDebugger*, struct CLIDebuggerSystem*);
67#endif
68
69#endif