Search in sources :

Example 1 with ExecuteSourceListener

use of com.oracle.truffle.api.instrumentation.ExecuteSourceListener 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)

Aggregations

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