博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
gdb server调试步骤
阅读量:5888 次
发布时间:2019-06-19

本文共 2570 字,大约阅读时间需要 8 分钟。

编译gdb/gdbserver

编译arm-linux-gdb

下载gdb-7.12,解压缩进入目录

./configure --target=arm-linux --program-prefix=arm-linux- --prefix=/opt/arm-linux-gdb/

 修改gdb/remote.c

 

//==================================

  如果gdb提示:GDB7.6 Remote 'g' packet reply is too long 
  修改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;
      }
   }

 
make && make install

 

 

编译gdbserver

进入gdb/gdbserver目录

./configure --target=arm-linux --host=arm-linux

 修改生成的makefile,将CC AR GXX都修改为交叉编译工具链中的工具

make

 将生成的gdbserver移植到目标机即可

 

目标机:arm

 假设正在运行的程序名字为hello,其进程ID 为6622,目标机IP为192.168.0.11,那么在目标机端开启gdbserver的命令格式:

#命令格式gdbserver IP:PORT --attach PID

 具体到目标机开启的命令为:

[root@test ~]# gdbserver 192.168.0.11:8888  --attach 6622Attached; pid = 6622Listening on port 8888

 

调试机:PC

root@liangwode:# arm-linux-gdbGNU gdb (GDB) 7.12Copyright (C) 2016 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "--host=x86_64-pc-linux-gnu --target=arm-linux".Type "show configuration" for configuration details.For bug reporting instructions, please see:
.Find the GDB manual and other documentation resources online at:
.For help, type "help".Type "apropos word" to search for commands related to "word".(gdb) target remote 192.168.0.11:8888Remote debugging using 192.168.0.11:8888warning: Can not parse XML target description; XML support was disabled at compile timeReading /home/storm/ftp/hello from remote target...warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.Reading /home/storm/ftp/hello from remote target...Reading symbols from target:/home/storm/ftp/hello...done.Reading /lib/libc.so.6 from remote target...Reading /lib/ld-linux-armhf.so.3 from remote target...Reading symbols from target:/lib/libc.so.6...done.Reading symbols from target:/lib/ld-linux-armhf.so.3...done.0x76f0a8d4 in nanosleep () at ../sysdeps/unix/syscall-template.S:8484 ../sysdeps/unix/syscall-template.S: No such file or directory.

 

转载于:https://www.cnblogs.com/liangwode/p/6242577.html

你可能感兴趣的文章
nginx报错pread() returned only 0 bytes instead of 4091的分析
查看>>
质数因子
查看>>
Spring源码浅析之事务(四)
查看>>
[转载] Live Writer 配置写 CSDN、BlogBus、cnBlogs、163、sina 博客
查看>>
SQL:连表查询
查看>>
MySQL日期函数、时间函数总结(MySQL 5.X)
查看>>
c语言用尾插法新建链表和输出建好的链表
查看>>
高性能 Oracle JDBC 编程
查看>>
java 中ResultSet可以获取的数据类型及返回值类型列表
查看>>
ubuntu 13 安装SH程序
查看>>
支付宝升级延时到账功能
查看>>
ghost后只剩下一个盘的数据寻回方法
查看>>
输入输出练习
查看>>
Git commit message和工作流规范
查看>>
java面试。答案源于网上
查看>>
yii中取得CActiveDataProvider的分页信息
查看>>
我的大学
查看>>
Google翻译接口收费啦
查看>>
Debian+Apache2服务器
查看>>
MySQL库和表的操作
查看>>