1 | name = "info";
|
---|
2 |
|
---|
3 | group = "status";
|
---|
4 |
|
---|
5 | shortDescription = "Display information about something";
|
---|
6 |
|
---|
7 | longDescription = "info scripts : Names of scripts being debugged";
|
---|
8 | longDescription += "\ninfo breakpoints : Status of breakpoints currently set";
|
---|
9 | longDescription += "\ninfo locals : Local variables of current stack frame";
|
---|
10 |
|
---|
11 | argumentTypes = [ "subcommand-name" ];
|
---|
12 |
|
---|
13 | subCommands = [ "breakpoints", "locals", "scripts" ];
|
---|
14 |
|
---|
15 | function execute() {
|
---|
16 | var arg = arguments[0];
|
---|
17 | if (arg == undefined) {
|
---|
18 | message("\"info\" must be followed by the name of an info command.");
|
---|
19 | return;
|
---|
20 | } else if (arg == "scripts") {
|
---|
21 | scheduleGetScripts();
|
---|
22 | state = 1;
|
---|
23 | } else if (arg == "breakpoints") {
|
---|
24 | if (arguments.length > 1) {
|
---|
25 | var id = parseInt(arguments[1]);
|
---|
26 | if (isNaN(id)) {
|
---|
27 | message("Breakpoint id expected.");
|
---|
28 | return;
|
---|
29 | }
|
---|
30 | scheduleGetBreakpointData(id);
|
---|
31 | breakpointId = id;
|
---|
32 | state = 3;
|
---|
33 | } else {
|
---|
34 | scheduleGetBreakpoints();
|
---|
35 | state = 2;
|
---|
36 | }
|
---|
37 | } else if (arg == "locals") {
|
---|
38 | scheduleGetActivationObject(getCurrentFrameIndex());
|
---|
39 | state = 4;
|
---|
40 | } else {
|
---|
41 | warning("Undefined info command \"" + arg + "\". Try \"help info\".");
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 | function breakpointString(id, data) {
|
---|
46 | var fn = data.fileName;
|
---|
47 | if (fn.length == 0)
|
---|
48 | fn = "<anonymous script, id=" + data.scriptId + ">";
|
---|
49 | var ret = id + "\t" + (data.enabled ? "yes" : "no")
|
---|
50 | + "\t" + fn + ":" + data.lineNumber;
|
---|
51 | if (data.condition.length != 0) {
|
---|
52 | ret += "\n\tstop only if " + data.condition;
|
---|
53 | }
|
---|
54 | return ret;
|
---|
55 | }
|
---|
56 |
|
---|
57 | function handleResponse(resp) {
|
---|
58 | if (state == 1) {
|
---|
59 | // info scripts
|
---|
60 | var scripts = resp.result;
|
---|
61 | if (scripts == undefined) {
|
---|
62 | message("No scripts loaded.");
|
---|
63 | return;
|
---|
64 | }
|
---|
65 | for (var id in scripts) {
|
---|
66 | var fn = scripts[id].fileName;
|
---|
67 | if (fn.length == 0)
|
---|
68 | fn = "<anonymous script, id=" + id + ">";
|
---|
69 | message("\t" + fn);
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | else if (state == 2) {
|
---|
74 | // info breakpoints
|
---|
75 | var breakpoints = resp.result;
|
---|
76 | if (breakpoints == undefined) {
|
---|
77 | message("No breakpoints set.");
|
---|
78 | return;
|
---|
79 | }
|
---|
80 | message("Id\tEnabled\tWhere");
|
---|
81 | for (var id in breakpoints) {
|
---|
82 | var data = breakpoints[id];
|
---|
83 | message(breakpointString(id, data));
|
---|
84 | }
|
---|
85 | } else if (state == 3) {
|
---|
86 | // info breakpoints N
|
---|
87 | var data = resp.result;
|
---|
88 | if (data == undefined) {
|
---|
89 | message("No breakpoint number " + breakpointId + ".");
|
---|
90 | return;
|
---|
91 | }
|
---|
92 | message("Id\tEnabled\tWhere");
|
---|
93 | message(breakpointString(breakpointId, data));
|
---|
94 | }
|
---|
95 |
|
---|
96 | else if (state == 4) {
|
---|
97 | // info locals
|
---|
98 | var act = resp.result;
|
---|
99 | scheduleNewScriptValueIterator(act);
|
---|
100 | state = 5;
|
---|
101 | } else if (state == 5) {
|
---|
102 | var id = resp.result;
|
---|
103 | scheduleGetPropertiesByIterator(id, 100);
|
---|
104 | iteratorId = id;
|
---|
105 | state = 6;
|
---|
106 | } else if (state == 6) {
|
---|
107 | var props = resp.result;
|
---|
108 | if (props.length == 0) {
|
---|
109 | scheduleDeleteScriptValueIterator(iteratorId);
|
---|
110 | state = 7;
|
---|
111 | return;
|
---|
112 | }
|
---|
113 | var maxLength = 0;
|
---|
114 | for (var i = 0; i < props.length; ++i)
|
---|
115 | maxLength = Math.max(props[i].name.length, maxLength);
|
---|
116 | for (var i = 0; i < props.length; ++i) {
|
---|
117 | var prop = props[i];
|
---|
118 | var msg = prop.name;
|
---|
119 | var pad = maxLength - prop.name.length;
|
---|
120 | for (var j = 0; j < pad; ++j)
|
---|
121 | msg += ' ';
|
---|
122 | message(msg + " : " + prop.valueAsString);
|
---|
123 | }
|
---|
124 | scheduleGetPropertiesByIterator(iteratorId, 100);
|
---|
125 | } else if (state == 7) {
|
---|
126 | // done
|
---|
127 | }
|
---|
128 | }
|
---|