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 系统也有一套这样的东东- ...
随机推荐
- 对实体 "characterEncoding" 的引用必须以 ';' 分隔符结尾
今天在springmvc集成mybatis时,遇到一个错误 "characterEncoding" 的引用必须以 ';' 分隔符结尾. 这是“&”定义与解析的原因,需要对& ...
- Oracle锦集
1:将数组转成datatable SELECT COLUMN_VALUE FROM TABLE(CAST(UTIL.INTONUMBERTABLE(REPLACE(NVL(V_CATEGORY_ID, ...
- Kubernetes中StatefulSet介绍
StatefulSet 是Kubernetes1.9版本中稳定的特性,本文使用的环境为 Kubernetes 1.11.如何搭建环境可以参考kubeadm安装kubernetes V1.11.1 集群 ...
- PyGreSQL入门,pg模块,pgdb模块
安装:http://www.pygresql.org/contents/install.html PyGreSQL入门 ——简单整理翻译自官方文档:http://www.pygresql.org/co ...
- Java和C#差异点
语法:----------------------------------------------------------1. Java的byte为-128~127相当于c#的sbyte,c#byte ...
- django 如何重写 HttpResponseRedirect 的响应状态码 302?
fetch无法获取302响应的header信息: 浏览器对于302状态重定向,是直接进行重定向. 且js的fetch请求无法获取(catch也好.then也罢)到302响应的header信息,自然也无 ...
- java的反射机制浅谈(转)
原文链接:java的反射机制浅谈 一.java的反射机制浅谈 1.何谓反射机制 根据网文,java中的反射机制可以如此定义: JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性 ...
- 最新自然语言处理(NLP)四步流程:Embed->Encode->Attend->Predict
http://blog.csdn.net/jdbc/article/details/53292414 过去半年以来,自然语言处理领域进化出了一件神器.此神器乃是深度神经网络的一种新模式,该模式分为:e ...
- 文本相似度-BM25算法
BM25 is a bag-of-words retrieval function that ranks a set of documents based on the query terms app ...
- 在centos7.4上安装mysql5.5
from: https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-centos-7