调试Linux内核预解压阶段 [英] Debug Linux kernel pre-decompression stage

查看:29
本文介绍了调试Linux内核预解压阶段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 GDB 在解压缩之前调试 Linux 内核 zImage.内核在 ARM 目标上运行,我有一个 JTAG 调试器与 GDB 服务器存根连接到它.目标必须加载引导加载程序.引导加载程序从闪存读取内核映像并将其放入 RAM 中 0x20008000,然后分支到该位置.

I am trying to use GDB to debug a Linux kernel zImage before it is decompressed. The kernel is running on an ARM target and I have a JTAG debugger connected to it with a GDB server stub. The target has to load a boot loader. The boot loader reads the kernel image from flash and puts it in RAM at 0x20008000, then branches to that location.

我已经启动 GDB 并连接到远程目标,然后我像这样使用 GDB 的 add-symbol-file 命令:

I have started GDB and connected to the remote target, then I use GDB's add-symbol-file command like so:

add-symbol-file arch/arm/boot/compressed/vmlinux 0x20008000 -readnow

当我为该地址设置断点时,它会在正确的位置捕获 - 就在它分支到内核时.但是,GDB 显示了来自 arch/arm/boot/compressed/head.S 源代码的错误行.它落后4行.我该如何解决这个问题?

When I set a breakpoint for that address, it does trap at the correct place - right when it branches to the kernel. However, GDB shows the wrong line from the source of arch/arm/boot/compressed/head.S. It's 4 lines behind. How can I fix this?

我也尝试将 -s section addr 选项添加到 add-symbol-file-s .start 0x20008000;这会导致完全相同的问题.

I also have tried adding the -s section addr option to add-symbol-file with -s .start 0x20008000; this results in exactly the same problem.

推荐答案

在使用低级调试进行编译时,有一些汇编宏可以打印出内容.您必须确保宏适用于您的电路板.

There are assembler macros that print out stuff when compiling with low level debug. You have to make sure the macros are appropriate for your board.

linux-latest/arch/arm$ find . -name debug-macro.S | wc
 56      56    2306

为您的电路板找到文件并确保正确的串行端口寄存器被命中.您无需使用 JTAG 即可检测代码.这些宏用于解压代码.当然用*CONFIG_DEBUG_LL*配置.

Find the file for your board and ensure the correct serial port registers are hit. You can instrument the code with out using JTAG. These macros are used in the decompress code. Of course configure with *CONFIG_DEBUG_LL*.

很可能 ATAG 不正确或其他要求之一.检查 Documentation/arm/Booting 以确保您正确设置了寄存器.请注意,最近的内核有一个新要求,即发送 dt 列表.

Most likely the ATAGs are not correct or one of the other requirements. Checkout Documentation/arm/Booting to make sure you have registers set properly. Note there is a new requirement with recent kernels to send a dt list.

这篇关于调试Linux内核预解压阶段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆