Linux下嵌入式目标程序的在线仿真调试方法(GD(2)

此时ARM端显示Remote debugging from host 188.188.187.38,Debug便建立连接了,可以调试了,具体的调试命令参考下面连接,这是GDB的命令,可能其中会有些不同:

9. GDB远程调试错误解决

使用GDB 7.2版本进行远程调试时出现:Remote ‘g’ packet reply is too long错误,需要修改gdb代码解决,办法是:修改gdb/remote.c文件,屏蔽process_g_packet函数中的下列两行:
  //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[i].pnum == -1)

                            continue;

 

                    if (rsa->regs[i].offset >= rsa->sizeof_g_packet)

                            rsa->regs[i].in_g_packet = 0;

                    else

                            rsa->regs[i].in_g_packet = 1;

            }   

      }

 

以上方法是通过网络仿真的,也可以通过串口也,具体可以看gdb-7.9/gdb/gdbserver下的README,以下截取部分:

Usage (server (target) side):

For example, using a serial port, you might say:

      target> gdbserver /dev/com1 emacs foo.txt

To use a TCP connection, you could say:

      target> gdbserver host:2345 emacs foo.txt

 

Usage (host side):

For example, using a serial port, you might say:

      (gdb) target remote /dev/ttyb

communicates with the server via serial line /dev/ttyb, and:

      (gdb) target remote the-target:2345

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/d73d200364b660fa3a19ca4efae39d11.html