我在指定 gdb-multiarch 中的體系結構中看到:
如果我使用任何 arm 編譯器(例如 arm-none-eabi-gcc)編譯 C 程式,然后使用二進制作為第二個引數(e)ter 呼叫 gdb-multiarch,它將正確確定機器型別,我可以除錯我的遙控器應用。
我mingw-w64-x86_64-gdb-multiarch 12.1-1在 Windows 10 上使用 MINGW64 (MSYS2);不幸的是,它似乎無法確定架構。我gcc在同一系統上為 Pico/RP2040 構建了一個可執行檔案,系統將其視為:
$ file myexecutable.elf
myexecutable.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
但是,如果我嘗試在 gdb-multiarch 中運行它,我會得到:
$ gdb-multiarch myexecutable.elf
GNU gdb (GDB) 12.1
...
warning: A handler for the OS ABI "Windows" is not built into this configuration
of GDB. Attempting to continue with the default armv6s-m settings.
Reading symbols from myexecutable.elf...
(gdb)
好吧,正如警告所說,似乎gdb-multiarch將此 .elf 視為 'OS ABI "Windows"' - 類似于在 gdb-multiarch 中指定架構中所述:
但是,如果我自己呼叫 gdb-multiarch,它將假定我的機器型別(x86_64)并嘗試使用錯誤的架構除錯遠程目標。
...除了,這里我用二進制作為第二個引數呼叫 gdb-multiarch - 我仍然有這個問題!
鏈接的問題已經解釋了set architecture arch從 GDB 內部應該可以作業;但是,我不完全確定要輸入什么:file說這個可執行檔案是“ARM,EABI5”,我試圖從中派生一個架構標簽,這不太奏效:
(gdb) set architecture armeabi5
Undefined item: "armeabi5".
...而且我對 ARM 不太了解,所以我確切地知道在此處手動輸入什么。
因此,我寧愿gdb-multiarch自己自動找到架構。
如何說服gdb-multiarch正確檢測編譯檔案的(ARM)架構?
uj5u.com熱心網友回復:
您可以嘗試使用僅適用于 Intel 架構的多架構 GDB。您可以通過啟動 GDB 并輸入以下命令來檢查:
set architecture. 如果是這種情況,支持的架構串列將如下所示:
(gdb) set architecture
Requires an argument. Valid arguments are i386, i386:x86-64, i386:x64-32, i8086, i386:intel, i386:x86-64:intel, i386:x64-32:intel, auto.
(gdb)
對于除錯cortex-m0目標,我建議使用 Arm arm-none-eabi 工具鏈arm-none-eabi-gdb提供的GDB ,:
(gdb) set architecture
Requires an argument. Valid arguments are arm, armv2, armv2a, armv3, armv3m, armv4, armv4t, armv5, armv5t, armv5te, xscale, ep9312, iwmmxt, iwmmxt2, armv5tej, armv6, armv6kz, armv6t2, armv6k, armv7, armv6-m, armv6s-m, armv7e-m, armv8-a, armv8-r, armv8-m.base, armv8-m.main, armv8.1-m.main, arm_any, auto.
(gdb)
(gdb) set architecture armv6-m
The target architecture is set to "armv6-m".
(gdb)
Cortex-M0/ Cortex-M0 is 的體系結構armv6-m,但我總是能夠Cortex-M0使用 GDB 除錯程式而無需使用set architecture.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/480639.html
