Yesterday, I was assigned a customer bug where the module I work on [say, D] crashed after taking up too much memory. I wanted to examine the core file and see which portions consumed most memory.
Using gdb, I looked at backtrace. The stack showed that ipc calls were being made when D core'ed. Few months back, D crashed due to similar behavior and we solved that bug. However, for this bug, I need to make sure before claiming it as duplicate.
Using a gdb script written by another developer, I examined various memory chunks consumed by D. It was obvious that chunks of 4K size that is used to make ipc calls is the reason for memory hike.
Now, I wanted to find out if ipc communication path between D and any particular module was clogged up. Using the tutorial provided at IBM DeveloperWorks page, I picked up nuts and bolts of gdb scripting.
It helped me determine which communication queue was overflowing with ipc messages. It was easy pickings from then onwards.
In this process, I was very pleased with gdb and folks who put in hours of work behind it. Learning gdb scripting is very easy. Especially when you have to do simple tasks.
I would recommend above article on IBM DeveloperWorks page as starting point. gdb's help can take you forward.Labels: gdb, gdb scripting, IBM DeveloperWorks, ipc