Skip to content

Commit

Permalink
helpers: support dmesg with RHEL 7
Browse files Browse the repository at this point in the history
RHEL 7 kernel still uses `struct log *` for a structured kernel log
instead of `struct printk_log *`, so lets try to support it.

Tested on:

* `3.10.0-229`
* `3.10.0-1160.80.1`
* `3.10.0-1160.83.1`

This should have no impact on existing supported cases.

Signed-off-by: Oleksandr Natalenko <[email protected]>
  • Loading branch information
pfactum committed Jul 25, 2023
1 parent 859b3c5 commit de5f501
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drgn/helpers/linux/printk.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,14 @@ def add_record(current_id: int) -> None:


def _get_printk_records_structured(prog: Program) -> List[PrintkRecord]:
printk_logp_type = prog.type("struct printk_log *")
try:
printk_logp_type = prog.type("struct printk_log *")
except LookupError:
# Before Linux kernel commit 62e32ac3505a ("printk: rename struct log
# to struct printk_log") (in v3.11), records were "struct log" instead
# of "struct printk_log". RHEL 7 kernel still uses old naming.
printk_logp_type = prog.type("struct log *")

have_caller_id = printk_logp_type.type.has_member("caller_id")
LOG_CONT = prog["LOG_CONT"].value_()

Expand Down

0 comments on commit de5f501

Please sign in to comment.