-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAPI.js
80 lines (70 loc) · 2.05 KB
/
API.js
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
"use strict";
var actions = {
GET_BREAKPOINTS : "get-breakpoints",
RUN_DEBUGEE : "run-debugee",
BREAK_DEBUGEE : "break-debugee",
STEP_INTO : "step-into",
STEP_OVER : "step-over",
STEP_INSTRUCTION : "step-instruction",
RESUME_DEBUGEE : "resume-debugee",
ADD_BREAKPOINT_FUNCNAME : "add-breakpoint-funcname",
ADD_BREAKPOINT_SOURCE : "add-breakpoint-source",
ADD_BREAKPOINT_ADDRESS : "add-breakpoint-address",
GET_BREAKPOINT_LIST : "get-breakpoints",
DISABLE_BREAKPOINT : "disable-breakpoint",
ENABLE_BREAKPOINT : "enable-breakpoint",
GET_SOURCE_FILE : "get-sourcefile",
GET_SOURCES_LIST : "get-sources-list",
REMOVE_BREAKPOINT : "remove-breakpoint",
SEND_CONSOLE_PROGRAM_INPUT : "send-console-input",
SEND_GDB_CONSOLE_INPUT : "send-gdb-console-input",
GET_LOCAL_VARIABLES : "get-local-variables",
SET_VARIABLE : "set-variable",
GET_STACK_TRACE : "get-stack-trace",
EVALUATE_EXPRESSION : "evaluate-expression",
GET_MEMORY_CHUNK : "get-memory-chunk",
SET_MEMORY_CHUNK : "set-memory-chunk",
GET_PROGRAM_STATE : "get-program-state",
DISASSEMBLE : "disassemble",
SELECT_STACK_FRAME : "select-stack-frame",
}
var uiproxyevents = {
ON_OPEN_SOURCE_FILE : "onopensource",
ON_INVALIDATE_MEMORY : "oninvalidatemem",
}
var results =
{
GDB_RESULT_RECORD : 0,
GDB_ERROR : 1,
GDB_INFERIOR_OUTPUT : 2,
GDB_ASYNC_OUTPUT : 3,
GDB_NOP : 4,
GDB_ENGINE_RESULT :5,
GDB_ENGINE_ERROR : 6,
GDB_CONSOLE_OUTPUT: 7,
}
class API
{
constructor()
{
this.APIBindings = {};
}
HandleRequest(request)
{
if (this.APIBindings[request["action"]] != undefined)
return this.APIBindings[request["action"]](request["params"]);
return undefined;
}
BindAPI(action_name, func)
{
this.APIBindings[action_name] = func;
}
static SerializeRequest(action_name, params)
{
return {"action" : action_name, "params" : params};
}
}
module.exports = API;
module.exports.actions = actions;
module.exports.uiproxyevents = uiproxyevents;
module.exports.results = results;