为 GDB 编写前端 [英] Writing Front End for GDB

查看:9
本文介绍了为 GDB 编写前端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个基于 GUI 的调试器,它包裹在 GDB 上.因为,我不希望程序在观察点或断点之后停止.相反,它应该将文件名、行号、新值和内容等详细信息重定向到文件并继续执行.

I want to write a GUI based debugger wrapped over GDB. Because, I dont want the program to stop after watch points or break points. Instead, it should redirect the details like filename, line number, new value and stuffs to a file and continue execution.

我不擅长编写脚本.所以,我想要一些起点来开始为 GDB 开发前端.据我谷歌搜索,此链接 http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_211.html对于初学者来说不太容易理解这个活动?

I am pretty bad at scripting. So, I want some starting point to start developing front end for GDB. As far as I googled, this link http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_211.html is not much understandable for a beginner in this activity?

希望我能在 C/C++ 开发方面获得帮助.

Hopefully, I will get help on development in C/C++.

推荐答案

要编写 GDB 前端,您确实想使用 GDB/MI 协议,但可能要阅读 最新副本,而不是您链接到的旧版本.

For writing a GDB frontend, you indeed want to use the GDB/MI protocol but perhaps read this up-to-date copy instead of the older one you linked to.

(此部分的轻微编辑版本 来自 GDB 手册)

(Lightly edited version of this section from the GDB manual)

使用 MI 命令解释器启动 GDB

$ gdb -q --interpreter=mi2
=thread-group-added,id="i1"
(gdb)

文件/bin/true

-file-exec-and-symbols /bin/true
^done
(gdb) 

打破主线

-break-insert main
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00000000004014c0",func="main",file="true.c",fullname="/usr/src/debug/coreutils-8.17/src/true.c",line="59",times="0",original-location="main"}
(gdb) 

运行和断点命中

-exec-run
=thread-group-started,id="i1",pid="2275"
=thread-created,id="1",group-id="i1"
^running
*running,thread-id="all"
(gdb) 
=library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1"
=library-loaded,id="/lib64/libc.so.6",target-name="/lib64/libc.so.6",host-name="/lib64/libc.so.6",symbols-loaded="0",thread-group="i1"
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00000000004014c0",func="main",file="true.c",fullname="/usr/src/debug/coreutils-8.17/src/true.c",line="59",times="1",original-location="main"}
*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x00000000004014c0",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffde98"}],file="true.c",fullname="/usr/src/debug/coreutils-8.17/src/true.c",line="59"},thread-id="1",stopped-threads="all",core="1"
(gdb) 

继续

-exec-continue
^running
*running,thread-id="1"
(gdb) 
=thread-exited,id="1",group-id="i1"
=thread-group-exited,id="i1",exit-code="0"
*stopped,reason="exited-normally"

退出 GDB

(gdb) 
-gdb-exit
^exit

现有的 GDB/MI 客户端

在 C、C++、Java、Python 中有几个 GDB/MI 客户端实现.我将列出一些我觉得容易阅读的内容:

Existing GDB/MI Clients

There are several GDB/MI client implementations in C, C++, Java, Python. I'll list a few that I find easy to read:

  • 不活跃的 libmigdb 项目(示例程序, 公共接口) -- 好消息是它尝试创建可重用的 C 库.坏消息是它没有得到很好的维护,例如我认为它缺少 GDB non-stop 模式和 catchpoint 命令支持,您的用例可能需要这些功能.
  • python-gdb-mi -- 如果你懂 Python,读起来很容易
  • C++QtCreator 中的 GDB/MI 客户端代码 -- 尽管它是作为抽象层的一部分编写的以支持多个调试器引擎,但也非常易读.
  • The inactive libmigdb project (sample program, public interfaces) -- The good news is that it's an attempt at creating a reusable C library. The bad news is that it's not well maintained, e.g. I think it's missing GDB non-stop mode and catchpoint commands support, features that your use case would likely need.
  • python-gdb-mi -- Quite readable if you know Python
  • The C++ GDB/MI client code in QtCreator -- Also quite readable though it's written as part of an abstraction layer to support multiple debugger engines.

您可能还想浏览 此列表 GDB 前端.

You might want to also browse this list of GDB frontends.

这篇关于为 GDB 编写前端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆