From: Peter Krempa <[email protected]>

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 <[email protected]>
---
 src/libvirt_probes.d |  6 +++---
 src/util/virobject.c | 14 +++++++++++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/libvirt_probes.d b/src/libvirt_probes.d
index 58d362ac6e..b73e9d6e82 100644
--- a/src/libvirt_probes.d
+++ b/src/libvirt_probes.d
@@ -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
diff --git a/src/util/virobject.c b/src/util/virobject.c
index 1aa42e62c1..0ccaaf101e 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -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;
 }

-- 
2.54.0

Reply via email to