From 55314f2a6c08045f6f7ca7700a4932628eff1b87 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 7 Jun 2017 16:17:35 -0400 Subject: [PATCH] Remove dependancies on ctf.fs source component caused by former logging API MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- plugins/ctf/common/btr/btr.c | 11 +- plugins/ctf/common/btr/btr.h | 4 +- plugins/ctf/common/metadata/Makefile.am | 4 +- plugins/ctf/common/metadata/ast.h | 8 +- plugins/ctf/common/metadata/decoder.c | 69 +- plugins/ctf/common/metadata/decoder.h | 7 +- plugins/ctf/common/metadata/logging.c | 26 + plugins/ctf/common/metadata/logging.h | 31 + .../ctf/common/metadata/visitor-generate-ir.c | 588 ++++++++---------- .../common/metadata/visitor-parent-links.c | 108 ++-- .../metadata/visitor-semantic-validator.c | 173 +++--- plugins/ctf/common/notif-iter/notif-iter.c | 9 +- plugins/ctf/common/notif-iter/notif-iter.h | 2 +- plugins/ctf/fs-src/Makefile.am | 4 +- plugins/ctf/fs-src/data-stream-file.c | 56 +- plugins/ctf/fs-src/file.c | 35 +- plugins/ctf/fs-src/file.h | 5 +- plugins/ctf/fs-src/fs.c | 116 ++-- plugins/ctf/fs-src/fs.h | 26 +- plugins/ctf/fs-src/logging.c | 26 + plugins/ctf/fs-src/logging.h | 31 + plugins/ctf/fs-src/metadata.c | 38 +- plugins/ctf/fs-src/metadata.h | 8 +- plugins/ctf/fs-src/query.c | 4 + plugins/ctf/lttng-live/data-stream.c | 4 +- plugins/ctf/lttng-live/metadata.c | 2 +- 26 files changed, 724 insertions(+), 671 deletions(-) create mode 100644 plugins/ctf/common/metadata/logging.c create mode 100644 plugins/ctf/common/metadata/logging.h create mode 100644 plugins/ctf/fs-src/logging.c create mode 100644 plugins/ctf/fs-src/logging.h diff --git a/plugins/ctf/common/btr/btr.c b/plugins/ctf/common/btr/btr.c index ecceb5b1..93c233fc 100644 --- a/plugins/ctf/common/btr/btr.c +++ b/plugins/ctf/common/btr/btr.c @@ -43,10 +43,6 @@ #include "btr.h" -#define PRINT_ERR_STREAM (btr ? btr->err_stream : stderr) -#define PRINT_PREFIX "ctf-btr" -#include "../print.h" - #define DIV8(_x) ((_x) >> 3) #define BYTES_TO_BITS(_x) ((_x) * 8) #define BITS_TO_BYTES_FLOOR(_x) DIV8(_x) @@ -95,9 +91,6 @@ struct bt_ctf_btr { /* Bisit stack */ struct stack *stack; - /* Error stream */ - FILE *err_stream; - /* Current basic field type */ struct bt_ctf_field_type *cur_basic_field_type; @@ -1404,8 +1397,7 @@ enum bt_ctf_btr_status handle_state(struct bt_ctf_btr *btr) return status; } -struct bt_ctf_btr *bt_ctf_btr_create(struct bt_ctf_btr_cbs cbs, void *data, - FILE *err_stream) +struct bt_ctf_btr *bt_ctf_btr_create(struct bt_ctf_btr_cbs cbs, void *data) { struct bt_ctf_btr *btr; @@ -1427,7 +1419,6 @@ struct bt_ctf_btr *bt_ctf_btr_create(struct bt_ctf_btr_cbs cbs, void *data, btr->state = BTR_STATE_NEXT_FIELD; btr->user.cbs = cbs; btr->user.data = data; - btr->err_stream = err_stream; BT_LOGD("Created BTR: addr=%p", btr); end: diff --git a/plugins/ctf/common/btr/btr.h b/plugins/ctf/common/btr/btr.h index 29020ca2..af2a6569 100644 --- a/plugins/ctf/common/btr/btr.h +++ b/plugins/ctf/common/btr/btr.h @@ -275,11 +275,9 @@ struct bt_ctf_btr_cbs { * * @param cbs User callback functions * @param data User data (passed to user callback functions) - * @param err_stream Error stream (can be \c NULL to disable) * @returns New binary type reader on success, or \c NULL on error */ -struct bt_ctf_btr *bt_ctf_btr_create(struct bt_ctf_btr_cbs cbs, void *data, - FILE *err_stream); +struct bt_ctf_btr *bt_ctf_btr_create(struct bt_ctf_btr_cbs cbs, void *data); /** * Destroys a CTF binary type reader, freeing all internal resources. diff --git a/plugins/ctf/common/metadata/Makefile.am b/plugins/ctf/common/metadata/Makefile.am index 9e675e22..1cd9e753 100644 --- a/plugins/ctf/common/metadata/Makefile.am +++ b/plugins/ctf/common/metadata/Makefile.am @@ -22,7 +22,9 @@ libctf_ast_la_SOURCES = \ scanner.h \ scanner-symbols.h \ decoder.c \ - decoder.h + decoder.h \ + logging.c \ + logging.h libctf_ast_la_LIBADD = diff --git a/plugins/ctf/common/metadata/ast.h b/plugins/ctf/common/metadata/ast.h index b06eb73f..737158cd 100644 --- a/plugins/ctf/common/metadata/ast.h +++ b/plugins/ctf/common/metadata/ast.h @@ -308,8 +308,8 @@ struct ctf_ast { const char *node_type(struct ctf_node *node); BT_HIDDEN -struct ctf_visitor_generate_ir *ctf_visitor_generate_ir_create(FILE *efd, - uint64_t clock_class_offset_ns, const char *name); +struct ctf_visitor_generate_ir *ctf_visitor_generate_ir_create( + int64_t clock_class_offset_ns, const char *name); void ctf_visitor_generate_ir_destroy(struct ctf_visitor_generate_ir *visitor); @@ -322,9 +322,9 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, struct ctf_node *node); BT_HIDDEN -int ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node); +int ctf_visitor_semantic_check(int depth, struct ctf_node *node); BT_HIDDEN -int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node); +int ctf_visitor_parent_links(int depth, struct ctf_node *node); #endif /* _CTF_AST_H */ diff --git a/plugins/ctf/common/metadata/decoder.c b/plugins/ctf/common/metadata/decoder.c index a1c76876..c0cfa438 100644 --- a/plugins/ctf/common/metadata/decoder.c +++ b/plugins/ctf/common/metadata/decoder.c @@ -27,15 +27,13 @@ #include "decoder.h" #include "scanner.h" -#define PRINT_ERR_STREAM (mdec ? mdec->err_stream : stderr) -#define PRINT_PREFIX "metadata-decoder" -#include "../print.h" +#define BT_LOG_TAG "PLUGIN-CTF-METADATA-DECODER" +#include "logging.h" #define TSDL_MAGIC 0x75d11d57 struct ctf_metadata_decoder { struct ctf_visitor_generate_ir *visitor; - FILE *err_stream; uint8_t uuid[16]; bool is_uuid_set; int bo; @@ -114,22 +112,22 @@ int decode_packet(struct ctf_metadata_decoder *mdec, FILE *in_fp, FILE *out_fp, } if (header.compression_scheme) { - PERR("Metadata packet compression not supported yet\n"); + BT_LOGE("Metadata packet compression not supported yet"); goto error; } if (header.encryption_scheme) { - PERR("Metadata packet encryption not supported yet\n"); + BT_LOGE("Metadata packet encryption not supported yet"); goto error; } if (header.checksum || header.checksum_scheme) { - PERR("Metadata packet checksum verification not supported yet\n"); + BT_LOGE("Metadata packet checksum verification not supported yet"); goto error; } if (!is_version_valid(header.major, header.minor)) { - PERR("Invalid metadata version: %u.%u\n", header.major, + BT_LOGE("Invalid metadata version: %u.%u", header.major, header.minor); goto error; } @@ -140,13 +138,13 @@ int decode_packet(struct ctf_metadata_decoder *mdec, FILE *in_fp, FILE *out_fp, memcpy(mdec->uuid, header.uuid, sizeof(header.uuid)); mdec->is_uuid_set = true; } else if (bt_uuid_compare(header.uuid, mdec->uuid)) { - PERR("Metadata UUID mismatch between packets of the same stream\n"); + BT_LOGE("Metadata UUID mismatch between packets of the same stream"); goto error; } } if ((header.content_size / CHAR_BIT) < sizeof(header)) { - PERR("Bad metadata packet content size: %u\n", + BT_LOGE("Bad metadata packet content size: %u", header.content_size); goto error; } @@ -157,14 +155,14 @@ int decode_packet(struct ctf_metadata_decoder *mdec, FILE *in_fp, FILE *out_fp, readlen = fread(buf, sizeof(uint8_t), MIN(sizeof(buf) - 1, toread), in_fp); if (ferror(in_fp)) { - PERR("Cannot read metadata packet buffer (at position %ld)\n", + BT_LOGE("Cannot read metadata packet buffer (at position %ld)", ftell(in_fp)); goto error; } writelen = fwrite(buf, sizeof(uint8_t), readlen, out_fp); if (writelen < readlen || ferror(out_fp)) { - PERR("Cannot write decoded metadata text to buffer\n"); + BT_LOGE("Cannot write decoded metadata text to buffer"); goto error; } @@ -177,7 +175,7 @@ int decode_packet(struct ctf_metadata_decoder *mdec, FILE *in_fp, FILE *out_fp, CHAR_BIT; fseek_ret = fseek(in_fp, toread, SEEK_CUR); if (fseek_ret < 0) { - PWARN("Missing padding at the end of the metadata file\n"); + BT_LOGW("Missing padding at the end of the metadata file"); } break; @@ -206,7 +204,7 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec( out_fp = bt_open_memstream(buf, &size); if (out_fp == NULL) { - PERR("Cannot open memory stream: %s\n", strerror(errno)); + BT_LOGE("Cannot open memory stream: %s", strerror(errno)); goto error; } @@ -217,7 +215,7 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec( tret = decode_packet(mdec, fp, out_fp, byte_order); if (tret) { - PERR("Cannot decode packet #%zu\n", packet_index); + BT_LOGE("Cannot decode packet #%zu", packet_index); goto error; } @@ -227,14 +225,14 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec( /* Make sure the whole string ends with a null character */ tret = fputc('\0', out_fp); if (tret == EOF) { - PERR("Cannot append '\\0' to the decoded metadata buffer\n"); + BT_LOGE("Cannot append '\\0' to the decoded metadata buffer"); goto error; } /* Close stream, which also flushes the buffer */ ret = bt_close_memstream(buf, &size, out_fp); if (ret < 0) { - PERR("Cannot close memory stream: %s\n", strerror(errno)); + BT_LOGE("Cannot close memory stream: %s", strerror(errno)); goto error; } @@ -265,8 +263,8 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf( } BT_HIDDEN -struct ctf_metadata_decoder *ctf_metadata_decoder_create(FILE *err, - uint64_t clock_class_offset_ns, const char *name) +struct ctf_metadata_decoder *ctf_metadata_decoder_create( + int64_t clock_class_offset_ns, const char *name) { struct ctf_metadata_decoder *mdec = g_new0(struct ctf_metadata_decoder, 1); @@ -275,9 +273,8 @@ struct ctf_metadata_decoder *ctf_metadata_decoder_create(FILE *err, goto end; } - mdec->err_stream = err; - mdec->visitor = ctf_visitor_generate_ir_create(err, - clock_class_offset_ns, name); + mdec->visitor = ctf_visitor_generate_ir_create(clock_class_offset_ns, + name); if (!mdec->visitor) { ctf_metadata_decoder_destroy(mdec); mdec = NULL; @@ -313,7 +310,7 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( assert(mdec); if (ctf_metadata_decoder_is_packetized(fp, &mdec->bo)) { - PDBG("Metadata stream is packetized\n"); + BT_LOGD("Metadata stream is packetized"); ret = ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec( mdec, fp, &buf, mdec->bo); if (ret) { @@ -331,7 +328,7 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( fp = bt_fmemopen(buf, strlen(buf), "rb"); close_fp = true; if (!fp) { - PERR("Cannot memory-open metadata buffer: %s\n", + BT_LOGE("Cannot memory-open metadata buffer: %s", strerror(errno)); status = CTF_METADATA_DECODER_STATUS_ERROR; goto end; @@ -341,24 +338,24 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( ssize_t nr_items; const long init_pos = ftell(fp); - PDBG("Metadata stream is plain text\n"); + BT_LOGD("Metadata stream is plain text"); /* Check text-only metadata header and version */ nr_items = fscanf(fp, "/* CTF %10u.%10u", &major, &minor); if (nr_items < 2) { - PWARN("Ill-shapen or missing \"/* CTF major.minor\" header in plain text metadata file stream\n"); + BT_LOGW("Ill-shapen or missing \"/* CTF major.minor\" header in plain text metadata file stream"); } - PDBG("Metadata version: %u.%u\n", major, minor); + BT_LOGD("Metadata version: %u.%u", major, minor); if (!is_version_valid(major, minor)) { - PERR("Invalid metadata version: %u.%u\n", major, minor); + BT_LOGE("Invalid metadata version: %u.%u", major, minor); status = CTF_METADATA_DECODER_STATUS_INVAL_VERSION; goto end; } if (fseek(fp, init_pos, SEEK_SET)) { - PERR("Cannot seek metadata file stream to initial position: %s\n", + BT_LOGE("Cannot seek metadata file stream to initial position: %s", strerror(errno)); status = CTF_METADATA_DECODER_STATUS_ERROR; goto end; @@ -368,7 +365,7 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( /* Allocate a scanner and append the metadata text content */ scanner = ctf_scanner_alloc(); if (!scanner) { - PERR("Cannot allocate a metadata lexical scanner\n"); + BT_LOGE("Cannot allocate a metadata lexical scanner"); status = CTF_METADATA_DECODER_STATUS_ERROR; goto end; } @@ -376,14 +373,14 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( assert(fp); ret = ctf_scanner_append_ast(scanner, fp); if (ret) { - PERR("Cannot create the metadata AST\n"); + BT_LOGE("Cannot create the metadata AST"); status = CTF_METADATA_DECODER_STATUS_INCOMPLETE; goto end; } - ret = ctf_visitor_semantic_check(stderr, 0, &scanner->ast->root); + ret = ctf_visitor_semantic_check(0, &scanner->ast->root); if (ret) { - PERR("Metadata semantic validation failed\n"); + BT_LOGE("Metadata semantic validation failed"); status = CTF_METADATA_DECODER_STATUS_ERROR; goto end; } @@ -395,11 +392,11 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( /* Success */ break; case -EINCOMPLETE: - PDBG("While visiting AST: incomplete data\n"); + BT_LOGD("While visiting AST: incomplete data"); status = CTF_METADATA_DECODER_STATUS_INCOMPLETE; goto end; default: - PERR("Cannot visit AST node to create CTF IR objects\n"); + BT_LOGE("Cannot visit AST node to create CTF IR objects"); status = CTF_METADATA_DECODER_STATUS_IR_VISITOR_ERROR; goto end; } @@ -411,7 +408,7 @@ end: if (fp && close_fp) { if (fclose(fp)) { - PERR("Cannot close metadata file stream\n"); + BT_LOGE("Cannot close metadata file stream"); } } diff --git a/plugins/ctf/common/metadata/decoder.h b/plugins/ctf/common/metadata/decoder.h index cf8ed00d..959bdd40 100644 --- a/plugins/ctf/common/metadata/decoder.h +++ b/plugins/ctf/common/metadata/decoder.h @@ -32,16 +32,15 @@ enum ctf_metadata_decoder_status { }; /* - * Creates a CTF metadata decoder with `err` as the error stream (can - * be `NULL` to disable error output). `clock_class_offset_ns` is an + * Creates a CTF metadata decoder. `clock_class_offset_ns` is an * offset to apply to the decoded clock classes's offsets. `name` is * this decoder's trace's name. * * Returns `NULL` on error. */ BT_HIDDEN -struct ctf_metadata_decoder *ctf_metadata_decoder_create(FILE *err, - uint64_t clock_class_offset_ns, const char *name); +struct ctf_metadata_decoder *ctf_metadata_decoder_create( + int64_t clock_class_offset_ns, const char *name); /* * Destroys a CTF metadata decoder that you created with diff --git a/plugins/ctf/common/metadata/logging.c b/plugins/ctf/common/metadata/logging.c new file mode 100644 index 00000000..3d12e291 --- /dev/null +++ b/plugins/ctf/common/metadata/logging.c @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define BT_LOG_OUTPUT_LEVEL metadata_log_level +#include + +BT_LOG_INIT_LOG_LEVEL(metadata_log_level, "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL"); diff --git a/plugins/ctf/common/metadata/logging.h b/plugins/ctf/common/metadata/logging.h new file mode 100644 index 00000000..5ecbdb13 --- /dev/null +++ b/plugins/ctf/common/metadata/logging.h @@ -0,0 +1,31 @@ +#ifndef CTF_METADATA_LOGGING_H +#define CTF_METADATA_LOGGING_H + +/* + * Copyright (c) 2017 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define BT_LOG_OUTPUT_LEVEL metadata_log_level +#include + +BT_LOG_LEVEL_EXTERN_SYMBOL(metadata_log_level); + +#endif /* CTF_METADATA_LOGGING_H */ diff --git a/plugins/ctf/common/metadata/visitor-generate-ir.c b/plugins/ctf/common/metadata/visitor-generate-ir.c index 6fefc24d..1ffa1c22 100644 --- a/plugins/ctf/common/metadata/visitor-generate-ir.c +++ b/plugins/ctf/common/metadata/visitor-generate-ir.c @@ -52,6 +52,9 @@ #include "parser.h" #include "ast.h" +#define BT_LOG_TAG "PLUGIN-CTF-METADATA-VISITOR-GENERATE-IR" +#include "logging.h" + /* Bit value (left shift) */ #define _BV(_val) (1 << (_val)) @@ -150,40 +153,9 @@ enum loglevel { #define _BT_CTF_FIELD_TYPE_INIT(_name) struct bt_ctf_field_type *_name = NULL; -/* Error printing wrappers */ -#define _PERROR(_fmt, ...) \ - do { \ - if (!ctx->efd) break; \ - fprintf(ctx->efd, "[error] %s: " _fmt "\n", \ - __func__, __VA_ARGS__); \ - } while (0) - -#define _PWARNING(_fmt, ...) \ - do { \ - if (!ctx->efd) break; \ - fprintf(ctx->efd, "[warning] %s: " _fmt "\n", \ - __func__, __VA_ARGS__); \ - } while (0) - -#define _FPERROR(_stream, _fmt, ...) \ +#define BT_LOGE_DUP_ATTR(_attr, _entity) \ do { \ - if (!_stream) break; \ - fprintf(_stream, "[error] %s: " _fmt "\n", \ - __func__, __VA_ARGS__); \ - } while (0) - -#define _FPWARNING(_stream, _fmt, ...) \ - do { \ - if (!_stream) break; \ - fprintf(_stream, "[warning] %s: " _fmt "\n", \ - __func__, __VA_ARGS__); \ - } while (0) - -#define _PERROR_DUP_ATTR(_attr, _entity) \ - do { \ - if (!ctx->efd) break; \ - fprintf(ctx->efd, \ - "[error] %s: duplicate attribute \"" \ + BT_LOGE("[error] %s: duplicate attribute \"" \ _attr "\" in " _entity "\n", __func__); \ } while (0) @@ -211,9 +183,6 @@ struct ctx { /* Trace being filled (owned by this) */ struct bt_ctf_trace *trace; - /* Error stream to use during visit */ - FILE *efd; - /* Current declaration scope (top of the stack) */ struct ctx_decl_scope *current_scope; @@ -224,7 +193,7 @@ struct ctx { bool is_lttng; /* Offset (ns) to apply to clock classes on creation */ - uint64_t clock_class_offset_ns; + int64_t clock_class_offset_ns; /* Eventual name suffix of the trace to set */ char *trace_name_suffix; @@ -618,12 +587,11 @@ end: * Creates a new visitor context. * * @param trace Associated trace - * @param efd Error stream * @returns New visitor context, or NULL on error */ static -struct ctx *ctx_create(struct bt_ctf_trace *trace, FILE *efd, - uint64_t clock_class_offset_ns, const char *trace_name_suffix) +struct ctx *ctx_create(struct bt_ctf_trace *trace, + int64_t clock_class_offset_ns, const char *trace_name_suffix) { struct ctx *ctx = NULL; struct ctx_decl_scope *scope = NULL; @@ -653,7 +621,6 @@ struct ctx *ctx_create(struct bt_ctf_trace *trace, FILE *efd, } ctx->trace = trace; - ctx->efd = efd; ctx->current_scope = scope; scope = NULL; ctx->trace_bo = BT_CTF_BYTE_ORDER_NATIVE; @@ -986,12 +953,12 @@ end: } static -int get_boolean(FILE *efd, struct ctf_node *unary_expr) +int get_boolean(struct ctf_node *unary_expr) { int ret = 0; if (unary_expr->type != NODE_UNARY_EXPRESSION) { - _FPERROR(efd, "%s", "expecting unary expression"); + BT_LOGE("expecting unary expression"); ret = -EINVAL; goto end; } @@ -1012,14 +979,14 @@ int get_boolean(FILE *efd, struct ctf_node *unary_expr) } else if (!strcmp(str, "false") || !strcmp(str, "FALSE")) { ret = FALSE; } else { - _FPERROR(efd, "unexpected string \"%s\"", str); + BT_LOGE("unexpected string \"%s\"", str); ret = -EINVAL; goto end; } break; } default: - _FPERROR(efd, "%s", "unexpected unary expression type"); + BT_LOGE("unexpected unary expression type"); ret = -EINVAL; goto end; } @@ -1029,15 +996,13 @@ end: } static -enum bt_ctf_byte_order byte_order_from_unary_expr(FILE *efd, - struct ctf_node *unary_expr) +enum bt_ctf_byte_order byte_order_from_unary_expr(struct ctf_node *unary_expr) { const char *str; enum bt_ctf_byte_order bo = BT_CTF_BYTE_ORDER_UNKNOWN; if (unary_expr->u.unary_expression.type != UNARY_STRING) { - _FPERROR(efd, "%s", - "\"byte_order\" attribute: expecting string"); + BT_LOGE("\"byte_order\" attribute: expecting string"); goto end; } @@ -1050,7 +1015,7 @@ enum bt_ctf_byte_order byte_order_from_unary_expr(FILE *efd, } else if (!strcmp(str, "native")) { bo = BT_CTF_BYTE_ORDER_NATIVE; } else { - _FPERROR(efd, "unexpected \"byte_order\" attribute value \"%s\"; should be \"be\", \"le\", \"network\", or \"native\"", + BT_LOGE("unexpected \"byte_order\" attribute value \"%s\"; should be \"be\", \"le\", \"network\", or \"native\"", str); goto end; } @@ -1063,7 +1028,7 @@ static enum bt_ctf_byte_order get_real_byte_order(struct ctx *ctx, struct ctf_node *uexpr) { - enum bt_ctf_byte_order bo = byte_order_from_unary_expr(ctx->efd, uexpr); + enum bt_ctf_byte_order bo = byte_order_from_unary_expr(uexpr); if (bo == BT_CTF_BYTE_ORDER_NATIVE) { bo = bt_ctf_trace_get_native_byte_order(ctx->trace); @@ -1140,7 +1105,7 @@ int get_type_specifier_name(struct ctx *ctx, struct ctf_node *type_specifier, struct ctf_node *node = type_specifier->u.type_specifier.node; if (!node->u._struct.name) { - _PERROR("%s", "unexpected empty structure name"); + BT_LOGE("unexpected empty structure name"); ret = -EINVAL; goto end; } @@ -1154,7 +1119,7 @@ int get_type_specifier_name(struct ctx *ctx, struct ctf_node *type_specifier, struct ctf_node *node = type_specifier->u.type_specifier.node; if (!node->u.variant.name) { - _PERROR("%s", "unexpected empty variant name"); + BT_LOGE("unexpected empty variant name"); ret = -EINVAL; goto end; } @@ -1168,7 +1133,7 @@ int get_type_specifier_name(struct ctx *ctx, struct ctf_node *type_specifier, struct ctf_node *node = type_specifier->u.type_specifier.node; if (!node->u._enum.enum_id) { - _PERROR("%s", "unexpected empty enum name"); + BT_LOGE("unexpected empty enum name"); ret = -EINVAL; goto end; } @@ -1181,7 +1146,7 @@ int get_type_specifier_name(struct ctx *ctx, struct ctf_node *type_specifier, case TYPESPEC_INTEGER: case TYPESPEC_STRING: default: - _PERROR("%s", "unknown specifier"); + BT_LOGE("unknown specifier"); ret = -EINVAL; goto end; } @@ -1278,7 +1243,7 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, /* TODO: GCC bitfields not supported yet */ if (node_type_declarator->u.type_declarator.bitfield_len != NULL) { - _PERROR("%s", "GCC bitfields are not supported as of this version"); + BT_LOGE("GCC bitfields are not supported as of this version"); ret = -EPERM; goto error; } @@ -1303,7 +1268,7 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, ctx_decl_scope_lookup_alias(ctx->current_scope, g_quark_to_string(qalias), -1); if (!nested_decl) { - _PERROR("cannot find typealias \"%s\"", + BT_LOGE("cannot find typealias \"%s\"", g_quark_to_string(qalias)); ret = -EINVAL; goto error; @@ -1313,7 +1278,7 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, nested_decl_copy = bt_ctf_field_type_copy(nested_decl); BT_PUT(nested_decl); if (!nested_decl_copy) { - _PERROR("%s", "cannot copy nested field type"); + BT_LOGE("cannot copy nested field type"); ret = -EINVAL; goto error; } @@ -1364,8 +1329,7 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, /* Create array/sequence, pass nested_decl as child */ if (bt_list_empty(length)) { - _PERROR("%s", - "expecting length field reference or value"); + BT_LOGE("expecting length field reference or value"); ret = -EINVAL; goto error; } @@ -1387,8 +1351,7 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, len); BT_PUT(nested_decl); if (!array_decl) { - _PERROR("%s", - "cannot create array field type"); + BT_LOGE("cannot create array field type"); ret = -ENOMEM; goto error; } @@ -1412,8 +1375,7 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, g_free(length_name); BT_PUT(nested_decl); if (!seq_decl) { - _PERROR("%s", - "cannot create sequence field type"); + BT_LOGE("cannot create sequence field type"); ret = -ENOMEM; goto error; } @@ -1486,7 +1448,7 @@ int visit_struct_decl_field(struct ctx *ctx, &qfield_name, iter, &field_decl, NULL); if (ret) { assert(!field_decl); - _PERROR("%s", "cannot visit type declarator"); + BT_LOGE("cannot visit type declarator"); goto error; } @@ -1499,7 +1461,7 @@ int visit_struct_decl_field(struct ctx *ctx, struct_decl, field_name); if (efield_decl) { BT_PUT(efield_decl); - _PERROR("duplicate field \"%s\" in structure", + BT_LOGE("duplicate field \"%s\" in structure", field_name); ret = -EINVAL; goto error; @@ -1510,7 +1472,7 @@ int visit_struct_decl_field(struct ctx *ctx, field_decl, field_name); BT_PUT(field_decl); if (ret) { - _PERROR("cannot add field \"%s\" to structure", + BT_LOGE("cannot add field \"%s\" to structure", g_quark_to_string(qfield_name)); goto error; } @@ -1544,8 +1506,7 @@ int visit_variant_decl_field(struct ctx *ctx, &qfield_name, iter, &field_decl, NULL); if (ret) { assert(!field_decl); - _PERROR("%s", - "cannot visit type declarator"); + BT_LOGE("cannot visit type declarator"); goto error; } @@ -1558,7 +1519,7 @@ int visit_variant_decl_field(struct ctx *ctx, variant_decl, field_name); if (efield_decl) { BT_PUT(efield_decl); - _PERROR("duplicate field \"%s\" in variant", + BT_LOGE("duplicate field \"%s\" in variant", field_name); ret = -EINVAL; goto error; @@ -1569,7 +1530,7 @@ int visit_variant_decl_field(struct ctx *ctx, field_decl, field_name); BT_PUT(field_decl); if (ret) { - _PERROR("cannot add field \"%s\" to variant", + BT_LOGE("cannot add field \"%s\" to variant", g_quark_to_string(qfield_name)); goto error; } @@ -1596,7 +1557,7 @@ int visit_typedef(struct ctx *ctx, struct ctf_node *type_specifier_list, ret = visit_type_declarator(ctx, type_specifier_list, &qidentifier, iter, &type_decl, NULL); if (ret) { - _PERROR("%s", "cannot visit type declarator"); + BT_LOGE("cannot visit type declarator"); ret = -EINVAL; goto end; } @@ -1604,7 +1565,7 @@ int visit_typedef(struct ctx *ctx, struct ctf_node *type_specifier_list, /* Do not allow typedef and typealias of untagged variants */ if (bt_ctf_field_type_is_variant(type_decl)) { if (bt_ctf_field_type_variant_get_tag_name(type_decl)) { - _PERROR("%s", "typedef of untagged variant is not allowed"); + BT_LOGE("typedef of untagged variant is not allowed"); ret = -EPERM; goto end; } @@ -1613,7 +1574,7 @@ int visit_typedef(struct ctx *ctx, struct ctf_node *type_specifier_list, ret = ctx_decl_scope_register_alias(ctx->current_scope, g_quark_to_string(qidentifier), type_decl); if (ret) { - _PERROR("cannot register typedef \"%s\"", + BT_LOGE("cannot register typedef \"%s\"", g_quark_to_string(qidentifier)); goto end; } @@ -1649,15 +1610,14 @@ int visit_typealias(struct ctx *ctx, struct ctf_node *target, &qdummy_field_name, node, &type_decl, NULL); if (ret) { assert(!type_decl); - _PERROR("%s", "cannot visit type declarator"); + BT_LOGE("cannot visit type declarator"); goto end; } /* Do not allow typedef and typealias of untagged variants */ if (bt_ctf_field_type_is_variant(type_decl)) { if (bt_ctf_field_type_variant_get_tag_name(type_decl)) { - _PERROR("%s", - "typealias of untagged variant is not allowed"); + BT_LOGE("typealias of untagged variant is not allowed"); ret = -EPERM; goto end; } @@ -1668,7 +1628,7 @@ int visit_typealias(struct ctx *ctx, struct ctf_node *target, * abstract or not (if it has an identifier). Check it here. */ if (qdummy_field_name != 0) { - _PERROR("%s", "expecting empty identifier"); + BT_LOGE("expecting empty identifier"); ret = -EINVAL; goto end; } @@ -1681,7 +1641,7 @@ int visit_typealias(struct ctx *ctx, struct ctf_node *target, ret = ctx_decl_scope_register_alias(ctx->current_scope, g_quark_to_string(qalias), type_decl); if (ret) { - _PERROR("cannot register typealias \"%s\"", + BT_LOGE("cannot register typealias \"%s\"", g_quark_to_string(qalias)); goto end; } @@ -1704,8 +1664,7 @@ int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, entry_node->u._typedef.type_specifier_list, &entry_node->u._typedef.type_declarators); if (ret) { - _PERROR("%s", - "cannot add typedef in \"struct\" declaration"); + BT_LOGE("cannot add typedef in \"struct\" declaration"); goto end; } break; @@ -1713,8 +1672,7 @@ int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = visit_typealias(ctx, entry_node->u.typealias.target, entry_node->u.typealias.alias); if (ret) { - _PERROR("%s", - "cannot add typealias in \"struct\" declaration"); + BT_LOGE("cannot add typealias in \"struct\" declaration"); goto end; } break; @@ -1730,7 +1688,7 @@ int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, } break; default: - _PERROR("unexpected node type: %d", (int) entry_node->type); + BT_LOGE("unexpected node type: %d", (int) entry_node->type); ret = -EINVAL; goto end; } @@ -1751,7 +1709,7 @@ int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, entry_node->u._typedef.type_specifier_list, &entry_node->u._typedef.type_declarators); if (ret) { - _PERROR("%s", + BT_LOGE( "cannot add typedef in \"variant\" declaration"); goto end; } @@ -1760,7 +1718,7 @@ int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = visit_typealias(ctx, entry_node->u.typealias.target, entry_node->u.typealias.alias); if (ret) { - _PERROR("%s", + BT_LOGE( "cannot add typealias in \"variant\" declaration"); goto end; } @@ -1777,7 +1735,7 @@ int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, } break; default: - _PERROR("unexpected node type: %d", (int) entry_node->type); + BT_LOGE("unexpected node type: %d", (int) entry_node->type); ret = -EINVAL; goto end; } @@ -1808,7 +1766,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name, *struct_decl = ctx_decl_scope_lookup_struct(ctx->current_scope, name, -1); if (!*struct_decl) { - _PERROR("cannot find \"struct %s\"", name); + BT_LOGE("cannot find \"struct %s\"", name); ret = -EINVAL; goto error; } @@ -1816,7 +1774,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name, /* Make a copy of it */ struct_decl_copy = bt_ctf_field_type_copy(*struct_decl); if (!struct_decl_copy) { - _PERROR("%s", + BT_LOGE( "cannot create copy of structure field type"); ret = -EINVAL; goto error; @@ -1834,7 +1792,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name, ctx->current_scope, name, 1); if (estruct_decl) { BT_PUT(estruct_decl); - _PERROR("\"struct %s\" already declared in local scope", + BT_LOGE("\"struct %s\" already declared in local scope", name); ret = -EINVAL; goto error; @@ -1844,14 +1802,14 @@ int visit_struct_decl(struct ctx *ctx, const char *name, if (!bt_list_empty(min_align)) { ret = get_unary_unsigned(min_align, &min_align_value); if (ret) { - _PERROR("%s", "unexpected unary expression for structure declaration's \"align\" attribute"); + BT_LOGE("unexpected unary expression for structure declaration's \"align\" attribute"); goto error; } } *struct_decl = bt_ctf_field_type_structure_create(); if (!*struct_decl) { - _PERROR("%s", "cannot create structure field type"); + BT_LOGE("cannot create structure field type"); ret = -ENOMEM; goto error; } @@ -1860,14 +1818,14 @@ int visit_struct_decl(struct ctx *ctx, const char *name, ret = bt_ctf_field_type_set_alignment(*struct_decl, min_align_value); if (ret) { - _PERROR("%s", "failed to set structure's minimal alignment"); + BT_LOGE("failed to set structure's minimal alignment"); goto error; } } ret = ctx_push_scope(ctx); if (ret) { - _PERROR("%s", "cannot push scope"); + BT_LOGE("cannot push scope"); goto error; } @@ -1886,7 +1844,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name, ret = ctx_decl_scope_register_struct(ctx->current_scope, name, *struct_decl); if (ret) { - _PERROR("cannot register \"struct %s\" in declaration scope", + BT_LOGE("cannot register \"struct %s\" in declaration scope", name); goto error; } @@ -1924,7 +1882,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name, ctx_decl_scope_lookup_variant(ctx->current_scope, name, -1); if (!untagged_variant_decl) { - _PERROR("cannot find \"variant %s\"", name); + BT_LOGE("cannot find \"variant %s\"", name); ret = -EINVAL; goto error; } @@ -1933,7 +1891,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name, variant_decl_copy = bt_ctf_field_type_copy( untagged_variant_decl); if (!variant_decl_copy) { - _PERROR("%s", + BT_LOGE( "cannot create copy of variant field type"); ret = -EINVAL; goto error; @@ -1950,7 +1908,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name, if (evariant_decl) { BT_PUT(evariant_decl); - _PERROR("\"variant %s\" already declared in local scope", + BT_LOGE("\"variant %s\" already declared in local scope", name); ret = -EINVAL; goto error; @@ -1960,14 +1918,14 @@ int visit_variant_decl(struct ctx *ctx, const char *name, untagged_variant_decl = bt_ctf_field_type_variant_create(NULL, NULL); if (!untagged_variant_decl) { - _PERROR("%s", "cannot create variant field type"); + BT_LOGE("cannot create variant field type"); ret = -ENOMEM; goto error; } ret = ctx_push_scope(ctx); if (ret) { - _PERROR("%s", "cannot push scope"); + BT_LOGE("cannot push scope"); goto error; } @@ -1987,7 +1945,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name, ctx->current_scope, name, untagged_variant_decl); if (ret) { - _PERROR("cannot register \"variant %s\" in declaration scope", + BT_LOGE("cannot register \"variant %s\" in declaration scope", name); goto error; } @@ -2041,7 +1999,7 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator, int64_t *target; if (iter->type != NODE_UNARY_EXPRESSION) { - _PERROR("wrong unary expression for enumeration label \"%s\"", + BT_LOGE("wrong unary expression for enumeration label \"%s\"", label); ret = -EINVAL; goto error; @@ -2062,14 +2020,14 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator, iter->u.unary_expression.u.unsigned_constant; break; default: - _PERROR("invalid enumeration entry: \"%s\"", + BT_LOGE("invalid enumeration entry: \"%s\"", label); ret = -EINVAL; goto error; } if (nr_vals > 1) { - _PERROR("invalid enumeration entry: \"%s\"", + BT_LOGE("invalid enumeration entry: \"%s\"", label); ret = -EINVAL; goto error; @@ -2096,7 +2054,7 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator, label, (uint64_t) start, (uint64_t) end); } if (ret) { - _PERROR("cannot add mapping to enumeration for label \"%s\"", + BT_LOGE("cannot add mapping to enumeration for label \"%s\"", label); goto error; } @@ -2132,7 +2090,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name, *enum_decl = ctx_decl_scope_lookup_enum(ctx->current_scope, name, -1); if (!*enum_decl) { - _PERROR("cannot find \"enum %s\"", name); + BT_LOGE("cannot find \"enum %s\"", name); ret = -EINVAL; goto error; } @@ -2140,7 +2098,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name, /* Make a copy of it */ enum_decl_copy = bt_ctf_field_type_copy(*enum_decl); if (!enum_decl_copy) { - _PERROR("%s", + BT_LOGE( "cannot create copy of enumeration field type"); ret = -EINVAL; goto error; @@ -2159,7 +2117,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name, ctx->current_scope, name, 1); if (eenum_decl) { BT_PUT(eenum_decl); - _PERROR("\"enum %s\" already declared in local scope", + BT_LOGE("\"enum %s\" already declared in local scope", name); ret = -EINVAL; goto error; @@ -2170,7 +2128,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name, integer_decl = ctx_decl_scope_lookup_alias( ctx->current_scope, "int", -1); if (!integer_decl) { - _PERROR("%s", "cannot find \"int\" type for enumeration"); + BT_LOGE("cannot find \"int\" type for enumeration"); ret = -EINVAL; goto error; } @@ -2187,14 +2145,14 @@ int visit_enum_decl(struct ctx *ctx, const char *name, assert(integer_decl); if (!bt_ctf_field_type_is_integer(integer_decl)) { - _PERROR("%s", "container type for enumeration is not an integer"); + BT_LOGE("container type for enumeration is not an integer"); ret = -EINVAL; goto error; } *enum_decl = bt_ctf_field_type_enumeration_create(integer_decl); if (!*enum_decl) { - _PERROR("%s", "cannot create enumeration field type"); + BT_LOGE("cannot create enumeration field type"); ret = -ENOMEM; goto error; } @@ -2246,7 +2204,7 @@ int visit_type_specifier(struct ctx *ctx, *decl = ctx_decl_scope_lookup_alias(ctx->current_scope, str->str, -1); if (!*decl) { - _PERROR("cannot find type alias \"%s\"", str->str); + BT_LOGE("cannot find type alias \"%s\"", str->str); ret = -EINVAL; goto error; } @@ -2254,7 +2212,7 @@ int visit_type_specifier(struct ctx *ctx, /* Make a copy of the type declaration */ decl_copy = bt_ctf_field_type_copy(*decl); if (!decl_copy) { - _PERROR("%s", "cannot create field type copy"); + BT_LOGE("cannot create field type copy"); ret = -EINVAL; goto error; } @@ -2309,13 +2267,13 @@ int visit_integer_decl(struct ctx *ctx, if (!strcmp(left->u.unary_expression.u.string, "signed")) { if (_IS_SET(&set, _INTEGER_SIGNED_SET)) { - _PERROR_DUP_ATTR("signed", + BT_LOGE_DUP_ATTR("signed", "integer declaration"); ret = -EPERM; goto error; } - signedness = get_boolean(ctx->efd, right); + signedness = get_boolean(right); if (signedness < 0) { ret = -EINVAL; goto error; @@ -2325,7 +2283,7 @@ int visit_integer_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "byte_order")) { if (_IS_SET(&set, _INTEGER_BYTE_ORDER_SET)) { - _PERROR_DUP_ATTR("byte_order", + BT_LOGE_DUP_ATTR("byte_order", "integer declaration"); ret = -EPERM; goto error; @@ -2333,7 +2291,7 @@ int visit_integer_decl(struct ctx *ctx, byte_order = get_real_byte_order(ctx, right); if (byte_order == BT_CTF_BYTE_ORDER_UNKNOWN) { - _PERROR("%s", "invalid \"byte_order\" attribute in integer declaration"); + BT_LOGE("invalid \"byte_order\" attribute in integer declaration"); ret = -EINVAL; goto error; } @@ -2341,7 +2299,7 @@ int visit_integer_decl(struct ctx *ctx, _SET(&set, _INTEGER_BYTE_ORDER_SET); } else if (!strcmp(left->u.unary_expression.u.string, "size")) { if (_IS_SET(&set, _INTEGER_SIZE_SET)) { - _PERROR_DUP_ATTR("size", + BT_LOGE_DUP_ATTR("size", "integer declaration"); ret = -EPERM; goto error; @@ -2349,18 +2307,18 @@ int visit_integer_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - _PERROR("%s", "invalid \"size\" attribute in integer declaration: expecting unsigned constant"); + BT_LOGE("invalid \"size\" attribute in integer declaration: expecting unsigned constant"); ret = -EINVAL; goto error; } size = right->u.unary_expression.u.unsigned_constant; if (size == 0) { - _PERROR("%s", "invalid \"size\" attribute in integer declaration: expecting positive constant"); + BT_LOGE("invalid \"size\" attribute in integer declaration: expecting positive constant"); ret = -EINVAL; goto error; } else if (size > 64) { - _PERROR("%s", "invalid \"size\" attribute in integer declaration: integers over 64-bit are not supported as of this version"); + BT_LOGE("invalid \"size\" attribute in integer declaration: integers over 64-bit are not supported as of this version"); ret = -EINVAL; goto error; } @@ -2369,7 +2327,7 @@ int visit_integer_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "align")) { if (_IS_SET(&set, _INTEGER_ALIGN_SET)) { - _PERROR_DUP_ATTR("align", + BT_LOGE_DUP_ATTR("align", "integer declaration"); ret = -EPERM; goto error; @@ -2377,7 +2335,7 @@ int visit_integer_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - _PERROR("%s", "invalid \"align\" attribute in integer declaration: expecting unsigned constant"); + BT_LOGE("invalid \"align\" attribute in integer declaration: expecting unsigned constant"); ret = -EINVAL; goto error; } @@ -2385,7 +2343,7 @@ int visit_integer_decl(struct ctx *ctx, alignment = right->u.unary_expression.u.unsigned_constant; if (!is_align_valid(alignment)) { - _PERROR("%s", "invalid \"align\" attribute in integer declaration: expecting power of two"); + BT_LOGE("invalid \"align\" attribute in integer declaration: expecting power of two"); ret = -EINVAL; goto error; } @@ -2393,7 +2351,7 @@ int visit_integer_decl(struct ctx *ctx, _SET(&set, _INTEGER_ALIGN_SET); } else if (!strcmp(left->u.unary_expression.u.string, "base")) { if (_IS_SET(&set, _INTEGER_BASE_SET)) { - _PERROR_DUP_ATTR("base", "integer declaration"); + BT_LOGE_DUP_ATTR("base", "integer declaration"); ret = -EPERM; goto error; } @@ -2418,7 +2376,7 @@ int visit_integer_decl(struct ctx *ctx, base = BT_CTF_INTEGER_BASE_HEXADECIMAL; break; default: - _PERROR("invalid \"base\" attribute in integer declaration: %" PRIu64, + BT_LOGE("invalid \"base\" attribute in integer declaration: %" PRIu64, right->u.unary_expression.u.unsigned_constant); ret = -EINVAL; goto error; @@ -2430,7 +2388,7 @@ int visit_integer_decl(struct ctx *ctx, char *s_right = concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { - _PERROR("%s", "unexpected unary expression for integer declaration's \"base\" attribute"); + BT_LOGE("unexpected unary expression for integer declaration's \"base\" attribute"); ret = -EINVAL; goto error; } @@ -2455,7 +2413,7 @@ int visit_integer_decl(struct ctx *ctx, !strcmp(s_right, "b")) { base = BT_CTF_INTEGER_BASE_BINARY; } else { - _PERROR("unexpected unary expression for integer declaration's \"base\" attribute: \"%s\"", + BT_LOGE("unexpected unary expression for integer declaration's \"base\" attribute: \"%s\"", s_right); g_free(s_right); ret = -EINVAL; @@ -2466,7 +2424,7 @@ int visit_integer_decl(struct ctx *ctx, break; } default: - _PERROR("%s", "invalid \"base\" attribute in integer declaration: expecting unsigned constant or unary string"); + BT_LOGE("invalid \"base\" attribute in integer declaration: expecting unsigned constant or unary string"); ret = -EINVAL; goto error; } @@ -2477,14 +2435,14 @@ int visit_integer_decl(struct ctx *ctx, char *s_right; if (_IS_SET(&set, _INTEGER_ENCODING_SET)) { - _PERROR_DUP_ATTR("encoding", + BT_LOGE_DUP_ATTR("encoding", "integer declaration"); ret = -EPERM; goto error; } if (right->u.unary_expression.type != UNARY_STRING) { - _PERROR("%s", "invalid \"encoding\" attribute in integer declaration: expecting unary string"); + BT_LOGE("invalid \"encoding\" attribute in integer declaration: expecting unary string"); ret = -EINVAL; goto error; } @@ -2492,7 +2450,7 @@ int visit_integer_decl(struct ctx *ctx, s_right = concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { - _PERROR("%s", "unexpected unary expression for integer declaration's \"encoding\" attribute"); + BT_LOGE("unexpected unary expression for integer declaration's \"encoding\" attribute"); ret = -EINVAL; goto error; } @@ -2508,7 +2466,7 @@ int visit_integer_decl(struct ctx *ctx, } else if (!strcmp(s_right, "none")) { encoding = BT_CTF_STRING_ENCODING_NONE; } else { - _PERROR("invalid \"encoding\" attribute in integer declaration: unknown encoding \"%s\"", + BT_LOGE("invalid \"encoding\" attribute in integer declaration: unknown encoding \"%s\"", s_right); g_free(s_right); ret = -EINVAL; @@ -2521,13 +2479,13 @@ int visit_integer_decl(struct ctx *ctx, const char *clock_name; if (_IS_SET(&set, _INTEGER_MAP_SET)) { - _PERROR_DUP_ATTR("map", "integer declaration"); + BT_LOGE_DUP_ATTR("map", "integer declaration"); ret = -EPERM; goto error; } if (right->u.unary_expression.type != UNARY_STRING) { - _PERROR("%s", "invalid \"map\" attribute in integer declaration: expecting unary string"); + BT_LOGE("invalid \"map\" attribute in integer declaration: expecting unary string"); ret = -EINVAL; goto error; } @@ -2540,12 +2498,12 @@ int visit_integer_decl(struct ctx *ctx, &expression->u.ctf_expression.right); if (!s_right) { - _PERROR("%s", "unexpected unary expression for integer declaration's \"map\" attribute"); + BT_LOGE("unexpected unary expression for integer declaration's \"map\" attribute"); ret = -EINVAL; goto error; } - _PWARNING("invalid \"map\" attribute in integer declaration: unknown clock class: \"%s\"", + BT_LOGW("invalid \"map\" attribute in integer declaration: unknown clock class: \"%s\"", s_right); _SET(&set, _INTEGER_MAP_SET); g_free(s_right); @@ -2555,7 +2513,7 @@ int visit_integer_decl(struct ctx *ctx, mapped_clock = bt_ctf_trace_get_clock_class_by_name( ctx->trace, clock_name); if (!mapped_clock) { - _PERROR("invalid \"map\" attribute in integer declaration: cannot find clock class \"%s\"", + BT_LOGE("invalid \"map\" attribute in integer declaration: cannot find clock class \"%s\"", clock_name); ret = -EINVAL; goto error; @@ -2563,13 +2521,13 @@ int visit_integer_decl(struct ctx *ctx, _SET(&set, _INTEGER_MAP_SET); } else { - _PWARNING("unknown attribute \"%s\" in integer declaration", + BT_LOGW("unknown attribute \"%s\" in integer declaration", left->u.unary_expression.u.string); } } if (!_IS_SET(&set, _INTEGER_SIZE_SET)) { - _PERROR("%s", + BT_LOGE( "missing \"size\" attribute in integer declaration"); ret = -EPERM; goto error; @@ -2587,7 +2545,7 @@ int visit_integer_decl(struct ctx *ctx, *integer_decl = bt_ctf_field_type_integer_create((unsigned int) size); if (!*integer_decl) { - _PERROR("%s", "cannot create integer field type"); + BT_LOGE("cannot create integer field type"); ret = -ENOMEM; goto error; } @@ -2608,7 +2566,7 @@ int visit_integer_decl(struct ctx *ctx, } if (ret) { - _PERROR("%s", "cannot configure integer field type"); + BT_LOGE("cannot configure integer field type"); ret = -EINVAL; goto error; } @@ -2655,7 +2613,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, if (!strcmp(left->u.unary_expression.u.string, "byte_order")) { if (_IS_SET(&set, _FLOAT_BYTE_ORDER_SET)) { - _PERROR_DUP_ATTR("byte_order", + BT_LOGE_DUP_ATTR("byte_order", "floating point number declaration"); ret = -EPERM; goto error; @@ -2663,7 +2621,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, byte_order = get_real_byte_order(ctx, right); if (byte_order == BT_CTF_BYTE_ORDER_UNKNOWN) { - _PERROR("%s", "invalid \"byte_order\" attribute in floating point number declaration"); + BT_LOGE("invalid \"byte_order\" attribute in floating point number declaration"); ret = -EINVAL; goto error; } @@ -2672,7 +2630,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "exp_dig")) { if (_IS_SET(&set, _FLOAT_EXP_DIG_SET)) { - _PERROR_DUP_ATTR("exp_dig", + BT_LOGE_DUP_ATTR("exp_dig", "floating point number declaration"); ret = -EPERM; goto error; @@ -2680,7 +2638,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - _PERROR("%s", "invalid \"exp_dig\" attribute in floating point number declaration: expecting unsigned constant"); + BT_LOGE("invalid \"exp_dig\" attribute in floating point number declaration: expecting unsigned constant"); ret = -EINVAL; goto error; } @@ -2690,7 +2648,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "mant_dig")) { if (_IS_SET(&set, _FLOAT_MANT_DIG_SET)) { - _PERROR_DUP_ATTR("mant_dig", + BT_LOGE_DUP_ATTR("mant_dig", "floating point number declaration"); ret = -EPERM; goto error; @@ -2698,7 +2656,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - _PERROR("%s", "invalid \"mant_dig\" attribute in floating point number declaration: expecting unsigned constant"); + BT_LOGE("invalid \"mant_dig\" attribute in floating point number declaration: expecting unsigned constant"); ret = -EINVAL; goto error; } @@ -2709,7 +2667,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "align")) { if (_IS_SET(&set, _FLOAT_ALIGN_SET)) { - _PERROR_DUP_ATTR("align", + BT_LOGE_DUP_ATTR("align", "floating point number declaration"); ret = -EPERM; goto error; @@ -2717,7 +2675,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - _PERROR("%s", "invalid \"align\" attribute in floating point number declaration: expecting unsigned constant"); + BT_LOGE("invalid \"align\" attribute in floating point number declaration: expecting unsigned constant"); ret = -EINVAL; goto error; } @@ -2726,26 +2684,26 @@ int visit_floating_point_number_decl(struct ctx *ctx, unsigned_constant; if (!is_align_valid(alignment)) { - _PERROR("%s", "invalid \"align\" attribute in floating point number declaration: expecting power of two"); + BT_LOGE("invalid \"align\" attribute in floating point number declaration: expecting power of two"); ret = -EINVAL; goto error; } _SET(&set, _FLOAT_ALIGN_SET); } else { - _PWARNING("unknown attribute \"%s\" in floating point number declaration", + BT_LOGW("unknown attribute \"%s\" in floating point number declaration", left->u.unary_expression.u.string); } } if (!_IS_SET(&set, _FLOAT_MANT_DIG_SET)) { - _PERROR("%s", "missing \"mant_dig\" attribute in floating point number declaration"); + BT_LOGE("missing \"mant_dig\" attribute in floating point number declaration"); ret = -EPERM; goto error; } if (!_IS_SET(&set, _FLOAT_EXP_DIG_SET)) { - _PERROR("%s", "missing \"exp_dig\" attribute in floating point number declaration"); + BT_LOGE("missing \"exp_dig\" attribute in floating point number declaration"); ret = -EPERM; goto error; } @@ -2762,7 +2720,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, *float_decl = bt_ctf_field_type_floating_point_create(); if (!*float_decl) { - _PERROR("%s", + BT_LOGE( "cannot create floating point number field type"); ret = -ENOMEM; goto error; @@ -2775,7 +2733,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, ret |= bt_ctf_field_type_set_byte_order(*float_decl, byte_order); ret |= bt_ctf_field_type_set_alignment(*float_decl, alignment); if (ret) { - _PERROR("%s", + BT_LOGE( "cannot configure floating point number field type"); ret = -EINVAL; goto error; @@ -2819,14 +2777,14 @@ int visit_string_decl(struct ctx *ctx, char *s_right; if (_IS_SET(&set, _STRING_ENCODING_SET)) { - _PERROR_DUP_ATTR("encoding", + BT_LOGE_DUP_ATTR("encoding", "string declaration"); ret = -EPERM; goto error; } if (right->u.unary_expression.type != UNARY_STRING) { - _PERROR("%s", "invalid \"encoding\" attribute in string declaration: expecting unary string"); + BT_LOGE("invalid \"encoding\" attribute in string declaration: expecting unary string"); ret = -EINVAL; goto error; } @@ -2834,7 +2792,7 @@ int visit_string_decl(struct ctx *ctx, s_right = concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { - _PERROR("%s", "unexpected unary expression for string declaration's \"encoding\" attribute"); + BT_LOGE("unexpected unary expression for string declaration's \"encoding\" attribute"); ret = -EINVAL; goto error; } @@ -2850,7 +2808,7 @@ int visit_string_decl(struct ctx *ctx, } else if (!strcmp(s_right, "none")) { encoding = BT_CTF_STRING_ENCODING_NONE; } else { - _PERROR("invalid \"encoding\" attribute in string declaration: unknown encoding \"%s\"", + BT_LOGE("invalid \"encoding\" attribute in string declaration: unknown encoding \"%s\"", s_right); g_free(s_right); ret = -EINVAL; @@ -2860,21 +2818,21 @@ int visit_string_decl(struct ctx *ctx, g_free(s_right); _SET(&set, _STRING_ENCODING_SET); } else { - _PWARNING("unknown attribute \"%s\" in string declaration", + BT_LOGW("unknown attribute \"%s\" in string declaration", left->u.unary_expression.u.string); } } *string_decl = bt_ctf_field_type_string_create(); if (!*string_decl) { - _PERROR("%s", "cannot create string field type"); + BT_LOGE("cannot create string field type"); ret = -ENOMEM; goto error; } ret = bt_ctf_field_type_string_set_encoding(*string_decl, encoding); if (ret) { - _PERROR("%s", "cannot configure string field type"); + BT_LOGE("cannot configure string field type"); ret = -EINVAL; goto error; } @@ -2987,7 +2945,7 @@ int visit_type_specifier_list(struct ctx *ctx, } break; default: - _PERROR("unexpected node type: %d", + BT_LOGE("unexpected node type: %d", (int) first->u.type_specifier.type); ret = -EINVAL; goto error; @@ -3017,7 +2975,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = visit_typedef(ctx, node->u._typedef.type_specifier_list, &node->u._typedef.type_declarators); if (ret) { - _PERROR("%s", + BT_LOGE( "cannot add typedef in \"event\" declaration"); goto error; } @@ -3026,7 +2984,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = visit_typealias(ctx, node->u.typealias.target, node->u.typealias.alias); if (ret) { - _PERROR("%s", "cannot add typealias in \"event\" declaration"); + BT_LOGE("cannot add typealias in \"event\" declaration"); goto error; } break; @@ -3041,7 +2999,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, if (!strcmp(left, "name")) { /* This is already known at this stage */ if (_IS_SET(set, _EVENT_NAME_SET)) { - _PERROR_DUP_ATTR("name", "event declaration"); + BT_LOGE_DUP_ATTR("name", "event declaration"); ret = -EPERM; goto error; } @@ -3051,7 +3009,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, int64_t id; if (_IS_SET(set, _EVENT_ID_SET)) { - _PERROR_DUP_ATTR("id", "event declaration"); + BT_LOGE_DUP_ATTR("id", "event declaration"); ret = -EPERM; goto error; } @@ -3060,14 +3018,14 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, (uint64_t *) &id); /* Only read "id" if get_unary_unsigned() succeeded. */ if (ret || (!ret && id < 0)) { - _PERROR("%s", "unexpected unary expression for event declaration's \"id\" attribute"); + BT_LOGE("unexpected unary expression for event declaration's \"id\" attribute"); ret = -EINVAL; goto error; } ret = bt_ctf_event_class_set_id(event_class, id); if (ret) { - _PERROR("%s", + BT_LOGE( "cannot set event declaration's ID"); goto error; } @@ -3075,7 +3033,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _EVENT_ID_SET); } else if (!strcmp(left, "stream_id")) { if (_IS_SET(set, _EVENT_STREAM_ID_SET)) { - _PERROR_DUP_ATTR("stream_id", + BT_LOGE_DUP_ATTR("stream_id", "event declaration"); ret = -EPERM; goto error; @@ -3088,7 +3046,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, * succeeded. */ if (ret || (!ret && *stream_id < 0)) { - _PERROR("%s", "unexpected unary expression for event declaration's \"stream_id\" attribute"); + BT_LOGE("unexpected unary expression for event declaration's \"stream_id\" attribute"); ret = -EINVAL; goto error; } @@ -3096,7 +3054,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _EVENT_STREAM_ID_SET); } else if (!strcmp(left, "context")) { if (_IS_SET(set, _EVENT_CONTEXT_SET)) { - _PERROR("%s", "duplicate \"context\" entry in event declaration"); + BT_LOGE("duplicate \"context\" entry in event declaration"); ret = -EPERM; goto error; } @@ -3107,7 +3065,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &decl); if (ret) { - _PERROR("%s", "cannot create event context declaration"); + BT_LOGE("cannot create event context declaration"); goto error; } @@ -3116,14 +3074,14 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, event_class, decl); BT_PUT(decl); if (ret) { - _PERROR("%s", "cannot set event's context declaration"); + BT_LOGE("cannot set event's context declaration"); goto error; } _SET(set, _EVENT_CONTEXT_SET); } else if (!strcmp(left, "fields")) { if (_IS_SET(set, _EVENT_FIELDS_SET)) { - _PERROR("%s", "duplicate \"fields\" entry in event declaration"); + BT_LOGE("duplicate \"fields\" entry in event declaration"); ret = -EPERM; goto error; } @@ -3134,7 +3092,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &decl); if (ret) { - _PERROR("%s", "cannot create event payload field type"); + BT_LOGE("cannot create event payload field type"); goto error; } @@ -3143,7 +3101,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, event_class, decl); BT_PUT(decl); if (ret) { - _PERROR("%s", "cannot set event's payload field type"); + BT_LOGE("cannot set event's payload field type"); goto error; } @@ -3154,7 +3112,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, struct bt_value *value_obj, *str_obj; if (_IS_SET(set, _EVENT_LOGLEVEL_SET)) { - _PERROR_DUP_ATTR("loglevel", + BT_LOGE_DUP_ATTR("loglevel", "event declaration"); ret = -EPERM; goto error; @@ -3163,19 +3121,19 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = get_unary_unsigned(&node->u.ctf_expression.right, &loglevel_value); if (ret) { - _PERROR("%s", "unexpected unary expression for event declaration's \"loglevel\" attribute"); + BT_LOGE("unexpected unary expression for event declaration's \"loglevel\" attribute"); ret = -EINVAL; goto error; } value_obj = bt_value_integer_create_init(loglevel_value); if (!value_obj) { - _PERROR("%s", "cannot allocate memory for loglevel value object"); + BT_LOGE("cannot allocate memory for loglevel value object"); ret = -ENOMEM; goto error; } if (bt_ctf_event_class_set_attribute(event_class, "loglevel", value_obj) != BT_VALUE_STATUS_OK) { - _PERROR("%s", "cannot set loglevel value"); + BT_LOGE("cannot set loglevel value"); ret = -EINVAL; bt_put(value_obj); goto error; @@ -3185,7 +3143,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, str_obj = bt_value_string_create_init(loglevel_str); if (bt_ctf_event_class_set_attribute(event_class, "loglevel_string", str_obj) != BT_VALUE_STATUS_OK) { - _PERROR("%s", "cannot set loglevel string"); + BT_LOGE("cannot set loglevel string"); ret = -EINVAL; bt_put(str_obj); goto error; @@ -3198,7 +3156,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, char *right; if (_IS_SET(set, _EVENT_MODEL_EMF_URI_SET)) { - _PERROR_DUP_ATTR("model.emf.uri", + BT_LOGE_DUP_ATTR("model.emf.uri", "event declaration"); ret = -EPERM; goto error; @@ -3207,7 +3165,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, right = concatenate_unary_strings( &node->u.ctf_expression.right); if (!right) { - _PERROR("%s", "unexpected unary expression for event declaration's \"model.emf.uri\" attribute"); + BT_LOGE("unexpected unary expression for event declaration's \"model.emf.uri\" attribute"); ret = -EINVAL; goto error; } @@ -3217,7 +3175,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, g_free(right); _SET(set, _EVENT_MODEL_EMF_URI_SET); } else { - _PWARNING("unknown attribute \"%s\" in event declaration", + BT_LOGW("unknown attribute \"%s\" in event declaration", left); } @@ -3264,7 +3222,7 @@ char *get_event_decl_name(struct ctx *ctx, struct ctf_node *node) name = concatenate_unary_strings( &iter->u.ctf_expression.right); if (!name) { - _PERROR("%s", "unexpected unary expression for event declaration's \"name\" attribute"); + BT_LOGE("unexpected unary expression for event declaration's \"name\" attribute"); goto error; } } @@ -3294,14 +3252,14 @@ int reset_event_decl_types(struct ctx *ctx, /* Context type. */ ret = bt_ctf_event_class_set_context_type(event_class, NULL); if (ret) { - _PERROR("%s", "cannot set initial NULL event context"); + BT_LOGE("cannot set initial NULL event context"); goto end; } /* Event payload. */ ret = bt_ctf_event_class_set_payload_type(event_class, NULL); if (ret) { - _PERROR("%s", "cannot set initial NULL event payload"); + BT_LOGE("cannot set initial NULL event payload"); goto end; } end: @@ -3317,21 +3275,21 @@ int reset_stream_decl_types(struct ctx *ctx, /* Packet context. */ ret = bt_ctf_stream_class_set_packet_context_type(stream_class, NULL); if (ret) { - _PERROR("%s", "cannot set initial empty packet context"); + BT_LOGE("cannot set initial empty packet context"); goto end; } /* Event header. */ ret = bt_ctf_stream_class_set_event_header_type(stream_class, NULL); if (ret) { - _PERROR("%s", "cannot set initial empty event header"); + BT_LOGE("cannot set initial empty event header"); goto end; } /* Event context. */ ret = bt_ctf_stream_class_set_event_context_type(stream_class, NULL); if (ret) { - _PERROR("%s", "cannot set initial empty stream event context"); + BT_LOGE("cannot set initial empty stream event context"); goto end; } end: @@ -3346,7 +3304,7 @@ struct bt_ctf_stream_class *create_reset_stream_class(struct ctx *ctx) stream_class = bt_ctf_stream_class_create(NULL); if (!stream_class) { - _PERROR("%s", "cannot create stream class"); + BT_LOGE("cannot create stream class"); goto error; } @@ -3389,7 +3347,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) node->visited = TRUE; event_name = get_event_decl_name(ctx, node); if (!event_name) { - _PERROR("%s", + BT_LOGE( "missing \"name\" attribute in event declaration"); ret = -EPERM; goto error; @@ -3407,7 +3365,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) ret = ctx_push_scope(ctx); if (ret) { - _PERROR("%s", "cannot push scope"); + BT_LOGE("cannot push scope"); goto error; } @@ -3443,7 +3401,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) ret = bt_ctf_stream_class_set_id(new_stream_class, 0); if (ret) { - _PERROR("%s", "cannot set stream class's ID"); + BT_LOGE("cannot set stream class's ID"); BT_PUT(new_stream_class); goto error; } @@ -3474,7 +3432,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) } break; default: - _PERROR("%s", "missing \"stream_id\" attribute in event declaration"); + BT_LOGE("missing \"stream_id\" attribute in event declaration"); ret = -EPERM; goto error; } @@ -3490,7 +3448,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) stream_class = bt_ctf_trace_get_stream_class_by_id(ctx->trace, stream_id); if (!stream_class) { - _PERROR("cannot find stream class with ID %" PRId64, + BT_LOGE("cannot find stream class with ID %" PRId64, stream_id); ret = -EINVAL; goto error; @@ -3503,7 +3461,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) /* Allow only one event without ID per stream */ if (bt_ctf_stream_class_get_event_class_count(stream_class) != 0) { - _PERROR("%s", + BT_LOGE( "missing \"id\" field in event declaration"); ret = -EPERM; goto error; @@ -3512,14 +3470,14 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) /* Automatic ID */ ret = bt_ctf_event_class_set_id(event_class, 0); if (ret) { - _PERROR("%s", "cannot set event's ID"); + BT_LOGE("cannot set event's ID"); goto error; } } event_id = bt_ctf_event_class_get_id(event_class); if (event_id < 0) { - _PERROR("%s", "cannot get event's ID"); + BT_LOGE("cannot get event's ID"); ret = -EINVAL; goto error; } @@ -3528,7 +3486,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) event_id); if (eevent_class) { BT_PUT(eevent_class); - _PERROR("duplicate event with ID %" PRId64 " in same stream", event_id); + BT_LOGE("duplicate event with ID %" PRId64 " in same stream", event_id); ret = -EEXIST; goto error; } @@ -3536,7 +3494,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) ret = bt_ctf_stream_class_add_event_class(stream_class, event_class); BT_PUT(event_class); if (ret) { - _PERROR("%s", "cannot add event class to stream class"); + BT_LOGE("cannot add event class to stream class"); goto error; } @@ -3568,7 +3526,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = visit_typedef(ctx, node->u._typedef.type_specifier_list, &node->u._typedef.type_declarators); if (ret) { - _PERROR("%s", + BT_LOGE( "cannot add typedef in \"stream\" declaration"); goto error; } @@ -3577,7 +3535,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = visit_typealias(ctx, node->u.typealias.target, node->u.typealias.alias); if (ret) { - _PERROR("%s", "cannot add typealias in \"stream\" declaration"); + BT_LOGE("cannot add typealias in \"stream\" declaration"); goto error; } break; @@ -3594,7 +3552,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, gpointer ptr; if (_IS_SET(set, _STREAM_ID_SET)) { - _PERROR_DUP_ATTR("id", "stream declaration"); + BT_LOGE_DUP_ATTR("id", "stream declaration"); ret = -EPERM; goto error; } @@ -3603,7 +3561,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, (uint64_t *) &id); /* Only read "id" if get_unary_unsigned() succeeded. */ if (ret || (!ret && id < 0)) { - _PERROR("%s", "unexpected unary expression for stream declaration's \"id\" attribute"); + BT_LOGE("unexpected unary expression for stream declaration's \"id\" attribute"); ret = -EINVAL; goto error; } @@ -3611,7 +3569,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, ptr = g_hash_table_lookup(ctx->stream_classes, (gpointer) id); if (ptr) { - _PERROR("duplicate stream with ID %" PRId64, + BT_LOGE("duplicate stream with ID %" PRId64, id); ret = -EEXIST; goto error; @@ -3619,7 +3577,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = bt_ctf_stream_class_set_id(stream_class, id); if (ret) { - _PERROR("%s", + BT_LOGE( "cannot set stream class's ID"); goto error; } @@ -3627,7 +3585,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _STREAM_ID_SET); } else if (!strcmp(left, "event.header")) { if (_IS_SET(set, _STREAM_EVENT_HEADER_SET)) { - _PERROR("%s", "duplicate \"event.header\" entry in stream declaration"); + BT_LOGE("duplicate \"event.header\" entry in stream declaration"); ret = -EPERM; goto error; } @@ -3638,7 +3596,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &decl); if (ret) { - _PERROR("%s", "cannot create event header field type"); + BT_LOGE("cannot create event header field type"); goto error; } @@ -3648,14 +3606,14 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, stream_class, decl); BT_PUT(decl); if (ret) { - _PERROR("%s", "cannot set stream's event header field type"); + BT_LOGE("cannot set stream's event header field type"); goto error; } _SET(set, _STREAM_EVENT_HEADER_SET); } else if (!strcmp(left, "event.context")) { if (_IS_SET(set, _STREAM_EVENT_CONTEXT_SET)) { - _PERROR("%s", "duplicate \"event.context\" entry in stream declaration"); + BT_LOGE("duplicate \"event.context\" entry in stream declaration"); ret = -EPERM; goto error; } @@ -3666,7 +3624,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &decl); if (ret) { - _PERROR("%s", "cannot create stream event context field type"); + BT_LOGE("cannot create stream event context field type"); goto error; } @@ -3676,14 +3634,14 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, stream_class, decl); BT_PUT(decl); if (ret) { - _PERROR("%s", "cannot set stream's event context field type"); + BT_LOGE("cannot set stream's event context field type"); goto error; } _SET(set, _STREAM_EVENT_CONTEXT_SET); } else if (!strcmp(left, "packet.context")) { if (_IS_SET(set, _STREAM_PACKET_CONTEXT_SET)) { - _PERROR("%s", "duplicate \"packet.context\" entry in stream declaration"); + BT_LOGE("duplicate \"packet.context\" entry in stream declaration"); ret = -EPERM; goto error; } @@ -3694,7 +3652,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &decl); if (ret) { - _PERROR("%s", "cannot create packet context field type"); + BT_LOGE("cannot create packet context field type"); goto error; } @@ -3704,13 +3662,13 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, stream_class, decl); BT_PUT(decl); if (ret) { - _PERROR("%s", "cannot set stream's packet context field type"); + BT_LOGE("cannot set stream's packet context field type"); goto error; } _SET(set, _STREAM_PACKET_CONTEXT_SET); } else { - _PWARNING("unknown attribute \"%s\" in stream declaration", + BT_LOGW("unknown attribute \"%s\" in stream declaration", left); } @@ -3757,7 +3715,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) ret = ctx_push_scope(ctx); if (ret) { - _PERROR("%s", "cannot push scope"); + BT_LOGE("cannot push scope"); goto error; } @@ -3779,7 +3737,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) packet_header_decl = bt_ctf_trace_get_packet_header_type(ctx->trace); if (!packet_header_decl) { - _PERROR("%s", + BT_LOGE( "cannot get trace packet header field type"); goto error; } @@ -3789,13 +3747,13 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) packet_header_decl, "stream_id"); BT_PUT(packet_header_decl); if (!stream_id_decl) { - _PERROR("%s", "missing \"stream_id\" field in packet header declaration, but \"id\" attribute is declared for stream"); + BT_LOGE("missing \"stream_id\" field in packet header declaration, but \"id\" attribute is declared for stream"); goto error; } if (!bt_ctf_field_type_is_integer(stream_id_decl)) { BT_PUT(stream_id_decl); - _PERROR("%s", "\"stream_id\" field in packet header declaration is not an integer"); + BT_LOGE("\"stream_id\" field in packet header declaration is not an integer"); goto error; } @@ -3803,7 +3761,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) } else { /* Allow only _one_ ID-less stream */ if (g_hash_table_size(ctx->stream_classes) != 0) { - _PERROR("%s", + BT_LOGE( "missing \"id\" field in stream declaration"); ret = -EPERM; goto error; @@ -3815,7 +3773,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) id = bt_ctf_stream_class_get_id(stream_class); if (id < 0) { - _PERROR("wrong stream ID: %" PRId64, id); + BT_LOGE("wrong stream ID: %" PRId64, id); ret = -EINVAL; goto error; } @@ -3825,7 +3783,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) * the trace. */ if (g_hash_table_lookup(ctx->stream_classes, (gpointer) id)) { - _PERROR("a stream class with ID: %" PRId64 " already exists in the trace", id); + BT_LOGE("a stream class with ID: %" PRId64 " already exists in the trace", id); ret = -EINVAL; goto error; } @@ -3833,7 +3791,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) existing_stream_class = bt_ctf_trace_get_stream_class_by_id(ctx->trace, id); if (existing_stream_class) { - _PERROR("a stream class with ID: %" PRId64 " already exists in the trace", id); + BT_LOGE("a stream class with ID: %" PRId64 " already exists in the trace", id); ret = -EINVAL; goto error; } @@ -3864,7 +3822,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = visit_typedef(ctx, node->u._typedef.type_specifier_list, &node->u._typedef.type_declarators); if (ret) { - _PERROR("%s", + BT_LOGE( "cannot add typedef in \"trace\" declaration"); goto error; } @@ -3873,7 +3831,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = visit_typealias(ctx, node->u.typealias.target, node->u.typealias.alias); if (ret) { - _PERROR("%s", + BT_LOGE( "cannot add typealias in \"trace\" declaration"); goto error; } @@ -3888,7 +3846,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) if (!strcmp(left, "major")) { if (_IS_SET(set, _TRACE_MAJOR_SET)) { - _PERROR_DUP_ATTR("major", "trace declaration"); + BT_LOGE_DUP_ATTR("major", "trace declaration"); ret = -EPERM; goto error; } @@ -3896,7 +3854,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = get_unary_unsigned(&node->u.ctf_expression.right, &ctx->trace_major); if (ret) { - _PERROR("%s", "unexpected unary expression for trace's \"major\" attribute"); + BT_LOGE("unexpected unary expression for trace's \"major\" attribute"); ret = -EINVAL; goto error; } @@ -3904,7 +3862,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) _SET(set, _TRACE_MAJOR_SET); } else if (!strcmp(left, "minor")) { if (_IS_SET(set, _TRACE_MINOR_SET)) { - _PERROR_DUP_ATTR("minor", "trace declaration"); + BT_LOGE_DUP_ATTR("minor", "trace declaration"); ret = -EPERM; goto error; } @@ -3912,7 +3870,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = get_unary_unsigned(&node->u.ctf_expression.right, &ctx->trace_minor); if (ret) { - _PERROR("%s", "unexpected unary expression for trace's \"minor\" attribute"); + BT_LOGE("unexpected unary expression for trace's \"minor\" attribute"); ret = -EINVAL; goto error; } @@ -3920,7 +3878,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) _SET(set, _TRACE_MINOR_SET); } else if (!strcmp(left, "uuid")) { if (_IS_SET(set, _TRACE_UUID_SET)) { - _PERROR_DUP_ATTR("uuid", "trace declaration"); + BT_LOGE_DUP_ATTR("uuid", "trace declaration"); ret = -EPERM; goto error; } @@ -3928,14 +3886,14 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = get_unary_uuid(&node->u.ctf_expression.right, ctx->trace_uuid); if (ret) { - _PERROR("%s", + BT_LOGE( "invalid trace declaration's UUID"); goto error; } ret = bt_ctf_trace_set_uuid(ctx->trace, ctx->trace_uuid); if (ret) { - _PERROR("%s", + BT_LOGE( "cannot set trace's UUID"); goto error; } @@ -3944,7 +3902,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) } else if (!strcmp(left, "byte_order")) { /* Native byte order is already known at this stage */ if (_IS_SET(set, _TRACE_BYTE_ORDER_SET)) { - _PERROR_DUP_ATTR("byte_order", + BT_LOGE_DUP_ATTR("byte_order", "trace declaration"); ret = -EPERM; goto error; @@ -3953,7 +3911,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) _SET(set, _TRACE_BYTE_ORDER_SET); } else if (!strcmp(left, "packet.header")) { if (_IS_SET(set, _TRACE_PACKET_HEADER_SET)) { - _PERROR("%s", "duplicate \"packet.header\" entry in trace declaration"); + BT_LOGE("duplicate \"packet.header\" entry in trace declaration"); ret = -EPERM; goto error; } @@ -3964,7 +3922,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) struct ctf_node, siblings), &packet_header_decl); if (ret) { - _PERROR("%s", "cannot create packet header field type"); + BT_LOGE("cannot create packet header field type"); goto error; } @@ -3973,13 +3931,13 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) packet_header_decl); BT_PUT(packet_header_decl); if (ret) { - _PERROR("%s", "cannot set trace's packet header field type"); + BT_LOGE("cannot set trace's packet header field type"); goto error; } _SET(set, _TRACE_PACKET_HEADER_SET); } else { - _PWARNING("%s", "unknown attribute \"%s\" in trace declaration"); + BT_LOGW("unknown attribute \"%s\" in trace declaration", left); } g_free(left); @@ -3987,7 +3945,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) break; } default: - _PERROR("%s", "unknown expression in trace declaration"); + BT_LOGE("unknown expression in trace declaration"); ret = -EINVAL; goto error; } @@ -4016,14 +3974,14 @@ int visit_trace_decl(struct ctx *ctx, struct ctf_node *node) node->visited = TRUE; if (ctx->is_trace_visited) { - _PERROR("%s", "duplicate \"trace\" block"); + BT_LOGE("duplicate \"trace\" block"); ret = -EEXIST; goto error; } ret = ctx_push_scope(ctx); if (ret) { - _PERROR("%s", "cannot push scope"); + BT_LOGE("cannot push scope"); goto error; } @@ -4038,21 +3996,21 @@ int visit_trace_decl(struct ctx *ctx, struct ctf_node *node) ctx_pop_scope(ctx); if (!_IS_SET(&set, _TRACE_MAJOR_SET)) { - _PERROR("%s", + BT_LOGE( "missing \"major\" attribute in trace declaration"); ret = -EPERM; goto error; } if (!_IS_SET(&set, _TRACE_MINOR_SET)) { - _PERROR("%s", + BT_LOGE( "missing \"minor\" attribute in trace declaration"); ret = -EPERM; goto error; } if (!_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) { - _PERROR("%s", "missing \"byte_order\" attribute in trace declaration"); + BT_LOGE("missing \"byte_order\" attribute in trace declaration"); ret = -EPERM; goto error; } @@ -4085,7 +4043,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) &entry_node->u.ctf_expression.right; if (entry_node->type != NODE_CTF_EXPRESSION) { - _PERROR("%s", "wrong expression in environment entry"); + BT_LOGE("wrong expression in environment entry"); ret = -EPERM; goto error; } @@ -4093,7 +4051,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) left = concatenate_unary_strings( &entry_node->u.ctf_expression.left); if (!left) { - _PERROR("%s", "cannot get environment entry name"); + BT_LOGE("cannot get environment entry name"); ret = -EINVAL; goto error; } @@ -4102,7 +4060,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) char *right = concatenate_unary_strings(right_head); if (!right) { - _PERROR("unexpected unary expression for environment entry's value (\"%s\")", + BT_LOGE("unexpected unary expression for environment entry's value (\"%s\")", left); ret = -EINVAL; goto error; @@ -4120,7 +4078,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) g_free(right); if (ret) { - _PERROR("environment: cannot add entry \"%s\" to trace", + BT_LOGE("environment: cannot add entry \"%s\" to trace", left); goto error; } @@ -4135,7 +4093,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) ret = get_unary_signed(right_head, &v); } if (ret) { - _PERROR("unexpected unary expression for environment entry's value (\"%s\")", + BT_LOGE("unexpected unary expression for environment entry's value (\"%s\")", left); ret = -EINVAL; goto error; @@ -4145,7 +4103,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) ret = bt_ctf_trace_set_environment_field_integer( ctx->trace, left, v); if (ret) { - _PERROR("environment: cannot add entry \"%s\" to trace", + BT_LOGE("environment: cannot add entry \"%s\" to trace", left); goto error; } @@ -4191,7 +4149,7 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) enum bt_ctf_byte_order bo; if (_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) { - _PERROR_DUP_ATTR("byte_order", + BT_LOGE_DUP_ATTR("byte_order", "trace declaration"); ret = -EPERM; goto error; @@ -4201,14 +4159,13 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) right_node = _BT_LIST_FIRST_ENTRY( &node->u.ctf_expression.right, struct ctf_node, siblings); - bo = byte_order_from_unary_expr(ctx->efd, - right_node); + bo = byte_order_from_unary_expr(right_node); if (bo == BT_CTF_BYTE_ORDER_UNKNOWN) { - _PERROR("%s", "unknown \"byte_order\" attribute in trace declaration"); + BT_LOGE("unknown \"byte_order\" attribute in trace declaration"); ret = -EINVAL; goto error; } else if (bo == BT_CTF_BYTE_ORDER_NATIVE) { - _PERROR("%s", "\"byte_order\" attribute cannot be set to \"native\" in trace declaration"); + BT_LOGE("\"byte_order\" attribute cannot be set to \"native\" in trace declaration"); ret = -EPERM; goto error; } @@ -4217,7 +4174,7 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) ret = bt_ctf_trace_set_native_byte_order( ctx->trace, bo); if (ret) { - _PERROR("cannot set trace's byte order (%d)", + BT_LOGE("cannot set trace's byte order (%d)", ret); goto error; } @@ -4229,7 +4186,7 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) } if (!_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) { - _PERROR("%s", "missing \"byte_order\" attribute in trace declaration"); + BT_LOGE("missing \"byte_order\" attribute in trace declaration"); ret = -EINVAL; goto error; } @@ -4264,7 +4221,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, char *right; if (_IS_SET(set, _CLOCK_NAME_SET)) { - _PERROR_DUP_ATTR("name", "clock class declaration"); + BT_LOGE_DUP_ATTR("name", "clock class declaration"); ret = -EPERM; goto error; } @@ -4272,14 +4229,14 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, right = concatenate_unary_strings( &entry_node->u.ctf_expression.right); if (!right) { - _PERROR("%s", "unexpected unary expression for clock class declaration's \"name\" attribute"); + BT_LOGE("unexpected unary expression for clock class declaration's \"name\" attribute"); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_name(clock, right); if (ret) { - _PERROR("%s", "cannot set clock class's name"); + BT_LOGE("cannot set clock class's name"); g_free(right); goto error; } @@ -4290,20 +4247,20 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, unsigned char uuid[BABELTRACE_UUID_LEN]; if (_IS_SET(set, _CLOCK_UUID_SET)) { - _PERROR_DUP_ATTR("uuid", "clock class declaration"); + BT_LOGE_DUP_ATTR("uuid", "clock class declaration"); ret = -EPERM; goto error; } ret = get_unary_uuid(&entry_node->u.ctf_expression.right, uuid); if (ret) { - _PERROR("%s", "invalid clock class UUID"); + BT_LOGE("invalid clock class UUID"); goto error; } ret = bt_ctf_clock_class_set_uuid(clock, uuid); if (ret) { - _PERROR("%s", "cannot set clock class's UUID"); + BT_LOGE("cannot set clock class's UUID"); goto error; } @@ -4312,7 +4269,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, char *right; if (_IS_SET(set, _CLOCK_DESCRIPTION_SET)) { - _PERROR_DUP_ATTR("description", "clock class declaration"); + BT_LOGE_DUP_ATTR("description", "clock class declaration"); ret = -EPERM; goto error; } @@ -4320,14 +4277,14 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, right = concatenate_unary_strings( &entry_node->u.ctf_expression.right); if (!right) { - _PERROR("%s", "unexpected unary expression for clock class's \"description\" attribute"); + BT_LOGE("unexpected unary expression for clock class's \"description\" attribute"); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_description(clock, right); if (ret) { - _PERROR("%s", "cannot set clock class's description"); + BT_LOGE("cannot set clock class's description"); g_free(right); goto error; } @@ -4338,7 +4295,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, uint64_t freq; if (_IS_SET(set, _CLOCK_FREQ_SET)) { - _PERROR_DUP_ATTR("freq", "clock class declaration"); + BT_LOGE_DUP_ATTR("freq", "clock class declaration"); ret = -EPERM; goto error; } @@ -4346,14 +4303,14 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_unsigned( &entry_node->u.ctf_expression.right, &freq); if (ret) { - _PERROR("%s", "unexpected unary expression for clock class declaration's \"freq\" attribute"); + BT_LOGE("unexpected unary expression for clock class declaration's \"freq\" attribute"); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_frequency(clock, freq); if (ret) { - _PERROR("%s", "cannot set clock class's frequency"); + BT_LOGE("cannot set clock class's frequency"); goto error; } @@ -4362,7 +4319,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, uint64_t precision; if (_IS_SET(set, _CLOCK_PRECISION_SET)) { - _PERROR_DUP_ATTR("precision", "clock class declaration"); + BT_LOGE_DUP_ATTR("precision", "clock class declaration"); ret = -EPERM; goto error; } @@ -4370,14 +4327,14 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_unsigned( &entry_node->u.ctf_expression.right, &precision); if (ret) { - _PERROR("%s", "unexpected unary expression for clock class declaration's \"precision\" attribute"); + BT_LOGE("unexpected unary expression for clock class declaration's \"precision\" attribute"); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_precision(clock, precision); if (ret) { - _PERROR("%s", "cannot set clock class's precision"); + BT_LOGE("cannot set clock class's precision"); goto error; } @@ -4386,7 +4343,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, uint64_t offset_s; if (_IS_SET(set, _CLOCK_OFFSET_S_SET)) { - _PERROR_DUP_ATTR("offset_s", "clock class declaration"); + BT_LOGE_DUP_ATTR("offset_s", "clock class declaration"); ret = -EPERM; goto error; } @@ -4394,14 +4351,14 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_unsigned( &entry_node->u.ctf_expression.right, &offset_s); if (ret) { - _PERROR("%s", "unexpected unary expression for clock class declaration's \"offset_s\" attribute"); + BT_LOGE("unexpected unary expression for clock class declaration's \"offset_s\" attribute"); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_offset_s(clock, offset_s); if (ret) { - _PERROR("%s", "cannot set clock class's offset in seconds"); + BT_LOGE("cannot set clock class's offset in seconds"); goto error; } @@ -4410,7 +4367,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, uint64_t offset; if (_IS_SET(set, _CLOCK_OFFSET_SET)) { - _PERROR_DUP_ATTR("offset", "clock class declaration"); + BT_LOGE_DUP_ATTR("offset", "clock class declaration"); ret = -EPERM; goto error; } @@ -4418,14 +4375,14 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_unsigned( &entry_node->u.ctf_expression.right, &offset); if (ret) { - _PERROR("%s", "unexpected unary expression for clock class declaration's \"offset\" attribute"); + BT_LOGE("unexpected unary expression for clock class declaration's \"offset\" attribute"); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_offset_cycles(clock, offset); if (ret) { - _PERROR("%s", "cannot set clock class's offset in cycles"); + BT_LOGE("cannot set clock class's offset in cycles"); goto error; } @@ -4434,7 +4391,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, struct ctf_node *right; if (_IS_SET(set, _CLOCK_ABSOLUTE_SET)) { - _PERROR_DUP_ATTR("absolute", "clock class declaration"); + BT_LOGE_DUP_ATTR("absolute", "clock class declaration"); ret = -EPERM; goto error; } @@ -4442,22 +4399,22 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, right = _BT_LIST_FIRST_ENTRY( &entry_node->u.ctf_expression.right, struct ctf_node, siblings); - ret = get_boolean(ctx->efd, right); + ret = get_boolean(right); if (ret < 0) { - _PERROR("%s", "unexpected unary expression for clock class declaration's \"absolute\" attribute"); + BT_LOGE("unexpected unary expression for clock class declaration's \"absolute\" attribute"); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_is_absolute(clock, ret); if (ret) { - _PERROR("%s", "cannot set clock class's absolute option"); + BT_LOGE("cannot set clock class's absolute option"); goto error; } _SET(set, _CLOCK_ABSOLUTE_SET); } else { - _PWARNING("unknown attribute \"%s\" in clock class declaration", + BT_LOGW("unknown attribute \"%s\" in clock class declaration", left); } @@ -4473,9 +4430,9 @@ error: } static -uint64_t cycles_from_ns(uint64_t frequency, uint64_t ns) +int64_t cycles_from_ns(uint64_t frequency, int64_t ns) { - uint64_t cycles; + int64_t cycles; /* 1GHz */ if (frequency == 1000000000ULL) { @@ -4496,14 +4453,14 @@ int apply_clock_class_offset(struct ctx *ctx, struct bt_ctf_clock_class *clock) freq = bt_ctf_clock_class_get_frequency(clock); if (freq == -1ULL) { - _PERROR("%s", "cannot get clock class frequency"); + BT_LOGE("cannot get clock class frequency"); ret = -1; goto end; } ret = bt_ctf_clock_class_get_offset_cycles(clock, &offset_cycles); if (ret) { - _PERROR("%s", "cannot get offset in cycles"); + BT_LOGE("cannot get offset in cycles"); ret = -1; goto end; } @@ -4532,7 +4489,7 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) clock_node->visited = TRUE; clock = bt_ctf_clock_class_create(NULL); if (!clock) { - _PERROR("%s", "cannot create clock"); + BT_LOGE("cannot create clock"); ret = -ENOMEM; goto error; } @@ -4545,7 +4502,7 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) } if (!_IS_SET(&set, _CLOCK_NAME_SET)) { - _PERROR("%s", + BT_LOGE( "missing \"name\" attribute in clock class declaration"); ret = -EPERM; goto error; @@ -4562,20 +4519,20 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) */ ret = bt_ctf_clock_class_set_is_absolute(clock, 1); if (ret) { - _PERROR("%s", "cannot set clock class's absolute option"); + BT_LOGE("cannot set clock class's absolute option"); goto error; } } ret = apply_clock_class_offset(ctx, clock); if (ret) { - _PERROR("%s", "cannot apply clock class offset "); + BT_LOGE("cannot apply clock class offset "); goto error; } ret = bt_ctf_trace_add_clock_class(ctx->trace, clock); if (ret) { - _PERROR("%s", "cannot add clock class to trace"); + BT_LOGE("cannot add clock class to trace"); goto error; } @@ -4602,7 +4559,7 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node) root_decl_node->u._typedef.type_specifier_list, &root_decl_node->u._typedef.type_declarators); if (ret) { - _PERROR("%s", "cannot add typedef in root scope"); + BT_LOGE("cannot add typedef in root scope"); goto end; } break; @@ -4610,7 +4567,7 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node) ret = visit_typealias(ctx, root_decl_node->u.typealias.target, root_decl_node->u.typealias.alias); if (ret) { - _PERROR("%s", "cannot add typealias in root scope"); + BT_LOGE("cannot add typealias in root scope"); goto end; } break; @@ -4724,7 +4681,7 @@ int move_ctx_stream_classes_to_trace(struct ctx *ctx) stream_class); if (ret) { int64_t id = bt_ctf_stream_class_get_id(stream_class); - _PERROR("cannot add stream class %" PRId64 " to trace", + BT_LOGE("cannot add stream class %" PRId64 " to trace", id); goto end; } @@ -4737,8 +4694,8 @@ end: } BT_HIDDEN -struct ctf_visitor_generate_ir *ctf_visitor_generate_ir_create(FILE *efd, - uint64_t clock_class_offset_ns, const char *name) +struct ctf_visitor_generate_ir *ctf_visitor_generate_ir_create( + int64_t clock_class_offset_ns, const char *name) { int ret; struct ctx *ctx = NULL; @@ -4746,22 +4703,21 @@ struct ctf_visitor_generate_ir *ctf_visitor_generate_ir_create(FILE *efd, trace = bt_ctf_trace_create(); if (!trace) { - _FPERROR(efd, "%s", "cannot create trace"); + BT_LOGE("cannot create trace"); goto error; } /* Set packet header to NULL to override the default one */ ret = bt_ctf_trace_set_packet_header_type(trace, NULL); if (ret) { - _FPERROR(efd, "%s", - "cannot set initial, empty packet header structure"); + BT_LOGE("cannot set initial, empty packet header structure"); goto error; } /* Create visitor's context */ - ctx = ctx_create(trace, efd, clock_class_offset_ns, name); + ctx = ctx_create(trace, clock_class_offset_ns, name); if (!ctx) { - _FPERROR(efd, "%s", "cannot create visitor context"); + BT_LOGE("cannot create visitor context"); goto error; } @@ -4820,14 +4776,14 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, if (ctx->trace_bo == BT_CTF_BYTE_ORDER_NATIVE) { bt_list_for_each_entry(iter, &node->u.root.trace, siblings) { if (got_trace_decl) { - _PERROR("%s", "duplicate trace declaration"); + BT_LOGE("duplicate trace declaration"); ret = -1; goto end; } ret = set_trace_byte_order(ctx, iter); if (ret) { - _PERROR("cannot set trace's native byte order (%d)", + BT_LOGE("cannot set trace's native byte order (%d)", ret); goto end; } @@ -4850,7 +4806,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.env, siblings) { ret = visit_env(ctx, iter); if (ret) { - _PERROR("error while visiting environment block (%d)", + BT_LOGE("error while visiting environment block (%d)", ret); goto end; } @@ -4865,7 +4821,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.clock, siblings) { ret = visit_clock_decl(ctx, iter); if (ret) { - _PERROR("error while visiting clock class declaration (%d)", + BT_LOGE("error while visiting clock class declaration (%d)", ret); goto end; } @@ -4882,7 +4838,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, siblings) { ret = visit_root_decl(ctx, iter); if (ret) { - _PERROR("error while visiting root declaration (%d)", + BT_LOGE("error while visiting root declaration (%d)", ret); goto end; } @@ -4901,14 +4857,14 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, ctx->current_scope->parent_scope == NULL); if (found_callsite) { - _PWARNING("%s", "\"callsite\" blocks are not supported as of this version"); + BT_LOGW("\"callsite\" blocks are not supported as of this version"); } /* Trace */ bt_list_for_each_entry(iter, &node->u.root.trace, siblings) { ret = visit_trace_decl(ctx, iter); if (ret) { - _PERROR("%s", "error while visiting trace declaration"); + BT_LOGE("error while visiting trace declaration"); goto end; } } @@ -4920,7 +4876,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.stream, siblings) { ret = visit_stream_decl(ctx, iter); if (ret) { - _PERROR("%s", "error while visiting stream declaration"); + BT_LOGE("error while visiting stream declaration"); goto end; } } @@ -4932,7 +4888,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.event, siblings) { ret = visit_event_decl(ctx, iter); if (ret) { - _PERROR("%s", "error while visiting event declaration"); + BT_LOGE("error while visiting event declaration"); goto end; } } @@ -4942,7 +4898,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, break; } default: - _PERROR("cannot decode node type: %d", (int) node->type); + BT_LOGE("cannot decode node type: %d", (int) node->type); ret = -EINVAL; goto end; } @@ -4950,7 +4906,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, /* Move decoded stream classes to trace, if any */ ret = move_ctx_stream_classes_to_trace(ctx); if (ret) { - _PERROR("%s", "cannot move stream classes to trace"); + BT_LOGE("cannot move stream classes to trace"); } end: diff --git a/plugins/ctf/common/metadata/visitor-parent-links.c b/plugins/ctf/common/metadata/visitor-parent-links.c index d134d71c..028e4777 100644 --- a/plugins/ctf/common/metadata/visitor-parent-links.c +++ b/plugins/ctf/common/metadata/visitor-parent-links.c @@ -38,10 +38,11 @@ #include "parser.h" #include "ast.h" -#define fprintf_dbg(fd, fmt, args...) fprintf(fd, "%s: " fmt, __func__, ## args) +#define BT_LOG_TAG "PLUGIN-CTF-METADATA-VISITOR-PARENT-LINKS" +#include "logging.h" static -int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) +int ctf_visitor_unary_expression(int depth, struct ctf_node *node) { int ret = 0; @@ -52,7 +53,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) case UNARY_DOTDOTDOT: break; default: - fprintf(fd, "[error] %s: unknown expression link type %d\n", __func__, + BT_LOGE("unknown expression link type %d\n", (int) node->u.unary_expression.link); return -EINVAL; } @@ -64,7 +65,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) break; case UNARY_SBRAC: node->u.unary_expression.u.sbrac_exp->parent = node; - ret = ctf_visitor_unary_expression(fd, depth + 1, + ret = ctf_visitor_unary_expression(depth + 1, node->u.unary_expression.u.sbrac_exp); if (ret) return ret; @@ -72,7 +73,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) case UNARY_UNKNOWN: default: - fprintf(fd, "[error] %s: unknown expression type %d\n", __func__, + BT_LOGE("unknown expression type %d\n", (int) node->u.unary_expression.type); return -EINVAL; } @@ -80,7 +81,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) } static -int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node) +int ctf_visitor_type_specifier(int depth, struct ctf_node *node) { int ret; @@ -107,14 +108,14 @@ int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node) case TYPESPEC_VARIANT: case TYPESPEC_ENUM: node->u.type_specifier.node->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, node->u.type_specifier.node); + ret = ctf_visitor_parent_links(depth + 1, node->u.type_specifier.node); if (ret) return ret; break; case TYPESPEC_UNKNOWN: default: - fprintf(fd, "[error] %s: unknown type specifier %d\n", __func__, + BT_LOGE("unknown type specifier %d\n", (int) node->u.type_specifier.type); return -EINVAL; } @@ -122,7 +123,7 @@ int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node) } static -int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) +int ctf_visitor_type_declarator(int depth, struct ctf_node *node) { int ret = 0; struct ctf_node *iter; @@ -132,7 +133,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) bt_list_for_each_entry(iter, &node->u.type_declarator.pointers, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -143,7 +144,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) case TYPEDEC_NESTED: if (node->u.type_declarator.u.nested.type_declarator) { node->u.type_declarator.u.nested.type_declarator->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, + ret = ctf_visitor_parent_links(depth + 1, node->u.type_declarator.u.nested.type_declarator); if (ret) return ret; @@ -152,14 +153,14 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) bt_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } } if (node->u.type_declarator.bitfield_len) { node->u.type_declarator.bitfield_len = node; - ret = ctf_visitor_parent_links(fd, depth + 1, + ret = ctf_visitor_parent_links(depth + 1, node->u.type_declarator.bitfield_len); if (ret) return ret; @@ -167,7 +168,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) break; case TYPEDEC_UNKNOWN: default: - fprintf(fd, "[error] %s: unknown type declarator %d\n", __func__, + BT_LOGE("unknown type declarator %d\n", (int) node->u.type_declarator.type); return -EINVAL; } @@ -175,7 +176,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) return 0; } -int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) +int ctf_visitor_parent_links(int depth, struct ctf_node *node) { int ret = 0; struct ctf_node *iter; @@ -187,37 +188,37 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_ROOT: bt_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.trace, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.stream, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.event, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.clock, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.callsite, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -226,7 +227,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_EVENT: bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -234,7 +235,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_STREAM: bt_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -242,7 +243,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_ENV: bt_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -250,7 +251,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_TRACE: bt_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -258,7 +259,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_CLOCK: bt_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -266,7 +267,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_CALLSITE: bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -276,30 +277,30 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) depth++; bt_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } depth--; break; case NODE_UNARY_EXPRESSION: - return ctf_visitor_unary_expression(fd, depth, node); + return ctf_visitor_unary_expression(depth, node); case NODE_TYPEDEF: depth++; node->u._typedef.type_specifier_list->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, node->u._typedef.type_specifier_list); + ret = ctf_visitor_parent_links(depth + 1, node->u._typedef.type_specifier_list); if (ret) return ret; bt_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -308,12 +309,12 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_TYPEALIAS_TARGET: depth++; node->u.typealias_target.type_specifier_list->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, node->u.typealias_target.type_specifier_list); + ret = ctf_visitor_parent_links(depth + 1, node->u.typealias_target.type_specifier_list); if (ret) return ret; bt_list_for_each_entry(iter, &node->u.typealias_target.type_declarators, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -322,12 +323,12 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_TYPEALIAS_ALIAS: depth++; node->u.typealias_alias.type_specifier_list->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, node->u.typealias_alias.type_specifier_list); + ret = ctf_visitor_parent_links(depth + 1, node->u.typealias_alias.type_specifier_list); if (ret) return ret; bt_list_for_each_entry(iter, &node->u.typealias_alias.type_declarators, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -335,11 +336,11 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) break; case NODE_TYPEALIAS: node->u.typealias.target->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, node->u.typealias.target); + ret = ctf_visitor_parent_links(depth + 1, node->u.typealias.target); if (ret) return ret; node->u.typealias.alias->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, node->u.typealias.alias); + ret = ctf_visitor_parent_links(depth + 1, node->u.typealias.alias); if (ret) return ret; break; @@ -347,21 +348,21 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_TYPE_SPECIFIER_LIST: bt_list_for_each_entry(iter, &node->u.type_specifier_list.head, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } break; case NODE_TYPE_SPECIFIER: - ret = ctf_visitor_type_specifier(fd, depth, node); + ret = ctf_visitor_type_specifier(depth, node); if (ret) return ret; break; case NODE_POINTER: break; case NODE_TYPE_DECLARATOR: - ret = ctf_visitor_type_declarator(fd, depth, node); + ret = ctf_visitor_type_declarator(depth, node); if (ret) return ret; break; @@ -369,7 +370,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_FLOATING_POINT: bt_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -377,7 +378,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_INTEGER: bt_list_for_each_entry(iter, &node->u.integer.expressions, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -385,7 +386,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_STRING: bt_list_for_each_entry(iter, &node->u.string.expressions, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -393,7 +394,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_ENUMERATOR: bt_list_for_each_entry(iter, &node->u.enumerator.values, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -401,14 +402,14 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_ENUM: depth++; if (node->u._enum.container_type) { - ret = ctf_visitor_parent_links(fd, depth + 1, node->u._enum.container_type); + ret = ctf_visitor_parent_links(depth + 1, node->u._enum.container_type); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -416,13 +417,13 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) break; case NODE_STRUCT_OR_VARIANT_DECLARATION: node->u.struct_or_variant_declaration.type_specifier_list->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, + ret = ctf_visitor_parent_links(depth + 1, node->u.struct_or_variant_declaration.type_specifier_list); if (ret) return ret; bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.type_declarators, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -430,7 +431,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_VARIANT: bt_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -438,14 +439,14 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_STRUCT: bt_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u._struct.min_align, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); + ret = ctf_visitor_parent_links(depth + 1, iter); if (ret) return ret; } @@ -453,8 +454,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) case NODE_UNKNOWN: default: - fprintf(fd, "[error] %s: unknown node type %d\n", __func__, - (int) node->type); + BT_LOGE("unknown node type %d\n", (int) node->type); return -EINVAL; } return ret; diff --git a/plugins/ctf/common/metadata/visitor-semantic-validator.c b/plugins/ctf/common/metadata/visitor-semantic-validator.c index d94a3bdf..f9b5eae4 100644 --- a/plugins/ctf/common/metadata/visitor-semantic-validator.c +++ b/plugins/ctf/common/metadata/visitor-semantic-validator.c @@ -38,16 +38,17 @@ #include "parser.h" #include "ast.h" +#define BT_LOG_TAG "PLUGIN-CTF-METADATA-VISITOR-SEMANTIC-VALIDATOR" +#include "logging.h" + #define _bt_list_first_entry(ptr, type, member) \ bt_list_entry((ptr)->next, type, member) -#define fprintf_dbg(fd, fmt, args...) fprintf(fd, "%s: " fmt, __func__, ## args) - static -int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node); +int _ctf_visitor_semantic_check(int depth, struct ctf_node *node); static -int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) +int ctf_visitor_unary_expression(int depth, struct ctf_node *node) { struct ctf_node *iter; int is_ctf_exp = 0, is_ctf_exp_left = 0; @@ -64,8 +65,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) * We are only allowed to be a string. */ if (node->u.unary_expression.type != UNARY_STRING) { - fprintf(fd, "[error]: semantic error (left child of a ctf expression is only allowed to be a string)\n"); - + BT_LOGE("semantic error (left child of a ctf expression is only allowed to be a string)"); goto errperm; } break; @@ -82,7 +82,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) case UNARY_STRING: break; default: - fprintf(fd, "[error]: semantic error (children of type declarator and enum can only be unsigned numeric constants or references to fields (a.b.c))\n"); + BT_LOGE("semantic error (children of type declarator and enum can only be unsigned numeric constants or references to fields (a.b.c))"); goto errperm; } break; /* OK */ @@ -95,7 +95,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) case UNARY_UNSIGNED_CONSTANT: break; default: - fprintf(fd, "[error]: semantic error (structure alignment attribute can only be unsigned numeric constants)\n"); + BT_LOGE("semantic error (structure alignment attribute can only be unsigned numeric constants)"); goto errperm; } break; @@ -109,7 +109,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) * We disallow nested unary expressions and "sbrac" unary * expressions. */ - fprintf(fd, "[error]: semantic error (nested unary expressions not allowed ( () and [] ))\n"); + BT_LOGE("semantic error (nested unary expressions not allowed ( () and [] ))"); goto errperm; case NODE_ROOT: @@ -143,7 +143,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) &node->parent->u.ctf_expression.right, struct ctf_node, siblings) != node) { - fprintf(fd, "[error]: semantic error (empty link not allowed except on first node of unary expression (need to separate nodes with \".\" or \"->\")\n"); + BT_LOGE("semantic error (empty link not allowed except on first node of unary expression (need to separate nodes with \".\" or \"->\")"); goto errperm; } break; /* OK */ @@ -151,7 +151,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) case UNARY_ARROWLINK: /* We only allow -> and . links between children of ctf_expression. */ if (node->parent->type != NODE_CTF_EXPRESSION) { - fprintf(fd, "[error]: semantic error (links \".\" and \"->\" are only allowed as children of ctf expression)\n"); + BT_LOGE("semantic error (links \".\" and \"->\" are only allowed as children of ctf expression)"); goto errperm; } /* @@ -159,7 +159,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) * This includes "", '' and non-quoted identifiers. */ if (node->u.unary_expression.type != UNARY_STRING) { - fprintf(fd, "[error]: semantic error (links \".\" and \"->\" are only allowed to separate strings and identifiers)\n"); + BT_LOGE("semantic error (links \".\" and \"->\" are only allowed to separate strings and identifiers)"); goto errperm; } /* We don't allow link on the first node of the list */ @@ -168,44 +168,44 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) &node->parent->u.ctf_expression.right, struct ctf_node, siblings) == node) { - fprintf(fd, "[error]: semantic error (links \".\" and \"->\" are not allowed before first node of the unary expression list)\n"); + BT_LOGE("semantic error (links \".\" and \"->\" are not allowed before first node of the unary expression list)"); goto errperm; } break; case UNARY_DOTDOTDOT: /* We only allow ... link between children of enumerator. */ if (node->parent->type != NODE_ENUMERATOR) { - fprintf(fd, "[error]: semantic error (link \"...\" is only allowed within enumerator)\n"); + BT_LOGE("semantic error (link \"...\" is only allowed within enumerator)"); goto errperm; } /* We don't allow link on the first node of the list */ if (_bt_list_first_entry(&node->parent->u.enumerator.values, struct ctf_node, siblings) == node) { - fprintf(fd, "[error]: semantic error (link \"...\" is not allowed on the first node of the unary expression list)\n"); + BT_LOGE("semantic error (link \"...\" is not allowed on the first node of the unary expression list)"); goto errperm; } break; default: - fprintf(fd, "[error] %s: unknown expression link type %d\n", __func__, + BT_LOGE("%s: unknown expression link type %d", __func__, (int) node->u.unary_expression.link); return -EINVAL; } return 0; errinval: - fprintf(fd, "[error] %s: incoherent parent type %s for node type %s\n", __func__, + BT_LOGE("%s: incoherent parent type %s for node type %s", __func__, node_type(node->parent), node_type(node)); return -EINVAL; /* Incoherent structure */ errperm: - fprintf(fd, "[error] %s: semantic error (parent type %s for node type %s)\n", __func__, + BT_LOGE("%s: semantic error (parent type %s for node type %s)", __func__, node_type(node->parent), node_type(node)); return -EPERM; /* Structure not allowed */ } static -int ctf_visitor_type_specifier_list(FILE *fd, int depth, struct ctf_node *node) +int ctf_visitor_type_specifier_list(int depth, struct ctf_node *node) { switch (node->parent->type) { case NODE_CTF_EXPRESSION: @@ -240,13 +240,13 @@ int ctf_visitor_type_specifier_list(FILE *fd, int depth, struct ctf_node *node) } return 0; errinval: - fprintf(fd, "[error] %s: incoherent parent type %s for node type %s\n", __func__, + BT_LOGE("%s: incoherent parent type %s for node type %s", __func__, node_type(node->parent), node_type(node)); return -EINVAL; /* Incoherent structure */ } static -int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node) +int ctf_visitor_type_specifier(int depth, struct ctf_node *node) { switch (node->parent->type) { case NODE_TYPE_SPECIFIER_LIST: @@ -281,13 +281,13 @@ int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node) } return 0; errinval: - fprintf(fd, "[error] %s: incoherent parent type %s for node type %s\n", __func__, + BT_LOGE("%s: incoherent parent type %s for node type %s", __func__, node_type(node->parent), node_type(node)); return -EINVAL; /* Incoherent structure */ } static -int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) +int ctf_visitor_type_declarator(int depth, struct ctf_node *node) { int ret = 0; struct ctf_node *iter; @@ -367,7 +367,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) bt_list_for_each_entry(iter, &node->u.type_declarator.pointers, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -378,7 +378,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) case TYPEDEC_NESTED: { if (node->u.type_declarator.u.nested.type_declarator) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, + ret = _ctf_visitor_semantic_check(depth + 1, node->u.type_declarator.u.nested.type_declarator); if (ret) return ret; @@ -387,21 +387,21 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) bt_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length, siblings) { if (iter->type != NODE_UNARY_EXPRESSION) { - fprintf(fd, "[error] %s: expecting unary expression as length\n", __func__); + BT_LOGE("%s: expecting unary expression as length", __func__); return -EINVAL; } - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } } else { if (node->parent->type == NODE_TYPEALIAS_TARGET) { - fprintf(fd, "[error] %s: abstract array declarator not permitted as target of typealias\n", __func__); + BT_LOGE("%s: abstract array declarator not permitted as target of typealias", __func__); return -EINVAL; } } if (node->u.type_declarator.bitfield_len) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, + ret = _ctf_visitor_semantic_check(depth + 1, node->u.type_declarator.bitfield_len); if (ret) return ret; @@ -410,7 +410,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) } case TYPEDEC_UNKNOWN: default: - fprintf(fd, "[error] %s: unknown type declarator %d\n", __func__, + BT_LOGE("%s: unknown type declarator %d", __func__, (int) node->u.type_declarator.type); return -EINVAL; } @@ -418,18 +418,18 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) return 0; errinval: - fprintf(fd, "[error] %s: incoherent parent type %s for node type %s\n", __func__, + BT_LOGE("%s: incoherent parent type %s for node type %s", __func__, node_type(node->parent), node_type(node)); return -EINVAL; /* Incoherent structure */ errperm: - fprintf(fd, "[error] %s: semantic error (parent type %s for node type %s)\n", __func__, + BT_LOGE("%s: semantic error (parent type %s for node type %s)", __func__, node_type(node->parent), node_type(node)); return -EPERM; /* Structure not allowed */ } static -int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) +int _ctf_visitor_semantic_check(int depth, struct ctf_node *node) { int ret = 0; struct ctf_node *iter; @@ -440,22 +440,22 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) switch (node->type) { case NODE_ROOT: bt_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.trace, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.stream, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.event, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -470,7 +470,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -484,7 +484,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } bt_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -498,7 +498,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } bt_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -512,7 +512,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } bt_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -526,7 +526,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } bt_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -540,7 +540,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -581,19 +581,19 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) depth++; bt_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } depth--; break; case NODE_UNARY_EXPRESSION: - return ctf_visitor_unary_expression(fd, depth, node); + return ctf_visitor_unary_expression(depth, node); case NODE_TYPEDEF: switch (node->parent->type) { @@ -629,12 +629,12 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } depth++; - ret = _ctf_visitor_semantic_check(fd, depth + 1, + ret = _ctf_visitor_semantic_check(depth + 1, node->u._typedef.type_specifier_list); if (ret) return ret; bt_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -652,19 +652,19 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } depth++; - ret = _ctf_visitor_semantic_check(fd, depth + 1, + ret = _ctf_visitor_semantic_check(depth + 1, node->u.typealias_target.type_specifier_list); if (ret) return ret; nr_declarators = 0; bt_list_for_each_entry(iter, &node->u.typealias_target.type_declarators, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; nr_declarators++; } if (nr_declarators > 1) { - fprintf(fd, "[error] %s: Too many declarators in typealias alias (%d, max is 1)\n", __func__, nr_declarators); + BT_LOGE("%s: Too many declarators in typealias alias (%d, max is 1)", __func__, nr_declarators); return -EINVAL; } @@ -683,19 +683,19 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } depth++; - ret = _ctf_visitor_semantic_check(fd, depth + 1, + ret = _ctf_visitor_semantic_check(depth + 1, node->u.typealias_alias.type_specifier_list); if (ret) return ret; nr_declarators = 0; bt_list_for_each_entry(iter, &node->u.typealias_alias.type_declarators, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; nr_declarators++; } if (nr_declarators > 1) { - fprintf(fd, "[error] %s: Too many declarators in typealias alias (%d, max is 1)\n", __func__, nr_declarators); + BT_LOGE("%s: Too many declarators in typealias alias (%d, max is 1)", __func__, nr_declarators); return -EINVAL; } @@ -735,21 +735,21 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) goto errinval; } - ret = _ctf_visitor_semantic_check(fd, depth + 1, node->u.typealias.target); + ret = _ctf_visitor_semantic_check(depth + 1, node->u.typealias.target); if (ret) return ret; - ret = _ctf_visitor_semantic_check(fd, depth + 1, node->u.typealias.alias); + ret = _ctf_visitor_semantic_check(depth + 1, node->u.typealias.alias); if (ret) return ret; break; case NODE_TYPE_SPECIFIER_LIST: - ret = ctf_visitor_type_specifier_list(fd, depth, node); + ret = ctf_visitor_type_specifier_list(depth, node); if (ret) return ret; break; case NODE_TYPE_SPECIFIER: - ret = ctf_visitor_type_specifier(fd, depth, node); + ret = ctf_visitor_type_specifier(depth, node); if (ret) return ret; break; @@ -762,7 +762,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } break; case NODE_TYPE_DECLARATOR: - ret = ctf_visitor_type_declarator(fd, depth, node); + ret = ctf_visitor_type_declarator(depth, node); if (ret) return ret; break; @@ -778,7 +778,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) goto errperm; } bt_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -793,7 +793,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } bt_list_for_each_entry(iter, &node->u.integer.expressions, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -810,7 +810,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } bt_list_for_each_entry(iter, &node->u.string.expressions, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -837,7 +837,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) || (iter->u.unary_expression.type != UNARY_SIGNED_CONSTANT && iter->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) || iter->u.unary_expression.link != UNARY_LINK_UNKNOWN) { - fprintf(fd, "[error]: semantic error (first unary expression of enumerator is unexpected)\n"); + BT_LOGE("semantic error (first unary expression of enumerator is unexpected)"); goto errperm; } break; @@ -845,7 +845,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) || (iter->u.unary_expression.type != UNARY_SIGNED_CONSTANT && iter->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) || iter->u.unary_expression.link != UNARY_DOTDOTDOT) { - fprintf(fd, "[error]: semantic error (second unary expression of enumerator is unexpected)\n"); + BT_LOGE("semantic error (second unary expression of enumerator is unexpected)"); goto errperm; } break; @@ -856,7 +856,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } bt_list_for_each_entry(iter, &node->u.enumerator.values, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -873,12 +873,12 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) } depth++; - ret = _ctf_visitor_semantic_check(fd, depth + 1, node->u._enum.container_type); + ret = _ctf_visitor_semantic_check(depth + 1, node->u._enum.container_type); if (ret) return ret; bt_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -892,12 +892,12 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) default: goto errinval; } - ret = _ctf_visitor_semantic_check(fd, depth + 1, + ret = _ctf_visitor_semantic_check(depth + 1, node->u.struct_or_variant_declaration.type_specifier_list); if (ret) return ret; bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.type_declarators, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -913,7 +913,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) goto errperm; } bt_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -930,7 +930,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) goto errperm; } bt_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) { - ret = _ctf_visitor_semantic_check(fd, depth + 1, iter); + ret = _ctf_visitor_semantic_check(depth + 1, iter); if (ret) return ret; } @@ -938,24 +938,24 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) case NODE_UNKNOWN: default: - fprintf(fd, "[error] %s: unknown node type %d\n", __func__, + BT_LOGE("%s: unknown node type %d", __func__, (int) node->type); return -EINVAL; } return ret; errinval: - fprintf(fd, "[error] %s: incoherent parent type %s for node type %s\n", __func__, + BT_LOGE("%s: incoherent parent type %s for node type %s", __func__, node_type(node->parent), node_type(node)); return -EINVAL; /* Incoherent structure */ errperm: - fprintf(fd, "[error] %s: semantic error (parent type %s for node type %s)\n", __func__, + BT_LOGE("%s: semantic error (parent type %s for node type %s)", __func__, node_type(node->parent), node_type(node)); return -EPERM; /* Structure not allowed */ } -int ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) +int ctf_visitor_semantic_check(int depth, struct ctf_node *node) { int ret = 0; @@ -964,15 +964,18 @@ int ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) * take the safe route and recreate them at each validation, just in * case the structure has changed. */ - printf_verbose("CTF visitor: parent links creation... "); - ret = ctf_visitor_parent_links(fd, depth, node); - if (ret) - return ret; - printf_verbose("done.\n"); - printf_verbose("CTF visitor: semantic check... "); - ret = _ctf_visitor_semantic_check(fd, depth, node); - if (ret) - return ret; - printf_verbose("done.\n"); + BT_LOGV("CTF visitor: parent links creation... "); + ret = ctf_visitor_parent_links(depth, node); + if (ret) { + goto end; + } + BT_LOGV("done."); + BT_LOGV("CTF visitor: semantic check... "); + ret = _ctf_visitor_semantic_check(depth, node); + if (ret) { + goto end; + } + BT_LOGV("done."); +end: return ret; } diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index 5a7b3255..0409ac01 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -143,9 +143,6 @@ struct bt_ctf_notif_iter { /* Visit stack */ struct stack *stack; - /* Error stream (may be NULL) */ - FILE *err_stream; - /* * Current dynamic scope field pointer. * @@ -2883,8 +2880,7 @@ end: BT_HIDDEN struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace, size_t max_request_sz, - struct bt_ctf_notif_iter_medium_ops medops, - void *data, FILE *err_stream) + struct bt_ctf_notif_iter_medium_ops medops, void *data) { int ret; struct bt_ctf_notif_iter *notit = NULL; @@ -2932,14 +2928,13 @@ struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace, notit->medium.medops = medops; notit->medium.max_request_sz = max_request_sz; notit->medium.data = data; - notit->err_stream = err_stream; notit->stack = stack_new(notit); if (!notit->stack) { BT_LOGE_STR("Failed to create field stack."); goto error; } - notit->btr = bt_ctf_btr_create(cbs, notit, err_stream); + notit->btr = bt_ctf_btr_create(cbs, notit); if (!notit->btr) { BT_LOGE_STR("Failed to create binary type reader (BTR)."); goto error; diff --git a/plugins/ctf/common/notif-iter/notif-iter.h b/plugins/ctf/common/notif-iter/notif-iter.h index 1fbf952a..988e54ba 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.h +++ b/plugins/ctf/common/notif-iter/notif-iter.h @@ -247,7 +247,7 @@ struct bt_ctf_notif_iter_notif_event { BT_HIDDEN struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace, size_t max_request_sz, struct bt_ctf_notif_iter_medium_ops medops, - void *medops_data, FILE *err_stream); + void *medops_data); /** * Destroys a CTF notification iterator, freeing all internal resources. diff --git a/plugins/ctf/fs-src/Makefile.am b/plugins/ctf/fs-src/Makefile.am index 9704c6b2..c79153fe 100644 --- a/plugins/ctf/fs-src/Makefile.am +++ b/plugins/ctf/fs-src/Makefile.am @@ -14,4 +14,6 @@ libbabeltrace_plugin_ctf_fs_la_SOURCES = \ metadata.h \ print.h \ query.h \ - query.c + query.c \ + logging.h \ + logging.c diff --git a/plugins/ctf/fs-src/data-stream-file.c b/plugins/ctf/fs-src/data-stream-file.c index 8fdda0a9..16977d9d 100644 --- a/plugins/ctf/fs-src/data-stream-file.c +++ b/plugins/ctf/fs-src/data-stream-file.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "file.h" #include "metadata.h" #include "../common/notif-iter/notif-iter.h" @@ -43,10 +44,8 @@ #include "data-stream-file.h" #include -#define PRINT_ERR_STREAM ctf_fs->error_fp -#define PRINT_PREFIX "ctf-fs-data-stream" -#define PRINT_DBG_CHECK ctf_fs_debug -#include "../print.h" +#define BT_LOG_TAG "PLUGIN-CTF-FS-SRC-DS" +#include "logging.h" static inline size_t remaining_mmap_bytes(struct ctf_fs_ds_file *ds_file) @@ -58,15 +57,13 @@ static int ds_file_munmap(struct ctf_fs_ds_file *ds_file) { int ret = 0; - struct ctf_fs_component *ctf_fs; if (!ds_file || !ds_file->mmap_addr) { goto end; } - ctf_fs = ds_file->file->ctf_fs; if (munmap(ds_file->mmap_addr, ds_file->mmap_len)) { - PERR("Cannot memory-unmap address %p (size %zu) of file \"%s\" (%p): %s\n", + BT_LOGE("Cannot memory-unmap address %p (size %zu) of file \"%s\" (%p): %s", ds_file->mmap_addr, ds_file->mmap_len, ds_file->file->path->str, ds_file->file->fp, strerror(errno)); @@ -84,9 +81,9 @@ static enum bt_ctf_notif_iter_medium_status ds_file_mmap_next( struct ctf_fs_ds_file *ds_file) { + const size_t page_size = bt_common_get_page_size(); enum bt_ctf_notif_iter_medium_status ret = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_OK; - struct ctf_fs_component *ctf_fs = ds_file->file->ctf_fs; /* Unmap old region */ if (ds_file->mmap_addr) { @@ -105,15 +102,15 @@ enum bt_ctf_notif_iter_medium_status ds_file_mmap_next( goto end; } /* Round up to next page, assuming page size being a power of 2. */ - ds_file->mmap_len = (ds_file->mmap_valid_len + ctf_fs->page_size - 1) - & ~(ctf_fs->page_size - 1); + ds_file->mmap_len = (ds_file->mmap_valid_len + page_size - 1) + & ~(page_size - 1); /* Map new region */ assert(ds_file->mmap_len); ds_file->mmap_addr = mmap((void *) 0, ds_file->mmap_len, PROT_READ, MAP_PRIVATE, fileno(ds_file->file->fp), ds_file->mmap_offset); if (ds_file->mmap_addr == MAP_FAILED) { - PERR("Cannot memory-map address (size %zu) of file \"%s\" (%p) at offset %zu: %s\n", + BT_LOGE("Cannot memory-map address (size %zu) of file \"%s\" (%p) at offset %zu: %s", ds_file->mmap_len, ds_file->file->path->str, ds_file->file->fp, ds_file->mmap_offset, strerror(errno)); @@ -136,7 +133,6 @@ enum bt_ctf_notif_iter_medium_status medop_request_bytes( enum bt_ctf_notif_iter_medium_status status = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_OK; struct ctf_fs_ds_file *ds_file = data; - struct ctf_fs_component *ctf_fs = ds_file->file->ctf_fs; if (request_sz == 0) { goto end; @@ -146,7 +142,7 @@ enum bt_ctf_notif_iter_medium_status medop_request_bytes( if (remaining_mmap_bytes(ds_file) == 0) { /* Are we at the end of the file? */ if (ds_file->mmap_offset >= ds_file->file->size) { - PDBG("Reached end of file \"%s\" (%p)\n", + BT_LOGD("Reached end of file \"%s\" (%p)", ds_file->file->path->str, ds_file->file->fp); status = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_EOF; goto end; @@ -159,7 +155,7 @@ enum bt_ctf_notif_iter_medium_status medop_request_bytes( case BT_CTF_NOTIF_ITER_MEDIUM_STATUS_EOF: goto end; default: - PERR("Cannot memory-map next region of file \"%s\" (%p)\n", + BT_LOGE("Cannot memory-map next region of file \"%s\" (%p)", ds_file->file->path->str, ds_file->file->fp); goto error; @@ -229,18 +225,23 @@ int build_index_from_idx_file(struct ctf_fs_ds_file *ds_file) /* Look for index file in relative path index/name.idx. */ basename = g_path_get_basename(ds_file->file->path->str); if (!basename) { + BT_LOGE("Failed to get the basename of datastream file %s", + ds_file->file->path->str); ret = -1; goto end; } directory = g_path_get_dirname(ds_file->file->path->str); if (!directory) { + BT_LOGE("Failed to get dirname of datastream file %s", + ds_file->file->path->str); ret = -1; goto end; } index_basename = g_string_new(basename); if (!index_basename) { + BT_LOGE("Failed to allocate index file basename string"); ret = -1; goto end; } @@ -250,12 +251,14 @@ int build_index_from_idx_file(struct ctf_fs_ds_file *ds_file) index_basename->str, NULL); mapped_file = g_mapped_file_new(index_file_path, FALSE, NULL); if (!mapped_file) { + BT_LOGD("Failed to create new mapped file %s", + index_file_path); ret = -1; goto end; } filesize = g_mapped_file_get_length(mapped_file); if (filesize < sizeof(*header)) { - printf_error("Invalid LTTng trace index: file size < header size"); + BT_LOGW("Invalid LTTng trace index file: file size < header size"); ret = -1; goto end; } @@ -265,7 +268,7 @@ int build_index_from_idx_file(struct ctf_fs_ds_file *ds_file) file_pos = g_mapped_file_get_contents(mapped_file) + sizeof(*header); if (be32toh(header->magic) != CTF_INDEX_MAGIC) { - printf_error("Invalid LTTng trace index: \"magic\" validation failed"); + BT_LOGW("Invalid LTTng trace index: \"magic\" validation failed"); ret = -1; goto end; } @@ -273,7 +276,7 @@ int build_index_from_idx_file(struct ctf_fs_ds_file *ds_file) file_index_entry_size = be32toh(header->packet_index_len); file_entry_count = (filesize - sizeof(*header)) / file_index_entry_size; if ((filesize - sizeof(*header)) % (file_entry_count * file_index_entry_size)) { - printf_error("Invalid index file size; not a multiple of index entry size"); + BT_LOGW("Invalid index file size; not a multiple of index entry size"); ret = -1; goto end; } @@ -292,7 +295,7 @@ int build_index_from_idx_file(struct ctf_fs_ds_file *ds_file) if (packet_size % CHAR_BIT) { ret = -1; - printf_error("Invalid packet size encountered in index file"); + BT_LOGW("Invalid packet size encountered in index file"); goto invalid_index; } @@ -302,7 +305,7 @@ int build_index_from_idx_file(struct ctf_fs_ds_file *ds_file) index->offset = be64toh(file_index->offset); if (i != 0 && index->offset < (index - 1)->offset) { - printf_error("Invalid, non-monotonic, packet offset encountered in index file"); + BT_LOGW("Invalid, non-monotonic, packet offset encountered in index file"); ret = -1; goto invalid_index; } @@ -310,7 +313,7 @@ int build_index_from_idx_file(struct ctf_fs_ds_file *ds_file) index->timestamp_begin = be64toh(file_index->timestamp_begin); index->timestamp_end = be64toh(file_index->timestamp_end); if (index->timestamp_end < index->timestamp_begin) { - printf_error("Invalid packet time bounds encountered in index file"); + BT_LOGW("Invalid packet time bounds encountered in index file"); ret = -1; goto invalid_index; } @@ -322,7 +325,7 @@ int build_index_from_idx_file(struct ctf_fs_ds_file *ds_file) /* Validate that the index addresses the complete stream. */ if (ds_file->file->size != total_packets_size) { - printf_error("Invalid index; indexed size != stream file size"); + BT_LOGW("Invalid index; indexed size != stream file size"); ret = -1; goto invalid_index; } @@ -370,13 +373,14 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create( bool build_index) { int ret; + const size_t page_size = bt_common_get_page_size(); struct ctf_fs_ds_file *ds_file = g_new0(struct ctf_fs_ds_file, 1); if (!ds_file) { goto error; } - ds_file->file = ctf_fs_file_create(ctf_fs_trace->ctf_fs); + ds_file->file = ctf_fs_file_create(); if (!ds_file->file) { goto error; } @@ -384,20 +388,18 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create( ds_file->stream = bt_get(stream); ds_file->cc_prio_map = bt_get(ctf_fs_trace->cc_prio_map); g_string_assign(ds_file->file->path, path); - ret = ctf_fs_file_open(ctf_fs_trace->ctf_fs, ds_file->file, "rb"); + ret = ctf_fs_file_open(ds_file->file, "rb"); if (ret) { goto error; } ds_file->notif_iter = bt_ctf_notif_iter_create( - ctf_fs_trace->metadata->trace, - ctf_fs_trace->ctf_fs->page_size, medops, ds_file, - ctf_fs_trace->ctf_fs->error_fp); + ctf_fs_trace->metadata->trace, page_size, medops, ds_file); if (!ds_file->notif_iter) { goto error; } - ds_file->mmap_max_len = ctf_fs_trace->ctf_fs->page_size * 2048; + ds_file->mmap_max_len = page_size * 2048; if (build_index) { ret = init_stream_index(ds_file); diff --git a/plugins/ctf/fs-src/file.c b/plugins/ctf/fs-src/file.c index 61a724b0..61c5a319 100644 --- a/plugins/ctf/fs-src/file.c +++ b/plugins/ctf/fs-src/file.c @@ -25,31 +25,24 @@ #include #include #include - -#define PRINT_ERR_STREAM ctf_fs->error_fp -#define PRINT_PREFIX "ctf-fs-file" -#define PRINT_DBG_CHECK ctf_fs_debug -#include "../print.h" - #include "file.h" +#define BT_LOG_TAG "PLUGIN-CTF-FS-FILE-SRC" +#include "logging.h" + BT_HIDDEN void ctf_fs_file_destroy(struct ctf_fs_file *file) { - struct ctf_fs_component *ctf_fs;; - if (!file) { return; } - ctf_fs = file->ctf_fs; - if (file->fp) { - PDBG("Closing file \"%s\" (%p)\n", + BT_LOGD("Closing file \"%s\" (%p)", file->path ? file->path->str : NULL, file->fp); if (fclose(file->fp)) { - PERR("Cannot close file \"%s\": %s\n", + BT_LOGE("Cannot close file \"%s\": %s", file->path ? file->path->str : "NULL", strerror(errno)); } @@ -63,7 +56,7 @@ void ctf_fs_file_destroy(struct ctf_fs_file *file) } BT_HIDDEN -struct ctf_fs_file *ctf_fs_file_create(struct ctf_fs_component *ctf_fs) +struct ctf_fs_file *ctf_fs_file_create(void) { struct ctf_fs_file *file = g_new0(struct ctf_fs_file, 1); @@ -71,7 +64,6 @@ struct ctf_fs_file *ctf_fs_file_create(struct ctf_fs_component *ctf_fs) goto error; } - file->ctf_fs = ctf_fs; file->path = g_string_new(NULL); if (!file->path) { goto error; @@ -88,29 +80,28 @@ end: } BT_HIDDEN -int ctf_fs_file_open(struct ctf_fs_component *ctf_fs, struct ctf_fs_file *file, - const char *mode) +int ctf_fs_file_open(struct ctf_fs_file *file, const char *mode) { int ret = 0; struct stat stat; - PDBG("Opening file \"%s\" with mode \"%s\"\n", file->path->str, mode); + BT_LOGD("Opening file \"%s\" with mode \"%s\"", file->path->str, mode); file->fp = fopen(file->path->str, mode); if (!file->fp) { - PERR("Cannot open file \"%s\" with mode \"%s\": %s\n", + BT_LOGE("Cannot open file \"%s\" with mode \"%s\": %s", file->path->str, mode, strerror(errno)); goto error; } - PDBG("Opened file: %p\n", file->fp); + BT_LOGD("Opened file: %p", file->fp); if (fstat(fileno(file->fp), &stat)) { - PERR("Cannot get file informations: %s\n", strerror(errno)); + BT_LOGE("Cannot get file informations: %s", strerror(errno)); goto error; } file->size = stat.st_size; - PDBG(" File is %zu bytes\n", file->size); + BT_LOGD("File is %zu bytes", file->size); goto end; error: @@ -118,7 +109,7 @@ error: if (file->fp) { if (fclose(file->fp)) { - PERR("Cannot close file \"%s\": %s\n", file->path->str, + BT_LOGE("Cannot close file \"%s\": %s", file->path->str, strerror(errno)); } } diff --git a/plugins/ctf/fs-src/file.h b/plugins/ctf/fs-src/file.h index 59f3d0ec..d18bd4f7 100644 --- a/plugins/ctf/fs-src/file.h +++ b/plugins/ctf/fs-src/file.h @@ -32,10 +32,9 @@ BT_HIDDEN void ctf_fs_file_destroy(struct ctf_fs_file *file); BT_HIDDEN -struct ctf_fs_file *ctf_fs_file_create(struct ctf_fs_component *ctf_fs); +struct ctf_fs_file *ctf_fs_file_create(void); BT_HIDDEN -int ctf_fs_file_open(struct ctf_fs_component *ctf_fs, struct ctf_fs_file *file, - const char *mode); +int ctf_fs_file_open(struct ctf_fs_file *file, const char *mode); #endif /* CTF_FS_FILE_H */ diff --git a/plugins/ctf/fs-src/fs.c b/plugins/ctf/fs-src/fs.c index 3f49e00c..47f780a9 100644 --- a/plugins/ctf/fs-src/fs.c +++ b/plugins/ctf/fs-src/fs.c @@ -49,10 +49,8 @@ #include "../common/metadata/decoder.h" #include "query.h" -#define PRINT_ERR_STREAM ctf_fs->error_fp -#define PRINT_PREFIX "ctf-fs" -#define PRINT_DBG_CHECK ctf_fs_debug -#include "../print.h" +#define BT_LOG_TAG "PLUGIN-CTF-FS-SRC" +#include "logging.h" BT_HIDDEN bool ctf_fs_debug; @@ -267,13 +265,13 @@ void port_data_destroy(void *data) { } static -int create_one_port_for_trace(struct ctf_fs_trace *ctf_fs_trace, +int create_one_port_for_trace(struct ctf_fs_component *ctf_fs, + struct ctf_fs_trace *ctf_fs_trace, struct ctf_fs_ds_file_group *ds_file_group) { int ret = 0; struct ctf_fs_port_data *port_data = NULL; GString *port_name = NULL; - struct ctf_fs_component *ctf_fs = ctf_fs_trace->ctf_fs; struct ctf_fs_ds_file_info *ds_file_info = g_ptr_array_index(ds_file_group->ds_file_infos, 0); @@ -290,7 +288,7 @@ int create_one_port_for_trace(struct ctf_fs_trace *ctf_fs_trace, assert(ds_file_group->ds_file_infos->len > 0); ds_file_info = g_ptr_array_index(ds_file_group->ds_file_infos, 0); g_string_assign(port_name, ds_file_info->path->str); - PDBG("Creating one port named `%s`\n", port_name->str); + BT_LOGD("Creating one port named `%s`", port_name->str); /* Create output port for this file */ port_data = g_new0(struct ctf_fs_port_data, 1); @@ -322,10 +320,10 @@ end: } static -int create_ports_for_trace(struct ctf_fs_trace *ctf_fs_trace) +int create_ports_for_trace(struct ctf_fs_component *ctf_fs, + struct ctf_fs_trace *ctf_fs_trace) { int ret = 0; - struct ctf_fs_component *ctf_fs = ctf_fs_trace->ctf_fs; size_t i; /* Create one output port for each stream file group */ @@ -333,9 +331,10 @@ int create_ports_for_trace(struct ctf_fs_trace *ctf_fs_trace) struct ctf_fs_ds_file_group *ds_file_group = g_ptr_array_index(ctf_fs_trace->ds_file_groups, i); - ret = create_one_port_for_trace(ctf_fs_trace, ds_file_group); + ret = create_one_port_for_trace(ctf_fs, ctf_fs_trace, + ds_file_group); if (ret) { - PERR("Cannot create output port.\n"); + BT_LOGE("Cannot create output port."); goto end; } } @@ -622,7 +621,6 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, struct bt_ctf_field *packet_header_field = NULL; struct bt_ctf_field *packet_context_field = NULL; struct bt_ctf_stream_class *stream_class = NULL; - struct ctf_fs_component *ctf_fs = ctf_fs_trace->ctf_fs; uint64_t stream_instance_id = -1ULL; uint64_t begin_ns = -1ULL; struct ctf_fs_ds_file_group *ds_file_group = NULL; @@ -634,7 +632,7 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, ctf_fs_trace, path, &packet_header_field, &packet_context_field); if (ret) { - PERR("Cannot get stream file's first packet's header and context fields (`%s`).\n", + BT_LOGE("Cannot get stream file's first packet's header and context fields (`%s`).", path); goto error; } @@ -748,12 +746,11 @@ int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace) const char *basename; GError *error = NULL; GDir *dir = NULL; - struct ctf_fs_component *ctf_fs = ctf_fs_trace->ctf_fs; /* Check each file in the path directory, except specific ones */ dir = g_dir_open(ctf_fs_trace->path->str, 0, &error); if (!dir) { - PERR("Cannot open directory `%s`: %s (code %d)\n", + BT_LOGE("Cannot open directory `%s`: %s (code %d)", ctf_fs_trace->path->str, error->message, error->code); goto error; @@ -764,21 +761,21 @@ int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace) if (!strcmp(basename, CTF_FS_METADATA_FILENAME)) { /* Ignore the metadata stream. */ - PDBG("Ignoring metadata file `%s/%s`\n", + BT_LOGD("Ignoring metadata file `%s/%s`", ctf_fs_trace->path->str, basename); continue; } if (basename[0] == '.') { - PDBG("Ignoring hidden file `%s/%s`\n", + BT_LOGD("Ignoring hidden file `%s/%s`", ctf_fs_trace->path->str, basename); continue; } /* Create the file. */ - file = ctf_fs_file_create(ctf_fs); + file = ctf_fs_file_create(); if (!file) { - PERR("Cannot create stream file object for file `%s/%s`\n", + BT_LOGE("Cannot create stream file object for file `%s/%s`", ctf_fs_trace->path->str, basename); goto error; } @@ -787,22 +784,22 @@ int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace) g_string_append_printf(file->path, "%s/%s", ctf_fs_trace->path->str, basename); if (!g_file_test(file->path->str, G_FILE_TEST_IS_REGULAR)) { - PDBG("Ignoring non-regular file `%s`\n", + BT_LOGD("Ignoring non-regular file `%s`", file->path->str); ctf_fs_file_destroy(file); file = NULL; continue; } - ret = ctf_fs_file_open(ctf_fs, file, "rb"); + ret = ctf_fs_file_open(file, "rb"); if (ret) { - PERR("Cannot open stream file `%s`\n", file->path->str); + BT_LOGE("Cannot open stream file `%s`", file->path->str); goto error; } if (file->size == 0) { /* Skip empty stream. */ - PDBG("Ignoring empty file `%s`\n", file->path->str); + BT_LOGD("Ignoring empty file `%s`", file->path->str); ctf_fs_file_destroy(file); continue; } @@ -810,7 +807,7 @@ int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace) ret = add_ds_file_to_ds_file_group(ctf_fs_trace, file->path->str); if (ret) { - PDBG("Cannot add stream file `%s` to stream file group\n", + BT_LOGD("Cannot add stream file `%s` to stream file group", file->path->str); ctf_fs_file_destroy(file); goto error; @@ -875,8 +872,8 @@ end: } static -struct ctf_fs_trace *ctf_fs_trace_create(struct ctf_fs_component *ctf_fs, - const char *path, const char *name) +struct ctf_fs_trace *ctf_fs_trace_create(const char *path, const char *name, + struct metadata_overrides *overrides) { struct ctf_fs_trace *ctf_fs_trace; int ret; @@ -886,7 +883,6 @@ struct ctf_fs_trace *ctf_fs_trace_create(struct ctf_fs_component *ctf_fs, goto end; } - ctf_fs_trace->ctf_fs = ctf_fs; ctf_fs_trace->path = g_string_new(path); if (!ctf_fs_trace->path) { goto error; @@ -908,7 +904,7 @@ struct ctf_fs_trace *ctf_fs_trace_create(struct ctf_fs_component *ctf_fs, goto error; } - ret = ctf_fs_metadata_set_trace(ctf_fs_trace); + ret = ctf_fs_metadata_set_trace(ctf_fs_trace, overrides); if (ret) { goto error; } @@ -923,11 +919,6 @@ struct ctf_fs_trace *ctf_fs_trace_create(struct ctf_fs_component *ctf_fs, goto error; } - ret = create_ports_for_trace(ctf_fs_trace); - if (ret) { - goto error; - } - /* * create_ds_file_groups() created all the streams that this * trace needs. There won't be any more. Therefore it is safe to @@ -968,21 +959,20 @@ end: } static -int add_trace_path(struct ctf_fs_component *ctf_fs, GList **trace_paths, - const char *path) +int add_trace_path(GList **trace_paths, const char *path) { GString *norm_path = NULL; int ret = 0; norm_path = bt_common_normalize_path(path, NULL); if (!norm_path) { - PERR("Failed to normalize path `%s`.\n", path); + BT_LOGE("Failed to normalize path `%s`.", path); ret = -1; goto end; } if (strcmp(norm_path->str, "/") == 0) { - PERR("Opening a trace in `/` is not supported.\n"); + BT_LOGE("Opening a trace in `/` is not supported."); ret = -1; goto end; } @@ -999,9 +989,8 @@ end: return ret; } -static -int find_ctf_traces(struct ctf_fs_component *ctf_fs, - GList **trace_paths, const char *start_path) +BT_HIDDEN +int ctf_fs_find_traces(GList **trace_paths, const char *start_path) { int ret; GError *error = NULL; @@ -1019,7 +1008,7 @@ int find_ctf_traces(struct ctf_fs_component *ctf_fs, * Stop recursion: a CTF trace cannot contain another * CTF trace. */ - ret = add_trace_path(ctf_fs, trace_paths, start_path); + ret = add_trace_path(trace_paths, start_path); goto end; } @@ -1032,12 +1021,12 @@ int find_ctf_traces(struct ctf_fs_component *ctf_fs, dir = g_dir_open(start_path, 0, &error); if (!dir) { if (error->code == G_FILE_ERROR_ACCES) { - PDBG("Cannot open directory `%s`: %s (code %d): continuing\n", + BT_LOGD("Cannot open directory `%s`: %s (code %d): continuing", start_path, error->message, error->code); goto end; } - PERR("Cannot open directory `%s`: %s (code %d)\n", + BT_LOGE("Cannot open directory `%s`: %s (code %d)", start_path, error->message, error->code); ret = -1; goto end; @@ -1052,7 +1041,7 @@ int find_ctf_traces(struct ctf_fs_component *ctf_fs, } g_string_printf(sub_path, "%s/%s", start_path, basename); - ret = find_ctf_traces(ctf_fs, trace_paths, sub_path->str); + ret = ctf_fs_find_traces(trace_paths, sub_path->str); g_string_free(sub_path, TRUE); if (ret) { goto end; @@ -1071,8 +1060,8 @@ end: return ret; } -static -GList *create_trace_names(GList *trace_paths, const char *base_path) { +BT_HIDDEN +GList *ctf_fs_create_trace_names(GList *trace_paths, const char *base_path) { GList *trace_names = NULL; GList *node; const char *last_sep; @@ -1135,28 +1124,32 @@ int create_ctf_fs_traces(struct ctf_fs_component *ctf_fs, GList *trace_names = NULL; GList *tp_node; GList *tn_node; + struct metadata_overrides metadata_overrides = { + .clock_offset_s = ctf_fs->options.clock_offset, + .clock_offset_ns = ctf_fs->options.clock_offset_ns, + }; norm_path = bt_common_normalize_path(path_param, NULL); if (!norm_path) { - PERR("Failed to normalize path: `%s`.\n", + BT_LOGE("Failed to normalize path: `%s`.", path_param); goto error; } - ret = find_ctf_traces(ctf_fs, &trace_paths, norm_path->str); + ret = ctf_fs_find_traces(&trace_paths, norm_path->str); if (ret) { goto error; } if (!trace_paths) { - PERR("No CTF traces recursively found in `%s`.\n", + BT_LOGE("No CTF traces recursively found in `%s`.", path_param); goto error; } - trace_names = create_trace_names(trace_paths, norm_path->str); + trace_names = ctf_fs_create_trace_names(trace_paths, norm_path->str); if (!trace_names) { - PERR("Cannot create trace names from trace paths.\n"); + BT_LOGE("Cannot create trace names from trace paths."); goto error; } @@ -1166,14 +1159,19 @@ int create_ctf_fs_traces(struct ctf_fs_component *ctf_fs, GString *trace_path = tp_node->data; GString *trace_name = tn_node->data; - ctf_fs_trace = ctf_fs_trace_create(ctf_fs, trace_path->str, - trace_name->str); + ctf_fs_trace = ctf_fs_trace_create(trace_path->str, + trace_name->str, &metadata_overrides); if (!ctf_fs_trace) { - PERR("Cannot create trace for `%s`.\n", + BT_LOGE("Cannot create trace for `%s`.", trace_path->str); goto error; } + ret = create_ports_for_trace(ctf_fs, ctf_fs_trace); + if (ret) { + goto error; + } + g_ptr_array_add(ctf_fs->traces, ctf_fs_trace); ctf_fs_trace = NULL; } @@ -1248,8 +1246,7 @@ struct ctf_fs_component *ctf_fs_create(struct bt_private_component *priv_comp, int64_t offset; if (!bt_value_is_integer(value)) { - fprintf(stderr, - "offset-s should be an integer\n"); + BT_LOGE("offset-s should be an integer"); goto error; } ret = bt_value_integer_get(value, &offset); @@ -1263,8 +1260,7 @@ struct ctf_fs_component *ctf_fs_create(struct bt_private_component *priv_comp, int64_t offset; if (!bt_value_is_integer(value)) { - fprintf(stderr, - "offset-ns should be an integer\n"); + BT_LOGE("offset-ns should be an integer"); goto error; } ret = bt_value_integer_get(value, &offset); @@ -1273,8 +1269,6 @@ struct ctf_fs_component *ctf_fs_create(struct bt_private_component *priv_comp, BT_PUT(value); } - ctf_fs->error_fp = stderr; - ctf_fs->page_size = bt_common_get_page_size(); ctf_fs->port_data = g_ptr_array_new_with_free_func(port_data_destroy); if (!ctf_fs->port_data) { goto error; @@ -1328,7 +1322,7 @@ struct bt_value *ctf_fs_query(struct bt_component_class *comp_class, if (!strcmp(object, "metadata-info")) { result = metadata_info_query(comp_class, params); } else { - fprintf(stderr, "Unknown query object `%s`\n", object); + BT_LOGE("Unknown query object `%s`", object); goto end; } end: diff --git a/plugins/ctf/fs-src/fs.h b/plugins/ctf/fs-src/fs.h index 02a5edfb..a4b04f37 100644 --- a/plugins/ctf/fs-src/fs.h +++ b/plugins/ctf/fs-src/fs.h @@ -38,9 +38,6 @@ BT_HIDDEN extern bool ctf_fs_debug; struct ctf_fs_file { - /* Weak, belongs to component */ - struct ctf_fs_component *ctf_fs; - /* Owned by this */ GString *path; @@ -100,8 +97,8 @@ struct ctf_fs_ds_file { }; struct ctf_fs_component_options { - uint64_t clock_offset; - uint64_t clock_offset_ns; + int64_t clock_offset; + int64_t clock_offset_ns; }; struct ctf_fs_component { @@ -115,14 +112,9 @@ struct ctf_fs_component { GPtrArray *traces; struct ctf_fs_component_options options; - FILE *error_fp; - size_t page_size; }; struct ctf_fs_trace { - /* Weak, belongs to component */ - struct ctf_fs_component *ctf_fs; - /* Owned by this */ struct ctf_fs_metadata *metadata; @@ -186,13 +178,19 @@ enum bt_notification_iterator_status ctf_fs_iterator_init( struct bt_private_notification_iterator *it, struct bt_private_port *port); +BT_HIDDEN +struct bt_value *ctf_fs_query(struct bt_component_class *comp_class, + const char *object, struct bt_value *params); + +BT_HIDDEN +int ctf_fs_find_traces(GList **trace_paths, const char *start_path); + +BT_HIDDEN +GList *ctf_fs_create_trace_names(GList *trace_paths, const char *base_path); + void ctf_fs_iterator_finalize(struct bt_private_notification_iterator *it); struct bt_notification_iterator_next_return ctf_fs_iterator_next( struct bt_private_notification_iterator *iterator); -BT_HIDDEN -struct bt_value *ctf_fs_query(struct bt_component_class *comp_class, - const char *object, struct bt_value *params); - #endif /* BABELTRACE_PLUGIN_CTF_FS_H */ diff --git a/plugins/ctf/fs-src/logging.c b/plugins/ctf/fs-src/logging.c new file mode 100644 index 00000000..c03b9845 --- /dev/null +++ b/plugins/ctf/fs-src/logging.c @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define BT_LOG_OUTPUT_LEVEL ctf_fs_src_log_level +#include + +BT_LOG_INIT_LOG_LEVEL(BT_LOG_OUTPUT_LEVEL, "BABELTRACE_PLUGIN_CTF_FS_SRC_LOG_LEVEL"); diff --git a/plugins/ctf/fs-src/logging.h b/plugins/ctf/fs-src/logging.h new file mode 100644 index 00000000..e82cbc98 --- /dev/null +++ b/plugins/ctf/fs-src/logging.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef CTF_FS_SRC_LOGGING_H +#define CTF_FS_SRC_LOGGING_H + +#define BT_LOG_OUTPUT_LEVEL ctf_fs_src_log_level +#include + +BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_fs_src_log_level); + +#endif /* CTF_FS_SRC_LOGGING_H */ diff --git a/plugins/ctf/fs-src/metadata.c b/plugins/ctf/fs-src/metadata.c index c6b50953..91465cb9 100644 --- a/plugins/ctf/fs-src/metadata.c +++ b/plugins/ctf/fs-src/metadata.c @@ -32,16 +32,14 @@ #include #include -#define PRINT_ERR_STREAM ctf_fs->error_fp -#define PRINT_PREFIX "ctf-fs-metadata" -#define PRINT_DBG_CHECK ctf_fs_debug -#include "../print.h" - #include "fs.h" #include "file.h" #include "metadata.h" #include "../common/metadata/decoder.h" +#define BT_LOG_TAG "PLUGIN-CTF-FS-METADATA-SRC" +#include "logging.h" + #define NSEC_PER_SEC 1000000000LL BT_HIDDEN @@ -73,10 +71,9 @@ end: return fp; } -static struct ctf_fs_file *get_file(struct ctf_fs_component *ctf_fs, - const char *trace_path) +static struct ctf_fs_file *get_file(const char *trace_path) { - struct ctf_fs_file *file = ctf_fs_file_create(ctf_fs); + struct ctf_fs_file *file = ctf_fs_file_create(); if (!file) { goto error; @@ -85,7 +82,7 @@ static struct ctf_fs_file *get_file(struct ctf_fs_component *ctf_fs, g_string_append(file->path, trace_path); g_string_append(file->path, "/" CTF_FS_METADATA_FILENAME); - if (ctf_fs_file_open(ctf_fs, file, "rb")) { + if (ctf_fs_file_open(file, "rb")) { goto error; } @@ -101,32 +98,37 @@ end: return file; } -int ctf_fs_metadata_set_trace(struct ctf_fs_trace *ctf_fs_trace) +int ctf_fs_metadata_set_trace(struct ctf_fs_trace *ctf_fs_trace, + struct metadata_overrides *overrides) { int ret = 0; - struct ctf_fs_component *ctf_fs = ctf_fs_trace->ctf_fs; struct ctf_fs_file *file = NULL; struct ctf_metadata_decoder *metadata_decoder = NULL; + int64_t clock_offset_adjustment = 0; - file = get_file(ctf_fs, ctf_fs_trace->path->str); + file = get_file(ctf_fs_trace->path->str); if (!file) { - PERR("Cannot create metadata file object\n"); + BT_LOGE("Cannot create metadata file object"); ret = -1; goto end; } - metadata_decoder = ctf_metadata_decoder_create(ctf_fs->error_fp, - ctf_fs->options.clock_offset * NSEC_PER_SEC + - ctf_fs->options.clock_offset_ns, ctf_fs_trace->name->str); + if (overrides) { + clock_offset_adjustment = + overrides->clock_offset_s * NSEC_PER_SEC + + overrides->clock_offset_ns; + } + metadata_decoder = ctf_metadata_decoder_create(clock_offset_adjustment, + ctf_fs_trace->name->str); if (!metadata_decoder) { - PERR("Cannot create metadata decoder object\n"); + BT_LOGE("Cannot create metadata decoder object"); ret = -1; goto end; } ret = ctf_metadata_decoder_decode(metadata_decoder, file->fp); if (ret) { - PERR("Cannot decode metadata file\n"); + BT_LOGE("Cannot decode metadata file"); goto end; } diff --git a/plugins/ctf/fs-src/metadata.h b/plugins/ctf/fs-src/metadata.h index cb822ad4..4976d62d 100644 --- a/plugins/ctf/fs-src/metadata.h +++ b/plugins/ctf/fs-src/metadata.h @@ -31,6 +31,11 @@ #define CTF_FS_METADATA_FILENAME "metadata" +struct metadata_overrides { + int64_t clock_offset_s; + int64_t clock_offset_ns; +}; + BT_HIDDEN int ctf_fs_metadata_init(struct ctf_fs_metadata *metadata); @@ -38,7 +43,8 @@ BT_HIDDEN void ctf_fs_metadata_fini(struct ctf_fs_metadata *metadata); BT_HIDDEN -int ctf_fs_metadata_set_trace(struct ctf_fs_trace *ctf_fs_trace); +int ctf_fs_metadata_set_trace(struct ctf_fs_trace *ctf_fs_trace, + struct metadata_overrides *overrides); BT_HIDDEN FILE *ctf_fs_metadata_open_file(const char *trace_path); diff --git a/plugins/ctf/fs-src/query.c b/plugins/ctf/fs-src/query.c index 60ec42e1..8fa9b282 100644 --- a/plugins/ctf/fs-src/query.c +++ b/plugins/ctf/fs-src/query.c @@ -29,6 +29,10 @@ #include #include "metadata.h" #include "../common/metadata/decoder.h" +#include + +#define BT_LOG_TAG "PLUGIN-CTF-FS-QUERY-SRC" +#include "logging.h" #define METADATA_TEXT_SIG "/* CTF 1.8" diff --git a/plugins/ctf/lttng-live/data-stream.c b/plugins/ctf/lttng-live/data-stream.c index 43e281bd..d7089108 100644 --- a/plugins/ctf/lttng-live/data-stream.c +++ b/plugins/ctf/lttng-live/data-stream.c @@ -118,7 +118,7 @@ enum bt_ctf_lttng_live_iterator_status lttng_live_lazy_notif_init( } stream->notif_iter = bt_ctf_notif_iter_create(trace->trace, lttng_live->max_query_size, medops, - stream, stderr); + stream); if (!stream->notif_iter) { goto error; } @@ -160,7 +160,7 @@ struct lttng_live_stream_iterator *lttng_live_stream_iterator_create( if (trace->trace) { stream->notif_iter = bt_ctf_notif_iter_create(trace->trace, lttng_live->max_query_size, medops, - stream, stderr); + stream); if (!stream->notif_iter) { goto error; } diff --git a/plugins/ctf/lttng-live/metadata.c b/plugins/ctf/lttng-live/metadata.c index fcdb247e..4ef794a4 100644 --- a/plugins/ctf/lttng-live/metadata.c +++ b/plugins/ctf/lttng-live/metadata.c @@ -246,7 +246,7 @@ int lttng_live_metadata_create_stream(struct lttng_live_session *session, if (!match) { goto error; } - metadata->decoder = ctf_metadata_decoder_create(stderr, 0, + metadata->decoder = ctf_metadata_decoder_create(0, match); if (!metadata->decoder) { goto error; -- 2.34.1