forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebuggerScript.js
More file actions
105 lines (96 loc) · 2.9 KB
/
DebuggerScript.js
File metadata and controls
105 lines (96 loc) · 2.9 KB
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
var controllerObj = {
Logger: (function () {
var logLevel = 0;
return {
Log: function (msg, loggingLevel) {
if ((typeof loggingLevel === "undefined") || (typeof loggingLevel === "number" && loggingLevel <= logLevel)) {
WScript.Echo(msg);
}
},
LogError: function (msg) {
WScript.Echo(msg);
},
SetLogLevel: function (newLogLevel) {
logLevel = newLogLevel;
},
GetLogLevel: function () {
return logLevel;
}
};
})(),
ProcessDebugEvent: function (event, eventJSON) {
switch (event) {
case "SourceCompilation": {
this.Logger.Log("SourceCompilation: " + eventJSON, 0);
this.GetAndProcessResponse();
break;
}
case "CompileError":
this.Logger.Log("SourceCompilation: " + eventJSON, 0);
break;
case "Break": {
this.Logger.Log("Break: " + eventJSON, 0);
this.GetAndProcessResponse();
break;
}
default: {
this.Logger.LogError("ProcessDebugEvent UnHandled event: " + event);
break;
}
}
},
ProcessUserInput: function (userInput) {
try {
this.Logger.Log(userInput, 1);
if (!eval(userInput)) {
this.GetAndProcessResponse();
}
} catch (ex) {
this.Logger.LogError(ex);
}
},
GetAndProcessResponse: function () {
var userInput = WScript.GetUserInput();
this.ProcessUserInput(userInput);
}
}
function ProcessDebugEvent(event, eventJSON) {
controllerObj.ProcessDebugEvent(event, eventJSON);
}
// Commands/Functions which can be executed from debugger prompt
function bp(sourceId, line, column) {
if (typeof sourceId === "number" && typeof line === "number" && typeof column === "number") {
var bpId = WScript.InsertBreakpoint(sourceId, line, column);
return true;
}
return false;
}
function step() {
WScript.ResumeFromBreakpoint(0);
return true;
}
function stepover() {
WScript.ResumeFromBreakpoint(1);
return true;
}
function stepout() {
WScript.ResumeFromBreakpoint(2);
return true;
}
function cont() {
return true;
}
function help() {
controllerObj.Logger.Log("Commands ", 0);
controllerObj.Logger.Log("\tbp(sourceId, line, column)", 0);
controllerObj.Logger.Log("\tcont()", 0);
controllerObj.Logger.Log("\tstep()", 0);
controllerObj.Logger.Log("\tstepover()", 0);
controllerObj.Logger.Log("\tstepout()", 0);
controllerObj.Logger.Log("\tloglevel(level)", 0);
return false;
}
function loglevel(newLevel) {
controllerObj.Logger.SetLogLevel(newLevel);
return false;
}