use of com.oracle.truffle.tools.chromeinspector.InspectorExecutionContext in project graal by oracle.
the class Session method connect.
private Object connect() {
if (iss != null) {
throw new InspectorStateException("The inspector session is already connected");
}
InspectorExecutionContext execContext = contextSupplier.get();
iss = InspectServerSession.create(execContext, false, new ConnectionWatcher());
iss.open(getListeners());
execContext.setSynchronous(true);
// Enable the Runtime by default
iss.sendCommand(new Command("{\"id\":0,\"method\":\"Runtime.enable\"}"));
return undefinedProvider.get();
}
use of com.oracle.truffle.tools.chromeinspector.InspectorExecutionContext in project graal by oracle.
the class InspectorInstrument method onCreate.
@Override
protected void onCreate(Env env) {
OptionValues options = env.getOptions();
if (options.hasSetOptions()) {
HostAndPort hostAndPort = options.get(Inspect);
connectionWatcher = new ConnectionWatcher();
try {
server = new Server(env, "Main Context", hostAndPort, options.get(Attach), options.get(Suspend), options.get(WaitAttached), options.get(HideErrors), options.get(Internal), options.get(Initialization), options.get(Path), options.hasBeenSet(Secure), options.get(Secure), new KeyStoreOptions(options), options.get(SourcePath), connectionWatcher);
} catch (IOException e) {
throw new InspectorIOException(hostAndPort.getHostPort(), e);
}
}
env.registerService(new Inspector(env, server != null ? server.getConnection() : null, new InspectorServerConnection.Open() {
@Override
// The parameters port and host should not be assigned
@SuppressWarnings("all")
public synchronized InspectorServerConnection open(int port, String host, boolean wait) {
if (server != null && server.wss != null) {
return null;
}
HostAndPort hostAndPort = options.get(Inspect);
if (port < 0) {
port = hostAndPort.port;
}
if (host == null) {
host = hostAndPort.host;
}
connectionWatcher = new ConnectionWatcher();
hostAndPort = new HostAndPort(host, port);
try {
server = new Server(env, "Main Context", hostAndPort, false, false, wait, options.get(HideErrors), options.get(Internal), options.get(Initialization), null, options.hasBeenSet(Secure), options.get(Secure), new KeyStoreOptions(options), options.get(SourcePath), connectionWatcher);
} catch (IOException e) {
PrintWriter info = new PrintWriter(env.err());
info.println(new InspectorIOException(hostAndPort.getHostPort(), e).getLocalizedMessage());
info.flush();
}
return server != null ? server.getConnection() : null;
}
}, new Supplier<InspectorExecutionContext>() {
@Override
public InspectorExecutionContext get() {
if (server != null) {
return server.getConnection().getExecutionContext();
} else {
PrintWriter err = (options.get(HideErrors)) ? null : new PrintWriter(env.err(), true);
return new InspectorExecutionContext("Main Context", options.get(Internal), options.get(Initialization), env, Collections.emptyList(), err);
}
}
}));
}
use of com.oracle.truffle.tools.chromeinspector.InspectorExecutionContext in project graal by oracle.
the class InspectSessionInfo method onCreate.
@Override
protected void onCreate(final Env env) {
env.registerService(new InspectSessionInfoProvider() {
@Override
public InspectSessionInfo getSessionInfo(final boolean suspend, final boolean inspectInternal, final boolean inspectInitialization, final List<URI> sourcePath) {
return new InspectSessionInfo() {
private InspectServerSession iss;
private InspectorExecutionContext context;
private ConnectionWatcher connectionWatcher;
private long id;
InspectSessionInfo init() {
this.context = new InspectorExecutionContext("test", inspectInternal, inspectInitialization, env, sourcePath, new PrintWriter(env.err(), true));
this.connectionWatcher = new ConnectionWatcher();
this.iss = InspectServerSession.create(context, suspend, connectionWatcher);
lastServerSession = new WeakReference<>(iss);
this.id = context.getId();
// Fake connection open
ReflectionUtils.invoke(connectionWatcher, "notifyOpen");
return this;
}
@Override
public InspectServerSession getInspectServerSession() {
return iss;
}
@Override
public InspectorExecutionContext getInspectorContext() {
return context;
}
@Override
public ConnectionWatcher getConnectionWatcher() {
return connectionWatcher;
}
@Override
public long getId() {
return id;
}
}.init();
}
});
}
Aggregations