X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Ffilter%2Ffilter-grammar-test.c;h=2804053cf29ceae93cfc3ce0a2a9b0d23a48922a;hb=ab5be9fa2eb5ba9600a82cd18fd3cfcbac69169a;hp=2b9a27dc299543beb38e3191ecd662c406121e40;hpb=d00c599e39ae45ec7c8e12e6bac6b5e58f08f817;p=lttng-tools.git diff --git a/src/lib/lttng-ctl/filter/filter-grammar-test.c b/src/lib/lttng-ctl/filter/filter-grammar-test.c index 2b9a27dc2..2804053cf 100644 --- a/src/lib/lttng-ctl/filter/filter-grammar-test.c +++ b/src/lib/lttng-ctl/filter/filter-grammar-test.c @@ -3,20 +3,10 @@ * * LTTng filter grammar test * - * Copyright 2012 - Mathieu Desnoyers + * Copyright 2012 Mathieu Desnoyers * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License, version 2.1 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: LGPL-2.1-only * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include @@ -34,7 +24,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 +37,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); @@ -58,11 +51,6 @@ int main(int argc, char **argv) fprintf(stderr, "Parse error\n"); goto parse_error; } - ret = filter_visitor_set_parent(ctx); - if (ret) { - fprintf(stderr, "Set parent error\n"); - goto parse_error; - } if (print_xml) { ret = filter_visitor_print_xml(ctx, stdout, 0); if (ret) { @@ -101,23 +89,28 @@ int main(int argc, char **argv) printf("Size of bytecode generated: %u bytes.\n", bytecode_get_len(&ctx->bytecode->b)); } -#if 0 - if (run_bytecode) { - int64_t retval; - printf("Interpreting bytecode... "); - fflush(stdout); - ret = bytecode_interpret(&ctx->bytecode->b, &retval, NULL); - if (ret) { - fprintf(stderr, "Error interpreting bytecode\n"); - goto parse_error; - } else { - printf("Bytecode interpret result: %" PRIi64 "\n", - retval); + 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("done\n"); + 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"); } -#endif //0 filter_bytecode_free(ctx); filter_ir_free(ctx);