2
|
1 |
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
|
2 |
// Use of this source code is governed by a BSD-style license that can be
|
|
3 |
// found in the LICENSE file.
|
|
4 |
|
|
5 |
package org.chromium.sdk.internal.tools.v8.request;
|
|
6 |
|
|
7 |
import java.util.List;
|
|
8 |
|
|
9 |
import org.chromium.sdk.Breakpoint;
|
|
10 |
import org.chromium.sdk.DebugContext.StepAction;
|
|
11 |
|
|
12 |
/**
|
|
13 |
* A factory for {@link DebuggerMessage}s. Static methods are used to construct
|
|
14 |
* commands to be sent to the remote V8 debugger.
|
|
15 |
*/
|
|
16 |
public class DebuggerMessageFactory {
|
|
17 |
|
|
18 |
public static DebuggerMessage backtrace(Integer fromFrame, Integer toFrame,
|
|
19 |
boolean compactFormat) {
|
|
20 |
return new BacktraceMessage(fromFrame, toFrame, compactFormat);
|
|
21 |
}
|
|
22 |
|
|
23 |
public static DebuggerMessage goOn(StepAction stepAction, Integer stepCount) {
|
|
24 |
return new ContinueMessage(stepAction, stepCount);
|
|
25 |
}
|
|
26 |
|
|
27 |
public static DebuggerMessage evaluate(String expression, Integer frame, Boolean global,
|
|
28 |
Boolean disableBreak) {
|
|
29 |
return new EvaluateMessage(expression, frame, global, disableBreak);
|
|
30 |
}
|
|
31 |
|
|
32 |
public static DebuggerMessage frame(Integer frameNumber) {
|
|
33 |
return new FrameMessage(frameNumber);
|
|
34 |
}
|
|
35 |
|
|
36 |
public static ContextlessDebuggerMessage scripts(Integer types, Boolean includeScripts) {
|
|
37 |
return new ScriptsMessage(types, includeScripts);
|
|
38 |
}
|
|
39 |
|
|
40 |
public static ContextlessDebuggerMessage scripts(List<Long> ids, Boolean includeScripts) {
|
|
41 |
return new ScriptsMessage(ids, includeScripts);
|
|
42 |
}
|
|
43 |
|
|
44 |
public static ContextlessDebuggerMessage source(Integer frame, Integer fromLine, Integer toLine) {
|
|
45 |
return new SourceMessage(frame, fromLine, toLine);
|
|
46 |
}
|
|
47 |
|
|
48 |
public static ContextlessDebuggerMessage setBreakpoint(Breakpoint.Type type, String target,
|
|
49 |
Integer line, Integer position, Boolean enabled, String condition, Integer ignoreCount) {
|
|
50 |
return new SetBreakpointMessage(type, target, line, position, enabled, condition, ignoreCount);
|
|
51 |
}
|
|
52 |
|
|
53 |
public static ContextlessDebuggerMessage changeBreakpoint(Breakpoint breakpoint) {
|
|
54 |
return new ChangeBreakpointMessage(breakpoint.getId(), breakpoint.isEnabled(),
|
|
55 |
breakpoint.getCondition(), getV8IgnoreCount(breakpoint.getIgnoreCount()));
|
|
56 |
}
|
|
57 |
|
|
58 |
public static ContextlessDebuggerMessage clearBreakpoint(Breakpoint breakpoint) {
|
|
59 |
return new ClearBreakpointMessage(breakpoint.getId());
|
|
60 |
}
|
|
61 |
|
|
62 |
public static DebuggerMessage lookup(List<Long> refs, Boolean inlineRefs) {
|
|
63 |
return new LookupMessage(refs, inlineRefs);
|
|
64 |
}
|
|
65 |
|
|
66 |
public static ContextlessDebuggerMessage suspend() {
|
|
67 |
return new SuspendMessage();
|
|
68 |
}
|
|
69 |
|
|
70 |
public static DebuggerMessage scope(int scopeNumber, int frameNumber) {
|
|
71 |
return new ScopeMessage(scopeNumber, frameNumber);
|
|
72 |
}
|
|
73 |
|
|
74 |
public static ContextlessDebuggerMessage version() {
|
|
75 |
return new VersionMessage();
|
|
76 |
}
|
|
77 |
|
|
78 |
private static Integer getV8IgnoreCount(int count) {
|
|
79 |
return count == Breakpoint.EMPTY_VALUE ? null : count;
|
|
80 |
}
|
|
81 |
}
|