Skip to content

Commit 3cceb68

Browse files
author
aaahuhong
committed
feat(core/events/dropwatch): show stack offsets instead of absolute addresses
`addr` is the return address saved on the stack when the kernel executes `__dev_queue_xmit`, and `sym.Addr` is the starting address of the `__dev_queue_xmit` function in the kernel. The resulting `offset` represents the position inside the function, not the absolute address.
1 parent 60b7e40 commit 3cceb68

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

internal/symbol/ksymbols.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,17 @@ func ksymbolSearch(key uint64) Symbol {
154154
// DumpKernelBackTrace converts the kernel stack address to the kernel symbol
155155
// and returns the Stack structure
156156
func DumpKernelBackTrace(stack []uint64, maxDepth int) Stack {
157-
var addrs []uint64
158157
var s Stack
159158

160159
for i, addr := range stack {
161160
if addr == 0 || i >= maxDepth {
162161
break
163162
}
164-
addrs = append(addrs, addr)
165-
}
166-
167-
for _, addr := range addrs {
168163
sym := ksymbolSearch(addr)
169164
if sym.Name != "" {
170-
s.BackTrace = append(s.BackTrace, fmt.Sprintf("%s/%x %s",
171-
sym.Name, sym.Addr, sym.Module))
165+
offset := addr - sym.Addr
166+
s.BackTrace = append(s.BackTrace, fmt.Sprintf("%s/+%d %s",
167+
sym.Name, offset, sym.Module))
172168
}
173169
}
174170
return s

0 commit comments

Comments
 (0)