gdb 8.0.1连接qemu时,出现“Remote 'g' packet reply is too long”

Posted phoenix tree

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了gdb 8.0.1连接qemu时,出现“Remote 'g' packet reply is too long”相关的知识,希望对你有一定的参考价值。

1 原因

Note that other tutorials also add a "-S" parameter so QEMU starts the kernel stopped, however this is ommitted deliberately. The "-S" parameter would allow gdb to set an initial breakpoint anywhere in the kernel before kernel execution begins. Unfortunately, a change made to the gdbserver in QEMU, to support debugging 32- and 16-bit guest code in an x86_64 session breaks the -S functionality. The symptoms are that gdb prints out "Remote ‘g‘ packet reply is too long:", and fails to interact successfully with QEMU. The suggested fix is to run the QEMU until it is in 64-bit code (i.e. after the boot loader has finished and the kernel started) before connecting from gdb (omitting the -S parameter). To debug a running kernel, this is sufficient; it is the method we will take.”

2 解决办法

gdb源码根目录/gdb/remote.c里面,将

if (buf_len > 2 * rsa->sizeof_g_packet)
error (_(“Remote ‘g’ packet reply is too long: %s”), rs->buf);
修改为
if (buf_len > 2 * rsa->sizeof_g_packet) {
    rsa->sizeof_g_packet = buf_len ;
    for (i = 0; i < gdbarch_num_regs (gdbarch); i++) {
        if (rsa->regs->pnum == -1)
            continue;
        if (rsa->regs->offset >= rsa->sizeof_g_packet)
            rsa->regs->in_g_packet = 0;
        else  
            rsa->regs->in_g_packet = 1;
    }     
}
也就是说,不是作为error来处理,而是按照下面的处理方式进行处理。
 
3 cpu是x86_64
 
 
 

 

以上是关于gdb 8.0.1连接qemu时,出现“Remote 'g' packet reply is too long”的主要内容,如果未能解决你的问题,请参考以下文章

Windows平台使用gdb连接qemu虚拟机上的系统

开启内核地址随机化KASLR后, qemu 调试 kernel 不能设置断点

GDB调试qemu源码纪录

qemu源码调试出现锁错误

qemu源码调试出现锁错误

qemu源码调试出现锁错误