linux kernel ptr dump

指针如何打印和调试

Plain Pointers
%p      abcdef12 or 00000000abcdef12
Pointers printed without a specifier extension (i.e unadorned %p) are hashed to prevent leaking information about the kernel memory layout. This has the added benefit of providing a unique identifier. On 64-bit machines the first 32 bits are zeroed. The kernel will print (ptrval) until it gathers enough entropy. If you really want the address see %px below.

Symbols/Function Pointers
%pS     versatile_init+0x0/0x110
%ps     versatile_init
%pF     versatile_init+0x0/0x110
%pf     versatile_init
%pSR    versatile_init+0x9/0x110
        (with __builtin_extract_return_addr() translation)
%pB     prev_fn_of_versatile_init+0x88/0x88

The S and s specifiers are used for printing a pointer in symbolic format. They result in the symbol name with (S) or without (s) offsets. If KALLSYMS are disabled then the symbol address is printed instead.

Note, that the F and f specifiers are identical to S (s) and thus deprecated. We have F and f because on ia64, ppc64 and parisc64 function pointers are indirect and, in fact, are function descriptors, which require additional dereferencing before we can lookup the symbol. As of now, S and s perform dereferencing on those platforms (when needed), so F and f exist for compatibility reasons only.

The B specifier results in the symbol name with offsets and should be used when printing stack backtraces. The specifier takes into consideration the effect of compiler optimisations which may occur when tail-calls are used and marked with the noreturn GCC attribute.

Kernel Pointers
%pK     01234567 or 0123456789abcdef
For printing kernel pointers which should be hidden from unprivileged users. The behaviour of %pK depends on the kptr_restrict sysctl - see Documentation/sysctl/kernel.txt for more details.

Unmodified Addresses
%px     01234567 or 0123456789abcdef


For printing pointers when you really want to print the address. Please consider whether or not you are leaking sensitive information about the kernel memory layout before printing pointers with %px. %px is functionally equivalent to %lx (or %lu). %px is preferred because it is more uniquely grep’able. If in the future we need to modify the way the kernel handles printing pointers we will be better equipped to find the call sites.

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-12 20:40:02       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-12 20:40:02       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-12 20:40:02       57 阅读
  4. Python语言-面向对象

    2024-07-12 20:40:02       68 阅读

热门阅读

  1. 软设之备忘录模式

    2024-07-12 20:40:02       21 阅读
  2. Nginx 高效加速策略:动静分离与缓存详解

    2024-07-12 20:40:02       22 阅读
  3. python 读取pcap文件并筛选数据包

    2024-07-12 20:40:02       20 阅读
  4. 在 Qt 中暂停程序的几种方法

    2024-07-12 20:40:02       20 阅读
  5. C++多态的实现原理

    2024-07-12 20:40:02       22 阅读
  6. 高级前端工程师面试题

    2024-07-12 20:40:02       23 阅读
  7. 实现原理:远程过程调用(RPC)

    2024-07-12 20:40:02       24 阅读