Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrumenter to observe behavior of nodes with UUID #7833

Merged
merged 35 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
99cb39e
Instrumenter to observe behavior of nodes with UUID
JaroslavTulach Sep 18, 2023
ea79b89
Instrumentor test
JaroslavTulach Sep 18, 2023
6f1a609
Return back original version of the comment
JaroslavTulach Sep 19, 2023
69ecf06
Remove unnecessary metadata from the test
JaroslavTulach Sep 19, 2023
9dae0cc
Merge remote-tracking branch 'origin/develop' into wip/jtulach/Instru…
JaroslavTulach Sep 20, 2023
aa8cff0
Compare also the final result
JaroslavTulach Sep 20, 2023
c9abb9c
Replay with (different) cache results
JaroslavTulach Sep 20, 2023
a4b02aa
Merge remote-tracking branch 'origin/develop' into wip/jtulach/Instru…
JaroslavTulach Oct 2, 2023
c41f70d
Adopt to hidden environment
JaroslavTulach Oct 2, 2023
1232a36
Adding documentation for the Instrumentor
JaroslavTulach Oct 2, 2023
1baefa5
Avoid onExceptionalCallback, propagate InteropException as PanicExcep…
JaroslavTulach Oct 3, 2023
9711534
Merging with Meta.Type.find
JaroslavTulach Oct 3, 2023
f5f2608
Treat Instrumentor as a managed resource
JaroslavTulach Oct 3, 2023
9c8b3e3
Merging with removal of onExceptionCallback
JaroslavTulach Oct 4, 2023
a68cd01
Deactivate self.impl
JaroslavTulach Oct 4, 2023
40fa087
Instrument tail recursive fibonacci
JaroslavTulach Oct 4, 2023
6fefaf3
Nicer display for builtin functions without source section
JaroslavTulach Oct 5, 2023
bfa4577
Testing behavior of on_call
JaroslavTulach Oct 5, 2023
f65c19a
Allow the on_call callback to change the result of function invocation
JaroslavTulach Oct 5, 2023
700c02c
on_enter replaces the whole regular execution and avoids on_call
JaroslavTulach Oct 5, 2023
6352d53
More robust, immutable implementation of Instrumentor
JaroslavTulach Oct 5, 2023
8f3bae5
Increase SerialVersionUID to prevent caches errors
JaroslavTulach Oct 5, 2023
7e7d61f
Increase SerialVersionUID to prevent caches errors
JaroslavTulach Oct 5, 2023
a5c7aa4
Note about Meta.instrument & Instrumentor API
JaroslavTulach Oct 5, 2023
7d12a37
Test to verify Instrumentor can be GCed
JaroslavTulach Oct 5, 2023
958ac95
Don't mangle return values when a binding handle has already been dis…
JaroslavTulach Oct 5, 2023
8b3d195
Using Windows version of the file
JaroslavTulach Oct 6, 2023
c303d1c
Removing obsolete code
JaroslavTulach Oct 6, 2023
e1b25bd
Resolving conflicts
JaroslavTulach Oct 7, 2023
b525fff
Merge branch 'develop' into wip/jtulach/Instrumenter_7683
mergify[bot] Oct 7, 2023
24b2976
Merge branch 'develop' into wip/jtulach/Instrumenter_7683
mergify[bot] Oct 9, 2023
22d3da1
Merge branch 'develop' into wip/jtulach/Instrumenter_7683
mergify[bot] Oct 9, 2023
0e49f2c
Trying to convince Git on Windows to not convert LF endings
JaroslavTulach Oct 9, 2023
a8da9f6
Convert CRLF to LF in the CLI tests
JaroslavTulach Oct 9, 2023
0f20687
Four more CRLF fixes
JaroslavTulach Oct 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Meta.enso
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ type Unresolved_Symbol
scope : Any
scope self = get_unresolved_symbol_scope self.value

## ADVANCED
GROUP Metadata

Starts building an instrumentation for a given node
instrument : Instrumentor
instrument self = Instrumentor.Value (instrumentor_builtin "newBuilder" [ self.value ])

type Error
## PRIVATE
ADVANCED
Expand Down Expand Up @@ -561,3 +568,24 @@ get_short_type_name typ = @Builtin_Method "Meta.get_short_type_name"
- constructor: the constructor to get the declaring type of.
get_constructor_declaring_type : Any -> Any
get_constructor_declaring_type constructor = @Builtin_Method "Meta.get_constructor_declaring_type"

instrumentor_builtin op args = @Builtin_Method "Meta.instrumentor_builtin"

# Builder to create instrumentation for a function
JaroslavTulach marked this conversation as resolved.
Show resolved Hide resolved
type Instrumentor
Value impl
on_enter self (fn : Text -> Any | Nothing) =
JaroslavTulach marked this conversation as resolved.
Show resolved Hide resolved
instrumentor_builtin "onEnter" [ self.impl, fn ]
self
on_return self (fn : Text -> Any -> Nothing) =
instrumentor_builtin "onReturn" [ self.impl, fn ]
self
on_function self (fn : Text -> Any | Nothing) =
instrumentor_builtin "onFunction" [ self.impl, fn ]
self
on_exception self (fn : Any -> Nothing) =
instrumentor_builtin "onException" [ self.impl, fn ]
self
activate self =
instrumentor_builtin "activate" [ self.impl ]
self
JaroslavTulach marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.enso.polyglot.debugger;

import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.instrumentation.EventBinding;
import com.oracle.truffle.api.instrumentation.ExecutionEventNodeFactory;
import com.oracle.truffle.api.interop.TruffleObject;
import java.util.UUID;

public interface IdExecutionService {
String INSTRUMENT_ID = "id-value-extractor";

public interface Callbacks {
/**
* Finds out previously computed result for given id. If a result is returned, then the
* execution of given node is skipped and the value is returned back.
*
* @param nodeId identification of the node to be computed
* @return {@code null} should the execution of the node be performed; any other value to skip
* the execution and return the value as a result.
*/
Object findCachedResult(UUID nodeId);

/**
* Notifies when an execution of a node is over.
*
* @param nodeId identification of the node to be computed
* @param result the just computed result
* @param isPanic was the result a panic?
* @param nanoElapsedTime how long it took to compute the result?
*/
void updateCachedResult(UUID nodeId, Object result, boolean isPanic, long nanoElapsedTime);

/**
* Notification when a returned value is a function.
*
* @param nodeId identification of the node to be computed
* @param result info about function call
* @return {@code null} should the execution of the node be performed; any other value to skip
* the execution and return the value as a result.
*/
Object onFunctionReturn(UUID nodeId, TruffleObject result);

/**
* Notification on an exception.
*
* @param e the reported exception
*/
void onExceptionalCallback(Exception e);
}

/**
* Attach a new event node factory to observe identified nodes within given function.
*
* @param module module that contains the code
* @param entryCallTarget the call target being observed.
* @param callbacks the interface to receive notifications
* @param timer the execution timer.
* @return a reference to the attached event node factory.
*/
EventBinding<ExecutionEventNodeFactory> bind(
TruffleObject module, CallTarget entryCallTarget, Callbacks callbacks, Object timer);
}
Loading
Loading