From ff7402abcd4cb88a2482e085df513afd6512ca30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Sun, 15 Mar 2026 13:20:43 +0200 Subject: [PATCH] fix PLT unwinding and add core dump tests --- nativeunwind/elfunwindinfo/elfehframe_x86.go | 4 +-- .../testdata/amd64/debian-echo-plt1.json | 29 +++++++++++++++++++ .../testdata/amd64/debian-echo-plt2.json | 29 +++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 tools/coredump/testdata/amd64/debian-echo-plt1.json create mode 100644 tools/coredump/testdata/amd64/debian-echo-plt2.json diff --git a/nativeunwind/elfunwindinfo/elfehframe_x86.go b/nativeunwind/elfunwindinfo/elfehframe_x86.go index a04f4bde5..fb060b66e 100644 --- a/nativeunwind/elfunwindinfo/elfehframe_x86.go +++ b/nativeunwind/elfunwindinfo/elfehframe_x86.go @@ -169,7 +169,7 @@ func (regs *vmRegs) getUnwindInfoX86() sdtypes.UnwindInfo { info.BaseReg = getUnwinderRegX86(regs.cfa.reg) info.Param = int32(regs.cfa.off) case regExprPLT: - info.Flags = support.UnwindFlagCommand + info.Flags |= support.UnwindFlagCommand info.Param = support.UnwindCommandPLT case regExprRegDeref: reg, _, off, off2 := splitOff(regs.cfa.off) @@ -184,7 +184,7 @@ func (regs *vmRegs) getUnwindInfoX86() sdtypes.UnwindInfo { } } } - if info.BaseReg == support.UnwindRegInvalid { + if info.Flags&support.UnwindFlagCommand == 0 && info.BaseReg == support.UnwindRegInvalid { return sdtypes.UnwindInfoInvalid } return info diff --git a/tools/coredump/testdata/amd64/debian-echo-plt1.json b/tools/coredump/testdata/amd64/debian-echo-plt1.json new file mode 100644 index 000000000..db71b5369 --- /dev/null +++ b/tools/coredump/testdata/amd64/debian-echo-plt1.json @@ -0,0 +1,29 @@ +{ + "coredump-ref": "898161f0dac2f375b028692591093e37bb60a2a43741038d7d4e27ecda49bb4a", + "threads": [ + { + "lwp": 3914, + "frames": [ + "echo+0x2030", + "echo+0x235e", + "libc.so.6+0x27249", + "libc.so.6+0x27304", + "echo+0x2900" + ] + } + ], + "modules": [ + { + "ref": "a049fb47554c6cde2ee452e5d87f6386abb63af7cdcae9cd0dc99fc80e0bcf35", + "local-path": "/usr/bin/echo" + }, + { + "ref": "593bb1d5355658e645f36e6b1f49832691b24e177209765914e4cce51499dbb4", + "local-path": "/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2" + }, + { + "ref": "bff8750fe719e6000791b88b11747dce8772c37118d0b2348044b70819d13835", + "local-path": "/usr/lib/x86_64-linux-gnu/libc.so.6" + } + ] +} diff --git a/tools/coredump/testdata/amd64/debian-echo-plt2.json b/tools/coredump/testdata/amd64/debian-echo-plt2.json new file mode 100644 index 000000000..3025703e1 --- /dev/null +++ b/tools/coredump/testdata/amd64/debian-echo-plt2.json @@ -0,0 +1,29 @@ +{ + "coredump-ref": "8f89a4d0c0f9e552e9a67ebf6151262b8c0f8c97899257c301f3ee46ac7403ae", + "threads": [ + { + "lwp": 3914, + "frames": [ + "echo+0x203b", + "echo+0x235e", + "libc.so.6+0x27249", + "libc.so.6+0x27304", + "echo+0x2900" + ] + } + ], + "modules": [ + { + "ref": "a049fb47554c6cde2ee452e5d87f6386abb63af7cdcae9cd0dc99fc80e0bcf35", + "local-path": "/usr/bin/echo" + }, + { + "ref": "593bb1d5355658e645f36e6b1f49832691b24e177209765914e4cce51499dbb4", + "local-path": "/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2" + }, + { + "ref": "bff8750fe719e6000791b88b11747dce8772c37118d0b2348044b70819d13835", + "local-path": "/usr/lib/x86_64-linux-gnu/libc.so.6" + } + ] +}