国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 操作系統 > 正文

gdb腳本

2024-06-28 13:20:20
字體:
來源:轉載
供稿:網友
gdb腳本

一、簡介

作為UNIX/linux下使用廣泛的調試器,gdb不僅提供了豐富的命令,還引入了對腳本的支持:一種是對已存在的腳本語言支持,比如python,用戶可以直接書寫python腳本,由gdb調用python解釋器執行;另一種是命令腳本(command file),用戶可以在腳本中書寫gdb已經提供的或者自定義的gdb命令,再由gdb執行。

二、命令腳本

自定義命令格式如下

define commandName      statement      ......  end

自定義命令幫助文檔格式如下

document commandName     statement     .......end

提示:在gdb中執行腳本要使用source命令,例如:“source xxx.gdb”。

三、python腳本

腳本示例:

1 #!/usr/bin/env python  2 from __future__ import with_statement                                                                                      3 import gdb  4   5 class SaveBreakpointsCommand (gdb.Command):  6     """Save the current breakpoints to a file.  7 This command takes a single argument, a file name.  8 The breakpoints can be restored using the 'source' command."""  9  10     def __init__ (self): 11         super (SaveBreakpointsCommand, self).__init__ ("save breakpoints", 12                                                        gdb.COMMAND_SUPPORT, 13                                                        gdb.COMPLETE_FILENAME) 14  15     def invoke (self, arg, from_tty): 16         with open (arg, 'w') as f: 17             for bp in gdb.get_breakpoints (): 18                 PRint >> f, "break", bp.get_location (), 19                 if bp.get_thread () is not None: 20                     print >> f, " thread", bp.get_thread (), 21                 if bp.get_condition () is not None: 22                     print >> f, " if", bp.get_condition (), 23                 print >> f 24                 if not bp.is_enabled (): 25                     print >> f, "disable $bpnum" 26                 # Note: we don't save the ignore count; there doesn't 27                 # seem to be much point. 28                 commands = bp.get_commands () 29                 if commands is not None: 30                     print >> f, "commands" 31                     # Note that COMMANDS has a trailing newline. 32                     print >> f, commands, 33                     print >> f, "end" 34 35 SaveBreakpointsCommand ()

運行:

image

四、腳本加載方式

gdb加載腳本的方式有

autoload方式            #需要把 腳本放置到/usr/share/gdb/auto-load/usr/lib/目錄下gdb -x script方式gdb命令source script方式

上一篇:who

下一篇:sudo 免密碼

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阿图什市| 博客| 彭州市| 马边| 汉沽区| 拉孜县| 永川市| 临清市| 英德市| 腾冲县| 雅安市| 海伦市| 仁布县| 临高县| 砚山县| 贵州省| 陆河县| 温州市| 遵化市| 绥江县| 灵寿县| 宜兴市| 慈利县| 屏边| 江西省| 泸西县| 吴堡县| 天气| 伊宁县| 聂荣县| 水城县| 凤阳县| 公主岭市| 宁波市| 石渠县| 奉化市| 林甸县| 高邑县| 谢通门县| 东丽区| 石渠县|