GDB和GDB Server
gdb是linux c编程标配的调试工具,平时接触比较多的可能是本机随gcc一起安装的调试工具。但是,即使是本机的gdb,也经常被printf代替,所以接触也仅限于知道。
简单程序固然可以用printf,但是复杂的,带有图形界面的程序,就不得不使用调试工具,比如,arm的跨平台图形程序调试。幸好Qt Creator支持gdb+gdbserver的方式来进行跨平台调试。
基本原理:
1. 目标板使用gdb-server来启动已经编译好的代码,执行断点、分步等调试动作,同时通过网络反馈调试需要的信息给host。
2. host上运行arm-linux-gdb,解析gdb-server传来的信息,同时,发送断点、分步等动作给目标板。
所以,首要的工作是工具的准备。
arm-linux-gdb 以及 gdb-server 的制作,参考这篇:QtCreator 环境使用 remote debug
gdb 的简单使用,可以参考这篇:gdb 简单使用
在远程调试时,首先,需要在远程使用 gdbserver 打开要调试的程序,有两种方式:
1) 直接用 gdbserver 打开:
gdbserver 192.168.1.230: packet_analyzer
上面一句的意思是,使用 gdbserver 运行程序 packet_analyzer, gdbserver 的监听地址为 192.168.1.230:1234
2) attach 到已经在执行的进程上:
gdbserver --attach localhost:
上面这句表示,用 attach 的方式打开 gdbserver,调试进程号为 16924 的程序。
然后,在另外一边,使用相应版本的 gdb 来作为 client 与 gdbserver 连接即可:
# arm-linux-gdb
Python Exception <type 'exceptions.ImportError'> No module named gdb: warning:
Could not load the Python gdb module from `/tmp/gdb-7.6/__install/share/gdb/python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory. GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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=i686-pc-linux-gnu --target=arm-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) target remote 192.168.1.230:1234
Remote debugging using 192.168.1.230:1234
0x400007c0 in ?? ()
(gdb) file packet_analyzer
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from /home/luo/Documents/time_analyzer_qt/packet_analyzer...done.
至此,gdb 与 gdbserver 就勾搭上了,可以像在本地调试一样,对远程机器上的程序进行调试。
需要说明的是,在调试过程中,gdbserver 侧是不接受 ctrl-c 来终止程序的。退出 gdbserver 目前知道的就两种方法,在 gdb 侧执行 quit,或者在 remote 侧使用 killall。
GDB和GDB Server的更多相关文章
- 27 Debugging Go Code with GDB 使用GDB调试go代码
Debugging Go Code with GDB 使用GDB调试go代码 Introduction Common Operations Go Extensions Known Issues Tu ...
- https://sourceware.org/gdb/onlinedocs/gdb/Forks.html
https://sourceware.org/gdb/onlinedocs/gdb/Forks.html Next: Checkpoint/Restart, Previous: Threads, Up ...
- 【转载】【GDB】GDB with Python
作者:薛定谔的喵链接:https://zhuanlan.zhihu.com/p/152274203来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 你还在用GDB调试程序 ...
- linux包之gdb之gdb命令与core文件产生
gdb-7.2-64.el6_5.2.x86_64/usr/bin/gcore/usr/bin/gdb/usr/bin/gdb-add-index/usr/bin/gdbtui/usr/bin/gst ...
- Debugging with GDB 用GDB调试多线程程序
Debugging with GDB http://www.delorie.com/gnu/docs/gdb/gdb_25.html GDB调试多线程程序总结 一直对GDB多线程调试接触不多,最近因为 ...
- GDB Core,gdb 调试大全,core文件调试
编译: gcc -g -o hello hello.c gdb 调试: 基本 gdb 命令. 命 令 描 述 小结:常用的gdb命令 backtrace 显示程序中的当前位置和表示如何到达当前位置的栈 ...
- J-Link GDB Server Command
J-Link GDB Server - SEGGER Hilden, Germany – September 15th, 2011 – SEGGER Microcontroller today ann ...
- 在php中使用strace、gdb、tcpdump调试工具
[转] http://www.syyong.com/php/Using-strace-GDB-and-tcpdump-debugging-tools-in-PHP.html 在php中我们最常使用调试 ...
- 使用GDB 追踪依赖poco的so程序,core dump文件分析.
前言 在windows 下 系统核心态程序蓝屏,会产生dump文件. 用户级程序在设置后,程序崩溃也会产生dump文件.以方便开发者用windbg进行分析. so,linux 系统也有一套这样的东东- ...
随机推荐
- Linux为sh脚本文件添加执行权限
chmod是权限管理命令change the permissions mode of a file的缩写..u代表所有者,x代表执行权限. + 表示增加权限.chmod u+x file.sh 就表示 ...
- ios之快速领会VFL的demo
在网上看到一篇blog,超正!快速领会ios的vfl. 这里贴上blog的地址. http://www.thinkandbuild.it/learn-to-love-auto-layout-prog ...
- 限制EditText必须输入中文的方法
给EditText做限制时,我们想要输入的字符串必须都是中文,不出现任何其他字符,下面的类可以很好的实现这个要求. InputLenLimit.java package com.kale.button ...
- Spring常用表单验证注解
下面是主要的验证注解及说明: 注解 适用的数据类型 说明 @AssertFalse Boolean, boolean 验证注解的元素值是false @AssertTrue Boolean, boole ...
- [转] OpenStack IPSec VPNaaS
OpenStack IPSec VPNaaS ( by quqi99 ) 作者:张华 发表于:2013-08-03版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声 ...
- TortoiseSVN 和 VisualSVN
ylbtech-Miscellaneos:TortoiseSVN 和 VisualSVN 1. TortoiseSVN 百科返回顶部 1-1.百科 TortoiseSVN 是 Subversion 版 ...
- SharePoint _layouts下自定义程序页面权限管理
在sharepoint中,_layouts下的自定义页面没有特别的权限,只要用户能访问sharepoint站点就可以访问_layouts下的自定义程序页面,现在我们需要给自定义页面做一下权限认证.要求 ...
- AOP AspectJ 字节码 示例 Hugo MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- Druid连接池简介和配置
Druid是什么?有什么作用? Druid首先是一个数据库连接池,但它不仅仅是一个数据库连接池,它还包含一个ProxyDriver,一系列内置的JDBC组件库,一个SQL Parser. Druid ...
- Tensorflow Serving 模型部署和服务
http://blog.csdn.net/wangjian1204/article/details/68928656 本文转载自:https://zhuanlan.zhihu.com/p/233614 ...