Message ID | 1475246744-29302-4-git-send-email-berrange@redhat.com |
---|---|
State | New |
Headers | show |
On 09/30/2016 09:45 AM, Daniel P. Berrange wrote: > Allow tracing of the operation of visitors > > Signed-off-by: Daniel P. Berrange <berrange@redhat.com> > --- > Makefile.objs | 1 + > qapi/qapi-visit-core.c | 27 +++++++++++++++++++++++++++ > qapi/trace-events | 33 +++++++++++++++++++++++++++++++++ > 3 files changed, 61 insertions(+) > create mode 100644 qapi/trace-events Reviewed-by: Eric Blake <eblake@redhat.com> > + > +visit_start_alternate(void *v, const char *name, void *obj, size_t size, bool promote_int) "v=%p name=%s obj=%p size=%zu promote_int=%d" Unrelated to your patch, but should the trace engines be taught how to honor line wrapping in the trace files?
Am 30.09.2016 um 16:45 hat Daniel P. Berrange geschrieben: > Allow tracing of the operation of visitors > > Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
"Daniel P. Berrange" <berrange@redhat.com> writes: > Allow tracing of the operation of visitors > > Signed-off-by: Daniel P. Berrange <berrange@redhat.com> > --- > Makefile.objs | 1 + > qapi/qapi-visit-core.c | 27 +++++++++++++++++++++++++++ > qapi/trace-events | 33 +++++++++++++++++++++++++++++++++ > 3 files changed, 61 insertions(+) > create mode 100644 qapi/trace-events > > diff --git a/Makefile.objs b/Makefile.objs > index a8e0224..b3e8aef 100644 > --- a/Makefile.objs > +++ b/Makefile.objs > @@ -160,3 +160,4 @@ trace-events-y += target-s390x/trace-events > trace-events-y += target-ppc/trace-events > trace-events-y += qom/trace-events > trace-events-y += linux-user/trace-events > +trace-events-y += qapi/trace-events > diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c > index 55f5876..bfcb276 100644 > --- a/qapi/qapi-visit-core.c > +++ b/qapi/qapi-visit-core.c > @@ -19,10 +19,12 @@ > #include "qapi/qmp/qerror.h" > #include "qapi/visitor.h" > #include "qapi/visitor-impl.h" > +#include "trace.h" > > void visit_complete(Visitor *v, void *opaque) > { > assert(v->type != VISITOR_OUTPUT || v->complete); > + trace_visit_complete(v, opaque); Trace after or before checking the precondition? Preferences, anyone? > if (v->complete) { > v->complete(v, opaque); > } > @@ -30,6 +32,7 @@ void visit_complete(Visitor *v, void *opaque) > > void visit_free(Visitor *v) > { > + trace_visit_free(v); > if (v) { > v->free(v); > } > @@ -40,6 +43,7 @@ void visit_start_struct(Visitor *v, const char *name, void **obj, > { > Error *err = NULL; > > + trace_visit_start_struct(v, name, obj, size); > if (obj) { > assert(size); > assert(!(v->type & VISITOR_OUTPUT) || *obj); > @@ -53,6 +57,7 @@ void visit_start_struct(Visitor *v, const char *name, void **obj, > > void visit_check_struct(Visitor *v, Error **errp) > { > + trace_visit_check_struct(v); > if (v->check_struct) { > v->check_struct(v, errp); > } > @@ -60,6 +65,7 @@ void visit_check_struct(Visitor *v, Error **errp) > > void visit_end_struct(Visitor *v, void **obj) > { > + trace_visit_end_struct(v, obj); > v->end_struct(v, obj); > } > > @@ -69,6 +75,7 @@ void visit_start_list(Visitor *v, const char *name, GenericList **list, > Error *err = NULL; > > assert(!list || size >= sizeof(GenericList)); > + trace_visit_start_list(v, name, list, size); > v->start_list(v, name, list, size, &err); > if (list && (v->type & VISITOR_INPUT)) { > assert(!(err && *list)); > @@ -79,11 +86,13 @@ void visit_start_list(Visitor *v, const char *name, GenericList **list, > GenericList *visit_next_list(Visitor *v, GenericList *tail, size_t size) > { > assert(tail && size >= sizeof(GenericList)); > + trace_visit_next_list(v, tail, size); > return v->next_list(v, tail, size); > } > > void visit_end_list(Visitor *v, void **obj) > { > + trace_visit_end_list(v, obj); > v->end_list(v, obj); > } > > @@ -95,6 +104,7 @@ void visit_start_alternate(Visitor *v, const char *name, > > assert(obj && size >= sizeof(GenericAlternate)); > assert(!(v->type & VISITOR_OUTPUT) || *obj); > + trace_visit_start_alternate(v, name, obj, size, promote_int); > if (v->start_alternate) { > v->start_alternate(v, name, obj, size, promote_int, &err); > } > @@ -106,6 +116,7 @@ void visit_start_alternate(Visitor *v, const char *name, > > void visit_end_alternate(Visitor *v, void **obj) > { > + trace_visit_end_alternate(v, obj); > if (v->end_alternate) { > v->end_alternate(v, obj); > } > @@ -113,6 +124,7 @@ void visit_end_alternate(Visitor *v, void **obj) > > bool visit_optional(Visitor *v, const char *name, bool *present) > { > + trace_visit_optional(v, name, present); > if (v->optional) { > v->optional(v, name, present); > } > @@ -127,6 +139,7 @@ bool visit_is_input(Visitor *v) > void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp) > { > assert(obj); > + trace_visit_type_int(v, name, obj); > v->type_int64(v, name, obj, errp); > } > > @@ -151,6 +164,7 @@ void visit_type_uint8(Visitor *v, const char *name, uint8_t *obj, > Error **errp) > { > uint64_t value = *obj; > + trace_visit_type_uint8(v, name, obj); > visit_type_uintN(v, &value, name, UINT8_MAX, "uint8_t", errp); > *obj = value; > } Putting the trace in the middle of the "value = *obj; visit_type_uintN(v, &value, ...); *obj = value" pattern makes it less visible. Preserving the pattern requires replacing the initializer by an assignment: uint64_t value; trace_visit_type_uint8(v, name, obj); value = *obj; visit_type_uintN(v, &value, name, UINT8_MAX, "uint8_t", errp); *obj = value; Looks slightly more legible to me. What do you think? [...]
On Fri, Oct 07, 2016 at 03:59:07PM +0200, Markus Armbruster wrote: > "Daniel P. Berrange" <berrange@redhat.com> writes: > > > Allow tracing of the operation of visitors > > > > Signed-off-by: Daniel P. Berrange <berrange@redhat.com> > > --- > > Makefile.objs | 1 + > > qapi/qapi-visit-core.c | 27 +++++++++++++++++++++++++++ > > qapi/trace-events | 33 +++++++++++++++++++++++++++++++++ > > 3 files changed, 61 insertions(+) > > create mode 100644 qapi/trace-events > > > > diff --git a/Makefile.objs b/Makefile.objs > > index a8e0224..b3e8aef 100644 > > --- a/Makefile.objs > > +++ b/Makefile.objs > > @@ -160,3 +160,4 @@ trace-events-y += target-s390x/trace-events > > trace-events-y += target-ppc/trace-events > > trace-events-y += qom/trace-events > > trace-events-y += linux-user/trace-events > > +trace-events-y += qapi/trace-events > > diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c > > index 55f5876..bfcb276 100644 > > --- a/qapi/qapi-visit-core.c > > +++ b/qapi/qapi-visit-core.c > > @@ -19,10 +19,12 @@ > > #include "qapi/qmp/qerror.h" > > #include "qapi/visitor.h" > > #include "qapi/visitor-impl.h" > > +#include "trace.h" > > > > void visit_complete(Visitor *v, void *opaque) > > { > > assert(v->type != VISITOR_OUTPUT || v->complete); > > + trace_visit_complete(v, opaque); > > Trace after or before checking the precondition? Preferences, anyone? I'm ambivalent, as the assert will crash you either way so whether you get a trace event just before the crash seems mostly irrelevant to me - the abort stack trace is what you'll use to diagnose the crash. > > > if (v->complete) { > > v->complete(v, opaque); > > } > > @@ -30,6 +32,7 @@ void visit_complete(Visitor *v, void *opaque) > > > > void visit_free(Visitor *v) > > { > > + trace_visit_free(v); > > if (v) { > > v->free(v); > > } > > @@ -40,6 +43,7 @@ void visit_start_struct(Visitor *v, const char *name, void **obj, > > { > > Error *err = NULL; > > > > + trace_visit_start_struct(v, name, obj, size); > > if (obj) { > > assert(size); > > assert(!(v->type & VISITOR_OUTPUT) || *obj); > > @@ -53,6 +57,7 @@ void visit_start_struct(Visitor *v, const char *name, void **obj, > > > > void visit_check_struct(Visitor *v, Error **errp) > > { > > + trace_visit_check_struct(v); > > if (v->check_struct) { > > v->check_struct(v, errp); > > } > > @@ -60,6 +65,7 @@ void visit_check_struct(Visitor *v, Error **errp) > > > > void visit_end_struct(Visitor *v, void **obj) > > { > > + trace_visit_end_struct(v, obj); > > v->end_struct(v, obj); > > } > > > > @@ -69,6 +75,7 @@ void visit_start_list(Visitor *v, const char *name, GenericList **list, > > Error *err = NULL; > > > > assert(!list || size >= sizeof(GenericList)); > > + trace_visit_start_list(v, name, list, size); > > v->start_list(v, name, list, size, &err); > > if (list && (v->type & VISITOR_INPUT)) { > > assert(!(err && *list)); > > @@ -79,11 +86,13 @@ void visit_start_list(Visitor *v, const char *name, GenericList **list, > > GenericList *visit_next_list(Visitor *v, GenericList *tail, size_t size) > > { > > assert(tail && size >= sizeof(GenericList)); > > + trace_visit_next_list(v, tail, size); > > return v->next_list(v, tail, size); > > } > > > > void visit_end_list(Visitor *v, void **obj) > > { > > + trace_visit_end_list(v, obj); > > v->end_list(v, obj); > > } > > > > @@ -95,6 +104,7 @@ void visit_start_alternate(Visitor *v, const char *name, > > > > assert(obj && size >= sizeof(GenericAlternate)); > > assert(!(v->type & VISITOR_OUTPUT) || *obj); > > + trace_visit_start_alternate(v, name, obj, size, promote_int); > > if (v->start_alternate) { > > v->start_alternate(v, name, obj, size, promote_int, &err); > > } > > @@ -106,6 +116,7 @@ void visit_start_alternate(Visitor *v, const char *name, > > > > void visit_end_alternate(Visitor *v, void **obj) > > { > > + trace_visit_end_alternate(v, obj); > > if (v->end_alternate) { > > v->end_alternate(v, obj); > > } > > @@ -113,6 +124,7 @@ void visit_end_alternate(Visitor *v, void **obj) > > > > bool visit_optional(Visitor *v, const char *name, bool *present) > > { > > + trace_visit_optional(v, name, present); > > if (v->optional) { > > v->optional(v, name, present); > > } > > @@ -127,6 +139,7 @@ bool visit_is_input(Visitor *v) > > void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp) > > { > > assert(obj); > > + trace_visit_type_int(v, name, obj); > > v->type_int64(v, name, obj, errp); > > } > > > > @@ -151,6 +164,7 @@ void visit_type_uint8(Visitor *v, const char *name, uint8_t *obj, > > Error **errp) > > { > > uint64_t value = *obj; > > + trace_visit_type_uint8(v, name, obj); > > visit_type_uintN(v, &value, name, UINT8_MAX, "uint8_t", errp); > > *obj = value; > > } > > Putting the trace in the middle of the "value = *obj; > visit_type_uintN(v, &value, ...); *obj = value" pattern makes it less > visible. > > Preserving the pattern requires replacing the initializer by an > assignment: > > uint64_t value; > > trace_visit_type_uint8(v, name, obj); > value = *obj; > visit_type_uintN(v, &value, name, UINT8_MAX, "uint8_t", errp); > *obj = value; > > Looks slightly more legible to me. What do you think? I'm fine with whatever you prefer. Regards, Daniel
"Daniel P. Berrange" <berrange@redhat.com> writes: > On Fri, Oct 07, 2016 at 03:59:07PM +0200, Markus Armbruster wrote: >> "Daniel P. Berrange" <berrange@redhat.com> writes: >> >> > Allow tracing of the operation of visitors >> > >> > Signed-off-by: Daniel P. Berrange <berrange@redhat.com> >> > --- >> > Makefile.objs | 1 + >> > qapi/qapi-visit-core.c | 27 +++++++++++++++++++++++++++ >> > qapi/trace-events | 33 +++++++++++++++++++++++++++++++++ >> > 3 files changed, 61 insertions(+) >> > create mode 100644 qapi/trace-events >> > >> > diff --git a/Makefile.objs b/Makefile.objs >> > index a8e0224..b3e8aef 100644 >> > --- a/Makefile.objs >> > +++ b/Makefile.objs >> > @@ -160,3 +160,4 @@ trace-events-y += target-s390x/trace-events >> > trace-events-y += target-ppc/trace-events >> > trace-events-y += qom/trace-events >> > trace-events-y += linux-user/trace-events >> > +trace-events-y += qapi/trace-events >> > diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c >> > index 55f5876..bfcb276 100644 >> > --- a/qapi/qapi-visit-core.c >> > +++ b/qapi/qapi-visit-core.c >> > @@ -19,10 +19,12 @@ >> > #include "qapi/qmp/qerror.h" >> > #include "qapi/visitor.h" >> > #include "qapi/visitor-impl.h" >> > +#include "trace.h" >> > >> > void visit_complete(Visitor *v, void *opaque) >> > { >> > assert(v->type != VISITOR_OUTPUT || v->complete); >> > + trace_visit_complete(v, opaque); >> >> Trace after or before checking the precondition? Preferences, anyone? > > I'm ambivalent, as the assert will crash you either way so > whether you get a trace event just before the crash seems > mostly irrelevant to me - the abort stack trace is what > you'll use to diagnose the crash. I have a slight preference for trace first, because trace is one call, while precondition checking can be several. However, grep shows neither order is prevalent. Not worth a respin. >> > if (v->complete) { >> > v->complete(v, opaque); >> > } >> > @@ -30,6 +32,7 @@ void visit_complete(Visitor *v, void *opaque) >> > >> > void visit_free(Visitor *v) >> > { >> > + trace_visit_free(v); >> > if (v) { >> > v->free(v); >> > } >> > @@ -40,6 +43,7 @@ void visit_start_struct(Visitor *v, const char *name, void **obj, >> > { >> > Error *err = NULL; >> > >> > + trace_visit_start_struct(v, name, obj, size); >> > if (obj) { >> > assert(size); >> > assert(!(v->type & VISITOR_OUTPUT) || *obj); >> > @@ -53,6 +57,7 @@ void visit_start_struct(Visitor *v, const char *name, void **obj, >> > >> > void visit_check_struct(Visitor *v, Error **errp) >> > { >> > + trace_visit_check_struct(v); >> > if (v->check_struct) { >> > v->check_struct(v, errp); >> > } >> > @@ -60,6 +65,7 @@ void visit_check_struct(Visitor *v, Error **errp) >> > >> > void visit_end_struct(Visitor *v, void **obj) >> > { >> > + trace_visit_end_struct(v, obj); >> > v->end_struct(v, obj); >> > } >> > >> > @@ -69,6 +75,7 @@ void visit_start_list(Visitor *v, const char *name, GenericList **list, >> > Error *err = NULL; >> > >> > assert(!list || size >= sizeof(GenericList)); >> > + trace_visit_start_list(v, name, list, size); >> > v->start_list(v, name, list, size, &err); >> > if (list && (v->type & VISITOR_INPUT)) { >> > assert(!(err && *list)); >> > @@ -79,11 +86,13 @@ void visit_start_list(Visitor *v, const char *name, GenericList **list, >> > GenericList *visit_next_list(Visitor *v, GenericList *tail, size_t size) >> > { >> > assert(tail && size >= sizeof(GenericList)); >> > + trace_visit_next_list(v, tail, size); >> > return v->next_list(v, tail, size); >> > } >> > >> > void visit_end_list(Visitor *v, void **obj) >> > { >> > + trace_visit_end_list(v, obj); >> > v->end_list(v, obj); >> > } >> > >> > @@ -95,6 +104,7 @@ void visit_start_alternate(Visitor *v, const char *name, >> > >> > assert(obj && size >= sizeof(GenericAlternate)); >> > assert(!(v->type & VISITOR_OUTPUT) || *obj); >> > + trace_visit_start_alternate(v, name, obj, size, promote_int); >> > if (v->start_alternate) { >> > v->start_alternate(v, name, obj, size, promote_int, &err); >> > } >> > @@ -106,6 +116,7 @@ void visit_start_alternate(Visitor *v, const char *name, >> > >> > void visit_end_alternate(Visitor *v, void **obj) >> > { >> > + trace_visit_end_alternate(v, obj); >> > if (v->end_alternate) { >> > v->end_alternate(v, obj); >> > } >> > @@ -113,6 +124,7 @@ void visit_end_alternate(Visitor *v, void **obj) >> > >> > bool visit_optional(Visitor *v, const char *name, bool *present) >> > { >> > + trace_visit_optional(v, name, present); >> > if (v->optional) { >> > v->optional(v, name, present); >> > } >> > @@ -127,6 +139,7 @@ bool visit_is_input(Visitor *v) >> > void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp) >> > { >> > assert(obj); >> > + trace_visit_type_int(v, name, obj); >> > v->type_int64(v, name, obj, errp); >> > } >> > >> > @@ -151,6 +164,7 @@ void visit_type_uint8(Visitor *v, const char *name, uint8_t *obj, >> > Error **errp) >> > { >> > uint64_t value = *obj; >> > + trace_visit_type_uint8(v, name, obj); >> > visit_type_uintN(v, &value, name, UINT8_MAX, "uint8_t", errp); >> > *obj = value; >> > } >> >> Putting the trace in the middle of the "value = *obj; >> visit_type_uintN(v, &value, ...); *obj = value" pattern makes it less >> visible. >> >> Preserving the pattern requires replacing the initializer by an >> assignment: >> >> uint64_t value; >> >> trace_visit_type_uint8(v, name, obj); >> value = *obj; >> visit_type_uintN(v, &value, name, UINT8_MAX, "uint8_t", errp); >> *obj = value; >> >> Looks slightly more legible to me. What do you think? > > I'm fine with whatever you prefer. I can touch up this one on commit.
diff --git a/Makefile.objs b/Makefile.objs index a8e0224..b3e8aef 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -160,3 +160,4 @@ trace-events-y += target-s390x/trace-events trace-events-y += target-ppc/trace-events trace-events-y += qom/trace-events trace-events-y += linux-user/trace-events +trace-events-y += qapi/trace-events diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 55f5876..bfcb276 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -19,10 +19,12 @@ #include "qapi/qmp/qerror.h" #include "qapi/visitor.h" #include "qapi/visitor-impl.h" +#include "trace.h" void visit_complete(Visitor *v, void *opaque) { assert(v->type != VISITOR_OUTPUT || v->complete); + trace_visit_complete(v, opaque); if (v->complete) { v->complete(v, opaque); } @@ -30,6 +32,7 @@ void visit_complete(Visitor *v, void *opaque) void visit_free(Visitor *v) { + trace_visit_free(v); if (v) { v->free(v); } @@ -40,6 +43,7 @@ void visit_start_struct(Visitor *v, const char *name, void **obj, { Error *err = NULL; + trace_visit_start_struct(v, name, obj, size); if (obj) { assert(size); assert(!(v->type & VISITOR_OUTPUT) || *obj); @@ -53,6 +57,7 @@ void visit_start_struct(Visitor *v, const char *name, void **obj, void visit_check_struct(Visitor *v, Error **errp) { + trace_visit_check_struct(v); if (v->check_struct) { v->check_struct(v, errp); } @@ -60,6 +65,7 @@ void visit_check_struct(Visitor *v, Error **errp) void visit_end_struct(Visitor *v, void **obj) { + trace_visit_end_struct(v, obj); v->end_struct(v, obj); } @@ -69,6 +75,7 @@ void visit_start_list(Visitor *v, const char *name, GenericList **list, Error *err = NULL; assert(!list || size >= sizeof(GenericList)); + trace_visit_start_list(v, name, list, size); v->start_list(v, name, list, size, &err); if (list && (v->type & VISITOR_INPUT)) { assert(!(err && *list)); @@ -79,11 +86,13 @@ void visit_start_list(Visitor *v, const char *name, GenericList **list, GenericList *visit_next_list(Visitor *v, GenericList *tail, size_t size) { assert(tail && size >= sizeof(GenericList)); + trace_visit_next_list(v, tail, size); return v->next_list(v, tail, size); } void visit_end_list(Visitor *v, void **obj) { + trace_visit_end_list(v, obj); v->end_list(v, obj); } @@ -95,6 +104,7 @@ void visit_start_alternate(Visitor *v, const char *name, assert(obj && size >= sizeof(GenericAlternate)); assert(!(v->type & VISITOR_OUTPUT) || *obj); + trace_visit_start_alternate(v, name, obj, size, promote_int); if (v->start_alternate) { v->start_alternate(v, name, obj, size, promote_int, &err); } @@ -106,6 +116,7 @@ void visit_start_alternate(Visitor *v, const char *name, void visit_end_alternate(Visitor *v, void **obj) { + trace_visit_end_alternate(v, obj); if (v->end_alternate) { v->end_alternate(v, obj); } @@ -113,6 +124,7 @@ void visit_end_alternate(Visitor *v, void **obj) bool visit_optional(Visitor *v, const char *name, bool *present) { + trace_visit_optional(v, name, present); if (v->optional) { v->optional(v, name, present); } @@ -127,6 +139,7 @@ bool visit_is_input(Visitor *v) void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp) { assert(obj); + trace_visit_type_int(v, name, obj); v->type_int64(v, name, obj, errp); } @@ -151,6 +164,7 @@ void visit_type_uint8(Visitor *v, const char *name, uint8_t *obj, Error **errp) { uint64_t value = *obj; + trace_visit_type_uint8(v, name, obj); visit_type_uintN(v, &value, name, UINT8_MAX, "uint8_t", errp); *obj = value; } @@ -159,6 +173,7 @@ void visit_type_uint16(Visitor *v, const char *name, uint16_t *obj, Error **errp) { uint64_t value = *obj; + trace_visit_type_uint16(v, name, obj); visit_type_uintN(v, &value, name, UINT16_MAX, "uint16_t", errp); *obj = value; } @@ -167,6 +182,7 @@ void visit_type_uint32(Visitor *v, const char *name, uint32_t *obj, Error **errp) { uint64_t value = *obj; + trace_visit_type_uint32(v, name, obj); visit_type_uintN(v, &value, name, UINT32_MAX, "uint32_t", errp); *obj = value; } @@ -175,6 +191,7 @@ void visit_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp) { assert(obj); + trace_visit_type_uint64(v, name, obj); v->type_uint64(v, name, obj, errp); } @@ -199,6 +216,7 @@ static void visit_type_intN(Visitor *v, int64_t *obj, const char *name, void visit_type_int8(Visitor *v, const char *name, int8_t *obj, Error **errp) { int64_t value = *obj; + trace_visit_type_int8(v, name, obj); visit_type_intN(v, &value, name, INT8_MIN, INT8_MAX, "int8_t", errp); *obj = value; } @@ -207,6 +225,7 @@ void visit_type_int16(Visitor *v, const char *name, int16_t *obj, Error **errp) { int64_t value = *obj; + trace_visit_type_int16(v, name, obj); visit_type_intN(v, &value, name, INT16_MIN, INT16_MAX, "int16_t", errp); *obj = value; } @@ -215,6 +234,7 @@ void visit_type_int32(Visitor *v, const char *name, int32_t *obj, Error **errp) { int64_t value = *obj; + trace_visit_type_int32(v, name, obj); visit_type_intN(v, &value, name, INT32_MIN, INT32_MAX, "int32_t", errp); *obj = value; } @@ -223,6 +243,7 @@ void visit_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp) { assert(obj); + trace_visit_type_int64(v, name, obj); v->type_int64(v, name, obj, errp); } @@ -230,6 +251,7 @@ void visit_type_size(Visitor *v, const char *name, uint64_t *obj, Error **errp) { assert(obj); + trace_visit_type_size(v, name, obj); if (v->type_size) { v->type_size(v, name, obj, errp); } else { @@ -240,6 +262,7 @@ void visit_type_size(Visitor *v, const char *name, uint64_t *obj, void visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp) { assert(obj); + trace_visit_type_bool(v, name, obj); v->type_bool(v, name, obj, errp); } @@ -252,6 +275,7 @@ void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp) * can enable: assert(!(v->type & VISITOR_OUTPUT) || *obj); */ + trace_visit_type_str(v, name, obj); v->type_str(v, name, obj, &err); if (v->type & VISITOR_INPUT) { assert(!err != !*obj); @@ -263,6 +287,7 @@ void visit_type_number(Visitor *v, const char *name, double *obj, Error **errp) { assert(obj); + trace_visit_type_number(v, name, obj); v->type_number(v, name, obj, errp); } @@ -272,6 +297,7 @@ void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp) assert(obj); assert(v->type != VISITOR_OUTPUT || *obj); + trace_visit_type_any(v, name, obj); v->type_any(v, name, obj, &err); if (v->type == VISITOR_INPUT) { assert(!err != !*obj); @@ -281,6 +307,7 @@ void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp) void visit_type_null(Visitor *v, const char *name, Error **errp) { + trace_visit_type_null(v, name); v->type_null(v, name, errp); } diff --git a/qapi/trace-events b/qapi/trace-events new file mode 100644 index 0000000..2c5d3bc --- /dev/null +++ b/qapi/trace-events @@ -0,0 +1,33 @@ +# qapi-visit-core.c +visit_free(void *v) "v=%p" +visit_complete(void *v, void *opaque) "v=%p opaque=%p" + +visit_start_struct(void *v, const char *name, void *obj, size_t size) "v=%p name=%s obj=%p size=%zu" +visit_check_struct(void *v) "v=%p" +visit_end_struct(void *v, void *obj) "v=%p obj=%p" + +visit_start_list(void *v, const char *name, void *obj, size_t size) "v=%p name=%s obj=%p size=%zu" +visit_next_list(void *v, void *tail, size_t size) "v=%p tail=%p size=%zu" +visit_end_list(void *v, void *obj) "v=%p obj=%p" + +visit_start_alternate(void *v, const char *name, void *obj, size_t size, bool promote_int) "v=%p name=%s obj=%p size=%zu promote_int=%d" +visit_end_alternate(void *v, void *obj) "v=%p obj=%p" + +visit_optional(void *v, const char *name, bool *present) "v=%p name=%s present=%p" + +visit_type_enum(void *v, const char *name, int *obj) "v=%p name=%s obj=%p" +visit_type_int(void *v, const char *name, int64_t *obj) "v=%p name=%s obj=%p" +visit_type_uint8(void *v, const char *name, uint8_t *obj) "v=%p name=%s obj=%p" +visit_type_uint16(void *v, const char *name, uint16_t *obj) "v=%p name=%s obj=%p" +visit_type_uint32(void *v, const char *name, uint32_t *obj) "v=%p name=%s obj=%p" +visit_type_uint64(void *v, const char *name, uint64_t *obj) "v=%p name=%s obj=%p" +visit_type_int8(void *v, const char *name, int8_t *obj) "v=%p name=%s obj=%p" +visit_type_int16(void *v, const char *name, int16_t *obj) "v=%p name=%s obj=%p" +visit_type_int32(void *v, const char *name, int32_t *obj) "v=%p name=%s obj=%p" +visit_type_int64(void *v, const char *name, int64_t *obj) "v=%p name=%s obj=%p" +visit_type_size(void *v, const char *name, uint64_t *obj) "v=%p name=%s obj=%p" +visit_type_bool(void *v, const char *name, bool *obj) "v=%p name=%s obj=%p" +visit_type_str(void *v, const char *name, char **obj) "v=%p name=%s obj=%p" +visit_type_number(void *v, const char *name, double *obj) "v=%p name=%s obj=%p" +visit_type_any(void *v, const char *name, void *obj) "v=%p name=%s obj=%p" +visit_type_null(void *v, const char *name) "v=%p name=%s"
Allow tracing of the operation of visitors Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- Makefile.objs | 1 + qapi/qapi-visit-core.c | 27 +++++++++++++++++++++++++++ qapi/trace-events | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 qapi/trace-events