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

coredump: Add gosym sub command #234

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

felixge
Copy link
Member

@felixge felixge commented Nov 10, 2024

gosym symbolizes go test cases using gopclntab and prints them. This is useful for
debugging the correctness of go stack unwinding results.

Example:

$ go run ./tools/coredump gosym -case ./tools/coredump/testdata/arm64/hello.3345.hello3.body.stp-after-bl.json
{
  "coredump-ref": "c5cafafe70f6a5aa9513c11e6606ad1a5ff2396a636766e6fc05b3c0c132a9d3",
  "threads": [
    {
      "lwp": 3662,
      "frames": [
        "main.hello3 in /media/psf/devel/prodfiler/utils/coredump/testsources/go/hello.go:30 (hello.3345+0x90c94)",
        "main.hello2 in /media/psf/devel/prodfiler/utils/coredump/testsources/go/hello.go:24 (hello.3345+0x90c43)",
        "main.hello1 in /media/psf/devel/prodfiler/utils/coredump/testsources/go/hello.go:16 (hello.3345+0x90b3b)",
        "main.hello in /media/psf/devel/prodfiler/utils/coredump/testsources/go/hello.go:11 (hello.3345+0x90afb)",
        "main.main in /media/psf/devel/prodfiler/utils/coredump/testsources/go/hello.go:46 (hello.3345+0x90e4b)",
        "runtime.main in /usr/local/go/src/runtime/proc.go:250 (hello.3345+0x43533)",
        "runtime.goexit in /usr/local/go/src/runtime/asm_arm64.s:1165 (hello.3345+0x6c513)"
      ]
    },
    {
      "lwp": 3664,
      "frames": [
        "runtime.usleep in /usr/local/go/src/runtime/sys_linux_arm64.s:142 (hello.3345+0x6d324)",
        "runtime.sysmon in /usr/local/go/src/runtime/proc.go:5145 (hello.3345+0x4eec7)",
        "runtime.mstart1 in /usr/local/go/src/runtime/proc.go:1425 (hello.3345+0x46237)",
        "runtime.mstart0 in /usr/local/go/src/runtime/proc.go:1382 (hello.3345+0x46187)",
        "runtime.mstart in /usr/local/go/src/runtime/asm_arm64.s:128 (hello.3345+0x69f5f)"
      ]
    },
    {
      "lwp": 3665,
      "frames": [
        "runtime.futex in /usr/local/go/src/runtime/sys_linux_arm64.s:666 (hello.3345+0x6d9bc)",
        "runtime.futexsleep in /usr/local/go/src/runtime/os_linux.go:69 (hello.3345+0x3d6fb)",
        "runtime.notesleep in /usr/local/go/src/runtime/lock_futex.go:160 (hello.3345+0x1993f)",
        "runtime.stopm in /usr/local/go/src/runtime/proc.go:1457 (hello.3345+0x47b13)",
        "runtime.findRunnable in /usr/local/go/src/runtime/proc.go:2866 (hello.3345+0x4938b)",
        "runtime.schedule in /usr/local/go/src/runtime/proc.go:3206 (hello.3345+0x4a3a7)",
        "runtime.park_m in /usr/local/go/src/runtime/proc.go:3355 (hello.3345+0x4a8ff)",
        "runtime.mcall in /usr/local/go/src/runtime/asm_arm64.s:192 (hello.3345+0x69fd3)"
      ]
    },
    {
      "lwp": 3666,
      "frames": [
        "runtime.futex in /usr/local/go/src/runtime/sys_linux_arm64.s:666 (hello.3345+0x6d9bc)",
        "runtime.futexsleep in /usr/local/go/src/runtime/os_linux.go:69 (hello.3345+0x3d6fb)",
        "runtime.notesleep in /usr/local/go/src/runtime/lock_futex.go:160 (hello.3345+0x1993f)",
        "runtime.stopm in /usr/local/go/src/runtime/proc.go:1457 (hello.3345+0x47b13)",
        "runtime.startlockedm in /usr/local/go/src/runtime/proc.go:2470 (hello.3345+0x485db)",
        "runtime.schedule in /usr/local/go/src/runtime/proc.go:3240 (hello.3345+0x4a363)",
        "runtime.park_m in /usr/local/go/src/runtime/proc.go:3355 (hello.3345+0x4a8ff)",
        "runtime.mcall in /usr/local/go/src/runtime/asm_arm64.s:192 (hello.3345+0x69fd3)"
      ]
    },
    {
      "lwp": 3667,
      "frames": [
        "runtime.futex in /usr/local/go/src/runtime/sys_linux_arm64.s:666 (hello.3345+0x6d9bc)",
        "runtime.futexsleep in /usr/local/go/src/runtime/os_linux.go:69 (hello.3345+0x3d6fb)",
        "runtime.notesleep in /usr/local/go/src/runtime/lock_futex.go:160 (hello.3345+0x1993f)",
        "runtime.stopm in /usr/local/go/src/runtime/proc.go:1457 (hello.3345+0x47b13)",
        "runtime.findRunnable in /usr/local/go/src/runtime/proc.go:2866 (hello.3345+0x4938b)",
        "runtime.schedule in /usr/local/go/src/runtime/proc.go:3206 (hello.3345+0x4a3a7)",
        "runtime.park_m in /usr/local/go/src/runtime/proc.go:3355 (hello.3345+0x4a8ff)",
        "runtime.mcall in /usr/local/go/src/runtime/asm_arm64.s:192 (hello.3345+0x69fd3)"
      ]
    }
  ],
  "modules": [
    {
      "ref": "bb87b9bba238372aad8a65bacbf088583cf7a580daa23abfed2467a19307c707",
      "local-path": "/media/psf/devel/prodfiler/utils/coredump/testsources/go/hello.3345"
    }
  ]
}

@felixge felixge requested review from a team as code owners November 10, 2024 14:46
gosym symbolizes go test cases using addr2line. This is useful for
debugging the correctness of go stack unwinding results.
@felixge felixge force-pushed the felix.geisendoerfer/coredump-gosym branch from 91354e8 to 0177cef Compare November 10, 2024 14:48
tools/coredump/gosym.go Outdated Show resolved Hide resolved
This enables gosym to work with
tesdata/arm64/go.symbhack.readheader.json which references several
modules.
tools/coredump/gosym.go Outdated Show resolved Hide resolved
tools/coredump/gosym.go Outdated Show resolved Hide resolved
tools/coredump/gosym.go Outdated Show resolved Hide resolved
tools/coredump/gosym.go Outdated Show resolved Hide resolved
Copy link
Member Author

@felixge felixge left a comment

Choose a reason for hiding this comment

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

Thanks for the review, I incorporated your suggestions 🙇

@felixge felixge requested a review from athre0z November 10, 2024 20:38
tools/coredump/gosym.go Outdated Show resolved Hide resolved
@fabled
Copy link
Contributor

fabled commented Nov 11, 2024

Could this instead be a flag for analyze command instead of a new command? Especially I'd expect this to not be Go specific. I would also love to see/follow up with the ELF dynamic symbol decoration based on same flag.

@felixge
Copy link
Member Author

felixge commented Nov 11, 2024

Could this instead be a flag for analyze command instead of a new command?

I could try that. What would you like to name this flag? -nativesym ?

Especially I'd expect this to not be Go specific. I would also love to see/follow up with the ELF dynamic symbol decoration based on same flag.

I probably won't have time to take care of non-Go binaries for now. This is already a bit of yak shave since what I'm really trying to do is debug and improve some go unwinding issues I'm seeing 😅. But yeah, making this more generic sounds good to me.

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