GObject Refcount Debugger
Welcome to the RefDbg web page.
What is it?
RefDbg is a GObject reference count debugger. GObject is part of the
glib library (not to be confused with glibc) which forms the basis of
GTK+ (the Gimp ToolKit), Gnome, GStreamer and many other projects. The
GObject library adds object oriented stuff to C which by itself lacks
object oriented features. Since C lacks garbage collection, a reference
counting system is used. Each object has a count of how many other
references (pointers) there are to it. Reference count bugs can be very
hard to track down and can lead to crashes and memory leaks. Refdbg is
a tool that can be used interactively with GDB to log, display and break
on reference count activity, thereby making this task easier.
News
2006 Aug 7: Released RefDbg 1.2. Changes in this release: vastly
improved backtraces with source and line numbers (using libbfd), alive object
dump to end of log file on exit, object displays are sorted by GType name,
performance and memory optimizations, other changes to interactive commands
(see README for details). This may be the friendliest release of RefDbg yet!
Thanks to Stefan Kost for testing and feature suggestions.
2005 Feb 5: Released RefDbg 1.1. Changes include: Information on using
refdbg with glib-2.6.x, improved refcount timer expiration, negative offsets
for event display to display from end of log, bug fixes including one that
caused false positive refcount errors and documentation updates. Not
thoroughly tested, so feedback would be much appreciated.
2005 Jan 24: Thanks go to Jean-François RAMEAU for pointing out that
refdbg does not work with stock glib-2.6.x. A work around for this is to
build glib yourself and pass the configure script "--disable-visibility".
Additional thanks go to David Necas and Matthias Clasen on the gtk-list for
confirming this problem and providing information on the build time option.
I'll add more information in regards to this issue in the README of the next
release.
2004 May 7: Released RefDbg 1.0. Features include: a nice
interactive readline enabled shell; flexible criteria for displaying,
setting break points, and logging refcount activity; display of
active/destroyed objects and their current refcounts; a refcount timer
to track object refcount changes over time (very useful for tracking
down refcount leaks, postive or negative); stack back traces (although
this could still be improved, see TODO items below).
More information
can be found in the README.
Check out the screen shots of RefDbg in
action! Yeah, so what if its just a console program, doesn't the
RefDbg shell look nice running in my terminal? :)
Download
You can download RefDbg from the
SourceForge file download page.
SourceForge Project
Head on over to the
RefDbg SourceForge page
for CVS access, mailing list and other goodies. Feel free to join the
mailing list and post any topics related to RefDbg or GObject
reference counting in general.
TODO and ISSUES
RefDbg for the most part is fairly complete although there are likely
some bugs and other improvements that can be made. Here is a list of
them:
-
Backtrace filtering:
RefDbg backtrace output is now vastly improved. Previously the glibc
backtrace() and backtrace_symbols() functions were being used. These were
lacking debugging information such as source and line numbers and didn't
always work correctly. Now libbfd and libdl are being employed and provide
much more fine grained information on backtraces. The next step is to add
filtering for event displays and possibly the event rules. This could be
used for example to not show any references originating from gtk or other
underlying libraries.
-
Improve refcount timer:
Starting with RefDbg 1.1 a glib main loop timer is used to expire refcount
timer events for cases where no additional refcount activity occurs for some
time. This seems to work well, as long as the main loop is running. I gave
SIGALRM a shot but it seemed far too problematic with gdb and I didn't like
the thought of it having adverse affects on the application being run if it
uses sleep or SIGALRM itself.
-
Problems with gobject-2.6.x:
Refdbg will not work with stock gobject 2.6.x. This is due to the fact that
the reference count related functions can no longer be completely overridden
by external programs (for performance reasons). A work around to this is
to use glib-2.4.x or build your own glib 2.6.x with the configure option
'--disable-visibility'. More information can be found in the
README.
Author: Josh Green
Remove the 'NOSPAM-' from the email address if you are not a spammer :)