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

Rework stack-frame handling in the VM #255

Merged
merged 1 commit into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions compiler/ast/reports.nim
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ type
currentExceptionA*, currentExceptionB*: PNode
traceReason*: ReportKind
stacktrace*: seq[tuple[sym: PSym, location: TLineInfo]]
skipped*: int

of rsemReportCountMismatch,
rsemWrongNumberOfVariables:
Expand Down
12 changes: 9 additions & 3 deletions compiler/front/cli_reporter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -527,13 +527,19 @@ proc reportBody*(conf: ConfigRef, r: SemReport): string =

of rsemVmStackTrace:
result = "stack trace: (most recent call last)\n"
for idx, (sym, loc) in r.stacktrace:
for idx in countdown(r.stacktrace.high, 0):
let (sym, loc) = r.stacktrace[idx]
result.add(
conf.toStr(loc),
" ",
sym.name.s,
if idx == r.stacktrace.high: "" else: "\n"
if sym != nil: sym.name.s else: "???"
)
if r.skipped > 0 and idx == r.stacktrace.high:
# The entry point is always the last element in the list
result.add("\nSkipped ", r.skipped, " entries, calls that led up to printing")

if idx > 0:
result.add("\n")

of rsemVmUnhandledException:
result.addf(
Expand Down
Loading