Tests: add print bytecode to filter grammar test
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 26 Sep 2012 00:49:41 +0000 (20:49 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 26 Sep 2012 02:01:09 +0000 (22:01 -0400)
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/lib/lttng-ctl/filter/filter-grammar-test.c

index 2b9a27dc299543beb38e3191ecd662c406121e40..136ef0c78f2b924d1befe61bd04050ba1fb7f04a 100644 (file)
@@ -34,7 +34,8 @@ int main(int argc, char **argv)
 {
        struct filter_parser_ctx *ctx;
        int ret;
-       int print_xml = 0, generate_ir = 0, generate_bytecode = 0;
+       int print_xml = 0, generate_ir = 0, generate_bytecode = 0,
+               print_bytecode = 0;
        int i;
 
        for (i = 1; i < argc; i++) {
@@ -46,6 +47,8 @@ int main(int argc, char **argv)
                        generate_bytecode = 1;
                else if (strcmp(argv[i], "-d") == 0)
                        filter_parser_debug = 1;
+               else if (strcmp(argv[i], "-B") == 0)
+                       print_bytecode = 1;
        }
 
        ctx = filter_parser_ctx_alloc(stdin);
@@ -119,6 +122,28 @@ int main(int argc, char **argv)
        }
 #endif //0
 
+       if (print_bytecode) {
+               unsigned int bytecode_len, len, i;
+
+               len = bytecode_get_len(&ctx->bytecode->b);
+               bytecode_len = ctx->bytecode->b.reloc_table_offset;
+               printf("Bytecode:\n");
+               for (i = 0; i < bytecode_len; i++) {
+                       printf("0x%X ",
+                               ((uint8_t *) ctx->bytecode->b.data)[i]);
+               }
+               printf("\n");
+               printf("Reloc table:\n");
+               for (i = bytecode_len; i < len;) {
+                       printf("{ 0x%X, ",
+                               *(uint16_t *) &ctx->bytecode->b.data[i]);
+                       i += sizeof(uint16_t);
+                       printf("%s } ", &((char *) ctx->bytecode->b.data)[i]);
+                       i += strlen(&((char *) ctx->bytecode->b.data)[i]) + 1;
+               }
+               printf("\n");
+       }
+
        filter_bytecode_free(ctx);
        filter_ir_free(ctx);
        filter_parser_ctx_free(ctx);
This page took 0.02592 seconds and 4 git commands to generate.