• VS Code 调试 start.S 汇编代码


    特别注意:debug时候,CFLAGS  AFLAGS  一定要加入 -g 参数。

    CFLAGS += -O0 -gdwarf-2
    AFLAGS += -gdwarf-2

     VS Code中加入汇编断点:

    在右侧 Run and Debug窗口的BREAKPOINTS,加入汇编的lable,如_boot、_start

    https://gitee.com/rtthread/rt-thread 

    rt-thread/.vscode/launch.json

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "(gdb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "program": "${workspaceFolder}/bsp/raspberry-pi/raspi3-64/rtthread.elf",
                "args": [],
                "stopAtEntry": true,
                "cwd": "${workspaceFolder}/bsp/raspberry-pi/raspi3-64",
                "environment": [],
                "externalConsole": false,
                "MIMode": "gdb",
                "targetArchitecture": "arm",
                "miDebuggerPath":"/usr/bin/gdb-multiarch",  // "/opt/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gdb"
                "miDebuggerServerAddress": "localhost:1234",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        ]
    }

    当gdb启动时,会读取HOME目录和当前目录下的的配置文件,执行里面的命令。这个文件通常为“.gdbinit”。

    所以 .gdbinit需要在 "cwd": "${workspaceFolder}/bsp/raspberry-pi/raspi3-64",目录下

    rt-thread/bsp/raspberry-pi/raspi3-64/.gdbinit

    # set architecture aarch64
    # target remote localhost:1234
    # file rtthread.elf
    # layout asm
    b main
    b *0x80000
    b *0x80088

    How to debug with gdb

    Append -s and -S options to the qemu command.

    • -s: enable to attach gdb to QEMU at port 1234
    • -S: start and halted CPU (wait for attach from gdb)

    VS Code 打开任何C/C++文件,右键选择  Open Disassembly View

    https://docs.lagerdata.com/tutorials/vscode.html

    https://github.com/Microsoft/vscode-cpptools/issues/1498

    https://github.com/microsoft/vscode-cpptools/issues/6010

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "(arm-none-eabi-gdb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "miDebuggerPath":"/usr/bin/gdb-multiarch",
                "targetArchitecture": "arm",
                "program": "${workspaceFolder}/kernel.elf",
                "setupCommands": [
                    {"text": "set remotetimeout 5"},
                    {"text": "target remote localhost:1234"},
                    {"text": "monitor reset halt"},
                    {"text": "file kernel.elf"},
                    {"text": "load"},
                    {"text": "break main thread 1","ignoreFailures": true},
                ],
                "launchCompleteCommand": "None",
                "externalConsole": false,
                "cwd": "${workspaceFolder}",
            }
        ]
    }

    不确定是否是QEMU的bug ?

    使用 img 二进制文件时,QEMU调试boot启动代码, mrs x0, CurrentEL,x0=8:  EL2

    qemu-system-aarch64 -M raspi3 -m 1024 -serial null -serial mon:stdio -nographic -kernel kernel.img -S -s

    使用 elf 文件时,QEMU调试boot启动代码, mrs x0, CurrentEL,x0=12:  EL3

    qemu-system-aarch64 -M raspi3 -m 1024 -serial null -serial mon:stdio -nographic -kernel kernel.elf -S -s

    其他:

    .gdbinit用法示例

    aarch64-none-elf-gdb -x .gdbinit -tui

    gdb 多核/多线程

    b main thread 1
    b *0x80000 thread 1
     
  • 相关阅读:
    chrome安装vue-devtools
    企业网络设计
    nginx的安装
    Typora 的使用
    如何学习dubbo?
    关于原码反码和补码以及byte&0xff
    HttpClient以及连接池的使用
    计算机网络读书笔记:tcp面试常见问题都在里面了
    接口类是否继承自Object?
    数据挖掘会议记录
  • 原文地址:https://www.cnblogs.com/sinferwu/p/15337290.html
Copyright © 2020-2023  润新知