Showing Real Kernel Addresses in '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_in_dmesg_output.txt
  • Zuletzt geändert: 2023-01-26 16:25
  • von martin