set(CMAKE_BUILD_TYPE "Release") # "Release" or "Debug"
set(CHCORE_PLAT "raspi3")
set(CHCORE_ARCH "aarch64")

这里为了使得CMake支持调试应该将Release改成Debug。
产生的elf文件中,.text段含有调试信息。

`Disassembly of section .text:

ffffff000008c000 <start_kernel>:
* Code in bootloader specified only the primary
* cpu with MPIDR = 0 can be boot here. So we directly
* set the TPIDR_EL1 to 0, which represent the logical
* cpuid in the kernel
*/
mov x3, #0
ffffff000008c000: d2800003 mov x3, #0x0 // #0
msr TPIDR_EL1, x3
ffffff000008c004: d518d083 msr tpidr_el1, x3`
但是 .init不含有调试信息,不知道什么原因

`Disassembly of section init:

0000000000080000 <_start>:
80000: d53800a8 mrs x8, mpidr_el1
80004: 92401d08 and x8, x8, #0xff
80008: b4000048 cbz x8, 80010 <primary>

000000000008000c <secondary_hang>:
8000c: 94000000 bl 8000c <secondary_hang>

0000000000080010 <primary>:
80010: 94001bfc bl 87000 <arm64_elX_to_el1>
80014: 1003bee0 adr x0, 877f0 <boot_cpu_stack>
80018: 91400400 add x0, x0, #0x1, lsl #12
8001c: 9100001f mov sp, x0
80020: 94001cd1 bl 87364 <init_c>
80024: 14000000 b 80024 <primary+0x14>
80028: 14000007 b 80044 <__start_kernel_veneer+0x18>`

    LYJ 你好,.init段可以查看相应函数的地址以及指令等和实验相关的信息,请问你所说的调试信息具体还需要哪些?

    • LYJ replied to this.

      ds_ssj 嗯。。。就是源代码的信息。这个init段,他是不携带调式信息的,也就是说,我在gdb里面将他的源码路径包含进来,他也是没办法知道源文件的,他会认为init段的源代码在kernel/main.c里面(因为第一个带有调试信息的段在main.c)。

        LYJ 明白了,这部分内容不影响做课程实验本身,不过在init段缺少了这部分调试信息,后续会考虑加上,谢谢!

        a year later

        因为init段那些object的调试信息被一起打包到init里面了,然而gdb只能从elf的debug相关字段读取调试信息。

        Write a Reply...