]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: object: Add class name to the Ref/Unref/Dispose debug messages
authorPeter Krempa <pkrempa@redhat.com>
Thu, 30 Apr 2026 05:56:54 +0000 (07:56 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 19 May 2026 07:42:35 +0000 (09:42 +0200)
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>
src/libvirt_probes.d
src/util/virobject.c

index 58d362ac6e2f82977a2ba1ffcfa594eb03bc6d00..b73e9d6e82de6d30ea284cf7ed1c24d53ab9a903 100644 (file)
@@ -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
index 1aa42e62c1d200f982363eba28c838dd5c57efc1..0ccaaf101e018aa84dc9b2e8b6f18d95b68cd98a 100644 (file)
@@ -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;
 }