sirkay777

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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.

posted on 2009-03-09 21:59  Sir. Kay  阅读(164)  评论(0编辑  收藏  举报