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

cgirgen: instrument with frameMsg #1399

Merged
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
2 changes: 1 addition & 1 deletion compiler/backend/ccgexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ proc useData(p: BProc, x: ConstId, typ: PType): string =

proc expr(p: BProc, n: CgNode, d: var TLoc) =
when defined(nimCompilerStacktraceHints):
frameMsg(p.config, n)
frameMsg(p.config, n.info)
p.currLineInfo = n.info

case n.kind
Expand Down
9 changes: 9 additions & 0 deletions compiler/backend/cgirgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ import std/options as std_options
from compiler/ast/ast import newSym, newType, rawAddSon
from compiler/sem/semdata import makeVarType

when defined(nimCompilerStacktraceHints):
import compiler/utils/debugutils

type
TranslateCl = object
graph: ModuleGraph
Expand Down Expand Up @@ -557,6 +560,9 @@ proc stmtToIr(tree: MirBody, env: MirEnv, cl: var TranslateCl,
let n {.cursor.} = tree.get(cr)
let info = cr.info ## the source information of `n`

when defined(nimCompilerStacktraceHints):
frameMsg(cl.graph.config, info)

template to(kind: CgNodeKind, args: varargs[untyped]) =
stmts.add newStmt(kind, info, args)

Expand Down Expand Up @@ -683,6 +689,9 @@ proc exprToIr(tree: MirBody, cl: var TranslateCl,
let n {.cursor.} = get(tree, cr)
let info = cr.info

when defined(nimCompilerStacktraceHints):
frameMsg(cl.graph.config, info)

template op(kind: CgNodeKind, e: CgNode): CgNode =
newOp(kind, info, cl.map(n.typ), e)

Expand Down
8 changes: 4 additions & 4 deletions compiler/utils/debugutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -636,13 +636,13 @@ template frameMsg*(c: ConfigRef, n: PNode) =
$n.info.line,
$n.info.col]

template frameMsg*(c: ConfigRef, n: CgNode) =
template frameMsg*(c: ConfigRef, info: TLineInfo) =
{.line.}:
setFrameMsg "$1 $2($3, $4)" % [
$n.kind,
c.toFullPath(n.info.fileIndex),
$n.info.line,
$n.info.col]
c.toFullPath(info.fileIndex),
$info.line,
$info.col]

const locOffset = -2

Expand Down
2 changes: 1 addition & 1 deletion compiler/vm/vmgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2998,7 +2998,7 @@ proc binaryArith(c: var TCtx, e, x, y: CgNode, dest: var TDest,

proc gen(c: var TCtx; n: CgNode; dest: var TDest) =
when defined(nimCompilerStacktraceHints):
frameMsg c.config, n
frameMsg c.config, n.info

case n.kind
of cnkProc:
Expand Down
Loading