mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-21 22:59:16 +02:00
Drop g_trap_object_ref debugging mechanism
This is really just a very crude and limited conditional breakpoint. Update the documentation to explain conditional breakpoints in gdb instead. Also, remove the link to refdbg, which appears dead. https://bugzilla.gnome.org/show_bug.cgi?id=719687
This commit is contained in:
parent
0f800cd1a8
commit
28c2706da7
@ -73,24 +73,17 @@
|
|||||||
The reference counting scheme used by GObject does solve quite
|
The reference counting scheme used by GObject does solve quite
|
||||||
a few memory management problems but also introduces new sources of bugs.
|
a few memory management problems but also introduces new sources of bugs.
|
||||||
In large applications, finding the exact spot where the reference count
|
In large applications, finding the exact spot where the reference count
|
||||||
of an Object is not properly handled can be very difficult. Hopefully,
|
of an Object is not properly handled can be very difficult.
|
||||||
there exist a tool named <ulink url="http://refdbg.sf.net/">refdbg</ulink>
|
|
||||||
which can be used to automate the task of tracking down the location
|
|
||||||
of invalid code with regard to reference counting. This application
|
|
||||||
intercepts the reference counting calls and tries to detect invalid behavior.
|
|
||||||
It supports a filter-rule mechanism to let you trace only the objects you are
|
|
||||||
interested in and it can be used together with GDB.
|
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
<indexterm><primary>g_trap_object_ref</primary></indexterm>
|
A useful tool in debugging reference counting problems is to
|
||||||
Note that if GObject has been compiled with <option>--enable-debug=yes</option>,
|
set breakpoints in gdb on g_object_ref() and g_object_unref().
|
||||||
it exports a trap variable
|
Once you know the address of the object you are interested in,
|
||||||
|
you can make the breakpoints conditional:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
static volatile GObject *g_trap_object_ref;
|
break g_object_ref if _object == 0xcafebabe
|
||||||
|
break g_object_unref if _object == 0xcafebabe
|
||||||
</programlisting>
|
</programlisting>
|
||||||
If set to a non-NULL value, <link linkend="g-object-ref">g_object_ref</link>()
|
|
||||||
and <link linkend="g-object-unref">g_object_unref</link>() will be intercepted
|
|
||||||
when called with that value.
|
|
||||||
</para>
|
</para>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
||||||
|
@ -313,7 +313,6 @@ g_object_notify_queue_add (GObject *object,
|
|||||||
#ifdef G_ENABLE_DEBUG
|
#ifdef G_ENABLE_DEBUG
|
||||||
#define IF_DEBUG(debug_type) if (_g_type_debug_flags & G_TYPE_DEBUG_ ## debug_type)
|
#define IF_DEBUG(debug_type) if (_g_type_debug_flags & G_TYPE_DEBUG_ ## debug_type)
|
||||||
G_LOCK_DEFINE_STATIC (debug_objects);
|
G_LOCK_DEFINE_STATIC (debug_objects);
|
||||||
static volatile GObject *g_trap_object_ref = NULL;
|
|
||||||
static guint debug_objects_count = 0;
|
static guint debug_objects_count = 0;
|
||||||
static GHashTable *debug_objects_ht = NULL;
|
static GHashTable *debug_objects_ht = NULL;
|
||||||
|
|
||||||
@ -3043,12 +3042,6 @@ g_object_ref (gpointer _object)
|
|||||||
g_return_val_if_fail (G_IS_OBJECT (object), NULL);
|
g_return_val_if_fail (G_IS_OBJECT (object), NULL);
|
||||||
g_return_val_if_fail (object->ref_count > 0, NULL);
|
g_return_val_if_fail (object->ref_count > 0, NULL);
|
||||||
|
|
||||||
#ifdef G_ENABLE_DEBUG
|
|
||||||
if (g_trap_object_ref == object)
|
|
||||||
G_BREAKPOINT ();
|
|
||||||
#endif /* G_ENABLE_DEBUG */
|
|
||||||
|
|
||||||
|
|
||||||
old_val = g_atomic_int_add (&object->ref_count, 1);
|
old_val = g_atomic_int_add (&object->ref_count, 1);
|
||||||
|
|
||||||
if (old_val == 1 && OBJECT_HAS_TOGGLE_REF (object))
|
if (old_val == 1 && OBJECT_HAS_TOGGLE_REF (object))
|
||||||
@ -3075,11 +3068,6 @@ g_object_unref (gpointer _object)
|
|||||||
g_return_if_fail (G_IS_OBJECT (object));
|
g_return_if_fail (G_IS_OBJECT (object));
|
||||||
g_return_if_fail (object->ref_count > 0);
|
g_return_if_fail (object->ref_count > 0);
|
||||||
|
|
||||||
#ifdef G_ENABLE_DEBUG
|
|
||||||
if (g_trap_object_ref == object)
|
|
||||||
G_BREAKPOINT ();
|
|
||||||
#endif /* G_ENABLE_DEBUG */
|
|
||||||
|
|
||||||
/* here we want to atomically do: if (ref_count>1) { ref_count--; return; } */
|
/* here we want to atomically do: if (ref_count>1) { ref_count--; return; } */
|
||||||
retry_atomic_decrement1:
|
retry_atomic_decrement1:
|
||||||
old_ref = g_atomic_int_get (&object->ref_count);
|
old_ref = g_atomic_int_get (&object->ref_count);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user