使用gdb調試內核遇到的一些問題

 

1 .  make config的時候報下面的錯誤,意思是變量沒有初始化,手動初始化成’NULL’,就行了。html


HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
In file included from scripts/kconfig/zconf.tab.c:2537:0:
scripts/kconfig/menu.c: In function ‘get_symbol_str’:
scripts/kconfig/menu.c:590:18: warning: ‘jump’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     jump->offset = strlen(r->s);
     ~~~~~~~~~~~~~^~~~~~~~~~~~~~
scripts/kconfig/menu.c:551:19: note: ‘jump’ was declared here
  struct jump_key *jump;
                   ^~~~
  HOSTLD  scripts/kconfig/conflinux

2. 如何給upstream內核打patchdom

xzcat ../patch-4.15.12.xz | patch -p1 –Ride

3.  內核config網站

      使用make help 查看可用的configthis

       make i386_defconfig.net

      make menuconfigdebug

在原來配置的基礎上,make menuconfig選中以下選項從新配置Linux,使之攜帶調試信息
kernel hacking—>
[*] compile the kernel with debug info
make從新編譯(時間較長)3d

make clean調試

make –j 4

 

4. 解決gcc找不到文件的問題

http://www.javashuo.com/article/p-pggyvtkt-cc.html

 

5. 關於printk的級別,console最大數字支持15,可是最好不要設置,定位問題可設置爲10

https://blog.csdn.net/weixin_38227420/article/details/79329491

https://www.aliyun.com/jiaocheng/183702.html

6. 關於4.0以上版本gdb調試時設置不了斷點的問題

https://blog.csdn.net/WANG__RONGWEI/article/details/79207536?utm_source=blogxgwz3

取消選項:
[ ] Randomize the address of the kernel image (KASLR)

7. qemu-system-i386 -curses -kernel ./linux-4.15.12/arch/x86/boot/bzImage -initrd ./rootfs.img -S –s

   4.15的qemu  gdb斷點調試,最新內核配置以下

image

 

image

image

image

 

image

image

image

image

image

image

image

除了上面的,別的都不選,編譯出來的內核1.2M

http://www.javashuo.com/article/p-uwhvgchu-m.html

https://blog.csdn.net/yejingx/article/details/6525405

還有兩個參考別人的網站

相關文章
相關標籤/搜索