Search in sources :

Example 1 with SourceFilter

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);
    }
}
Also used : SourceFilter(com.oracle.truffle.api.instrumentation.SourceFilter) ExecuteSourceEvent(com.oracle.truffle.api.instrumentation.ExecuteSourceEvent) ExecuteSourceListener(com.oracle.truffle.api.instrumentation.ExecuteSourceListener) SourceSection(com.oracle.truffle.api.source.SourceSection) SourceSectionFilter(com.oracle.truffle.api.instrumentation.SourceSectionFilter) Source(com.oracle.truffle.api.source.Source)

Example 2 with SourceFilter

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();
}
Also used : SourceFilter(com.oracle.truffle.api.instrumentation.SourceFilter) URI(java.net.URI) Source(com.oracle.truffle.api.source.Source)

Aggregations

SourceFilter (com.oracle.truffle.api.instrumentation.SourceFilter)2 Source (com.oracle.truffle.api.source.Source)2 ExecuteSourceEvent (com.oracle.truffle.api.instrumentation.ExecuteSourceEvent)1 ExecuteSourceListener (com.oracle.truffle.api.instrumentation.ExecuteSourceListener)1 SourceSectionFilter (com.oracle.truffle.api.instrumentation.SourceSectionFilter)1 SourceSection (com.oracle.truffle.api.source.SourceSection)1 URI (java.net.URI)1