mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
util: object: Add class name to the Ref/Unref/Dispose debug messages
Since the object stores the pointer to the parent class object internally we can add the name of the class of the object to the debug messages. Since the debug messages are based on probe points propagate it into the probe point rather than adding separate debug message. For virObjectUnref, this also fixes the ordering of the messages to be 'unref->dispose' by invoking the PROBE before unref rather than the other way around which didn't make sense in the logs and wouldn't allow accessing the class pointer from the already disposed-of object. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
1 parent
5516b10430
commit
dbbe72e83b
2 files changed
+14
-6
No files matched your search
@@ -16,9 +16,9 @@ provider libvirt {
|
||||
# file: src/util/virobject.c
|
||||
# prefix: object
|
||||
probe object_new(void *obj, const char *klassname);
|
||||
probe object_ref(void *obj);
|
||||
probe object_unref(void *obj);
|
||||
probe object_dispose(void *obj);
|
||||
probe object_ref(void *obj, const char *klassname);
|
||||
probe object_unref(void *obj, const char *klassname);
|
||||
probe object_dispose(void *obj, const char *klassname);
|
||||
|
||||
# file: src/rpc/virnetsocket.c
|
||||
# prefix: rpc
|
||||
|
||||
+11
-3
@@ -310,13 +310,14 @@ virObjectRWLockableNew(virClass *klass)
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
static void vir_object_finalize(GObject *gobj)
|
||||
{
|
||||
virObject *obj = VIR_OBJECT(gobj);
|
||||
virObjectPrivate *priv = vir_object_get_instance_private(obj);
|
||||
virClass *klass = priv->klass;
|
||||
|
||||
PROBE_DEBUG(OBJECT_DISPOSE, "obj=%p", gobj);
|
||||
PROBE_DEBUG(OBJECT_DISPOSE, "obj=%p classname=%s", gobj, klass->name);
|
||||
|
||||
while (klass) {
|
||||
if (klass->dispose)
|
||||
@@ -370,12 +371,15 @@ void
|
||||
virObjectUnref(void *anyobj)
|
||||
{
|
||||
virObject *obj = anyobj;
|
||||
virObjectPrivate *priv;
|
||||
|
||||
if (VIR_OBJECT_NOTVALID(obj))
|
||||
return;
|
||||
|
||||
priv = vir_object_get_instance_private(obj);
|
||||
PROBE_DEBUG(OBJECT_UNREF, "obj=%p classname=%s", obj, priv->klass->name);
|
||||
|
||||
g_object_unref(anyobj);
|
||||
PROBE_DEBUG(OBJECT_UNREF, "obj=%p", obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -392,12 +396,16 @@ void *
|
||||
virObjectRef(void *anyobj)
|
||||
{
|
||||
virObject *obj = anyobj;
|
||||
virObjectPrivate *priv;
|
||||
|
||||
if (VIR_OBJECT_NOTVALID(obj))
|
||||
return NULL;
|
||||
|
||||
|
||||
g_object_ref(obj);
|
||||
PROBE_DEBUG(OBJECT_REF, "obj=%p", obj);
|
||||
|
||||
priv = vir_object_get_instance_private(obj);
|
||||
PROBE_DEBUG(OBJECT_REF, "obj=%p classname=%s", obj, priv->klass->name);
|
||||
return anyobj;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user