X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Ffilter%2Ffilter-visitor-xml.c;h=d5ff0c187f515b2e81a1458080a50726ee97b49a;hp=d27a3bf0ee50f65f95871145dd339f3180842160;hb=d44f9a1878031bfdb6ceee49d817430b11f0a58b;hpb=a187da1ab55a90f95fed8a29ed232b344f0d32b2 diff --git a/src/lib/lttng-ctl/filter/filter-visitor-xml.c b/src/lib/lttng-ctl/filter/filter-visitor-xml.c index d27a3bf0e..d5ff0c187 100644 --- a/src/lib/lttng-ctl/filter/filter-visitor-xml.c +++ b/src/lib/lttng-ctl/filter/filter-visitor-xml.c @@ -3,20 +3,10 @@ * * LTTng filter XML pretty printer visitor * - * 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 @@ -49,6 +39,8 @@ static int recursive_visit_print_expression(struct filter_node *node, FILE *stream, int indent) { + struct filter_node *iter_node; + if (!node) { fprintf(stderr, "[error] %s: NULL child\n", __func__); return -EINVAL; @@ -73,37 +65,25 @@ int recursive_visit_print_expression(struct filter_node *node, fprintf(stream, "\n", node->u.expression.u.float_constant); break; - case AST_EXP_IDENTIFIER: + case AST_EXP_IDENTIFIER: /* fall-through */ + case AST_EXP_GLOBAL_IDENTIFIER: print_tabs(stream, indent); - fprintf(stream, "\n", + fprintf(stream, "<%s value=\"%s\"/>\n", + node->u.expression.type == AST_EXP_IDENTIFIER ? + "identifier" : "global_identifier", node->u.expression.u.identifier); - while (node->u.expression.next) { + iter_node = node->u.expression.next; + while (iter_node) { print_tabs(stream, indent); - fprintf(stream, "u.expression.pre_op) { - case AST_LINK_UNKNOWN: - default: - fprintf(stderr, "[error] %s: unknown link\n", __func__); + fprintf(stream, "\n"); + if (recursive_visit_print_expression(iter_node, + stream, indent + 1)) { return -EINVAL; - case AST_LINK_DOT: - fprintf(stream, "."); - break; - case AST_LINK_RARROW: - fprintf(stream, "->"); - break; } - fprintf(stream, "\"/>\n"); - - node = node->u.expression.next; - if (node->type != NODE_EXPRESSION || - node->u.expression.type != AST_EXP_IDENTIFIER) { - fprintf(stderr, "[error] %s: expecting identifier before link\n", __func__); - return -EINVAL; - } - print_tabs(stream, indent); - fprintf(stream, "\n", - node->u.expression.u.identifier); + fprintf(stream, "\n"); + iter_node = iter_node->u.expression.next; + } break; case AST_EXP_NESTED: @@ -167,10 +147,10 @@ int recursive_visit_print(struct filter_node *node, FILE *stream, int indent) case AST_OP_MINUS: fprintf(stream, "\"-\""); break; - case AST_OP_RSHIFT: + case AST_OP_BIT_RSHIFT: fprintf(stream, "\">>\""); break; - case AST_OP_LSHIFT: + case AST_OP_BIT_LSHIFT: fprintf(stream, "\"<<\""); break; case AST_OP_AND: @@ -179,13 +159,13 @@ int recursive_visit_print(struct filter_node *node, FILE *stream, int indent) case AST_OP_OR: fprintf(stream, "\"||\""); break; - case AST_OP_BIN_AND: + case AST_OP_BIT_AND: fprintf(stream, "\"&\""); break; - case AST_OP_BIN_OR: + case AST_OP_BIT_OR: fprintf(stream, "\"|\""); break; - case AST_OP_BIN_XOR: + case AST_OP_BIT_XOR: fprintf(stream, "\"^\""); break; @@ -237,7 +217,7 @@ int recursive_visit_print(struct filter_node *node, FILE *stream, int indent) case AST_UNARY_NOT: fprintf(stream, "\"!\""); break; - case AST_UNARY_BIN_NOT: + case AST_UNARY_BIT_NOT: fprintf(stream, "\"~\""); break; }