qemu运行stm32,并且使用gdb调试

编译

此处以 u-boot 为例子

make stm32f429-discovery_defconfig
make menuconfig
make V=1 > stm32f429_build.log

qemu 启动命令

qemu-system-arm -machine netduinoplus2 -nographic -kernel u-boot -S -gdb tcp::1234
或者
qemu-system-arm -machine netduinoplus2 -nographic -kernel u-boot -S -s

vscode配置

launch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/di/study/u-boot/u-boot",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "/opt/arm-none-gcc/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-gdb",
            "miDebuggerServerAddress": "localhost:1234",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }

    ]
}

执行 gdb 命令

# 启动gdb命令
arm-none-eabi-gdb u-boot
# 加载 gdbinit 文件
source ./.gdbinit

使用 gdb-multiarch

使用 gdb-multiarch 可以对多种架构的可执行程序进行调试

使用 .gdbinit 文件

简单的 .gdbinit 文件内容

target remote localhost:1234
layout split

复杂的 .gdbinit 文件
可以使用参考资料里gdb-dashbaord项目,使用复杂的gdbinit,

参考资源

100-gdb-tips
gdb-dashboard 使用python脚本对gdb调试信息进行增强展示
Gdbinit
python-peda

posted @   nikoladi  阅读(699)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示