使用gdb调试内核遇到的一些问题

1 .  make config的时候报下面的错误,意思是变量没有初始化,手动初始化成’NULL’,就好了。


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/conf

2. 如何给upstream内核打patch

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

3.  内核config

      使用make help 查看可用的config

       make i386_defconfig

      make menuconfig

在原来配置的基础上,make menuconfig选中如下选项重新配置Linux,使之携带调试信息
kernel hacking—>
[*] compile the kernel with debug info
make重新编译(时间较长)

make clean

make –j 4

4. 解决gcc找不到文件的问题

https://blog.csdn.net/u014525494/article/details/53573298

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

https://www.cnblogs.com/pengdonglin137/p/6442598.html

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

还有两个参考别人的网站

猜你喜欢

转载自blog.51cto.com/11325959/2328022
今日推荐