热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

GDBfirstimpression

IneveruseGDBbeforethoughI’veheardofitlongtimesago.Well,IneveruseitsimplybecauseIneverreall

I never use GDB before though I’ve heard of it long times ago. Well, I never use it simply because I never really debug program. And maybe I never write programs complicated enough that needs to debug. Though I’ve found time spent on debugging code is quite a lot. I never think of how to improve this. And I never care about the potential bugs left in the code as long as the code begins to work.

My previous experience with debugging is awful. Inserting printfs here and there and finally mess up the code. Changing here and there and later forget where have been changed.

I’m doing the labs of the Berkerley CS61C today and was required to used GDB to complete a exercise exploring the code of K&R’s memory allocator. This power tool get along well with Emacs editor which I’ve been using for studying this opencourse. To start gdb, you just fire it off from Emacs using the command M-x gdb.

The feature I love most is the print command. It make you feel like you are using a python shell. You can print out the value of a variable: ’p a’, a expression `p (int) A->array[5]' , assign values: `p a = 5', execute function: `p f(4, a)'. And In my very exercise, I use ((Header*)0x93db008)[-1].s.size to find out the size of allocated block. And there’s lots of other features I would like to explore later.

GNU has provided lots of powerful tools that make programmers’ life happier. But unfortunately most CS students in China are not get introduced to these powerful tools in their classroom.

转:https://www.cnblogs.com/sirkay777/archive/2009/03/09/1407324.html



推荐阅读
author-avatar
mobiledu2502885853
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有