- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * gdb 需要对程序以-g模式进行编译 gcc -g -c randutil.c gcc –g -c displayutil.c ar -rv libutil.a randutil.o displayutil.o gcc -g main.c -L. -lutil -ocompute gdb 常用命令及缩写 命令 缩写 意义 file NA 装入待调试的可执行文件 kill k 终止正在调试的程序 list l 列出部分源代码 next n 单步执行,不进入函数内部 step s 单步执行,进入函数内部 run r 执行当前调试的程序 quit q 退出gdb break b 设置断点 watch NA 监视指定变量是否满足条件,如果满足条件程序挂起 display NA 自动显示感兴趣的变量 continue c 继续执行 gdb示例1 启动gdb gdb (启动gdb后用file命令装载可执行文件) gdb test (启动gdb并装载可执行文件) gdb示例2 显示部分源代码 list (gdb) l 3 #define ITERATIONS 1000000L 4 5 int main() 6 { 7 long i; 8 long isum; 9 float fsum; 10 11 /* Initialize the random number API */ 12 initRand(); gdb示例2 显示指定行范围 list [filename:] line1,line2 (gdb) l main.c: 10,20 10 11 /* Initialize the random number API */ 12 initRand(); 13 14 /* Find the average of getRand(10) returns (0 .. 9) */ 15 isum = 0L; 16 for (i = 0; i ITERATIONS; i++) 17 isum += getRand(10); 18 displayInt(getRand(10) average, (int)(isum / ITERATIONS)); 19 20 /* Find the average of getSRand() returns (0.0 ... 1.0) */ gdb示例2 显示指定函数名list [filename:] function_name (gdb) l initRand 2 #include stdio.h 3 #include time.h 4 #include randutil.h 5 6 void initRand() 7 { 8 time_t seed; 9 seed = time(NULL); 10 srand(seed); 11 } gdb示例3 设置断点 breakpoint routine_name breakpoint line_number (gdb) b main Breakpoint 1 at 0x804847d: file main.c, line 12. (gdb) b 18 Breakpoint 2 at 0x80484b3: file main.c, line 18. (gdb) b initRand Breakpoint 3 at 0x8048536: file randutil.c, line 9. gdb示例3 管理断点 列出当前所有断点信息 info breakpoints 删除断点 delete index (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x0804847d in main at main.c:12 2 breakpoint keep y 0x080484b3 in main at main.c:18 3 breakpoint keep y 0in initRand at randutil.c:9 (gdb) delete 1 (gdb) info breakpoints Num Type Disp Enb Address What 2
您可能关注的文档
最近下载
- 劳动教育论文:依托学校种植园培养小学生劳技素养的实践研究.docx VIP
- 《斯特林制冷机》课件.ppt VIP
- 2024北京清华附中初二(上)期中物理(教师版).docx
- 2025领导干部任前廉政法规知识竞赛题库及参考答案.docx VIP
- 三个女性文本和一种帝国主义批评.pdf
- 2023学年新教材高中英语Unit3Festivalsandcustoms写作指导介绍传统节日课件牛津译林版必修第二册.pptx VIP
- 技术要素市场化配置水平测度及区域差异分析.pdf
- 统计预测与决策教材.pdf VIP
- 17J008 挡土墙(重力式、衡重式、悬臂式)(最新).pdf VIP
- Prayer X钢琴谱五线谱 完整版原版.pdf
文档评论(0)