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

Fix stack trace trimming across Driver/ChiselStage #1771

Merged
merged 2 commits into from
Feb 11, 2021

Conversation

seldridge
Copy link
Member

@seldridge seldridge commented Feb 3, 2021

Fix bug in stack trace trimming behavior. Now, the following is what
happens:

  1. The Builder, if catching accumulated errors, will now throw a
    ChiselException with a Scala-trimmed Stack trace. Previously, this
    would throw the full excpetion.
  2. The Elaborate phase handles stack trace trimming. By default, any
    Throwable thrown during elaboration will have its stack
    trace mutably trimmed and is rethrown. A logger.error is printed
    stating that there was an error during elaboration and how the user
    can turn on the full stack trace. If the --full-stacktrace option
    is on, then the Throwable is not caught and only the first
    logger.error (saying that elaboration failed) will be printed.
  3. ChiselStage (the class), ChiselStage$ (the object), and ChiselMain
    all inherit the behavior of (2).

Mutable stack trace trimming behavior is moved into an implicit
class (previously this was defined on ChiselException only) so this
can be applied to any Throwable.

No StageErrors are now thrown anymore. However, StageErrors may still
be caught by ChiselMain (since it is a StageMain).

Testing is added for ChiselMain, ChiselStage, and ChiselStage$ to test
all this behavior.

Fixes #1763. (I think...)

Contributor Checklist

  • Did you add Scaladoc to every public function/method?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you add appropriate documentation in docs/src?
  • Did you state the API impact?
  • Did you specify the code generation impact?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • bug fix
  • code refactoring

API Impact

None for actual user-facing API. Some exception behavior is changed.

Backend Code Generation Impact

None.

Desired Merge Strategy

  • Squash: The PR will be squashed and merged (choose this if you have no preference.

Release Notes

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels?
  • Did you mark the proper milestone (3.2.x, 3.3.x, 3.4.0, 3.5.0) ?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you mark as Please Merge?

@jackkoenig
Copy link
Contributor

Any Driver work here is going to conflict with #1730, any thoughts @seldridge and @sequencer?

@seldridge
Copy link
Member Author

seldridge commented Feb 3, 2021

No real conflict as far as I'm concerned. If #1730 goes first, then this PR should drop its Driver changes (because it doesn't exist). If this goes before #1730, then #1730 should still remove the driver.

@sequencer
Copy link
Member

I think if Driver will be dropped at last. So let's get #1730 merged first?

@seldridge
Copy link
Member Author

There are some weird interactions with capturing stdout and checking it seemingly having a weird interaction with the Logger. I'm also refactoring this so that it can be applied to the master branch and to 3.4.x. (I was incorrect above, this needs to be backported so that we can fix this in 3.4.3.)

@seldridge
Copy link
Member Author

Manual backport to 3.4.x is here: #1773.

@seldridge seldridge marked this pull request as ready for review February 4, 2021 06:49
Copy link
Contributor

@jackkoenig jackkoenig left a comment

Choose a reason for hiding this comment

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

This is fantastic, I have a few comments I'd like answered but the tests are great and I love the simplified and unified functionality

src/main/scala/chisel3/stage/phases/Elaborate.scala Outdated Show resolved Hide resolved
src/test/scala/chiselTests/stage/ChiselStageSpec.scala Outdated Show resolved Hide resolved
@seldridge seldridge force-pushed the dev/seldridge/issue-1763 branch from 65460ef to 4ff512e Compare February 10, 2021 22:54
@seldridge seldridge requested a review from jackkoenig February 10, 2021 22:55
@seldridge
Copy link
Member Author

Ready for re-review. Also, the backport (#1773) should be reviewed, too. I'm currently maintaining the backport and then cherry-picking onto master for this PR.

Copy link
Contributor

@jackkoenig jackkoenig left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Fix bug in stack trace trimming behavior. Now, the following is what
happens:

1. The Builder, if catching accumulated errors, will now throw a
   ChiselException with a Scala-trimmed Stack trace. Previously, this
   would throw the full excpetion.
2. The Elaborate phase handles stack trace trimming. By default, any
   Throwable thrown during elaboration will have its stack
   trace *mutably* trimmed and is rethrown. A logger.error is printed
   stating that there was an error during elaboration and how the user
   can turn on the full stack trace. If the --full-stacktrace option
   is on, then the Throwable is not caught and only the first
   logger.error (saying that elaboration failed) will be printed.
3. ChiselStage (the class), ChiselStage$ (the object), and ChiselMain
   all inherit the behavior of (2).

Mutable stack trace trimming behavior is moved into an implicit
class (previously this was defined on ChiselException only) so this
can be applied to any Throwable.

No StageErrors are now thrown anymore. However, StageErrors may still
be caught by ChiselMain (since it is a StageMain).

Testing is added for ChiselMain, ChiselStage, and ChiselStage$ to test
all this behavior.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
@seldridge seldridge force-pushed the dev/seldridge/issue-1763 branch from 1e92374 to edfbcad Compare February 11, 2021 01:56
@seldridge seldridge added the Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI. label Feb 11, 2021
@mergify mergify bot merged commit 2b5466c into master Feb 11, 2021
@seldridge seldridge deleted the dev/seldridge/issue-1763 branch February 11, 2021 03:20
jackkoenig pushed a commit that referenced this pull request Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stacktrace not trimmed or trimmed stacktrace ruined by additionnal full stacktrace
5 participants