miscellaneous_tips:20_software_development:kernel_drivers:showing_real_kernel_addresses_for_dmesg_output

Showing Real Kernel Addresses for 'dmesg' Output

In current kernel versions, if a pointer is to be printed in a message to the kernel log, the commonly used format string %p prints only a hash of the pointer value. This is for security reasons, but not very helpful for debugging.

If a real pointer value is to be printed, e.g. %px has to be used instead, e.g.

int i;
printk( KERN_INFO "Address of i: %px\n", &i );

There is quite a number of variations for the %p format specifier for different purposes, see e.g.:

:!: The new format specifier %px was introduced around Linux kernel 4.15 and may not be supported by older kernels.


Martin Burnicki martin.burnicki@burnicki.net, last updated 2022-01-19

  • miscellaneous_tips/20_software_development/kernel_drivers/showing_real_kernel_addresses_for_dmesg_output.txt
  • Zuletzt geändert: 2022-01-19 11:54
  • von martin