Linux printk formats
- 了解 linxu printk formats
1.Integer types
14 If variable is of Type, use printk format specifier:15 ------------------------------------------------------------16 int %d or %x17 unsigned int %u or %x18 long %ld or %lx19 unsigned long %lu or %lx20 long long %lld or %llx21 unsigned long long %llu or %llx22 size_t %zu or %zx23 ssize_t %zd or %zx24 s32 %d or %x25 u32 %u or %x26 s64 %lld or %llx27 u64 %llu or %llx
2.Symbols/Function Pointers
53 %pF versatile_init+0x0/0x11054 %pf versatile_init55 %pS versatile_init+0x0/0x11056 %pSR versatile_init+0x9/0x11057 (with __builtin_extract_return_addr() translation)58 %ps versatile_init59 %pB prev_fn_of_versatile_init+0x88/0x8878 Examples::80 printk("Going to call: %pF\n", gettimeofday);81 printk("Going to call: %pF\n", p->func);82 printk("%s: called from %pS\n", __func__, (void *)_RET_IP_);83 printk("%s: called from %pS\n", __func__,84 (void *)__builtin_return_address(0)); 85 printk("Faulted at %pS\n", (void *)regs->ip);86 printk(" %s%pB\n", (reliable ? "" : "? "), (void *)*stack);
3.kobjects
352 kobjects
353 ========
354
357 %pO
358
359 Base specifier for kobject based structs. Must be followed with
360 character for specific type of kobject as listed below:
361
362 Device tree nodes:
363
364 %pOF[fnpPcCF]
365
366 For printing device tree nodes. The optional arguments are:
367 f device node full_name
368 n device node name
369 p device node phandle
370 P device node path spec (name + @unit)
371 F device node flags
372 c major compatible string
373 C full compatible string
374 Without any arguments prints full_name (same as %pOFf)
375 The separator when using multiple arguments is ':'377 Examples:
378
379 %pOF /foo/bar@0 - Node full name
380 %pOFf /foo/bar@0 - Same as above
381 %pOFfp /foo/bar@0:10 - Node full name + phandle
382 %pOFfcF /foo/bar@0:foo,device:--P- - Node full name +
383 major compatible string +
384 node flags
385 D - dynamic
386 d - detached
387 P - Populated
388 B - Populated bus
4.Virtual kernel memory layout print
问题描述:查看kernel log,发现.text等无法显示地址,如下所示:
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
[ 0.000000] vmalloc : 0xf0800000 - 0xff800000 ( 240 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xf0000000 ( 768 MB)
[ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
[ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
[ 0.000000] .text : 0x(ptrval) - 0x(ptrval) (4064 kB)
[ 0.000000] .init : 0x(ptrval) - 0x(ptrval) (1024 kB)
[ 0.000000] .data : 0x(ptrval) - 0x(ptrval) ( 158 kB)
[ 0.000000] .bss : 0x(ptrval) - 0x(ptrval) (7425 kB)
解决方法:使用%px即可。
arch/arm/mm/init.c:540 " .text : 0x%px" " - 0x%px" " (%4td kB)\n" 541 " .init : 0x%px" " - 0x%px" " (%4td kB)\n"542 " .data : 0x%px" " - 0x%px" " (%4td kB)\n"543 " .bss : 0x%px" " - 0x%px" " (%4td kB)\n",544
修改之后:
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
[ 0.000000] vmalloc : 0xf0800000 - 0xff800000 ( 240 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xf0000000 ( 768 MB)
[ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
[ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
[ 0.000000] .text : 0xc0008000 - 0xc0400000 (4064 kB)
[ 0.000000] .init : 0xc0500000 - 0xc0600000 (1024 kB)
[ 0.000000] .data : 0xc0600000 - 0xc06274a8 ( 158 kB)
[ 0.000000] .bss : 0xc062d170 - 0xc0d6d250 (7425 kB)
参考:
Documentation/printk-formats.txt(linux-4.14)
Linux printk formats相关推荐
- linux printk 时间戳,linux – kern.log中“00:00:00”时间戳的含义是什么?
我正在寻找kern.log中特定问题的原因.有许多条目的00:00:00时间戳: Jun 11 00:00:00 mymachine kernel: [ 0.000000] Initializing ...
- linux printk 头文件,printk函数详解
printk是内核态信息打印函数,功能和比准C库的printf类似. printk还有信息打印级别. 函数原型: int printk(const char *fmt, ...) 需要的头文件: #i ...
- linux printk 源码,Printk原理简介
可变参数操作宏 假设有一段代码如程序清单 1.3所示: 程序清单 1.3 int printk(const char *fmt, ...) { va_list args; va_start(args, ...
- linux printk 优先级,printk与日志优先级设置
1. 控制台的日志优先级 #define KERN_EMERG "<0>" /* 致命级:紧急事件消息,系统崩溃之前提示, ...
- linux printk 时间戳,printk_time 中时间戳的获取
可以在用prink打的log前面加上时间戳,但这个时间戳是怎么得到的呢? 我们知道printk-> vprintk_emit 1608 asmlinkage int vprintk_emit(i ...
- Linux 驱动 Printk 在终端没有输出
驱动使用printk 来输出信息,而不是 printf!因为在 Linux 内核中没有 printf 这个函数. printk 相当于 printf 的孪生兄妹, printf运行在用户态, prin ...
- linux 内核 printk 使用
在linux 中,内核打印语句 printk() 会将内核信息输出到内核信息缓冲区中.内核信息缓冲区是一个环形缓冲区(ring buffer),因此,如果插入的信息过多,就会将之前的信息冲刷掉. pr ...
- [Linux 基础] -- 驱动调试神器 printk 你掌握了吗?
导读 刚刚开始做Linux相关开发工作时,深感Linux内核代码庞大,要加些自己的驱动进内核代码树,常常深陷bug的泥沼难以自拔,今天来分享一下内核调试利器printk的使用心得. 前面一段时间很忙, ...
- Linux内核之 printk 打印
Linux内核之 printk 打印 前言 一.printk 介绍 1. printk 消息级别 2.内核 printk 文件 二.调整打印级别 1.在 menuconfig 中修改 2.在系统中修改 ...
最新文章
- python读写文件绝对路径_[Spark][Python]对HDFS 上的文件,采用绝对路径,来读取获得 RDD...
- 二叉树代码我写得很乱!!!整理一下思路
- TransactionTemplate和@Transactional注解的区别
- latex在论文中添加行号
- 诗与远方:无题(十六)
- python调用java文件_Python程序中调用Java代码的实践
- 集合代码----小练习3
- javascript基础案例解析
- Android修改读写速度,Android 通过adb测试机器读写速度(rk)
- Ensembl数据库简介
- n维椭球体积公式_钻井常用单位换算及计算公式
- 企业微信网页授权登陆
- win10重装,检测到硬盘错误:在MBR硬盘上没有找到可以引导的分区
- 鸿蒙系统我的二次元之旅,创世神的二次元
- 异构群体机器人协作任务分配(群体智能论文学习)
- GPS定位系统及协议介绍
- GetPrivateProfileString函数之新手上路
- 爱可生开源mysql_爱可生开源社区官网正式发布啦!
- NOIP simulation
- mysql对称_对于《由对称性解2