简体   繁体   English

Qemu arm Linux内核启动调试,没有源代码

[英]Qemu arm Linux kernel boot debug, no source code

I am using Qemu to learn some linux kernel development/hacking and wanted to debug the boot process of Linux (2.6.34.3). 我正在使用Qemu学习一些Linux内核开发/黑客,并希望调试Linux的启动过程(2.6.34.3)。 I have compiled for the ARM versatile platform and is using Codesourcerys arm-none-eabi crosscompiler. 我已经为ARM多功能平台编译并使用Codesourcerys arm-none-eabi交叉编译器。 I am using Eclipse as the environment to build and debug using gdbserver. 我使用Eclipse作为使用gdbserver构建和调试的环境。

So I have manged to successfully build and run the kernel in qemu but the problem is that I dont see any source code in the debugger at the boot process (at address 0), I can only see the disassembly code. 所以我已经成功地在qemu中构建并运行内核,但问题是我在启动过程中没有看到调试器中的任何源代码 (在地址0),我只能看到反汇编代码。 However, when it switches to virtual memory at init/main.c (address over 0xC0000000), the source code appears and I can see the source code and step through and over code. 但是,当它在init / main.c(地址超过0xC0000000)切换到虚拟内存时,会出现源代码,我可以看到源代码并逐步完成代码。 Why is that? 这是为什么? I want that from the beginning. 我从一开始就想要那个。

Anyone have any tips on how to debug the boot process of Linux? 任何人都有关于如何调试Linux的启动过程的任何提示? All the guides in google shows how to debug the kernel, but they all show from start_kernel() (located in init/main.c ) and not from the beginning of the boot process (in arch/arm/boot/compressed/head.S ). 谷歌中的所有指南都显示了如何调试内核,但它们都显示在start_kernel()(位于init / main.c中 )而不是从启动过程的开始(在arch / arm / boot / compressed / head中)。 S )。 Anyone with experience help please, thank you! 有经验的人请帮忙,谢谢!

Looked into the System.map in the root folder and there is only symbols for stuff from c0004000 (where the virtual address start). 查看根文件夹中的System.map,并且只有来自c0004000(虚拟地址开始)的内容的符号。 I load vmlinux into gdbserver to get debug information, Maybe thats why theres no source? 我将vmlinux加载到gdbserver中以获取调试信息,也许这就是为什么没有源代码?

The Linux kernel uses a 2-step booting processing (and this does not include any boot loader like u-Boot ...). Linux内核使用两步启动处理(这不包括任何启动加载程序,如u-Boot ...)。 You can better understand this especially by looking into 2 .lds files (detailed below) for linking: 你可以更好地理解这一点,特别是通过查看2个.lds文件(详见下文)进行链接:

  1. arch/arm/boot/compressed/vmlinux.lds.in , which generates arch/arm/boot/compressed/vmlinux.lds . arch/arm/boot/compressed/vmlinux.lds.in ,生成arch/arm/boot/compressed/vmlinux.lds

    Along with other .o files in arch/arm/boot/compressed , a vmlinux is generated inside this folder. arch/arm/boot/compressed其他.o文件一起,在此文件夹中生成vmlinux。

    You can use arm-none-eabi-nm -a -n arch/arm/boot/compressed/vmlinux to see the symbols for this stage. 您可以使用arm-none-eabi-nm -a -n arch/arm/boot/compressed/vmlinux来查看此阶段的符号。 All addresses are physical addresses. 所有地址都是物理地址。

    These symbols are NOT included in System.map 这些符号不包含在System.map中

  2. The second vmlinux is generated by kernel .o files and arch/arm/kernel/vmlinux.lds (note: the path is different) 第二个vmlinux由内核.o文件和arch/arm/kernel/vmlinux.lds (注意:路径不同)

I hope this explains why you can not see the booting source code in Eclipse. 我希望这能解释为什么你无法在Eclipse中看到启动源代码。

linux kernel is too complex to understand(for a beginner). linux内核太复杂了(对初学者来说)。
Why dont use use a smaller OS like xv6 : 为什么不使用像xv6这样的小型操作系统:

OS is small, sourcecode is about 8000 lines 操作系统很小, 源代码大约是8000行
used by many universities 被许多大学使用
based on V6(unix), 基于V6(unix),
boot process is the same except that its less complicated than that of linux. 引导过程是相同的,除了它比linux的复杂性少。
Appendix B of the xv6 book deals with boot process(its short and sweet).You can run gdb on qemu and see the boot process, the main files to check out for are bootasm.S(in assembler) and bootmain.c. xv6 书的附录B介绍了启动过程(它的简短和甜蜜)。你可以在qemu上运行gdb并查看启动过程,要检查的主要文件是bootasm.S(在汇编程序中)和bootmain.c。

This is much simpler and easier to do and understand when compared to linux.(atleast for beginners).There are assingmennts on , setting up qemu , using gdb ,tracking the boot process , doing changes to the source code etc in the link given.Give it a shot :) 与linux相比,这更简单,更容易理解和理解。(至少对初学者而言)。有开发人员,设置qemu,使用gdb,跟踪启动过程,对给定链接中的源代码进行更改等。试一试 :)

Cheers, 干杯,
sharan 夏朗

head.S是用汇编语言编写的,而不是C.这就是.S后缀表示的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM