1. 程式人生 > >Remote 'g' packet reply is too long 錯誤

Remote 'g' packet reply is too long 錯誤

在 用 kgdb 除錯64位arm核心的時候,當一切準備停當,在aarch64-linux-gnu-gdb 下輸入 target remote /dev/ttyUSB0 後,gdb報出Remote ‘g’ packet reply is too long 的錯誤。

(gdb) target remote /dev/ttyUSB0
Remote debugging using /dev/ttyUSB0
Remote 'g' packet reply is too long: b8b9a300c0ffffff01000000000000000000000000000000c0b9a300c0ffffff000000000000000008016f00c0ffffff825e9f00c0ffffff4b4744423a20456e746572696e67204bc07a753ac0ffffffffe0f50500000000800100000000000006000000000000006d5e9f00c0ffffff5f5e9f80c0ffffff1000000000000000e0911600c0ffffff0000000000000000000000000000000000009a00c0ffffff6700000000000000402d9a00c0ffffff0700000000000000000000000000000011000000000000008601000000000000040000000000000000406c00c0ffffff0040753ac0ffffff307d753ac0ffffff6c3a1100c0ffffff307d753ac0ffffffd4391100c0ffffff450100600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

在網上找了很久,最後還是翻牆用google找到了正確的答案。
先說一下原因,在4.4核心的kgdb程式碼中,cpsr 暫存器的長度是64bit的,而在我用的aarch64-linux-gnu-gdb 中, cpsr 暫存器的長度被定義成32bit了,這樣兩邊就無法匹配。正規的解決辦法應該是下載最新的gdb,重新編譯。但是編譯gdb很麻煩,所以在stackoverflow上有人給出了一個簡單的辦法:
下載gdb原始碼,然後把其中的aarch64-core.xml aarch64-fpu.xml aarch64.xml 這3個檔案複製到你的工作目錄下面,確保 aarch64-core.xml 中的cpsr 暫存器的長度為64位(我下的gdb7.8,這個問題還沒有修復)

<reg name="cpsr" bitsize="64"/>

然後 在gdb 中,在執行 target remote /dev/ttyUSB0 之前,輸入如下命令,以更新暫存器定義

set tdesc filename aarch64.xml

這樣做了以後,就可以在64位的ARM核心上使用kgdb了。