-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
helpers: linux: add module kallsyms helpers
Add Python helpers which load module kallsyms and return a symbol index for them. Unlike the /proc/kallsyms and built-in kallsyms, these are quite easy to handle using regular Python & drgn code, so implement them as Python helpers. There are (at least) two use cases for these helpers: 1. After loading CTF and built-in vmlinux kallsyms, support for module kallsyms is still necessary. 2. Sometimes, people only extract vmlinux DWARF debuginfo. Adding module symbols can allow stack traces and other symbolization to work even without module debuginfo. Signed-off-by: Stephen Brennan <[email protected]>
- Loading branch information
Showing
3 changed files
with
156 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (c) 2024 Oracle and/or its affiliates | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
""" | ||
Modules | ||
------- | ||
The ``drgn.helpers.linux.module`` module contains helpers for working with | ||
loaded kernel modules. | ||
""" | ||
from typing import Iterable | ||
|
||
from drgn import Object, Program | ||
from drgn.helpers.linux.list import list_for_each_entry | ||
|
||
__all__ = ("for_each_module",) | ||
|
||
|
||
def for_each_module(prog: Program) -> Iterable[Object]: | ||
""" | ||
Returns all loaded kernel modules | ||
:param prog: Program being debugged | ||
:returns: Iterable of ``struct module *`` objects | ||
""" | ||
return list_for_each_entry("struct module", prog["modules"].address_of_(), "list") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters