Skip to content

runtime: add line info for stack frames#1926

Closed
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-fixedbugs-lineinfo-coverage
Closed

runtime: add line info for stack frames#1926
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-fixedbugs-lineinfo-coverage

Conversation

@cpunion

@cpunion cpunion commented May 24, 2026

Copy link
Copy Markdown
Collaborator

Adds compact LLGo runtime funcinfo metadata and uses it for stack/function lookup.

  • Emits DCE-safe function metadata as strings and links a compact table/string blob/hash table into the binary.
  • Resolves runtime.Caller, CallersFrames, FuncForPC, runtime.Stack, and debug.Stack through dladdr, cached StackTrace frame names, and funcinfo. Linux funcinfo executables narrowly export main-frame dynamic symbols for dladdr.
  • Removes the LLGO_LINEINFO/DWARF/dSYM/llvm-symbolizer path; this PR provides function-level source positions, not statement-level line tables.
  • Preserves stack API frames under optimization by marking the runtime stack wrappers noinline and disabling tail calls there.

Tests cover funcinfo encoding/table emission, DCE safety, Linux link flags, //go:noinline attributes, renamed symbols, Caller/CallersFrames/FuncForPC/Stack/debug.Stack, and fixedbugs/issue29735.go.

@cpunion cpunion force-pushed the codex/goroot-fixedbugs-lineinfo-coverage branch from 570148d to 366b139 Compare May 24, 2026 15:45
@codecov-commenter

codecov-commenter commented May 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cpunion

cpunion commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator Author

Added c9c9cad to cover the Codecov patch gap in cl/compile.go.\n\nWhat changed:\n- Added TestDebugOnlyValueReferrerHelpers in cl/builtin_test.go.\n- It directly covers hasNoSemanticReferrers, debugOnlyPureValue, and the compileInstr debug-only pure value skip branch.\n\nLocal verification:\n- go test ./cl -run 'Test(DebugOnlyValueReferrerHelpers|CompileLargeNilDerefInterfaceGuards)$' -coverprofile=/tmp/llgo-cl-focused.cover\n - go tool cover shows hasNoSemanticReferrers: 100%, debugOnlyPureValue: 100%, and the compileInstr skip branch covered.\n- go test ./cl -run 'Test(DebugOnlyValueReferrerHelpers|CompileLargeNilDerefInterfaceGuards|CompileRangeFuncDeferModule|RangeFuncDeferAnalysisHelpers)$' -count=1\n\nCI/Codecov are pending a fresh run for the new head commit.

@cpunion

cpunion commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator Author

Resolved the latest merge conflict with xgo-dev/main (51d665e). Kept this PR's broader litgen debug metadata handling and did not re-add fixedbugs/issue29735.go to xfail, since it is covered by this PR.\n\nLocal verification:\n- go test -timeout 20m ./chore/litgen -count=1\n- go test -timeout 20m ./cl -run 'Test(DebugOnlyValueReferrerHelpers|CompileLargeNilDerefInterfaceGuards|CompileRangeFuncDeferModule|RangeFuncDeferAnalysisHelpers)$' -count=1\n- git diff --check

@cpunion cpunion force-pushed the codex/goroot-fixedbugs-lineinfo-coverage branch 4 times, most recently from 7ed5055 to b16bf62 Compare June 8, 2026 04:57
@cpunion cpunion force-pushed the codex/goroot-fixedbugs-lineinfo-coverage branch from 14adc9f to 4a27076 Compare June 27, 2026 12:20
@cpunion cpunion marked this pull request as ready for review June 28, 2026 06:09
@cpunion cpunion force-pushed the codex/goroot-fixedbugs-lineinfo-coverage branch 2 times, most recently from 4275534 to 6fdeaee Compare June 28, 2026 12:28
@cpunion cpunion force-pushed the codex/goroot-fixedbugs-lineinfo-coverage branch 15 times, most recently from 44f8a93 to 182c665 Compare June 29, 2026 13:37
@cpunion cpunion force-pushed the codex/goroot-fixedbugs-lineinfo-coverage branch from 182c665 to 94b2350 Compare June 29, 2026 13:59
Comment thread cl/compile.go
goName = funcName(pkgTypes, f, false)
}
pos := p.goProg.Fset.Position(f.Pos())
pkg.EmitFuncInfo(fn.Name(), goName, pos.Filename, pos.Line, pos.Column)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这里记录的原始信息是函数定义的位置的文件名 行号等信息 这样的话 运行时恢复的堆栈就也是定义的位置,而不是调用的位置,这个是预期的吗?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

之前是自定义定义位置加上 llvm-symbolizer,感觉太重了,这个 PR 先移掉。#2002 尝试把调用行也加进来,对比一下数据和运行时开销,先 draft

@cpunion cpunion marked this pull request as draft June 30, 2026 00:23
@cpunion

cpunion commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #2002. The runtime funcinfo/line metadata plan is now tracked in #2004; any remaining stack/function lookup work should build on #2002 rather than this older function-level lineinfo branch.

@cpunion cpunion closed this Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants