From: Simon Marchi Date: Tue, 31 Mar 2020 03:24:24 +0000 (-0400) Subject: Fix: filter-grammar-test: add dependencies between steps X-Git-Tag: v2.13.0-rc1~688 X-Git-Url: http://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=606757e482b9fb6282c5a63fb888942424f9d5c5 Fix: filter-grammar-test: add dependencies between steps If the user specifies only the -B switch of the filter-grammar-test program, the program will try to print the bytecode without having generated it first, leaving to a segfault. Similarly, if the user specifies only the -b switch, the program will try to generate the bytecode from the IR, without having generated the IR first, also leading to a segfault. This patch adds some kind of dependency between the steps, such that if the user is interested in a particular step (let's say, print the bytecode), all the required steps will also be done. Change-Id: Idc365a12b992a950566f227759fd3223cf5c5fd8 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- diff --git a/src/lib/lttng-ctl/filter/filter-grammar-test.c b/src/lib/lttng-ctl/filter/filter-grammar-test.c index 2804053cf..70656e1a8 100644 --- a/src/lib/lttng-ctl/filter/filter-grammar-test.c +++ b/src/lib/lttng-ctl/filter/filter-grammar-test.c @@ -41,6 +41,22 @@ int main(int argc, char **argv) print_bytecode = 1; } + /* + * Force generate the bytecode if the user asks to print the bytecode + * (can't print it without generating it first). + */ + if (print_bytecode) { + generate_bytecode = 1; + } + + /* + * Force generate the IR if the user asks to generate the bytecode + * (the bytecode is generated by visiting the IR). + */ + if (generate_bytecode) { + generate_ir = 1; + } + ctx = filter_parser_ctx_alloc(stdin); if (!ctx) { fprintf(stderr, "Error allocating parser\n");