Skip to content

Commit

Permalink
tests: linux_kernel: test built-in ORC unwinding
Browse files Browse the repository at this point in the history
Unwinding through a kernel module with no DWARF info would have been
impossible without support of built-in ORC. Further, the tests here
would not pass without 329bd5d ("Make StackFrame.name fall back to
symbol/PC and add StackFrame.function_name").

Signed-off-by: Stephen Brennan <[email protected]>
  • Loading branch information
brenns10 committed Dec 20, 2024
1 parent 9571743 commit 17872c3
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/linux_kernel/test_stack_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import unittest

from _drgn_util.platform import NORMALIZED_MACHINE_NAME
from drgn import Object, Program, reinterpret
from drgn import MissingDebugInfoError, Object, Program, reinterpret
from drgn.helpers.linux import load_module_kallsyms
from tests import assertReprPrettyEqualsStr, modifyenv
from tests.linux_kernel import (
LinuxKernelTestCase,
Expand Down Expand Up @@ -59,6 +60,32 @@ def test_by_pid_dwarf(self):
def test_by_pid_orc(self):
self._test_by_pid(True)

@unittest.skipUnless(
NORMALIZED_MACHINE_NAME == "x86_64",
f"{NORMALIZED_MACHINE_NAME} does not use ORC",
)
@skip_unless_have_test_kmod
def test_by_pid_builtin_orc(self):
# Create a program with the core kernel debuginfo loaded,
# but without module debuginfo. Load a symbol finder using
# kallsyms so that the module's stack traces can still have
# usable frame names.
prog = Program()
prog.set_kernel()
try:
prog.load_default_debug_info()
except MissingDebugInfoError:
pass
kallsyms = load_module_kallsyms(prog)
prog.register_symbol_finder("module_kallsyms", kallsyms, enable_index=1)
for thread in prog.threads():
if b"drgn_test_kthread".startswith(thread.object.comm.string_()):
pid = thread.tid
break
else:
self.fail("couldn't find drgn_test_kthread")
self._test_drgn_test_kthread_trace(prog.stack_trace(pid))

@skip_unless_have_test_kmod
def test_by_pt_regs(self):
pt_regs = self.prog["drgn_test_kthread_pt_regs"]
Expand Down

0 comments on commit 17872c3

Please sign in to comment.