use of com.oracle.truffle.api.instrumentation.SourceFilter in project graal by oracle.
the class BreakpointSnippets method install.
private void install() {
assert Thread.holdsLock(this);
if (sourceBinding == null) {
SourceFilter filter = locationKey.createSourceFilter();
final boolean[] sourceResolved = new boolean[] { false };
sourceBinding = debugger.getInstrumenter().attachExecuteSourceListener(filter, new ExecuteSourceListener() {
@Override
public void onExecute(ExecuteSourceEvent event) {
if (sourceResolved[0]) {
return;
}
sourceResolved[0] = true;
synchronized (Breakpoint.this) {
if (sourceBinding != null) {
sourceBinding.dispose();
}
}
Source source = event.getSource();
SourceSection location = locationKey.adjustLocation(source, debugger.getEnv(), suspendAnchor);
if (location != null) {
resolveBreakpoint(location);
}
SourceSectionFilter locationFilter = locationKey.createLocationFilter(source, suspendAnchor);
breakpointBinding = createBinding(locationFilter);
}
}, true);
if (sourceResolved[0]) {
sourceBinding.dispose();
}
} else if (breakpointBinding == null && sourceBinding.isDisposed()) {
// re-installing breakpoint
SourceSectionFilter locationFilter = locationKey.createLocationFilter(null, suspendAnchor);
breakpointBinding = createBinding(locationFilter);
}
}
use of com.oracle.truffle.api.instrumentation.SourceFilter in project graal by oracle.
the class BreakpointLocation method createSourceFilter.
SourceFilter createSourceFilter() {
if (key == null) {
return SourceFilter.ANY;
}
SourceFilter.Builder f = SourceFilter.newBuilder();
if (key instanceof URI) {
final URI sourceUri = (URI) key;
f.sourceIs(new Predicate<Source>() {
@Override
public boolean test(Source s) {
URI uri = s.getURI();
return sourceUri.equals(uri);
}
@Override
public String toString() {
return "URI equals " + sourceUri;
}
});
} else {
assert key instanceof Source;
Source s = (Source) key;
f.sourceIs(s);
}
return f.build();
}
Aggregations