Re: [PATCH v2 01/10] qom: add trace events for object/property lifecycle

2026-05-08 Thread Daniel P . Berrangé
On Fri, May 08, 2026 at 07:18:29PM +0400, [email protected] wrote:
> On Fri, 08 May 2026 12:24:20 +0100, Daniel P. Berrangé  
> wrote:
> > diff --git a/qom/trace-events b/qom/trace-events
> > index b2e9f4a7127..9aabbae4f73 100644
> > --- a/qom/trace-events
> > +++ b/qom/trace-events
> > @@ -1,5 +1,13 @@
> >  # See docs/devel/tracing.rst for syntax documentation.
> >  
> >  # object.c
> > -object_dynamic_cast_assert(const char *type, const char *target, const 
> > char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
> > -object_class_dynamic_cast_assert(const char *type, const char *target, 
> > const char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
> > +object_dynamic_cast_assert(void *obj, const char *type, const char 
> > *target, const char *file, int line, const char *func) "obj=%p type=%s->%s 
> > (%s:%d:%s)"
> > +object_finalize(void *obj, const char *type) "obj=%p type=%s"
> > +object_new(void *obj, const char *type) "obj=%p type=%s"
> > +object_property_add(void *obj, const char *type, const char *name, void 
> > *value) "obj=%p type=%s name=%s value=%p"
> > +object_property_add_child(void *obj, const char *type, const char *name, 
> > void *parent, const char *parenttype) "obj=%p type=%s name=%s parent=%p 
> > parent-type=%s"
> 
> The 4th and 5th parameters are the child being added, not a parent.
> In object_property_try_add_child the call is:
> 
>   trace_object_property_add_child(obj, ..., child, child->class->type->name)
> 
> So the parameter names should be "child"/"childtype" and the format
> string should use "child=" / "child-type=".
> 
> > +object_property_del(void *obj, const char *type, const char *name, void 
> > *value) "obj=%p type=%s name=%s value=%p"
> > +object_property_del_child(void *obj, const char *type, void *parent, const 
> > char *parenttype) "obj=%p type=%s parent=%p parent-type=%s"
> 
> Same here

Opps, yes, I don't know what I was thinking there !

With regards,
Daniel
-- 
|: https://berrange.com   ~~https://hachyderm.io/@berrange :|
|: https://libvirt.org  ~~  https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~https://fstop138.berrange.com :|




Re: [PATCH v2 01/10] qom: add trace events for object/property lifecycle

2026-05-08 Thread marcandre . lureau
On Fri, 08 May 2026 12:24:20 +0100, Daniel P. Berrangé  
wrote:
> diff --git a/qom/trace-events b/qom/trace-events
> index b2e9f4a7127..9aabbae4f73 100644
> --- a/qom/trace-events
> +++ b/qom/trace-events
> @@ -1,5 +1,13 @@
>  # See docs/devel/tracing.rst for syntax documentation.
>  
>  # object.c
> -object_dynamic_cast_assert(const char *type, const char *target, const char 
> *file, int line, const char *func) "%s->%s (%s:%d:%s)"
> -object_class_dynamic_cast_assert(const char *type, const char *target, const 
> char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
> +object_dynamic_cast_assert(void *obj, const char *type, const char *target, 
> const char *file, int line, const char *func) "obj=%p type=%s->%s (%s:%d:%s)"
> +object_finalize(void *obj, const char *type) "obj=%p type=%s"
> +object_new(void *obj, const char *type) "obj=%p type=%s"
> +object_property_add(void *obj, const char *type, const char *name, void 
> *value) "obj=%p type=%s name=%s value=%p"
> +object_property_add_child(void *obj, const char *type, const char *name, 
> void *parent, const char *parenttype) "obj=%p type=%s name=%s parent=%p 
> parent-type=%s"

The 4th and 5th parameters are the child being added, not a parent.
In object_property_try_add_child the call is:

  trace_object_property_add_child(obj, ..., child, child->class->type->name)

So the parameter names should be "child"/"childtype" and the format
string should use "child=" / "child-type=".

> +object_property_del(void *obj, const char *type, const char *name, void 
> *value) "obj=%p type=%s name=%s value=%p"
> +object_property_del_child(void *obj, const char *type, void *parent, const 
> char *parenttype) "obj=%p type=%s parent=%p parent-type=%s"

Same here

-- 
Marc-André Lureau 




[PATCH v2 01/10] qom: add trace events for object/property lifecycle

2026-05-08 Thread Daniel P . Berrangé
This adds tracing around object allocation & finalization, the addition &
deletion of properties, and the addition & deletion of children.

Signed-off-by: Daniel P. Berrangé 
---
 qom/object.c | 34 +++---
 qom/trace-events | 12 ++--
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index f981e27044..9c391071fb 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -603,6 +603,8 @@ static void object_property_del_all(Object *obj)
 object_property_iter_init(&iter, obj);
 while ((prop = object_property_iter_next(&iter)) != NULL) {
 if (g_hash_table_add(done, prop)) {
+trace_object_property_del(obj, obj->class->type->name,
+  prop->name, prop->opaque);
 if (prop->release) {
 prop->release(obj, prop->name, prop->opaque);
 released = true;
@@ -621,10 +623,14 @@ static void object_property_del_child(Object *obj, Object 
*child)
 GHashTableIter iter;
 gpointer key, value;
 
+trace_object_property_del_child(obj, obj->class->type->name,
+child, child->class->type->name);
 g_hash_table_iter_init(&iter, obj->properties);
 while (g_hash_table_iter_next(&iter, &key, &value)) {
 prop = value;
 if (object_property_is_child(prop) && prop->opaque == child) {
+trace_object_property_del(obj, obj->class->type->name,
+  prop->name, prop->opaque);
 if (prop->release) {
 prop->release(obj, prop->name, prop->opaque);
 prop->release = NULL;
@@ -664,7 +670,7 @@ static void object_finalize(void *data)
 {
 Object *obj = data;
 TypeImpl *ti = obj->class->type;
-
+trace_object_finalize(obj, obj->class->type->name);
 object_property_del_all(obj);
 object_deinit(obj, ti);
 
@@ -714,6 +720,7 @@ static Object *object_new_with_type(Type type)
 object_initialize_with_type(obj, size, type);
 obj->free = obj_free;
 
+trace_object_new(obj, obj->class->type->name);
 return obj;
 }
 
@@ -844,8 +851,9 @@ Object *object_dynamic_cast(Object *obj, const char 
*typename)
 Object *object_dynamic_cast_assert(Object *obj, const char *typename,
const char *file, int line, const char 
*func)
 {
-trace_object_dynamic_cast_assert(obj ? obj->class->type->name : "(null)",
- typename, file, line, func);
+trace_object_dynamic_cast_assert(
+obj, obj ? obj->class->type->name : "(null)",
+typename, file, line, func);
 
 #ifdef CONFIG_QOM_CAST_DEBUG
 int i;
@@ -935,8 +943,9 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass 
*class,
 {
 ObjectClass *ret;
 
-trace_object_class_dynamic_cast_assert(class ? class->type->name : 
"(null)",
-   typename, file, line, func);
+trace_object_class_dynamic_cast_assert(
+class ? class->type->name : "(null)",
+typename, file, line, func);
 
 #ifdef CONFIG_QOM_CAST_DEBUG
 int i;
@@ -1220,6 +1229,8 @@ object_property_try_add(Object *obj, const char *name, 
const char *type,
 prop->release = release;
 prop->opaque = opaque;
 
+trace_object_property_add(obj, obj->class->type->name,
+  prop->name, prop->opaque);
 g_hash_table_insert(obj->properties, prop->name, prop);
 return prop;
 }
@@ -1258,6 +1269,8 @@ object_class_property_add(ObjectClass *klass,
 prop->release = release;
 prop->opaque = opaque;
 
+trace_object_class_property_add(klass->type->name, prop->name,
+prop->opaque);
 g_hash_table_insert(klass->properties, prop->name, prop);
 
 return prop;
@@ -1346,6 +1359,8 @@ void object_property_del(Object *obj, const char *name)
 {
 ObjectProperty *prop = g_hash_table_lookup(obj->properties, name);
 
+trace_object_property_del(obj, obj->class->type->name, prop->name,
+  prop->opaque);
 if (prop->release) {
 prop->release(obj, name, prop->opaque);
 }
@@ -1634,8 +1649,11 @@ int object_property_get_enum(Object *obj, const char 
*name,
 bool object_property_parse(Object *obj, const char *name,
const char *string, Error **errp)
 {
-Visitor *v = string_input_visitor_new(string);
-bool ok = object_property_set(obj, name, v, errp);
+Visitor *v;
+bool ok;
+trace_object_property_parse(obj, obj->class->type->name, name, string);
+v = string_input_visitor_new(string);
+ok = object_property_set(obj, name, v, errp);
 
 visit_free(v);
 return ok;
@@ -1766,6 +1784,8 @@ object_property_try_add_child(Object *obj, const char 
*name,
 g_autofree char *type = NULL;
 ObjectProperty *op;
 
+trace_object_property_add_child(obj, obj->class->type