Skip to content

Call trace for failing evaluation via new emitter mode #7178

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

Merged
merged 8 commits into from
Jul 15, 2025
Merged

Conversation

SeungheonOh
Copy link
Collaborator

@SeungheonOh SeungheonOh commented Jul 2, 2025

closes #7146.

This replaces #7148. Unlike my original PR which made the plugin generate callstack message, this PR uses already existing profile-all option and make no addition to plugin. Since profile-all option gives function entrance and exit, it is possible to just have another EmitterMode that can make call trace from the trace messages.

I decided added new machinery just for callstack into plugin while we have profile-all which does something similar is unfavorable. This PR is much simpler and doesn't add maintenance burden to the plugin.

We can do something more on the emitter: like putting all call traces together. I kept it simple but let me know if there something that can be improved on emitter

@SeungheonOh SeungheonOh requested a review from Unisay July 2, 2025 05:57
Copy link
Contributor

github-actions bot commented Jul 2, 2025

PR Preview Action v1.6.2

🚀 View preview at
https://IntersectMBO.github.io/plutus/pr-preview/pr-7178/

Built to branch gh-pages at 2025-07-10 16:34 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copy link
Contributor

@Unisay Unisay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach looks less invasive, indeed!

@SeungheonOh
Copy link
Collaborator Author

Sorry for all the formatting error!

Comment on lines 5 to 12
Trace:
-> func:test/CallTrace/Spec.hs:78:1-78:4
func 1
-> nestedLinear:test/CallTrace/Spec.hs:71:1-71:12
-> nestedLinear2:test/CallTrace/Spec.hs:72:1-72:13
-> nestedLinear3:test/CallTrace/Spec.hs:73:1-73:13
-> nestedLinear4:test/CallTrace/Spec.hs:74:1-74:13
-> error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice, IMO: the direction of calls is clear.
Having a space between the function name and its source location makes it even easier to 👀 scan:

Trace:
-> func (test/CallTrace/Spec.hs @ 78:1-78:4)
func 1
-> nestedLinear (test/CallTrace/Spec.hs @ 71:1-71:12)
-> nestedLinear2 (test/CallTrace/Spec.hs @ 72:1-72:13)
-> nestedLinear3 (test/CallTrace/Spec.hs @ 73:1-73:13)
-> nestedLinear4 (test/CallTrace/Spec.hs @ 74:1-74:13)
-> error

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a value in having this golden file: what exactly is being tested here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests that when program got evaluated without failure, there's no enter/exit marker left on the trace log.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explanation makes sense to me. Do you mind embedding it into the name of the golden file, e.g.:
successfullEvaluationYieldsNoTraceLog or something along these lines?

Comment on lines 670 to 671
-- FIXME: Variables will miss span information when the module they are defined
-- in is loaded from cache instead of getting compiled.
Copy link
Contributor

@Unisay Unisay Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have recently agreed to avoid leaving orphaned TODO, FIXME comments in the code. The best course of action would be:

  • Create a github issue, such that a FIXME or TODO work can be a part of our dev process: triaged, assigned to a sprint, assigned to a person ("owned") etc.
  • Amend your FIXME comment with a link to the issue.

(The "triage" role that you assume this sprint includes work on removing such orphaned comments ;-) )

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done #7203

Caused by: error

Trace:
-> func (test/CallTrace/Spec.hs:78:1-78:4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This encoding :78:1-78:4 confuses me: what does each section mean ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from line 78 column 1 to line 78 column 4. this is what SrcSpan pretty printer does. I don't really want to change the pretty instance.

Copy link
Contributor

@Unisay Unisay Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see!
My first attempt to parse it in the head produced this result:

  1. test/CallTrace/Spec.hs
  2. 78
  3. 1-78
  4. 4

🤣

I think that my mental parser trips over the : as a separator between the file path (LHS) and SrcSpan (RHS).
I agree that we don't want to change the way SrcSpan is printed here,
but we can avoid mixing the same char : to separate

  1. File path / Src Span
  2. Line / Column

I suggested to use @ as a 1. separator before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't change this without changing Pretty instances

Just src -> nameStr <> " (" <> show (src ^. srcSpanIso) <> ")"

I think this is okay honestly. This is standard format used by GHC(and other languages as well!), e.g. test/CallTrace/Spec.hs:88:10

module CallTrace.OtherModule where

import PlutusTx.Prelude
import Prelude ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import Prelude ()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, we need this because we don't have NoImplicitPrelude

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add NoImplicitPrelude ? It seems to be more explicit in its purpose than import Prelude ()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, necessity to add explicitly add NoImplicitPrelude to make prelude not implicit!

I generally not prefer adding extra language extension, but I don't really mind here.

Copy link
Contributor

@Unisay Unisay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments.

Copy link
Contributor

@Unisay Unisay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great stuff, thanks a lot!

@SeungheonOh SeungheonOh merged commit 5bdbb8d into master Jul 15, 2025
7 checks passed
@SeungheonOh SeungheonOh deleted the sho/7146-2 branch July 15, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add bind tracing mode
3 participants