+/*
+ * Our basic tracing support callback.
+ *
+ * Print out each instruction as it's executed, including the values of
+ * the num and str registers if they've changed.
+ */
+
+static void
+test_trace(void *context, struct format *fmt, int num, char *str, char *outbuf)
+{
+ struct trace_context *ctx = (struct trace_context *) context;
+ int changed = 0;
+
+ dumpone(fmt);
+
+ if (num != ctx->num) {
+ printf("num=%d", num);
+ ctx->num = num;
+ changed++;
+ }
+
+ if (str != ctx->str) {
+ if (changed++)
+ printf(" ");
+ printf("str=\"%s\"", str ? str : "NULL");
+ ctx->str = str;
+ }
+
+ if (changed)
+ printf("\n");
+
+ if (strcmp(outbuf, ctx->outbuf) != 0) {
+ printf("outbuf=\"%s\"\n", outbuf);
+ free(ctx->outbuf);
+ ctx->outbuf = getcpy(outbuf);
+ }
+}
+