-
Notifications
You must be signed in to change notification settings - Fork 485
Add a way to generate callstack trace message #7148
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
base: master
Are you sure you want to change the base?
Conversation
Added `generate-callstack` option, which, when turned on, will replace every occurances of `PlutusTx.Trace.callStack` with the callstack message at its relative position. This is "rudimentary" because it won't correctly handled when `PlutusTx.Trace.callStack` is called inside of function, call it `bob`, which gets called in multiple locations. It will use callstack when `bob` was called the first time and use that exact callstack in any subsequent calls of `bob` which can be very misleading. This, however, is the best we can get without needing to pass around callstack values at UPLC level or generating multiple copies of `bob` for all of its unique relative positions.
|
Figured out a way to do "real" callstack, with some runtime overhead. This will handle something like this correctly: silly, silly2, silly3, silly4 :: Integer -> Integer
silly x = silly2 x
silly2 x = silly3 x
silly3 x = silly4 x
silly4 x = bob
bob, rob, cob :: Integer
bob = traceError callStack
rob = traceError callStack
cob = traceError callStack
tom :: Integer -> Integer
tom 1 = silly 1
tom 2 = rob
tom 3 = cob
tom _ = 42
|
-- FIXME: Variables will miss span information when the module they are defined | ||
-- in is loaded from cache instead of getting compiled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a workaround for this?
\-nestedLinear:test/Plugin/CallStack/Spec.hs:63:1-63:12 | ||
\-nestedLinear2:test/Plugin/CallStack/Spec.hs:64:1-64:13 | ||
\-nestedLinear3:test/Plugin/CallStack/Spec.hs:65:1-65:13 | ||
\-nestedLinear4:test/Plugin/CallStack/Spec.hs:66:1-66:13 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The span provided points to the definition of executed function instead of location of invocation. Is this fine?
... I think it's fine
@@ -0,0 +1,4 @@ | |||
### Added | |||
- `generate-callstack` option: When enabled, the plugin replaces every occurrence of `PlutusTx.Trace.callStack` with a `BuiltinString` containing the callstack at that relative point. Enabling this option incurs execution-cost overhead: it adds an extra callstack argument to all user-defined functions, and every time they are invoked it requires having extra application node for providing the current callstack. When `gennerate-callstack` is not enabled, `PlutusTx.Trace.callStack` is string "<CallStack>". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `generate-callstack` option: When enabled, the plugin replaces every occurrence of `PlutusTx.Trace.callStack` with a `BuiltinString` containing the callstack at that relative point. Enabling this option incurs execution-cost overhead: it adds an extra callstack argument to all user-defined functions, and every time they are invoked it requires having extra application node for providing the current callstack. When `gennerate-callstack` is not enabled, `PlutusTx.Trace.callStack` is string "<CallStack>". | |
- `generate-callstack` option: When enabled, the plugin replaces every occurrence of `PlutusTx.Trace.callStack` with a `BuiltinString` containing the callstack at that relative point. Enabling this option incurs execution-cost overhead: it adds an extra callstack argument to all user-defined functions, and every time they are invoked it requires having extra application node for providing the current callstack. When `generate-callstack` is not enabled, `PlutusTx.Trace.callStack` is string "<CallStack>". |
closes #7146.
Add plugin option to generate callstack trace message. Currently this won't handle cases when a function hasPlutusTx.Trace.callStack
and that function is called in multiple places. It will just use callstack of the first occurance :/ (working on it. more detail on first commit message).I redid everything, now it will have correct callstack, but with some execution cost overhead. I'm not too unhappy about this since callstack in general is almost exclusively used for debug scripts anyways.
Example