GDB and debugging techniques

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: StephenSmithischis2@home.com
Date:  
Subject: GDB and debugging techniques
are you using the insight version of the gdb debugger from cygwin or Redhat?

Where can we learn more from the master!

sps

> I once used a similar approach to debug a memory leak. The program in
> question was a client in a client/server relationship (though the same
> approach would just as easily work for the server) and it was observed
> that the program would leak memory even with no network activity. I
> put breakpoints on the C++ memory allocation and deallocation routines
> and used the ``commands'' command to add commands for printing out the
> memory that was being either allocated or deallocated along with a
> limited (four or five frame) backtrace (e.g. use ``bt 5'' to do
> this). I then let the program run for a while, stopped it, and then
> used a perl script to filter the output. The perl script removed the
> lines which had matching allocations and deallocations. The
> allocations which were left had to be the leak. The backtrace was
> necessary to find the location of the allocate - there were multiple
> layers of allocation functions in the program. It turned out that the
> problem was in the customer supplied library. They (fortunately) had
> left debugging symbols in their library that they had supplied to us
> and were very much surprised when I was able to tell them the exact
> file and line number at which to look for the problem (even though
> they had not suppled source code).
>
> Kevin