Skip to content

Commit

Permalink
Add test for mini debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
zmj64351508 committed Sep 27, 2024
1 parent d6fe436 commit c17890d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Binary file added ebpf/symtab/elf/testdata/elfs/elf.minidebuginfo
Binary file not shown.
23 changes: 23 additions & 0 deletions ebpf/symtab/elf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,26 @@ func TestFindBaseUnalignedSeparateCode(t *testing.T) {
assert.True(t, et.findBase(&ef))
assert.Equal(t, uint64(0x555e3d192000), et.base)
}

func TestMiniDebugInfo(t *testing.T) {
elfCache, _ := NewElfCache(testCacheOptions, testCacheOptions)
logger := util.TestLogger(t)
tab := NewElfTable(logger, &ProcMap{StartAddr: 0x1000, Offset: 0x1000}, ".", "elf/testdata/elfs/elf.minidebuginfo",
ElfTableOptions{
ElfCache: elfCache,
Metrics: metrics.NewSymtabMetrics(nil),
})

syms := []struct {
name string
pc uint64
}{
{"", 0x0},
{"android_res_cancel", 0x1330}, // in .dynsym
{"__on_dlclose", 0x1000}, // in .gnu_debugdata.symtab
}
for _, sym := range syms {
res := tab.Resolve(sym.pc)
require.Equal(t, res, sym.name)
}
}

0 comments on commit c17890d

Please sign in to comment.