使用gdb
发布日期:2021-06-30 18:53:39 浏览次数:3 分类:技术文章

本文共 2351 字,大约阅读时间需要 7 分钟。

1、gdb调试

gdb 对于看系统内部是非常有用. 在这个级别精通调试器的使用要求对 gdb 命令有信心,

需要理解目标平台的汇编代码, 以及对应源码和优化的汇编码的能力.
LINUX DEVICE DRIVERS,3RD EDITION
调试器必须把内核作为一个应用程序来调用. 除了指定内核映象的文件名之外, 你需要在
命令行提供一个核心文件的名子. 对于一个运行的内核, 核心文件是内核核心映象,
/proc/kcore. 一个典型的 gdb 调用看来如下:
gdb /usr/src/linux/vmlinux /proc/kcore
第一个参数是非压缩的 ELF 内核可执行文件的名子, 不是 zImage 或者 bzImage 或者给
启动环境特别编译的任何东东.
gdb 命令行的第二个参数是核心文件的名子. 如同任何 /proc 中的文件, /proc/kcore
是在被读的时候产生的. 当 read 系统调用在 /proc 文件系统中执行时, 它映射到一个
数据产生函数,而不是一个数据获取函数; 我们已经在本章”使用 /proc 文件系统”一节中
利用了这个特点. kcore 用来代表内核”可执行文件”, 以一个核心文件的形式; 它是一个
巨大的文件, 因为他代表整个的内核地址空间, 对应于所有的物理内存. 从 gdb 中, 你
可查看内核变量,通过发出标准 gdb 命令. 例如, p jiffies 打印时钟的从启动到当前时
间的嘀哒数

weiqifa@weiqifa-Inspiron-3847:~/weiqifa/new_tm100/tm100$ vim wmkkernel weiqifa@weiqifa-Inspiron-3847:~/weiqifa/new_tm100/tm100$ find ./out/ -iname vmlinux./out/target/product/mid713l_lp_lvds/obj/KERNEL_OBJ/arch/arm/boot/compressed/vmlinux./out/target/product/mid713l_lp_lvds/obj/KERNEL_OBJ/vmlinux^Cweiqifa@weiqifa-Inspiron-3847:~/weiqifa/new_tm100/tm100$ gdb ./out/target/product/mid713l_lp_lvds/obj/KERNEL_OBJ/vmlinux /proc/GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1Copyright (C) 2014 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "x86_64-linux-gnu".Type "show configuration" for configuration details.For bug reporting instructions, please see:
.Find the GDB manual and other documentation resources online at:
.For help, type "help".Type "apropos word" to search for commands related to "word"...Reading symbols from ./out/target/product/mid713l_lp_lvds/obj/KERNEL_OBJ/vmlinux...done."/proc/" is not a core dump: Is a directory(gdb) l* tpd_down0xc05ca0ac is in tpd_down (/home/weiqifa/weiqifa/new_tm100/tm100/kernel/mediatek/custom/out/kernel/touchpanel/mtk_gslX680.c:689).684 685 }686 #endif687 688 void tpd_down( int id, int x, int y, int p) 689 {690 print_info("============tpd_down id: %d, x:%d, y:%d============ \n", id, x, y);691 while(1);692 input_report_key(tpd->dev, BTN_TOUCH, 1);693 input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, 1);(gdb)

2、在内核驱动里面加上一个while(1);系统会不会挂掉

上面的代码就是我加的while(1)代码。

linux内核是进程调度的,系统肯定没有崩溃,但是你加代码的位置,这个驱动已经用不了了。

转载地址:https://linus.blog.csdn.net/article/details/49888329 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:linux自旋锁
下一篇:Linux shell sed awk

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2024年04月29日 05时00分11秒