From 087cd0f57f0f7d815a609a4e041d1200f380e4aa Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 19 Jan 2022 13:32:03 -0500 Subject: [PATCH] ctf: compile plugin as C++ Rename files under src/plugins/ctf: - .c to .cpp - .h to .hpp - .y to .ypp - .l to .lpp Do the necessary adjustements to get it to compile as C++. Most changes are not too surprising, just typical adjustments to casts and things like that. But there a few things worthy of mention: * g++ 7 doesn't accept non-trivial static initializers. This means that parameter validation descriptors don't compile, and we need another approach. Add constructors (only if __cplusplus is defined) to bt_param_validation_value_descr to allow constructing a descriptor of the various types. This allows retaining a syntax very close to the existing one. * Similary, g++ 7 doesn't like the existing initialization of node_error, in parser.ypp. Explicitly initialize the fields before `type` to work around that. * About the class hierarchies of ctf_field_class and fs_sink_ctf_field_class. Casting to sub- or super-class is currently done by casting to `void *`, which doesn't work in C++. Replace that with: * to cast to a super-class, get the pointer to the right base, like `&fc->base.base`. It might be a bit ugly, but it's shorter than casting and type-safe, so why not. * to cast to a sub-class, add some free functions such as `ctf_field_class_as_string` that check the field class' type, make sure they are indeed an instance of the requested type, and do the cast. Note that this cast still assumes that bases are the first member in each sub-class. * For the rest, if you are wondering why some change is necessary, try reverting and compiling (with a recent gcc and clang), the compiler will tell you. Change-Id: I05b12b906c5df0d89fdc2a70ce4a3b6810b48d41 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/7096 Reviewed-by: Philippe Proulx --- src/common/macros.h | 6 + src/common/mmap-align.h | 6 +- src/compat/bitfield.h | 6 +- src/compat/memstream.h | 2 +- src/compat/mman.h | 6 +- src/compat/socket.h | 4 +- src/ctfser/ctfser.h | 18 +- src/plugins/common/muxing/muxing.h | 2 +- .../param-validation/param-validation.h | 58 +++++- src/plugins/ctf/Makefile.am | 2 +- src/plugins/ctf/common/Makefile.am | 2 +- src/plugins/ctf/common/bfcr/Makefile.am | 4 +- .../ctf/common/bfcr/{bfcr.c => bfcr.cpp} | 26 ++- .../ctf/common/bfcr/{bfcr.h => bfcr.hpp} | 2 +- src/plugins/ctf/common/metadata/Makefile.am | 80 ++++---- .../ctf/common/metadata/{ast.h => ast.hpp} | 95 +++++----- ...race.c => ctf-meta-configure-ir-trace.cpp} | 2 +- ...race.h => ctf-meta-configure-ir-trace.hpp} | 2 +- ...tf-meta-resolve.c => ctf-meta-resolve.cpp} | 103 +++++----- ...eta-translate.c => ctf-meta-translate.cpp} | 89 +++++---- ...ments.c => ctf-meta-update-alignments.cpp} | 12 +- ...ctf-meta-update-default-clock-classes.cpp} | 18 +- ...date-in-ir.c => ctf-meta-update-in-ir.cpp} | 24 +-- ...eanings.c => ctf-meta-update-meanings.cpp} | 36 ++-- ...> ctf-meta-update-stream-class-config.cpp} | 12 +- ...> ctf-meta-update-text-array-sequence.cpp} | 14 +- ...ctf-meta-update-value-storing-indexes.cpp} | 18 +- ...-meta-validate.c => ctf-meta-validate.cpp} | 56 +++--- ...-meta-visitors.h => ctf-meta-visitors.hpp} | 2 +- ...f-meta-warn-meaningless-header-fields.cpp} | 16 +- .../metadata/{ctf-meta.h => ctf-meta.hpp} | 179 +++++++++++++----- ...decoder-packetized-file-stream-to-buf.cpp} | 10 +- ...decoder-packetized-file-stream-to-buf.hpp} | 0 .../metadata/{decoder.c => decoder.cpp} | 12 +- .../metadata/{decoder.h => decoder.hpp} | 1 + .../common/metadata/{lexer.l => lexer.lpp} | 8 +- .../metadata/{logging.c => logging.cpp} | 0 .../metadata/{logging.h => logging.hpp} | 0 .../metadata/{objstack.c => objstack.cpp} | 10 +- .../metadata/{objstack.h => objstack.hpp} | 0 .../{parser-wrap.h => parser-wrap.hpp} | 2 +- .../common/metadata/{parser.y => parser.ypp} | 44 +++-- ...{scanner-symbols.h => scanner-symbols.hpp} | 0 .../metadata/{scanner.h => scanner.hpp} | 2 +- ...-generate-ir.c => visitor-generate-ir.cpp} | 174 ++++++++++------- ...arent-links.c => visitor-parent-links.cpp} | 6 +- ...dator.c => visitor-semantic-validator.cpp} | 6 +- src/plugins/ctf/common/msg-iter/Makefile.am | 4 +- .../msg-iter/{msg-iter.c => msg-iter.cpp} | 52 ++--- .../msg-iter/{msg-iter.h => msg-iter.hpp} | 2 +- src/plugins/ctf/common/{print.h => print.hpp} | 0 src/plugins/ctf/fs-sink/Makefile.am | 22 +-- ...s-sink-ctf-meta.h => fs-sink-ctf-meta.hpp} | 175 +++++++++++++---- .../{fs-sink-stream.c => fs-sink-stream.cpp} | 60 +++--- .../{fs-sink-stream.h => fs-sink-stream.hpp} | 2 +- .../{fs-sink-trace.c => fs-sink-trace.cpp} | 12 +- .../{fs-sink-trace.h => fs-sink-trace.hpp} | 2 +- .../ctf/fs-sink/{fs-sink.c => fs-sink.cpp} | 45 +++-- .../ctf/fs-sink/{fs-sink.h => fs-sink.hpp} | 0 ...to-tsdl.c => translate-ctf-ir-to-tsdl.cpp} | 45 ++--- ...to-tsdl.h => translate-ctf-ir-to-tsdl.hpp} | 2 +- ...-ir.c => translate-trace-ir-to-ctf-ir.cpp} | 112 ++++++----- ...-ir.h => translate-trace-ir-to-ctf-ir.hpp} | 4 +- src/plugins/ctf/fs-src/Makefile.am | 22 +-- ...ata-stream-file.c => data-stream-file.cpp} | 34 ++-- ...ata-stream-file.h => data-stream-file.hpp} | 4 +- src/plugins/ctf/fs-src/{file.c => file.cpp} | 2 +- src/plugins/ctf/fs-src/{file.h => file.hpp} | 2 +- src/plugins/ctf/fs-src/{fs.c => fs.cpp} | 145 +++++++------- src/plugins/ctf/fs-src/{fs.h => fs.hpp} | 6 +- .../fs-src/{lttng-index.h => lttng-index.hpp} | 0 .../ctf/fs-src/{metadata.c => metadata.cpp} | 26 +-- .../ctf/fs-src/{metadata.h => metadata.hpp} | 0 src/plugins/ctf/fs-src/{query.c => query.cpp} | 28 +-- src/plugins/ctf/fs-src/{query.h => query.hpp} | 0 src/plugins/ctf/lttng-live/Makefile.am | 18 +- .../{data-stream.c => data-stream.cpp} | 23 +-- .../{data-stream.h => data-stream.hpp} | 4 +- .../{lttng-live.c => lttng-live.cpp} | 73 +++---- .../{lttng-live.h => lttng-live.hpp} | 6 +- ...ttng-viewer-abi.h => lttng-viewer-abi.hpp} | 0 .../lttng-live/{metadata.c => metadata.cpp} | 24 +-- .../lttng-live/{metadata.h => metadata.hpp} | 2 +- ...wer-connection.c => viewer-connection.cpp} | 32 +++- ...wer-connection.h => viewer-connection.hpp} | 0 src/plugins/ctf/{plugin.c => plugin.cpp} | 6 +- 86 files changed, 1258 insertions(+), 915 deletions(-) rename src/plugins/ctf/common/bfcr/{bfcr.c => bfcr.cpp} (97%) rename src/plugins/ctf/common/bfcr/{bfcr.h => bfcr.hpp} (99%) rename src/plugins/ctf/common/metadata/{ast.h => ast.hpp} (90%) rename src/plugins/ctf/common/metadata/{ctf-meta-configure-ir-trace.c => ctf-meta-configure-ir-trace.cpp} (95%) rename src/plugins/ctf/common/metadata/{ctf-meta-configure-ir-trace.h => ctf-meta-configure-ir-trace.hpp} (93%) rename src/plugins/ctf/common/metadata/{ctf-meta-resolve.c => ctf-meta-resolve.cpp} (93%) rename src/plugins/ctf/common/metadata/{ctf-meta-translate.c => ctf-meta-translate.cpp} (86%) rename src/plugins/ctf/common/metadata/{ctf-meta-update-alignments.c => ctf-meta-update-alignments.cpp} (88%) rename src/plugins/ctf/common/metadata/{ctf-meta-update-default-clock-classes.c => ctf-meta-update-default-clock-classes.cpp} (87%) rename src/plugins/ctf/common/metadata/{ctf-meta-update-in-ir.c => ctf-meta-update-in-ir.cpp} (87%) rename src/plugins/ctf/common/metadata/{ctf-meta-update-meanings.c => ctf-meta-update-meanings.cpp} (78%) rename src/plugins/ctf/common/metadata/{ctf-meta-update-stream-class-config.c => ctf-meta-update-stream-class-config.cpp} (81%) rename src/plugins/ctf/common/metadata/{ctf-meta-update-text-array-sequence.c => ctf-meta-update-text-array-sequence.cpp} (86%) rename src/plugins/ctf/common/metadata/{ctf-meta-update-value-storing-indexes.c => ctf-meta-update-value-storing-indexes.cpp} (85%) rename src/plugins/ctf/common/metadata/{ctf-meta-validate.c => ctf-meta-validate.cpp} (86%) rename src/plugins/ctf/common/metadata/{ctf-meta-visitors.h => ctf-meta-visitors.hpp} (98%) rename src/plugins/ctf/common/metadata/{ctf-meta-warn-meaningless-header-fields.c => ctf-meta-warn-meaningless-header-fields.cpp} (84%) rename src/plugins/ctf/common/metadata/{ctf-meta.h => ctf-meta.hpp} (87%) rename src/plugins/ctf/common/metadata/{decoder-packetized-file-stream-to-buf.c => decoder-packetized-file-stream-to-buf.cpp} (98%) rename src/plugins/ctf/common/metadata/{decoder-packetized-file-stream-to-buf.h => decoder-packetized-file-stream-to-buf.hpp} (100%) rename src/plugins/ctf/common/metadata/{decoder.c => decoder.cpp} (98%) rename src/plugins/ctf/common/metadata/{decoder.h => decoder.hpp} (99%) rename src/plugins/ctf/common/metadata/{lexer.l => lexer.lpp} (98%) rename src/plugins/ctf/common/metadata/{logging.c => logging.cpp} (100%) rename src/plugins/ctf/common/metadata/{logging.h => logging.hpp} (100%) rename src/plugins/ctf/common/metadata/{objstack.c => objstack.cpp} (90%) rename src/plugins/ctf/common/metadata/{objstack.h => objstack.hpp} (100%) rename src/plugins/ctf/common/metadata/{parser-wrap.h => parser-wrap.hpp} (96%) rename src/plugins/ctf/common/metadata/{parser.y => parser.ypp} (99%) rename src/plugins/ctf/common/metadata/{scanner-symbols.h => scanner-symbols.hpp} (100%) rename src/plugins/ctf/common/metadata/{scanner.h => scanner.hpp} (98%) rename src/plugins/ctf/common/metadata/{visitor-generate-ir.c => visitor-generate-ir.cpp} (97%) rename src/plugins/ctf/common/metadata/{visitor-parent-links.c => visitor-parent-links.cpp} (99%) rename src/plugins/ctf/common/metadata/{visitor-semantic-validator.c => visitor-semantic-validator.cpp} (99%) rename src/plugins/ctf/common/msg-iter/{msg-iter.c => msg-iter.cpp} (98%) rename src/plugins/ctf/common/msg-iter/{msg-iter.h => msg-iter.hpp} (99%) rename src/plugins/ctf/common/{print.h => print.hpp} (100%) rename src/plugins/ctf/fs-sink/{fs-sink-ctf-meta.h => fs-sink-ctf-meta.hpp} (81%) rename src/plugins/ctf/fs-sink/{fs-sink-stream.c => fs-sink-stream.cpp} (90%) rename src/plugins/ctf/fs-sink/{fs-sink-stream.h => fs-sink-stream.hpp} (99%) rename src/plugins/ctf/fs-sink/{fs-sink-trace.c => fs-sink-trace.cpp} (98%) rename src/plugins/ctf/fs-sink/{fs-sink-trace.h => fs-sink-trace.hpp} (98%) rename src/plugins/ctf/fs-sink/{fs-sink.c => fs-sink.cpp} (96%) rename src/plugins/ctf/fs-sink/{fs-sink.h => fs-sink.hpp} (100%) rename src/plugins/ctf/fs-sink/{translate-ctf-ir-to-tsdl.c => translate-ctf-ir-to-tsdl.cpp} (95%) rename src/plugins/ctf/fs-sink/{translate-ctf-ir-to-tsdl.h => translate-ctf-ir-to-tsdl.hpp} (93%) rename src/plugins/ctf/fs-sink/{translate-trace-ir-to-ctf-ir.c => translate-trace-ir-to-ctf-ir.cpp} (94%) rename src/plugins/ctf/fs-sink/{translate-trace-ir-to-ctf-ir.h => translate-trace-ir-to-ctf-ir.hpp} (94%) rename src/plugins/ctf/fs-src/{data-stream-file.c => data-stream-file.cpp} (97%) rename src/plugins/ctf/fs-src/{data-stream-file.h => data-stream-file.hpp} (97%) rename src/plugins/ctf/fs-src/{file.c => file.cpp} (99%) rename src/plugins/ctf/fs-src/{file.h => file.hpp} (96%) rename src/plugins/ctf/fs-src/{fs.c => fs.cpp} (93%) rename src/plugins/ctf/fs-src/{fs.h => fs.hpp} (98%) rename src/plugins/ctf/fs-src/{lttng-index.h => lttng-index.hpp} (100%) rename src/plugins/ctf/fs-src/{metadata.c => metadata.cpp} (83%) rename src/plugins/ctf/fs-src/{metadata.h => metadata.hpp} (100%) rename src/plugins/ctf/fs-src/{query.c => query.cpp} (96%) rename src/plugins/ctf/fs-src/{query.h => query.hpp} (100%) rename src/plugins/ctf/lttng-live/{data-stream.c => data-stream.cpp} (93%) rename src/plugins/ctf/lttng-live/{data-stream.h => data-stream.hpp} (90%) rename src/plugins/ctf/lttng-live/{lttng-live.c => lttng-live.cpp} (97%) rename src/plugins/ctf/lttng-live/{lttng-live.h => lttng-live.hpp} (98%) rename src/plugins/ctf/lttng-live/{lttng-viewer-abi.h => lttng-viewer-abi.hpp} (100%) rename src/plugins/ctf/lttng-live/{metadata.c => metadata.cpp} (95%) rename src/plugins/ctf/lttng-live/{metadata.h => metadata.hpp} (95%) rename src/plugins/ctf/lttng-live/{viewer-connection.c => viewer-connection.cpp} (98%) rename src/plugins/ctf/lttng-live/{viewer-connection.h => viewer-connection.hpp} (100%) rename src/plugins/ctf/{plugin.c => plugin.cpp} (96%) diff --git a/src/common/macros.h b/src/common/macros.h index 5549b857..34ac393f 100644 --- a/src/common/macros.h +++ b/src/common/macros.h @@ -11,6 +11,12 @@ extern "C" { #endif +#ifdef __cplusplus +#define BT_EXTERN_C extern "C" +#else +#define BT_EXTERN_C +#endif + #define bt_max_t(type, a, b) \ ((type) (a) > (type) (b) ? (type) (a) : (type) (b)) diff --git a/src/common/mmap-align.h b/src/common/mmap-align.h index d2750241..7c164935 100644 --- a/src/common/mmap-align.h +++ b/src/common/mmap-align.h @@ -46,9 +46,9 @@ struct mmap_align_data *mmap_align(size_t length, int prot, page_size = bt_common_get_page_size(log_level); - mma = malloc(sizeof(*mma)); + mma = (struct mmap_align_data *) malloc(sizeof(*mma)); if (!mma) - return MAP_FAILED; + return (struct mmap_align_data *) MAP_FAILED; mma->length = length; page_aligned_offset = get_page_aligned_offset(offset, log_level); /* @@ -62,7 +62,7 @@ struct mmap_align_data *mmap_align(size_t length, int prot, prot, flags, fd, page_aligned_offset, log_level); if (mma->page_aligned_addr == MAP_FAILED) { free(mma); - return MAP_FAILED; + return (struct mmap_align_data *) MAP_FAILED; } mma->addr = ((uint8_t *) mma->page_aligned_addr) + (offset - page_aligned_offset); return mma; diff --git a/src/compat/bitfield.h b/src/compat/bitfield.h index e0a3885c..df67401d 100644 --- a/src/compat/bitfield.h +++ b/src/compat/bitfield.h @@ -189,7 +189,7 @@ do { \ #define _bt_bitfield_write_le(ptr, type, start, length, v) \ do { \ __typeof__(v) _v = (v); \ - type *_ptr = (void *) (ptr); \ + type *_ptr = (type *) (ptr); \ unsigned long _start = (start), _length = (length); \ type _mask, _cmask; \ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \ @@ -248,7 +248,7 @@ do { \ #define _bt_bitfield_write_be(ptr, type, start, length, v) \ do { \ __typeof__(v) _v = (v); \ - type *_ptr = (void *) (ptr); \ + type *_ptr = (type *) (ptr); \ unsigned long _start = (start), _length = (length); \ type _mask, _cmask; \ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \ @@ -409,7 +409,7 @@ do { \ do { \ __typeof__(*(vptr)) *_vptr = (vptr); \ __typeof__(*_vptr) _v; \ - type *_ptr = (void *) (ptr); \ + type *_ptr = (type *) (ptr); \ unsigned long _start = (start), _length = (length); \ type _mask, _cmask; \ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \ diff --git a/src/compat/memstream.h b/src/compat/memstream.h index 30d974ca..dcadf048 100644 --- a/src/compat/memstream.h +++ b/src/compat/memstream.h @@ -299,7 +299,7 @@ int bt_close_memstream(char **buf, size_t *size, FILE *fp) } *size = pos; /* add final \0 */ - *buf = calloc(pos + 1, sizeof(char)); + *buf = (char *) calloc(pos + 1, sizeof(char)); if (!*buf) { return -ENOMEM; } diff --git a/src/compat/mman.h b/src/compat/mman.h index 3f03d490..a9568c6b 100644 --- a/src/compat/mman.h +++ b/src/compat/mman.h @@ -29,16 +29,16 @@ * Note that some platforms (e.g. Windows) do not allow read-only * mappings to exceed the file's size (even within a page). */ -void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd, +BT_EXTERN_C void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset, int log_level); -int bt_munmap(void *addr, size_t length); +BT_EXTERN_C int bt_munmap(void *addr, size_t length); /* * On Windows the memory mapping offset must be aligned to the memory * allocator allocation granularity and not the page size. */ -size_t bt_mmap_get_offset_align_size(int log_level); +BT_EXTERN_C size_t bt_mmap_get_offset_align_size(int log_level); #else /* __MINGW32__ */ diff --git a/src/compat/socket.h b/src/compat/socket.h index f5c59b4b..7a57678b 100644 --- a/src/compat/socket.h +++ b/src/compat/socket.h @@ -59,13 +59,13 @@ int bt_socket_fini(void) static inline int bt_socket_send(int sockfd, const void *buf, size_t len, int flags) { - return send(sockfd, buf, len, flags); + return send(sockfd, (const char *) buf, len, flags); } static inline int bt_socket_recv(int sockfd, void *buf, size_t len, int flags) { - return recv(sockfd, buf, len, flags); + return recv(sockfd, (char *) buf, len, flags); } static inline diff --git a/src/ctfser/ctfser.h b/src/ctfser/ctfser.h index 2abe65a3..d2fb0b91 100644 --- a/src/ctfser/ctfser.h +++ b/src/ctfser/ctfser.h @@ -67,7 +67,7 @@ struct bt_ctfser { * * This function opens the file `path` for writing. */ -BT_HIDDEN +BT_EXTERN_C BT_HIDDEN int bt_ctfser_init(struct bt_ctfser *ctfser, const char *path, int log_level); @@ -77,7 +77,7 @@ int bt_ctfser_init(struct bt_ctfser *ctfser, const char *path, * This function truncates the stream file so that there's no extra * padding after the last packet, and then closes the file. */ -BT_HIDDEN +BT_EXTERN_C BT_HIDDEN int bt_ctfser_fini(struct bt_ctfser *ctfser); /* @@ -85,17 +85,17 @@ int bt_ctfser_fini(struct bt_ctfser *ctfser); * * All the next writing functions are performed within this new packet. */ -BT_HIDDEN +BT_EXTERN_C BT_HIDDEN int bt_ctfser_open_packet(struct bt_ctfser *ctfser); /* * Closes the current packet, making its size `packet_size_bytes`. */ -BT_HIDDEN +BT_EXTERN_C BT_HIDDEN void bt_ctfser_close_current_packet(struct bt_ctfser *ctfser, uint64_t packet_size_bytes); -BT_HIDDEN +BT_EXTERN_C BT_HIDDEN int _bt_ctfser_increase_cur_packet_size(struct bt_ctfser *ctfser); static inline @@ -404,11 +404,11 @@ int bt_ctfser_write_unsigned_int(struct bt_ctfser *ctfser, uint64_t value, } if (byte_order == LITTLE_ENDIAN) { - bt_bitfield_write_le(mmap_align_addr(ctfser->base_mma) + + bt_bitfield_write_le((uint8_t *) mmap_align_addr(ctfser->base_mma) + ctfser->mmap_base_offset, uint8_t, ctfser->offset_in_cur_packet_bits, size_bits, value); } else { - bt_bitfield_write_be(mmap_align_addr(ctfser->base_mma) + + bt_bitfield_write_be((uint8_t *) mmap_align_addr(ctfser->base_mma) + ctfser->mmap_base_offset, uint8_t, ctfser->offset_in_cur_packet_bits, size_bits, value); } @@ -449,11 +449,11 @@ int bt_ctfser_write_signed_int(struct bt_ctfser *ctfser, int64_t value, } if (byte_order == LITTLE_ENDIAN) { - bt_bitfield_write_le(mmap_align_addr(ctfser->base_mma) + + bt_bitfield_write_le((uint8_t *) mmap_align_addr(ctfser->base_mma) + ctfser->mmap_base_offset, uint8_t, ctfser->offset_in_cur_packet_bits, size_bits, value); } else { - bt_bitfield_write_be(mmap_align_addr(ctfser->base_mma) + + bt_bitfield_write_be((uint8_t *) mmap_align_addr(ctfser->base_mma) + ctfser->mmap_base_offset, uint8_t, ctfser->offset_in_cur_packet_bits, size_bits, value); } diff --git a/src/plugins/common/muxing/muxing.h b/src/plugins/common/muxing/muxing.h index e34f1efa..07232ee2 100644 --- a/src/plugins/common/muxing/muxing.h +++ b/src/plugins/common/muxing/muxing.h @@ -10,7 +10,7 @@ #include #include "common/macros.h" -BT_HIDDEN +BT_EXTERN_C BT_HIDDEN int common_muxing_compare_messages(const bt_message *left_msg, const bt_message *right_msg); diff --git a/src/plugins/common/param-validation/param-validation.h b/src/plugins/common/param-validation/param-validation.h index f89ae349..0daee1ff 100644 --- a/src/plugins/common/param-validation/param-validation.h +++ b/src/plugins/common/param-validation/param-validation.h @@ -17,7 +17,12 @@ struct bt_param_validation_context; struct bt_param_validation_value_descr; +#if defined(__cplusplus) +#define BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END \ + { bt_param_validation_map_value_entry_descr::end } +#else #define BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END { NULL, 0, {} } +#endif struct bt_param_validation_map_value_descr { const struct bt_param_validation_map_value_entry_descr *entries; @@ -47,6 +52,32 @@ typedef enum bt_param_validation_status struct bt_param_validation_context *); struct bt_param_validation_value_descr { +#if defined(__cplusplus) + static struct {} array_t; + static struct {} string_t; + static struct {} signed_integer_t; + static struct {} bool_t; + + bt_param_validation_value_descr(decltype(array_t), + uint64_t min_length, uint64_t max_length, + const bt_param_validation_value_descr &element_type) + : type{BT_VALUE_TYPE_ARRAY}, array{min_length, max_length, &element_type} + {} + + bt_param_validation_value_descr(decltype(string_t), + const char **choices = nullptr) + : type{BT_VALUE_TYPE_STRING}, string{choices} + {} + + bt_param_validation_value_descr(decltype(signed_integer_t)) + : type{BT_VALUE_TYPE_SIGNED_INTEGER} + {} + + bt_param_validation_value_descr(decltype(bool_t)) + : type{BT_VALUE_TYPE_BOOL} + {} +#endif + bt_value_type type; /* Additional checks dependent on the type. */ @@ -64,26 +95,45 @@ struct bt_param_validation_value_descr { * `bt_param_validation_error` with the provided context * to set the error string. */ - bt_param_validation_func *validation_func; + bt_param_validation_func *validation_func +#if defined(__cplusplus) + = nullptr +#endif + ; }; #define BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL true #define BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_MANDATORY false struct bt_param_validation_map_value_entry_descr { +#if defined(__cplusplus) + static struct {} end; + + bt_param_validation_map_value_entry_descr(decltype(end)) + : key{nullptr}, + /* These values are not important. */ + is_optional{false}, value_descr(bt_param_validation_value_descr::bool_t) + {} + + bt_param_validation_map_value_entry_descr(const char *key_, bool is_optional_, + bt_param_validation_value_descr value_descr_) + : key(key_), is_optional(is_optional_), value_descr(value_descr_) + {} + +#endif + /* If NULL/nullptr, this entry represents the end of the list. */ const char *key; bool is_optional; - const struct bt_param_validation_value_descr value_descr; }; -BT_HIDDEN +BT_EXTERN_C BT_HIDDEN enum bt_param_validation_status bt_param_validation_validate( const bt_value *params, const struct bt_param_validation_map_value_entry_descr *entries, gchar **error); -BT_HIDDEN __BT_ATTR_FORMAT_PRINTF(2, 3) +BT_EXTERN_C BT_HIDDEN __BT_ATTR_FORMAT_PRINTF(2, 3) enum bt_param_validation_status bt_param_validation_error( struct bt_param_validation_context *ctx, const char *format, ...); diff --git a/src/plugins/ctf/Makefile.am b/src/plugins/ctf/Makefile.am index 24a43401..b5050b8d 100644 --- a/src/plugins/ctf/Makefile.am +++ b/src/plugins/ctf/Makefile.am @@ -9,7 +9,7 @@ plugindir = "$(BABELTRACE_PLUGINS_DIR)" plugin_LTLIBRARIES = babeltrace-plugin-ctf.la # ctf plugin -babeltrace_plugin_ctf_la_SOURCES = plugin.c +babeltrace_plugin_ctf_la_SOURCES = plugin.cpp babeltrace_plugin_ctf_la_LDFLAGS = \ $(AM_LDFLAGS) \ diff --git a/src/plugins/ctf/common/Makefile.am b/src/plugins/ctf/common/Makefile.am index 3f7458bf..78b76fe2 100644 --- a/src/plugins/ctf/common/Makefile.am +++ b/src/plugins/ctf/common/Makefile.am @@ -3,7 +3,7 @@ SUBDIRS = metadata bfcr msg-iter noinst_LTLIBRARIES = libbabeltrace2-plugin-ctf-common.la -libbabeltrace2_plugin_ctf_common_la_SOURCES = print.h +libbabeltrace2_plugin_ctf_common_la_SOURCES = print.hpp libbabeltrace2_plugin_ctf_common_la_LIBADD = \ $(builddir)/metadata/libctf-parser.la \ $(builddir)/metadata/libctf-ast.la \ diff --git a/src/plugins/ctf/common/bfcr/Makefile.am b/src/plugins/ctf/common/bfcr/Makefile.am index e4c2d2e8..17b7705d 100644 --- a/src/plugins/ctf/common/bfcr/Makefile.am +++ b/src/plugins/ctf/common/bfcr/Makefile.am @@ -2,5 +2,5 @@ noinst_LTLIBRARIES = libctf-bfcr.la libctf_bfcr_la_SOURCES = \ - bfcr.c \ - bfcr.h + bfcr.cpp \ + bfcr.hpp diff --git a/src/plugins/ctf/common/bfcr/bfcr.c b/src/plugins/ctf/common/bfcr/bfcr.cpp similarity index 97% rename from src/plugins/ctf/common/bfcr/bfcr.c rename to src/plugins/ctf/common/bfcr/bfcr.cpp index eba591c7..b745dd05 100644 --- a/src/plugins/ctf/common/bfcr/bfcr.c +++ b/src/plugins/ctf/common/bfcr/bfcr.cpp @@ -26,8 +26,8 @@ #include "common/align.h" #include -#include "bfcr.h" -#include "../metadata/ctf-meta.h" +#include "bfcr.hpp" +#include "../metadata/ctf-meta.hpp" #define DIV8(_x) ((_x) >> 3) #define BYTES_TO_BITS(_x) ((_x) * 8) @@ -254,7 +254,7 @@ int64_t get_compound_field_class_length(struct bt_bfcr *bfcr, switch (fc->type) { case CTF_FIELD_CLASS_TYPE_STRUCT: { - struct ctf_field_class_struct *struct_fc = (void *) fc; + ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc); length = (int64_t) struct_fc->members->len; break; @@ -267,7 +267,7 @@ int64_t get_compound_field_class_length(struct bt_bfcr *bfcr, } case CTF_FIELD_CLASS_TYPE_ARRAY: { - struct ctf_field_class_array *array_fc = (void *) fc; + struct ctf_field_class_array *array_fc = ctf_field_class_as_array(fc); length = (int64_t) array_fc->length; break; @@ -544,7 +544,7 @@ enum bt_bfcr_status read_basic_float_and_call_cb(struct bt_bfcr *bfcr, unsigned int field_size; enum ctf_byte_order bo; enum bt_bfcr_status status = BT_BFCR_STATUS_OK; - struct ctf_field_class_float *fc = (void *) bfcr->cur_basic_field_class; + ctf_field_class_float *fc = ctf_field_class_as_float(bfcr->cur_basic_field_class); BT_ASSERT_DBG(fc); field_size = fc->base.size; @@ -606,7 +606,7 @@ enum bt_bfcr_status read_basic_int_and_call_cb(struct bt_bfcr *bfcr, unsigned int field_size; enum ctf_byte_order bo; enum bt_bfcr_status status = BT_BFCR_STATUS_OK; - struct ctf_field_class_int *fc = (void *) bfcr->cur_basic_field_class; + ctf_field_class_int *fc = ctf_field_class_as_int(bfcr->cur_basic_field_class); field_size = fc->base.size; bo = fc->base.byte_order; @@ -664,8 +664,7 @@ enum bt_bfcr_status read_bit_array_class_and_call_continue(struct bt_bfcr *bfcr, size_t available; size_t needed_bits; enum bt_bfcr_status status = BT_BFCR_STATUS_OK; - struct ctf_field_class_bit_array *fc = - (void *) bfcr->cur_basic_field_class; + ctf_field_class_bit_array *fc = ctf_field_class_as_bit_array(bfcr->cur_basic_field_class); if (!at_least_one_bit_left(bfcr)) { BT_COMP_LOGT("Reached end of data: bfcr-addr=%p", bfcr); @@ -719,8 +718,7 @@ enum bt_bfcr_status read_bit_array_class_and_call_begin(struct bt_bfcr *bfcr, { size_t available; enum bt_bfcr_status status = BT_BFCR_STATUS_OK; - struct ctf_field_class_bit_array *fc = - (void *) bfcr->cur_basic_field_class; + ctf_field_class_bit_array *fc = ctf_field_class_as_bit_array(bfcr->cur_basic_field_class); if (!at_least_one_bit_left(bfcr)) { BT_COMP_LOGT("Reached end of data: bfcr-addr=%p", bfcr); @@ -826,7 +824,7 @@ enum bt_bfcr_status read_basic_string_class_and_call( buf_at_bytes = BITS_TO_BYTES_FLOOR(buf_at_from_addr(bfcr)); BT_ASSERT_DBG(bfcr->buf.addr); first_chr = &bfcr->buf.addr[buf_at_bytes]; - result = memchr(first_chr, '\0', available_bytes); + result = (const uint8_t *) memchr(first_chr, '\0', available_bytes); if (begin && bfcr->user.cbs.classes.string_begin) { BT_COMP_LOGT("Calling user function (string, beginning)."); @@ -1068,13 +1066,13 @@ enum bt_bfcr_status next_field_state(struct bt_bfcr *bfcr) switch (top->base_class->type) { case CTF_FIELD_CLASS_TYPE_STRUCT: next_field_class = ctf_field_class_struct_borrow_member_by_index( - (void *) top->base_class, (uint64_t) top->index)->fc; + ctf_field_class_as_struct(top->base_class), (uint64_t) top->index)->fc; break; case CTF_FIELD_CLASS_TYPE_ARRAY: case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_array_base *array_fc = - (void *) top->base_class; + ctf_field_class_array_base *array_fc = + ctf_field_class_as_array_base(top->base_class); next_field_class = array_fc->elem_fc; break; diff --git a/src/plugins/ctf/common/bfcr/bfcr.h b/src/plugins/ctf/common/bfcr/bfcr.hpp similarity index 99% rename from src/plugins/ctf/common/bfcr/bfcr.h rename to src/plugins/ctf/common/bfcr/bfcr.hpp index 8326e310..e94c05b4 100644 --- a/src/plugins/ctf/common/bfcr/bfcr.h +++ b/src/plugins/ctf/common/bfcr/bfcr.hpp @@ -16,7 +16,7 @@ #include #include "common/macros.h" -#include "../metadata/ctf-meta.h" +#include "../metadata/ctf-meta.hpp" /** * @file bfcr.h diff --git a/src/plugins/ctf/common/metadata/Makefile.am b/src/plugins/ctf/common/metadata/Makefile.am index 7fe4ce77..7d843d64 100644 --- a/src/plugins/ctf/common/metadata/Makefile.am +++ b/src/plugins/ctf/common/metadata/Makefile.am @@ -5,51 +5,51 @@ AM_YFLAGS = -t -d -v -Wno-yacc noinst_LTLIBRARIES = libctf-parser.la libctf-ast.la -BUILT_SOURCES = parser.h +BUILT_SOURCES = parser.hpp -libctf_parser_la_SOURCES = lexer.l parser.y objstack.c +libctf_parser_la_SOURCES = lexer.lpp parser.ypp objstack.cpp # scanner-symbols.h is included to prefix generated yy_* symbols # with bt_. libctf_parser_la_CPPFLAGS = $(AM_CPPFLAGS) \ - -include $(srcdir)/scanner-symbols.h + -include $(srcdir)/scanner-symbols.hpp # This library contains (mostly) generated code, silence some warnings that it # produces. -libctf_parser_la_CFLAGS = $(AM_CFLAGS) \ +libctf_parser_la_CXXFLAGS = $(AM_CXXFLAGS) \ -Wno-unused-function \ -Wno-null-dereference libctf_ast_la_SOURCES = \ - visitor-generate-ir.c \ - visitor-semantic-validator.c \ - visitor-parent-links.c \ - ast.h \ - objstack.h \ - parser.h \ - parser-wrap.h \ - scanner.h \ - scanner-symbols.h \ - decoder.c \ - decoder.h \ - decoder-packetized-file-stream-to-buf.c \ - decoder-packetized-file-stream-to-buf.h \ - logging.c \ - logging.h \ - ctf-meta.h \ - ctf-meta-visitors.h \ - ctf-meta-validate.c \ - ctf-meta-update-meanings.c \ - ctf-meta-update-in-ir.c \ - ctf-meta-update-default-clock-classes.c \ - ctf-meta-update-text-array-sequence.c \ - ctf-meta-update-alignments.c \ - ctf-meta-update-value-storing-indexes.c \ - ctf-meta-update-stream-class-config.c \ - ctf-meta-warn-meaningless-header-fields.c \ - ctf-meta-translate.c \ - ctf-meta-resolve.c \ - ctf-meta-configure-ir-trace.c \ - ctf-meta-configure-ir-trace.h + visitor-generate-ir.cpp \ + visitor-semantic-validator.cpp \ + visitor-parent-links.cpp \ + ast.hpp \ + objstack.hpp \ + parser.hpp \ + parser-wrap.hpp \ + scanner.hpp \ + scanner-symbols.hpp \ + decoder.cpp \ + decoder.hpp \ + decoder-packetized-file-stream-to-buf.cpp \ + decoder-packetized-file-stream-to-buf.hpp \ + logging.cpp \ + logging.hpp \ + ctf-meta.hpp \ + ctf-meta-visitors.hpp \ + ctf-meta-validate.cpp \ + ctf-meta-update-meanings.cpp \ + ctf-meta-update-in-ir.cpp \ + ctf-meta-update-default-clock-classes.cpp \ + ctf-meta-update-text-array-sequence.cpp \ + ctf-meta-update-alignments.cpp \ + ctf-meta-update-value-storing-indexes.cpp \ + ctf-meta-update-stream-class-config.cpp \ + ctf-meta-warn-meaningless-header-fields.cpp \ + ctf-meta-translate.cpp \ + ctf-meta-resolve.cpp \ + ctf-meta-configure-ir-trace.cpp \ + ctf-meta-configure-ir-trace.hpp if BABELTRACE_BUILD_WITH_MINGW libctf_ast_la_LIBADD = -lintl -liconv -lole32 @@ -60,32 +60,32 @@ CLEANFILES = if HAVE_BISON # we have bison: we can clean the generated parser files -CLEANFILES += parser.c parser.h parser.output +CLEANFILES += parser.cpp parser.hpp parser.output else # HAVE_BISON # create target used to stop the build if we want to build the parser, # but we don't have the necessary tool to do so ERR_MSG = "Error: Cannot build target because bison is missing." ERR_MSG += "Make sure bison is installed and run the configure script again." -parser.c parser.h: parser.y +parser.cpp parser.hpp: parser.ypp @echo $(ERR_MSG) @false -all-local: parser.c parser.h +all-local: parser.cpp parser.hpp endif # HAVE_BISON if HAVE_FLEX # we have flex: we can clean the generated lexer files -CLEANFILES += lexer.c +CLEANFILES += lexer.cpp else # HAVE_FLEX # create target used to stop the build if we want to build the lexer, # but we don't have the necessary tool to do so ERR_MSG = "Error: Cannot build target because flex is missing." ERR_MSG += "Make sure flex is installed and run the configure script again." -filter-lexer.c: lexer.l +filter-lexer.cpp: lexer.lpp @echo $(ERR_MSG) @false -all-local: lexer.c +all-local: lexer.cpp endif # HAVE_FLEX diff --git a/src/plugins/ctf/common/metadata/ast.h b/src/plugins/ctf/common/metadata/ast.hpp similarity index 90% rename from src/plugins/ctf/common/metadata/ast.h rename to src/plugins/ctf/common/metadata/ast.hpp index afab4093..490e4d29 100644 --- a/src/plugins/ctf/common/metadata/ast.h +++ b/src/plugins/ctf/common/metadata/ast.hpp @@ -15,8 +15,8 @@ #include "common/macros.h" #include "common/assert.h" -#include "decoder.h" -#include "ctf-meta.h" +#include "decoder.hpp" +#include "ctf-meta.hpp" // the parameter name (of the reentrant 'yyparse' function) // data is a pointer to a 'SParserParam' structure @@ -61,7 +61,51 @@ enum node_type { #define ENTRY(S) S, FOREACH_CTF_NODES(ENTRY) #undef ENTRY - NR_NODE_TYPES, +}; + +enum ctf_unary { + UNARY_UNKNOWN = 0, + UNARY_STRING, + UNARY_SIGNED_CONSTANT, + UNARY_UNSIGNED_CONSTANT, + UNARY_SBRAC, +}; + +enum ctf_unary_link { + UNARY_LINK_UNKNOWN = 0, + UNARY_DOTLINK, + UNARY_ARROWLINK, + UNARY_DOTDOTDOT, +}; + +enum ctf_typedec { + TYPEDEC_UNKNOWN = 0, + TYPEDEC_ID, /* identifier */ + TYPEDEC_NESTED, /* (), array or sequence */ +}; + +enum ctf_typespec { + TYPESPEC_UNKNOWN = 0, + TYPESPEC_VOID, + TYPESPEC_CHAR, + TYPESPEC_SHORT, + TYPESPEC_INT, + TYPESPEC_LONG, + TYPESPEC_FLOAT, + TYPESPEC_DOUBLE, + TYPESPEC_SIGNED, + TYPESPEC_UNSIGNED, + TYPESPEC_BOOL, + TYPESPEC_COMPLEX, + TYPESPEC_IMAGINARY, + TYPESPEC_CONST, + TYPESPEC_ID_TYPE, + TYPESPEC_FLOATING_POINT, + TYPESPEC_INTEGER, + TYPESPEC_STRING, + TYPESPEC_STRUCT, + TYPESPEC_VARIANT, + TYPESPEC_ENUM, }; struct ctf_node { @@ -145,13 +189,7 @@ struct ctf_node { struct bt_list_head right; /* Unary exp. or type */ } ctf_expression; struct { - enum { - UNARY_UNKNOWN = 0, - UNARY_STRING, - UNARY_SIGNED_CONSTANT, - UNARY_UNSIGNED_CONSTANT, - UNARY_SBRAC, - } type; + ctf_unary type; union { /* * string for identifier, id_type, keywords, @@ -162,12 +200,7 @@ struct ctf_node { uint64_t unsigned_constant; struct ctf_node *sbrac_exp; } u; - enum { - UNARY_LINK_UNKNOWN = 0, - UNARY_DOTLINK, - UNARY_ARROWLINK, - UNARY_DOTDOTDOT, - } link; + ctf_unary_link link; } unary_expression; struct { struct ctf_node *field_class_specifier_list; @@ -187,29 +220,7 @@ struct ctf_node { struct ctf_node *alias; } field_class_alias; struct { - enum { - TYPESPEC_UNKNOWN = 0, - TYPESPEC_VOID, - TYPESPEC_CHAR, - TYPESPEC_SHORT, - TYPESPEC_INT, - TYPESPEC_LONG, - TYPESPEC_FLOAT, - TYPESPEC_DOUBLE, - TYPESPEC_SIGNED, - TYPESPEC_UNSIGNED, - TYPESPEC_BOOL, - TYPESPEC_COMPLEX, - TYPESPEC_IMAGINARY, - TYPESPEC_CONST, - TYPESPEC_ID_TYPE, - TYPESPEC_FLOATING_POINT, - TYPESPEC_INTEGER, - TYPESPEC_STRING, - TYPESPEC_STRUCT, - TYPESPEC_VARIANT, - TYPESPEC_ENUM, - } type; + ctf_typespec type; /* For struct, variant and enum */ struct ctf_node *node; const char *id_type; @@ -223,11 +234,7 @@ struct ctf_node { } pointer; struct { struct bt_list_head pointers; - enum { - TYPEDEC_UNKNOWN = 0, - TYPEDEC_ID, /* identifier */ - TYPEDEC_NESTED, /* (), array or sequence */ - } type; + ctf_typedec type; union { char *id; struct { diff --git a/src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.c b/src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.cpp similarity index 95% rename from src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.c rename to src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.cpp index 26105750..e8023161 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.cpp @@ -6,7 +6,7 @@ #include -#include "ctf-meta-configure-ir-trace.h" +#include "ctf-meta-configure-ir-trace.hpp" BT_HIDDEN int ctf_trace_class_configure_ir_trace(struct ctf_trace_class *tc, diff --git a/src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.h b/src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.hpp similarity index 93% rename from src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.h rename to src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.hpp index 775b9a0b..09d5ade1 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.h +++ b/src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.hpp @@ -9,7 +9,7 @@ #include "common/macros.h" -#include "ctf-meta.h" +#include "ctf-meta.hpp" BT_HIDDEN int ctf_trace_class_configure_ir_trace(struct ctf_trace_class *tc, diff --git a/src/plugins/ctf/common/metadata/ctf-meta-resolve.c b/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp similarity index 93% rename from src/plugins/ctf/common/metadata/ctf-meta-resolve.c rename to src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp index a8019da2..972ea701 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-resolve.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp @@ -24,10 +24,10 @@ #include #include -#include "ctf-meta-visitors.h" -#include "logging.h" +#include "ctf-meta-visitors.hpp" +#include "logging.hpp" -typedef GPtrArray field_class_stack; +using field_class_stack_t = GPtrArray ; /* * A stack frame. @@ -68,28 +68,28 @@ struct resolve_context { /* Root scope being visited */ enum ctf_scope root_scope; - field_class_stack *field_class_stack; + field_class_stack_t *field_class_stack; struct ctf_field_class *cur_fc; }; /* TSDL dynamic scope prefixes as defined in CTF Section 7.3.2 */ static const char * const absolute_path_prefixes[] = { - [CTF_SCOPE_PACKET_HEADER] = "trace.packet.header.", - [CTF_SCOPE_PACKET_CONTEXT] = "stream.packet.context.", - [CTF_SCOPE_EVENT_HEADER] = "stream.event.header.", - [CTF_SCOPE_EVENT_COMMON_CONTEXT] = "stream.event.context.", - [CTF_SCOPE_EVENT_SPECIFIC_CONTEXT] = "event.context.", - [CTF_SCOPE_EVENT_PAYLOAD] = "event.fields.", + /* CTF_SCOPE_PACKET_HEADER */ "trace.packet.header.", + /* CTF_SCOPE_PACKET_CONTEXT */ "stream.packet.context.", + /* CTF_SCOPE_EVENT_HEADER */ "stream.event.header.", + /* CTF_SCOPE_EVENT_COMMON_CONTEXT */ "stream.event.context.", + /* CTF_SCOPE_EVENT_SPECIFIC_CONTEXT */ "event.context.", + /* CTF_SCOPE_EVENT_PAYLOAD */ "event.fields.", }; /* Number of path tokens used for the absolute prefixes */ static const uint64_t absolute_path_prefix_ptoken_counts[] = { - [CTF_SCOPE_PACKET_HEADER] = 3, - [CTF_SCOPE_PACKET_CONTEXT] = 3, - [CTF_SCOPE_EVENT_HEADER] = 3, - [CTF_SCOPE_EVENT_COMMON_CONTEXT] = 3, - [CTF_SCOPE_EVENT_SPECIFIC_CONTEXT] = 2, - [CTF_SCOPE_EVENT_PAYLOAD] = 2, + /* CTF_SCOPE_PACKET_HEADER */ 3, + /* CTF_SCOPE_PACKET_CONTEXT */ 3, + /* CTF_SCOPE_EVENT_HEADER */ 3, + /* CTF_SCOPE_EVENT_COMMON_CONTEXT */ 3, + /* CTF_SCOPE_EVENT_SPECIFIC_CONTEXT */ 2, + /* CTF_SCOPE_EVENT_PAYLOAD */ 2, }; static @@ -106,7 +106,7 @@ void destroy_field_class_stack_frame(struct field_class_stack_frame *frame) * Creates a class stack. */ static -field_class_stack *field_class_stack_create(void) +field_class_stack_t *field_class_stack_create(void) { return g_ptr_array_new_with_free_func( (GDestroyNotify) destroy_field_class_stack_frame); @@ -116,7 +116,7 @@ field_class_stack *field_class_stack_create(void) * Destroys a class stack. */ static -void field_class_stack_destroy(field_class_stack *stack) +void field_class_stack_destroy(field_class_stack_t *stack) { if (stack) { g_ptr_array_free(stack, TRUE); @@ -127,7 +127,7 @@ void field_class_stack_destroy(field_class_stack *stack) * Pushes a field class onto a class stack. */ static -int field_class_stack_push(field_class_stack *stack, struct ctf_field_class *fc, +int field_class_stack_push(field_class_stack_t *stack, struct ctf_field_class *fc, struct resolve_context *ctx) { int ret = 0; @@ -159,7 +159,7 @@ end: * Checks whether or not `stack` is empty. */ static -bool field_class_stack_empty(field_class_stack *stack) +bool field_class_stack_empty(field_class_stack_t *stack) { return stack->len == 0; } @@ -168,7 +168,7 @@ bool field_class_stack_empty(field_class_stack *stack) * Returns the number of frames in `stack`. */ static -size_t field_class_stack_size(field_class_stack *stack) +size_t field_class_stack_size(field_class_stack_t *stack) { return stack->len; } @@ -177,32 +177,32 @@ size_t field_class_stack_size(field_class_stack *stack) * Returns the top frame of `stack`. */ static -struct field_class_stack_frame *field_class_stack_peek(field_class_stack *stack) +struct field_class_stack_frame *field_class_stack_peek(field_class_stack_t *stack) { BT_ASSERT(stack); BT_ASSERT(!field_class_stack_empty(stack)); - return g_ptr_array_index(stack, stack->len - 1); + return (field_class_stack_frame *) g_ptr_array_index(stack, stack->len - 1); } /* * Returns the frame at index `index` in `stack`. */ static -struct field_class_stack_frame *field_class_stack_at(field_class_stack *stack, +struct field_class_stack_frame *field_class_stack_at(field_class_stack_t *stack, size_t index) { BT_ASSERT(stack); BT_ASSERT(index < stack->len); - return g_ptr_array_index(stack, index); + return (field_class_stack_frame *) g_ptr_array_index(stack, index); } /* * Removes the top frame of `stack`. */ static -void field_class_stack_pop(field_class_stack *stack, +void field_class_stack_pop(field_class_stack_t *stack, struct resolve_context *ctx) { if (!field_class_stack_empty(stack)) { @@ -257,7 +257,7 @@ enum ctf_scope get_root_scope_from_absolute_pathstr(const char *pathstr, sizeof(*absolute_path_prefixes); for (scope = CTF_SCOPE_PACKET_HEADER; scope < CTF_SCOPE_PACKET_HEADER + - prefixes_count; scope++) { + prefixes_count; scope = (ctf_scope) (scope + 1)) { /* * Check if path string starts with a known absolute * path prefix. @@ -292,7 +292,7 @@ end: static void ptokens_destroy_func(gpointer ptoken, gpointer data) { - g_string_free(ptoken, TRUE); + g_string_free((GString *) ptoken, TRUE); } /* @@ -920,7 +920,7 @@ int validate_target_field_path(struct ctf_field_path *target_field_path, break; case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_int *int_fc = (void *) target_fc; + struct ctf_field_class_int *int_fc = ctf_field_class_as_int(target_fc); if (target_fc->type != CTF_FIELD_CLASS_TYPE_INT && target_fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { @@ -969,13 +969,13 @@ int resolve_sequence_or_variant_field_class(struct ctf_field_class *fc, switch (fc->type) { case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_sequence *seq_fc = (void *) fc; + struct ctf_field_class_sequence *seq_fc = ctf_field_class_as_sequence(fc); pathstr = seq_fc->length_ref->str; break; } case CTF_FIELD_CLASS_TYPE_VARIANT: { - struct ctf_field_class_variant *var_fc = (void *) fc; + struct ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc); pathstr = var_fc->tag_ref->str; break; } @@ -1025,21 +1025,21 @@ int resolve_sequence_or_variant_field_class(struct ctf_field_class *fc, switch (fc->type) { case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_sequence *seq_fc = (void *) fc; + ctf_field_class_sequence *seq_fc = ctf_field_class_as_sequence(fc); ctf_field_path_copy_content(&seq_fc->length_path, &target_field_path); - seq_fc->length_fc = (void *) target_fc; + seq_fc->length_fc = ctf_field_class_as_int(target_fc); break; } case CTF_FIELD_CLASS_TYPE_VARIANT: { - struct ctf_field_class_variant *var_fc = (void *) fc; + ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc); ctf_field_path_copy_content(&var_fc->tag_path, &target_field_path); ctf_field_class_variant_set_tag_field_class(var_fc, - (void *) target_fc); + ctf_field_class_as_enum(target_fc)); break; } default: @@ -1153,7 +1153,7 @@ int resolve_root_class(enum ctf_scope root_scope, struct resolve_context *ctx) BT_ASSERT(field_class_stack_size(ctx->field_class_stack) == 0); ctx->root_scope = root_scope; ret = resolve_field_class(borrow_class_from_ctx(ctx, root_scope), ctx); - ctx->root_scope = -1; + ctx->root_scope = CTF_SCOPE_PACKET_UNKNOWN; return ret; } @@ -1237,7 +1237,7 @@ int resolve_stream_class_field_classes(struct resolve_context *ctx, ctx->scopes.event_common_context = sc->event_common_context_fc; for (i = 0; i < sc->event_classes->len; i++) { - struct ctf_event_class *ec = sc->event_classes->pdata[i]; + ctf_event_class *ec = (ctf_event_class *) sc->event_classes->pdata[i]; ret = resolve_event_class_field_classes(ctx, ec); if (ret) { @@ -1262,24 +1262,15 @@ int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc, { int ret = 0; uint64_t i; - struct resolve_context local_ctx = { - .log_level = log_cfg->log_level, - .self_comp = log_cfg->self_comp, - .self_comp_class = log_cfg->self_comp_class, - .tc = tc, - .sc = NULL, - .ec = NULL, - .scopes = { - .packet_header = tc->packet_header_fc, - .packet_context = NULL, - .event_header = NULL, - .event_common_context = NULL, - .event_spec_context = NULL, - .event_payload = NULL, - }, - .root_scope = CTF_SCOPE_PACKET_HEADER, - .cur_fc = NULL, - }; + + resolve_context local_ctx{}; + local_ctx.log_level = log_cfg->log_level; + local_ctx.self_comp = log_cfg->self_comp; + local_ctx.self_comp_class = log_cfg->self_comp_class; + local_ctx.tc = tc; + local_ctx.scopes.packet_header = tc->packet_header_fc; + local_ctx.root_scope = CTF_SCOPE_PACKET_HEADER; + struct resolve_context *ctx = &local_ctx; /* Initialize class stack */ @@ -1303,7 +1294,7 @@ int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc, ctx->scopes.packet_header = tc->packet_header_fc; for (i = 0; i < tc->stream_classes->len; i++) { - struct ctf_stream_class *sc = tc->stream_classes->pdata[i]; + ctf_stream_class *sc = (ctf_stream_class *) tc->stream_classes->pdata[i]; ret = resolve_stream_class_field_classes(ctx, sc); if (ret) { diff --git a/src/plugins/ctf/common/metadata/ctf-meta-translate.c b/src/plugins/ctf/common/metadata/ctf-meta-translate.cpp similarity index 86% rename from src/plugins/ctf/common/metadata/ctf-meta-translate.c rename to src/plugins/ctf/common/metadata/ctf-meta-translate.cpp index 9c9e23ee..0d66dace 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-translate.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-translate.cpp @@ -13,7 +13,7 @@ #include #include -#include "ctf-meta-visitors.h" +#include "ctf-meta-visitors.hpp" struct ctx { bt_self_component *self_comp; @@ -71,22 +71,23 @@ bt_field_class *ctf_field_class_enum_to_ir(struct ctx *ctx, } BT_ASSERT(ir_fc); - ctf_field_class_int_set_props((void *) fc, ir_fc); + ctf_field_class_int_set_props(&fc->base, ir_fc); for (i = 0; i < fc->mappings->len; i++) { struct ctf_field_class_enum_mapping *mapping = ctf_field_class_enum_borrow_mapping_by_index(fc, i); - void *range_set; + bt_integer_range_set_signed *range_set_signed = NULL; + bt_integer_range_set_unsigned *range_set_unsigned = NULL; uint64_t range_i; if (fc->base.is_signed) { - range_set = bt_integer_range_set_signed_create(); + range_set_signed = bt_integer_range_set_signed_create(); + BT_ASSERT(range_set_signed); } else { - range_set = bt_integer_range_set_unsigned_create(); + range_set_unsigned = bt_integer_range_set_unsigned_create(); + BT_ASSERT(range_set_unsigned); } - BT_ASSERT(range_set); - for (range_i = 0; range_i < mapping->ranges->len; range_i++) { struct ctf_range *range = ctf_field_class_enum_mapping_borrow_range_by_index( @@ -94,11 +95,11 @@ bt_field_class *ctf_field_class_enum_to_ir(struct ctx *ctx, if (fc->base.is_signed) { ret = bt_integer_range_set_signed_add_range( - range_set, range->lower.i, + range_set_signed, range->lower.i, range->upper.i); } else { ret = bt_integer_range_set_unsigned_add_range( - range_set, range->lower.u, + range_set_unsigned, range->lower.u, range->upper.u); } @@ -107,12 +108,12 @@ bt_field_class *ctf_field_class_enum_to_ir(struct ctx *ctx, if (fc->base.is_signed) { ret = bt_field_class_enumeration_signed_add_mapping( - ir_fc, mapping->label->str, range_set); - BT_INTEGER_RANGE_SET_SIGNED_PUT_REF_AND_RESET(range_set); + ir_fc, mapping->label->str, range_set_signed); + BT_INTEGER_RANGE_SET_SIGNED_PUT_REF_AND_RESET(range_set_signed); } else { ret = bt_field_class_enumeration_unsigned_add_mapping( - ir_fc, mapping->label->str, range_set); - BT_INTEGER_RANGE_SET_UNSIGNED_PUT_REF_AND_RESET(range_set); + ir_fc, mapping->label->str, range_set_unsigned); + BT_INTEGER_RANGE_SET_UNSIGNED_PUT_REF_AND_RESET(range_set_unsigned); } BT_ASSERT(ret == 0); @@ -204,38 +205,40 @@ bt_field_class *borrow_ir_fc_from_field_path(struct ctx *ctx, } static inline -const void *find_ir_enum_field_class_mapping_by_label(const bt_field_class *fc, - const char *label, bool is_signed) +const bt_field_class_enumeration_mapping *find_ir_enum_field_class_mapping_by_label( + const bt_field_class *fc, const char *label, bool is_signed) { - const void *mapping = NULL; + const bt_field_class_enumeration_mapping *mapping = NULL; uint64_t i; for (i = 0; i < bt_field_class_enumeration_get_mapping_count(fc); i++) { const bt_field_class_enumeration_mapping *this_mapping; - const void *spec_this_mapping; + const bt_field_class_enumeration_signed_mapping *signed_this_mapping = NULL; + const bt_field_class_enumeration_unsigned_mapping *unsigned_this_mapping = NULL; if (is_signed) { - spec_this_mapping = + signed_this_mapping = bt_field_class_enumeration_signed_borrow_mapping_by_index_const( fc, i); + BT_ASSERT(signed_this_mapping); this_mapping = bt_field_class_enumeration_signed_mapping_as_mapping_const( - spec_this_mapping); + signed_this_mapping); } else { - spec_this_mapping = + unsigned_this_mapping = bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const( fc, i); + BT_ASSERT(unsigned_this_mapping); this_mapping = bt_field_class_enumeration_unsigned_mapping_as_mapping_const( - spec_this_mapping); + unsigned_this_mapping); } BT_ASSERT(this_mapping); - BT_ASSERT(spec_this_mapping); if (strcmp(bt_field_class_enumeration_mapping_get_label( this_mapping), label) == 0) { - mapping = spec_this_mapping; + mapping = this_mapping; goto end; } } @@ -285,9 +288,10 @@ bt_field_class *ctf_field_class_variant_to_ir(struct ctx *ctx, */ if (fc->tag_fc->base.is_signed) { const bt_field_class_enumeration_signed_mapping *mapping = - find_ir_enum_field_class_mapping_by_label( - ir_tag_fc, - named_fc->orig_name->str, true); + (bt_field_class_enumeration_signed_mapping *) + find_ir_enum_field_class_mapping_by_label( + ir_tag_fc, + named_fc->orig_name->str, true); const bt_integer_range_set_signed *range_set; BT_ASSERT(mapping); @@ -300,10 +304,11 @@ bt_field_class *ctf_field_class_variant_to_ir(struct ctx *ctx, option_ir_fc, range_set); } else { const bt_field_class_enumeration_unsigned_mapping *mapping = - find_ir_enum_field_class_mapping_by_label( - ir_tag_fc, - named_fc->orig_name->str, - false); + (bt_field_class_enumeration_unsigned_mapping *) + find_ir_enum_field_class_mapping_by_label( + ir_tag_fc, + named_fc->orig_name->str, + false); const bt_integer_range_set_unsigned *range_set; BT_ASSERT(mapping); @@ -395,28 +400,28 @@ bt_field_class *ctf_field_class_to_ir(struct ctx *ctx, switch (fc->type) { case CTF_FIELD_CLASS_TYPE_INT: - ir_fc = ctf_field_class_int_to_ir(ctx, (void *) fc); + ir_fc = ctf_field_class_int_to_ir(ctx, ctf_field_class_as_int(fc)); break; case CTF_FIELD_CLASS_TYPE_ENUM: - ir_fc = ctf_field_class_enum_to_ir(ctx, (void *) fc); + ir_fc = ctf_field_class_enum_to_ir(ctx, ctf_field_class_as_enum(fc)); break; case CTF_FIELD_CLASS_TYPE_FLOAT: - ir_fc = ctf_field_class_float_to_ir(ctx, (void *) fc); + ir_fc = ctf_field_class_float_to_ir(ctx, ctf_field_class_as_float(fc)); break; case CTF_FIELD_CLASS_TYPE_STRING: - ir_fc = ctf_field_class_string_to_ir(ctx, (void *) fc); + ir_fc = ctf_field_class_string_to_ir(ctx, ctf_field_class_as_string(fc)); break; case CTF_FIELD_CLASS_TYPE_STRUCT: - ir_fc = ctf_field_class_struct_to_ir(ctx, (void *) fc); + ir_fc = ctf_field_class_struct_to_ir(ctx, ctf_field_class_as_struct(fc)); break; case CTF_FIELD_CLASS_TYPE_ARRAY: - ir_fc = ctf_field_class_array_to_ir(ctx, (void *) fc); + ir_fc = ctf_field_class_array_to_ir(ctx, ctf_field_class_as_array(fc)); break; case CTF_FIELD_CLASS_TYPE_SEQUENCE: - ir_fc = ctf_field_class_sequence_to_ir(ctx, (void *) fc); + ir_fc = ctf_field_class_sequence_to_ir(ctx, ctf_field_class_as_sequence(fc)); break; case CTF_FIELD_CLASS_TYPE_VARIANT: - ir_fc = ctf_field_class_variant_to_ir(ctx, (void *) fc); + ir_fc = ctf_field_class_variant_to_ir(ctx, ctf_field_class_as_variant(fc)); break; default: bt_common_abort(); @@ -481,7 +486,7 @@ bt_field_class *scope_ctf_field_class_to_ir(struct ctx *ctx) } if (fc && ctf_field_class_struct_has_immediate_member_in_ir( - (void *) fc)) { + ctf_field_class_as_struct(fc))) { ir_fc = ctf_field_class_to_ir(ctx, fc); } @@ -650,7 +655,7 @@ int ctf_trace_class_to_ir(struct ctx *ctx) } for (i = 0; i < ctx->tc->clock_classes->len; i++) { - struct ctf_clock_class *cc = ctx->tc->clock_classes->pdata[i]; + ctf_clock_class *cc = (ctf_clock_class *) ctx->tc->clock_classes->pdata[i]; cc->ir_cc = bt_clock_class_create(ctx->self_comp); ctf_clock_class_to_ir(cc->ir_cc, cc); @@ -683,12 +688,12 @@ int ctf_trace_class_translate(bt_self_component *self_comp, for (i = 0; i < tc->stream_classes->len; i++) { uint64_t j; - ctx.sc = tc->stream_classes->pdata[i]; + ctx.sc = (ctf_stream_class *) tc->stream_classes->pdata[i]; ctf_stream_class_to_ir(&ctx); for (j = 0; j < ctx.sc->event_classes->len; j++) { - ctx.ec = ctx.sc->event_classes->pdata[j]; + ctx.ec = (ctf_event_class *) ctx.sc->event_classes->pdata[j]; ctf_event_class_to_ir(&ctx); ctx.ec = NULL; diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-alignments.c b/src/plugins/ctf/common/metadata/ctf-meta-update-alignments.cpp similarity index 88% rename from src/plugins/ctf/common/metadata/ctf-meta-update-alignments.c rename to src/plugins/ctf/common/metadata/ctf-meta-update-alignments.cpp index 8cea669a..6e93b671 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-alignments.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-alignments.cpp @@ -12,7 +12,7 @@ #include #include -#include "ctf-meta-visitors.h" +#include "ctf-meta-visitors.hpp" static inline int set_alignments(struct ctf_field_class *fc) @@ -27,7 +27,7 @@ int set_alignments(struct ctf_field_class *fc) switch (fc->type) { case CTF_FIELD_CLASS_TYPE_STRUCT: { - struct ctf_field_class_struct *struct_fc = (void *) fc; + struct ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc); for (i = 0; i < struct_fc->members->len; i++) { struct ctf_named_field_class *named_fc = @@ -48,7 +48,7 @@ int set_alignments(struct ctf_field_class *fc) } case CTF_FIELD_CLASS_TYPE_VARIANT: { - struct ctf_field_class_variant *var_fc = (void *) fc; + struct ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc); for (i = 0; i < var_fc->options->len; i++) { struct ctf_named_field_class *named_fc = @@ -66,7 +66,7 @@ int set_alignments(struct ctf_field_class *fc) case CTF_FIELD_CLASS_TYPE_ARRAY: case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_array_base *array_fc = (void *) fc; + struct ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc); ret = set_alignments(array_fc->elem_fc); if (ret) { @@ -128,7 +128,7 @@ int ctf_trace_class_update_alignments( } for (i = 0; i < ctf_tc->stream_classes->len; i++) { - struct ctf_stream_class *sc = ctf_tc->stream_classes->pdata[i]; + ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i]; uint64_t j; if (!sc->is_translated) { @@ -150,7 +150,7 @@ int ctf_trace_class_update_alignments( for (j = 0; j < sc->event_classes->len; j++) { struct ctf_event_class *ec = - sc->event_classes->pdata[j]; + (ctf_event_class *) sc->event_classes->pdata[j]; if (ec->is_translated) { continue; diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c b/src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.cpp similarity index 87% rename from src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c rename to src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.cpp index f6c19b1a..d40adda3 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.cpp @@ -18,8 +18,8 @@ #include #include -#include "ctf-meta-visitors.h" -#include "logging.h" +#include "ctf-meta-visitors.hpp" +#include "logging.hpp" static inline int find_mapped_clock_class(struct ctf_field_class *fc, @@ -37,7 +37,7 @@ int find_mapped_clock_class(struct ctf_field_class *fc, case CTF_FIELD_CLASS_TYPE_INT: case CTF_FIELD_CLASS_TYPE_ENUM: { - struct ctf_field_class_int *int_fc = (void *) fc; + struct ctf_field_class_int *int_fc = ctf_field_class_as_int(fc); if (int_fc->mapped_clock_class) { if (*clock_class && *clock_class != @@ -58,7 +58,7 @@ int find_mapped_clock_class(struct ctf_field_class *fc, } case CTF_FIELD_CLASS_TYPE_STRUCT: { - struct ctf_field_class_struct *struct_fc = (void *) fc; + struct ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc); for (i = 0; i < struct_fc->members->len; i++) { struct ctf_named_field_class *named_fc = @@ -76,7 +76,7 @@ int find_mapped_clock_class(struct ctf_field_class *fc, } case CTF_FIELD_CLASS_TYPE_VARIANT: { - struct ctf_field_class_variant *var_fc = (void *) fc; + struct ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc); for (i = 0; i < var_fc->options->len; i++) { struct ctf_named_field_class *named_fc = @@ -95,7 +95,7 @@ int find_mapped_clock_class(struct ctf_field_class *fc, case CTF_FIELD_CLASS_TYPE_ARRAY: case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_array_base *array_fc = (void *) fc; + struct ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc); ret = find_mapped_clock_class(array_fc->elem_fc, clock_class, log_cfg); @@ -143,7 +143,7 @@ int update_stream_class_default_clock_class( for (i = 0; i < stream_class->event_classes->len; i++) { struct ctf_event_class *event_class = - stream_class->event_classes->pdata[i]; + (ctf_event_class *) stream_class->event_classes->pdata[i]; ret = find_mapped_clock_class(event_class->spec_context_fc, &clock_class, log_cfg); @@ -187,10 +187,10 @@ int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc, for (i = 0; i < ctf_tc->stream_classes->len; i++) { struct ctf_stream_class *sc = - ctf_tc->stream_classes->pdata[i]; + (ctf_stream_class *) ctf_tc->stream_classes->pdata[i]; ret = update_stream_class_default_clock_class( - ctf_tc->stream_classes->pdata[i], log_cfg); + (ctf_stream_class *) ctf_tc->stream_classes->pdata[i], log_cfg); if (ret) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Stream class contains more than one " "clock class: stream-class-id=%" PRIu64, diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c b/src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.cpp similarity index 87% rename from src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c rename to src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.cpp index ffd09259..765f38c5 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.cpp @@ -15,7 +15,7 @@ #include #include "common/assert.h" -#include "ctf-meta-visitors.h" +#include "ctf-meta-visitors.hpp" static void force_update_field_class_in_ir(struct ctf_field_class *fc, bool in_ir) @@ -31,7 +31,7 @@ void force_update_field_class_in_ir(struct ctf_field_class *fc, bool in_ir) switch (fc->type) { case CTF_FIELD_CLASS_TYPE_STRUCT: { - struct ctf_field_class_struct *struct_fc = (void *) fc; + struct ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc); for (i = 0; i < struct_fc->members->len; i++) { struct ctf_named_field_class *named_fc = @@ -46,7 +46,7 @@ void force_update_field_class_in_ir(struct ctf_field_class *fc, bool in_ir) case CTF_FIELD_CLASS_TYPE_VARIANT: { struct ctf_named_field_class *named_fc; - struct ctf_field_class_variant *var_fc = (void *) fc; + struct ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc); for (i = 0; i < var_fc->options->len; i++) { named_fc = @@ -61,7 +61,7 @@ void force_update_field_class_in_ir(struct ctf_field_class *fc, bool in_ir) case CTF_FIELD_CLASS_TYPE_ARRAY: case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_array_base *array_fc = (void *) fc; + struct ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc); force_update_field_class_in_ir(array_fc->elem_fc, in_ir); break; @@ -88,7 +88,7 @@ void update_field_class_in_ir(struct ctf_field_class *fc, case CTF_FIELD_CLASS_TYPE_INT: case CTF_FIELD_CLASS_TYPE_ENUM: { - struct ctf_field_class_int *int_fc = (void *) fc; + struct ctf_field_class_int *int_fc = ctf_field_class_as_int(fc); /* * Conditions to be in trace IR; one of: @@ -107,7 +107,7 @@ void update_field_class_in_ir(struct ctf_field_class *fc, } case CTF_FIELD_CLASS_TYPE_STRUCT: { - struct ctf_field_class_struct *struct_fc = (void *) fc; + struct ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc); /* * Make it part of IR if it's empty because it was @@ -136,7 +136,7 @@ void update_field_class_in_ir(struct ctf_field_class *fc, case CTF_FIELD_CLASS_TYPE_VARIANT: { struct ctf_named_field_class *named_fc; - struct ctf_field_class_variant *var_fc = (void *) fc; + struct ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc); /* * Reverse order, although it is not important for this @@ -186,13 +186,13 @@ void update_field_class_in_ir(struct ctf_field_class *fc, case CTF_FIELD_CLASS_TYPE_ARRAY: case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_array_base *array_fc = (void *) fc; + struct ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc); update_field_class_in_ir(array_fc->elem_fc, ft_dependents); fc->in_ir = array_fc->elem_fc->in_ir; if (fc->type == CTF_FIELD_CLASS_TYPE_ARRAY) { - struct ctf_field_class_array *arr_fc = (void *) fc; + struct ctf_field_class_array *arr_fc = ctf_field_class_as_array(fc); assert(arr_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE || arr_fc->meaning == CTF_FIELD_CLASS_MEANING_UUID); @@ -207,7 +207,7 @@ void update_field_class_in_ir(struct ctf_field_class *fc, } } else if (fc->type == CTF_FIELD_CLASS_TYPE_SEQUENCE) { if (fc->in_ir) { - struct ctf_field_class_sequence *seq_fc = (void *) fc; + struct ctf_field_class_sequence *seq_fc = ctf_field_class_as_sequence(fc); /* * This sequence field class is part of @@ -248,11 +248,11 @@ int ctf_trace_class_update_in_ir(struct ctf_trace_class *ctf_tc) BT_ASSERT(ft_dependents); for (i = 0; i < ctf_tc->stream_classes->len; i++) { - struct ctf_stream_class *sc = ctf_tc->stream_classes->pdata[i]; + ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i]; uint64_t j; for (j = 0; j < sc->event_classes->len; j++) { - struct ctf_event_class *ec = sc->event_classes->pdata[j]; + ctf_event_class *ec = (ctf_event_class *) sc->event_classes->pdata[j]; if (ec->is_translated) { continue; diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-meanings.c b/src/plugins/ctf/common/metadata/ctf-meta-update-meanings.cpp similarity index 78% rename from src/plugins/ctf/common/metadata/ctf-meta-update-meanings.c rename to src/plugins/ctf/common/metadata/ctf-meta-update-meanings.cpp index 838c9ebb..4e8d6471 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-meanings.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-meanings.cpp @@ -12,7 +12,7 @@ #include #include -#include "ctf-meta-visitors.h" +#include "ctf-meta-visitors.hpp" static int set_int_field_class_meaning_by_name(struct ctf_field_class *fc, @@ -30,7 +30,7 @@ int set_int_field_class_meaning_by_name(struct ctf_field_class *fc, case CTF_FIELD_CLASS_TYPE_INT: case CTF_FIELD_CLASS_TYPE_ENUM: { - struct ctf_field_class_int *int_fc = (void *) fc; + struct ctf_field_class_int *int_fc = ctf_field_class_as_int(fc); if (field_name && strcmp(field_name, id_name) == 0) { int_fc->meaning = meaning; @@ -40,7 +40,7 @@ int set_int_field_class_meaning_by_name(struct ctf_field_class *fc, } case CTF_FIELD_CLASS_TYPE_STRUCT: { - struct ctf_field_class_struct *struct_fc = (void *) fc; + struct ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc); for (i = 0; i < struct_fc->members->len; i++) { struct ctf_named_field_class *named_fc = @@ -58,7 +58,7 @@ int set_int_field_class_meaning_by_name(struct ctf_field_class *fc, } case CTF_FIELD_CLASS_TYPE_VARIANT: { - struct ctf_field_class_variant *var_fc = (void *) fc; + struct ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc); for (i = 0; i < var_fc->options->len; i++) { struct ctf_named_field_class *named_fc = @@ -77,7 +77,7 @@ int set_int_field_class_meaning_by_name(struct ctf_field_class *fc, case CTF_FIELD_CLASS_TYPE_ARRAY: case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_array_base *array_fc = (void *) fc; + struct ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc); ret = set_int_field_class_meaning_by_name(array_fc->elem_fc, NULL, id_name, meaning); @@ -105,13 +105,13 @@ int update_stream_class_meanings(struct ctf_stream_class *sc) if (!sc->is_translated) { if (sc->packet_context_fc) { int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) sc->packet_context_fc, "timestamp_begin"); + ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_begin"); if (int_fc) { int_fc->meaning = CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME; } int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) sc->packet_context_fc, "timestamp_end"); + ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_end"); if (int_fc) { int_fc->meaning = CTF_FIELD_CLASS_MEANING_PACKET_END_TIME; @@ -123,26 +123,26 @@ int update_stream_class_meanings(struct ctf_stream_class *sc) } int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) sc->packet_context_fc, "events_discarded"); + ctf_field_class_as_struct(sc->packet_context_fc), "events_discarded"); if (int_fc) { int_fc->meaning = CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT; } int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) sc->packet_context_fc, "packet_seq_num"); + ctf_field_class_as_struct(sc->packet_context_fc), "packet_seq_num"); if (int_fc) { int_fc->meaning = CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT; } int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) sc->packet_context_fc, "packet_size"); + ctf_field_class_as_struct(sc->packet_context_fc), "packet_size"); if (int_fc) { int_fc->meaning = CTF_FIELD_CLASS_MEANING_EXP_PACKET_TOTAL_SIZE; } int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) sc->packet_context_fc, "content_size"); + ctf_field_class_as_struct(sc->packet_context_fc), "content_size"); if (int_fc) { int_fc->meaning = CTF_FIELD_CLASS_MEANING_EXP_PACKET_CONTENT_SIZE; } @@ -159,7 +159,7 @@ int update_stream_class_meanings(struct ctf_stream_class *sc) } for (i = 0; i < sc->event_classes->len; i++) { - struct ctf_event_class *ec = sc->event_classes->pdata[i]; + struct ctf_event_class *ec = (ctf_event_class *) sc->event_classes->pdata[i]; if (ec->is_translated) { continue; @@ -180,29 +180,29 @@ int ctf_trace_class_update_meanings(struct ctf_trace_class *ctf_tc) if (!ctf_tc->is_translated && ctf_tc->packet_header_fc) { int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) ctf_tc->packet_header_fc, "magic"); + ctf_field_class_as_struct(ctf_tc->packet_header_fc), "magic"); if (int_fc) { int_fc->meaning = CTF_FIELD_CLASS_MEANING_MAGIC; } int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) ctf_tc->packet_header_fc, "stream_id"); + ctf_field_class_as_struct(ctf_tc->packet_header_fc), "stream_id"); if (int_fc) { int_fc->meaning = CTF_FIELD_CLASS_MEANING_STREAM_CLASS_ID; } int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) ctf_tc->packet_header_fc, + ctf_field_class_as_struct(ctf_tc->packet_header_fc), "stream_instance_id"); if (int_fc) { int_fc->meaning = CTF_FIELD_CLASS_MEANING_DATA_STREAM_ID; } named_fc = ctf_field_class_struct_borrow_member_by_name( - (void *) ctf_tc->packet_header_fc, "uuid"); + ctf_field_class_as_struct(ctf_tc->packet_header_fc), "uuid"); if (named_fc && named_fc->fc->type == CTF_FIELD_CLASS_TYPE_ARRAY) { struct ctf_field_class_array *array_fc = - (void *) named_fc->fc; + ctf_field_class_as_array(named_fc->fc); array_fc->meaning = CTF_FIELD_CLASS_MEANING_UUID; } @@ -210,7 +210,7 @@ int ctf_trace_class_update_meanings(struct ctf_trace_class *ctf_tc) for (i = 0; i < ctf_tc->stream_classes->len; i++) { ret = update_stream_class_meanings( - ctf_tc->stream_classes->pdata[i]); + (ctf_stream_class *) ctf_tc->stream_classes->pdata[i]); if (ret) { goto end; } diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.c b/src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.cpp similarity index 81% rename from src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.c rename to src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.cpp index ae88a87f..b3e0d6e0 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.cpp @@ -12,7 +12,7 @@ #include #include -#include "ctf-meta-visitors.h" +#include "ctf-meta-visitors.hpp" BT_HIDDEN int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc) @@ -22,7 +22,7 @@ int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc) for (i = 0; i < ctf_tc->stream_classes->len; i++) { struct ctf_stream_class *sc = - ctf_tc->stream_classes->pdata[i]; + (ctf_stream_class *) ctf_tc->stream_classes->pdata[i]; if (sc->is_translated) { continue; @@ -33,21 +33,21 @@ int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc) } int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) sc->packet_context_fc, "timestamp_begin"); + ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_begin"); if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME) { sc->packets_have_ts_begin = true; } int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) sc->packet_context_fc, "timestamp_end"); + ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_end"); if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_END_TIME) { sc->packets_have_ts_end = true; } int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) sc->packet_context_fc, "events_discarded"); + ctf_field_class_as_struct(sc->packet_context_fc), "events_discarded"); if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT) { sc->has_discarded_events = true; @@ -57,7 +57,7 @@ int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc) sc->has_discarded_events && sc->packets_have_ts_begin && sc->packets_have_ts_end; int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( - (void *) sc->packet_context_fc, "packet_seq_num"); + ctf_field_class_as_struct(sc->packet_context_fc), "packet_seq_num"); if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT) { sc->has_discarded_packets = true; diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.c b/src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.cpp similarity index 86% rename from src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.c rename to src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.cpp index 2830caa9..186b98a6 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.cpp @@ -12,7 +12,7 @@ #include #include -#include "ctf-meta-visitors.h" +#include "ctf-meta-visitors.hpp" static inline int set_text_array_sequence_field_class(struct ctf_field_class *fc) @@ -27,7 +27,7 @@ int set_text_array_sequence_field_class(struct ctf_field_class *fc) switch (fc->type) { case CTF_FIELD_CLASS_TYPE_STRUCT: { - struct ctf_field_class_struct *struct_fc = (void *) fc; + struct ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc); for (i = 0; i < struct_fc->members->len; i++) { struct ctf_named_field_class *named_fc = @@ -44,7 +44,7 @@ int set_text_array_sequence_field_class(struct ctf_field_class *fc) } case CTF_FIELD_CLASS_TYPE_VARIANT: { - struct ctf_field_class_variant *var_fc = (void *) fc; + struct ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc); for (i = 0; i < var_fc->options->len; i++) { struct ctf_named_field_class *named_fc = @@ -62,12 +62,12 @@ int set_text_array_sequence_field_class(struct ctf_field_class *fc) case CTF_FIELD_CLASS_TYPE_ARRAY: case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_array_base *array_fc = (void *) fc; + struct ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc); if (array_fc->elem_fc->type == CTF_FIELD_CLASS_TYPE_INT || array_fc->elem_fc->type == CTF_FIELD_CLASS_TYPE_ENUM) { struct ctf_field_class_int *int_fc = - (void *) array_fc->elem_fc; + ctf_field_class_as_int(array_fc->elem_fc); if (int_fc->base.base.alignment == 8 && int_fc->base.size == 8 && @@ -115,7 +115,7 @@ int ctf_trace_class_update_text_array_sequence(struct ctf_trace_class *ctf_tc) } for (i = 0; i < ctf_tc->stream_classes->len; i++) { - struct ctf_stream_class *sc = ctf_tc->stream_classes->pdata[i]; + ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i]; uint64_t j; if (!sc->is_translated) { @@ -140,7 +140,7 @@ int ctf_trace_class_update_text_array_sequence(struct ctf_trace_class *ctf_tc) for (j = 0; j < sc->event_classes->len; j++) { struct ctf_event_class *ec = - sc->event_classes->pdata[j]; + (ctf_event_class *) sc->event_classes->pdata[j]; if (ec->is_translated) { continue; diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.c b/src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.cpp similarity index 85% rename from src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.c rename to src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.cpp index dd9dfff1..794c5422 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.cpp @@ -12,7 +12,7 @@ #include #include -#include "ctf-meta-visitors.h" +#include "ctf-meta-visitors.hpp" static int update_field_class_stored_value_index(struct ctf_field_class *fc, @@ -33,16 +33,16 @@ int update_field_class_stored_value_index(struct ctf_field_class *fc, switch (fc->type) { case CTF_FIELD_CLASS_TYPE_VARIANT: { - struct ctf_field_class_variant *var_fc = (void *) fc; + ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc); field_path = &var_fc->tag_path; stored_value_index = &var_fc->stored_tag_index; - tgt_fc = (void *) var_fc->tag_fc; + tgt_fc = &var_fc->tag_fc->base; break; } case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_sequence *seq_fc = (void *) fc; + struct ctf_field_class_sequence *seq_fc = ctf_field_class_as_sequence(fc); field_path = &seq_fc->length_path; stored_value_index = &seq_fc->stored_length_index; @@ -71,7 +71,7 @@ int update_field_class_stored_value_index(struct ctf_field_class *fc, switch (fc->type) { case CTF_FIELD_CLASS_TYPE_STRUCT: { - struct ctf_field_class_struct *struct_fc = (void *) fc; + struct ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc); for (i = 0; i < struct_fc->members->len; i++) { struct ctf_named_field_class *named_fc = @@ -89,7 +89,7 @@ int update_field_class_stored_value_index(struct ctf_field_class *fc, } case CTF_FIELD_CLASS_TYPE_VARIANT: { - struct ctf_field_class_variant *var_fc = (void *) fc; + struct ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc); for (i = 0; i < var_fc->options->len; i++) { struct ctf_named_field_class *named_fc = @@ -108,7 +108,7 @@ int update_field_class_stored_value_index(struct ctf_field_class *fc, case CTF_FIELD_CLASS_TYPE_ARRAY: case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_array_base *array_fc = (void *) fc; + struct ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc); ret = update_field_class_stored_value_index(array_fc->elem_fc, tc, sc, ec); @@ -138,7 +138,7 @@ int ctf_trace_class_update_value_storing_indexes(struct ctf_trace_class *ctf_tc) for (i = 0; i < ctf_tc->stream_classes->len; i++) { uint64_t j; - struct ctf_stream_class *sc = ctf_tc->stream_classes->pdata[i]; + ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i]; if (!sc->is_translated) { update_field_class_stored_value_index(sc->packet_context_fc, @@ -151,7 +151,7 @@ int ctf_trace_class_update_value_storing_indexes(struct ctf_trace_class *ctf_tc) for (j = 0; j < sc->event_classes->len; j++) { struct ctf_event_class *ec = - sc->event_classes->pdata[j]; + (ctf_event_class *) sc->event_classes->pdata[j]; if (!ec->is_translated) { update_field_class_stored_value_index( diff --git a/src/plugins/ctf/common/metadata/ctf-meta-validate.c b/src/plugins/ctf/common/metadata/ctf-meta-validate.cpp similarity index 86% rename from src/plugins/ctf/common/metadata/ctf-meta-validate.c rename to src/plugins/ctf/common/metadata/ctf-meta-validate.cpp index da5c95c2..d28a5fe8 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-validate.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-validate.cpp @@ -18,8 +18,8 @@ #include #include -#include "ctf-meta-visitors.h" -#include "logging.h" +#include "ctf-meta-visitors.hpp" +#include "logging.hpp" static int validate_stream_class(struct ctf_stream_class *sc, @@ -34,7 +34,7 @@ int validate_stream_class(struct ctf_stream_class *sc, } fc = ctf_field_class_struct_borrow_member_field_class_by_name( - (void *) sc->packet_context_fc, "timestamp_begin"); + ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_begin"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { @@ -43,7 +43,7 @@ int validate_stream_class(struct ctf_stream_class *sc, goto invalid; } - int_fc = (void *) fc; + int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: " @@ -53,7 +53,7 @@ int validate_stream_class(struct ctf_stream_class *sc, } fc = ctf_field_class_struct_borrow_member_field_class_by_name( - (void *) sc->packet_context_fc, "timestamp_end"); + ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_end"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { @@ -62,7 +62,7 @@ int validate_stream_class(struct ctf_stream_class *sc, goto invalid; } - int_fc = (void *) fc; + int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: " @@ -72,7 +72,7 @@ int validate_stream_class(struct ctf_stream_class *sc, } fc = ctf_field_class_struct_borrow_member_field_class_by_name( - (void *) sc->packet_context_fc, "events_discarded"); + ctf_field_class_as_struct(sc->packet_context_fc), "events_discarded"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { @@ -81,7 +81,7 @@ int validate_stream_class(struct ctf_stream_class *sc, goto invalid; } - int_fc = (void *) fc; + int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: " @@ -91,7 +91,7 @@ int validate_stream_class(struct ctf_stream_class *sc, } fc = ctf_field_class_struct_borrow_member_field_class_by_name( - (void *) sc->packet_context_fc, "packet_seq_num"); + ctf_field_class_as_struct(sc->packet_context_fc), "packet_seq_num"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { @@ -100,7 +100,7 @@ int validate_stream_class(struct ctf_stream_class *sc, goto invalid; } - int_fc = (void *) fc; + int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: " @@ -110,7 +110,7 @@ int validate_stream_class(struct ctf_stream_class *sc, } fc = ctf_field_class_struct_borrow_member_field_class_by_name( - (void *) sc->packet_context_fc, "packet_size"); + ctf_field_class_as_struct(sc->packet_context_fc), "packet_size"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { @@ -119,7 +119,7 @@ int validate_stream_class(struct ctf_stream_class *sc, goto invalid; } - int_fc = (void *) fc; + int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: " @@ -129,7 +129,7 @@ int validate_stream_class(struct ctf_stream_class *sc, } fc = ctf_field_class_struct_borrow_member_field_class_by_name( - (void *) sc->packet_context_fc, "content_size"); + ctf_field_class_as_struct(sc->packet_context_fc), "content_size"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { @@ -138,7 +138,7 @@ int validate_stream_class(struct ctf_stream_class *sc, goto invalid; } - int_fc = (void *) fc; + int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: " @@ -148,7 +148,7 @@ int validate_stream_class(struct ctf_stream_class *sc, } fc = ctf_field_class_struct_borrow_member_field_class_by_name( - (void *) sc->event_header_fc, "id"); + ctf_field_class_as_struct(sc->event_header_fc), "id"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { @@ -157,7 +157,7 @@ int validate_stream_class(struct ctf_stream_class *sc, goto invalid; } - int_fc = (void *) fc; + int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid event header field class: " @@ -194,11 +194,11 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, struct ctf_field_class *fc; fc = ctf_field_class_struct_borrow_member_field_class_by_name( - (void *) ctf_tc->packet_header_fc, "magic"); + ctf_field_class_as_struct(ctf_tc->packet_header_fc), "magic"); if (fc) { struct ctf_named_field_class *named_fc = ctf_field_class_struct_borrow_member_by_index( - (void *) ctf_tc->packet_header_fc, + ctf_field_class_as_struct(ctf_tc->packet_header_fc), 0); if (named_fc->fc != fc) { @@ -214,7 +214,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, goto invalid; } - int_fc = (void *) fc; + int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: " @@ -230,7 +230,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, } fc = ctf_field_class_struct_borrow_member_field_class_by_name( - (void *) ctf_tc->packet_header_fc, "stream_id"); + ctf_field_class_as_struct(ctf_tc->packet_header_fc), "stream_id"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { @@ -239,7 +239,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, goto invalid; } - int_fc = (void *) fc; + int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: " @@ -256,7 +256,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, } fc = ctf_field_class_struct_borrow_member_field_class_by_name( - (void *) ctf_tc->packet_header_fc, + ctf_field_class_as_struct(ctf_tc->packet_header_fc), "stream_instance_id"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && @@ -266,7 +266,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, goto invalid; } - int_fc = (void *) fc; + int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: " @@ -276,17 +276,15 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, } fc = ctf_field_class_struct_borrow_member_field_class_by_name( - (void *) ctf_tc->packet_header_fc, "uuid"); + ctf_field_class_as_struct(ctf_tc->packet_header_fc), "uuid"); if (fc) { - struct ctf_field_class_array *array_fc = (void *) fc; - if (fc->type != CTF_FIELD_CLASS_TYPE_ARRAY) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: " "`uuid` member is not an array field class."); goto invalid; } - array_fc = (void *) fc; + ctf_field_class_array *array_fc = ctf_field_class_as_array(fc); if (array_fc->length != 16) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: " @@ -301,7 +299,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, goto invalid; } - int_fc = (void *) array_fc->base.elem_fc; + int_fc = ctf_field_class_as_int(array_fc->base.elem_fc); if (int_fc->is_signed) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: " @@ -328,7 +326,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, for (i = 0; i < ctf_tc->stream_classes->len; i++) { struct ctf_stream_class *sc = - ctf_tc->stream_classes->pdata[i]; + (ctf_stream_class *) ctf_tc->stream_classes->pdata[i]; ret = validate_stream_class(sc, log_cfg); if (ret) { diff --git a/src/plugins/ctf/common/metadata/ctf-meta-visitors.h b/src/plugins/ctf/common/metadata/ctf-meta-visitors.hpp similarity index 98% rename from src/plugins/ctf/common/metadata/ctf-meta-visitors.h rename to src/plugins/ctf/common/metadata/ctf-meta-visitors.hpp index 34edb37e..ab227517 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-visitors.h +++ b/src/plugins/ctf/common/metadata/ctf-meta-visitors.hpp @@ -10,7 +10,7 @@ #include #include "common/macros.h" -#include "ctf-meta.h" +#include "ctf-meta.hpp" struct meta_log_config; diff --git a/src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c b/src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.cpp similarity index 84% rename from src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c rename to src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.cpp index d768f97c..03daddf9 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.cpp @@ -17,8 +17,8 @@ #include #include -#include "ctf-meta-visitors.h" -#include "logging.h" +#include "ctf-meta-visitors.hpp" +#include "logging.hpp" static inline void warn_meaningless_field(const char *name, const char *scope_name, @@ -52,7 +52,7 @@ void warn_meaningless_fields(struct ctf_field_class *fc, const char *name, case CTF_FIELD_CLASS_TYPE_INT: case CTF_FIELD_CLASS_TYPE_ENUM: { - struct ctf_field_class_int *int_fc = (void *) fc; + struct ctf_field_class_int *int_fc = ctf_field_class_as_int(fc); if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE && !int_fc->mapped_clock_class) { @@ -63,7 +63,7 @@ void warn_meaningless_fields(struct ctf_field_class *fc, const char *name, } case CTF_FIELD_CLASS_TYPE_STRUCT: { - struct ctf_field_class_struct *struct_fc = (void *) fc; + struct ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc); for (i = 0; i < struct_fc->members->len; i++) { struct ctf_named_field_class *named_fc = @@ -78,7 +78,7 @@ void warn_meaningless_fields(struct ctf_field_class *fc, const char *name, } case CTF_FIELD_CLASS_TYPE_VARIANT: { - struct ctf_field_class_variant *var_fc = (void *) fc; + struct ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc); for (i = 0; i < var_fc->options->len; i++) { struct ctf_named_field_class *named_fc = @@ -93,7 +93,7 @@ void warn_meaningless_fields(struct ctf_field_class *fc, const char *name, } case CTF_FIELD_CLASS_TYPE_ARRAY: { - struct ctf_field_class_array *array_fc = (void *) fc; + struct ctf_field_class_array *array_fc = ctf_field_class_as_array(fc); if (array_fc->meaning != CTF_FIELD_CLASS_MEANING_NONE) { goto end; @@ -103,7 +103,7 @@ void warn_meaningless_fields(struct ctf_field_class *fc, const char *name, /* fall-through */ case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_array_base *array_fc = (void *) fc; + struct ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc); warn_meaningless_fields(array_fc->elem_fc, name, scope_name, log_cfg); @@ -131,7 +131,7 @@ void ctf_trace_class_warn_meaningless_header_fields( } for (i = 0; i < ctf_tc->stream_classes->len; i++) { - struct ctf_stream_class *sc = ctf_tc->stream_classes->pdata[i]; + ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i]; if (!sc->is_translated) { warn_meaningless_fields(sc->event_header_fc, NULL, diff --git a/src/plugins/ctf/common/metadata/ctf-meta.h b/src/plugins/ctf/common/metadata/ctf-meta.hpp similarity index 87% rename from src/plugins/ctf/common/metadata/ctf-meta.h rename to src/plugins/ctf/common/metadata/ctf-meta.hpp index ea6b9260..74c5fac1 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta.h +++ b/src/plugins/ctf/common/metadata/ctf-meta.hpp @@ -311,6 +311,82 @@ struct ctf_trace_class { } quirks; }; +static inline +ctf_field_class_bit_array *ctf_field_class_as_bit_array(ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || (fc->type == CTF_FIELD_CLASS_TYPE_INT || + fc->type == CTF_FIELD_CLASS_TYPE_ENUM || + fc->type == CTF_FIELD_CLASS_TYPE_FLOAT)); + return (ctf_field_class_bit_array *) fc; +} + +static inline +ctf_field_class_int *ctf_field_class_as_int(ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || (fc->type == CTF_FIELD_CLASS_TYPE_INT || + fc->type == CTF_FIELD_CLASS_TYPE_ENUM)); + return (ctf_field_class_int *) fc; +} + +static inline +ctf_field_class_enum *ctf_field_class_as_enum(ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_ENUM); + return (ctf_field_class_enum *) fc; +} + +static inline +ctf_field_class_float *ctf_field_class_as_float(ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_FLOAT); + return (ctf_field_class_float *) fc; +} + +static inline +ctf_field_class_string *ctf_field_class_as_string(ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_STRING); + return (ctf_field_class_string *) fc; +} + +static inline +ctf_field_class_struct *ctf_field_class_as_struct(ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_STRUCT); + return (ctf_field_class_struct *) fc; +} + +static inline +ctf_field_class_array_base *ctf_field_class_as_array_base(ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || (fc->type == CTF_FIELD_CLASS_TYPE_ARRAY || + fc->type == CTF_FIELD_CLASS_TYPE_SEQUENCE)); + return (ctf_field_class_array_base *) fc; +} + +static inline +ctf_field_class_array *ctf_field_class_as_array(ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_ARRAY); + return (ctf_field_class_array *) fc; +} + +static inline +ctf_field_class_sequence *ctf_field_class_as_sequence(ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_SEQUENCE); + return (ctf_field_class_sequence *) fc; +} + +static inline +ctf_field_class_variant *ctf_field_class_as_variant( + ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_VARIANT); + return (ctf_field_class_variant *) fc; +} + + static inline void ctf_field_class_destroy(struct ctf_field_class *fc); @@ -328,14 +404,14 @@ static inline void _ctf_field_class_bit_array_init(struct ctf_field_class_bit_array *fc, enum ctf_field_class_type type) { - _ctf_field_class_init((void *) fc, type, 1); + _ctf_field_class_init(&fc->base, type, 1); } static inline void _ctf_field_class_int_init(struct ctf_field_class_int *fc, enum ctf_field_class_type type) { - _ctf_field_class_bit_array_init((void *) fc, type); + _ctf_field_class_bit_array_init(&fc->base, type); fc->meaning = CTF_FIELD_CLASS_MEANING_NONE; fc->storing_index = -1; } @@ -427,7 +503,7 @@ struct ctf_field_class_float *ctf_field_class_float_create(void) g_new0(struct ctf_field_class_float, 1); BT_ASSERT(fc); - _ctf_field_class_bit_array_init((void *) fc, CTF_FIELD_CLASS_TYPE_FLOAT); + _ctf_field_class_bit_array_init(&fc->base, CTF_FIELD_CLASS_TYPE_FLOAT); return fc; } @@ -438,7 +514,7 @@ struct ctf_field_class_string *ctf_field_class_string_create(void) g_new0(struct ctf_field_class_string, 1); BT_ASSERT(fc); - _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_STRING, 8); + _ctf_field_class_init(&fc->base, CTF_FIELD_CLASS_TYPE_STRING, 8); return fc; } @@ -448,7 +524,7 @@ struct ctf_field_class_enum *ctf_field_class_enum_create(void) struct ctf_field_class_enum *fc = g_new0(struct ctf_field_class_enum, 1); BT_ASSERT(fc); - _ctf_field_class_int_init((void *) fc, CTF_FIELD_CLASS_TYPE_ENUM); + _ctf_field_class_int_init(&fc->base, CTF_FIELD_CLASS_TYPE_ENUM); fc->mappings = g_array_new(FALSE, TRUE, sizeof(struct ctf_field_class_enum_mapping)); BT_ASSERT(fc->mappings); @@ -462,7 +538,7 @@ struct ctf_field_class_struct *ctf_field_class_struct_create(void) g_new0(struct ctf_field_class_struct, 1); BT_ASSERT(fc); - _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_STRUCT, 1); + _ctf_field_class_init(&fc->base, CTF_FIELD_CLASS_TYPE_STRUCT, 1); fc->members = g_array_new(FALSE, TRUE, sizeof(struct ctf_named_field_class)); BT_ASSERT(fc->members); @@ -477,7 +553,7 @@ struct ctf_field_class_variant *ctf_field_class_variant_create(void) g_new0(struct ctf_field_class_variant, 1); BT_ASSERT(fc); - _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_VARIANT, 1); + _ctf_field_class_init(&fc->base, CTF_FIELD_CLASS_TYPE_VARIANT, 1); fc->options = g_array_new(FALSE, TRUE, sizeof(struct ctf_named_field_class)); BT_ASSERT(fc->options); @@ -498,7 +574,7 @@ struct ctf_field_class_array *ctf_field_class_array_create(void) g_new0(struct ctf_field_class_array, 1); BT_ASSERT(fc); - _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_ARRAY, 1); + _ctf_field_class_init(&fc->base.base, CTF_FIELD_CLASS_TYPE_ARRAY, 1); fc->base.base.is_compound = true; return fc; } @@ -510,7 +586,7 @@ struct ctf_field_class_sequence *ctf_field_class_sequence_create(void) g_new0(struct ctf_field_class_sequence, 1); BT_ASSERT(fc); - _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_SEQUENCE, 1); + _ctf_field_class_init(&fc->base.base, CTF_FIELD_CLASS_TYPE_SEQUENCE, 1); fc->length_ref = g_string_new(NULL); BT_ASSERT(fc->length_ref); ctf_field_path_init(&fc->length_path); @@ -594,7 +670,7 @@ static inline void _ctf_field_class_array_destroy(struct ctf_field_class_array *fc) { BT_ASSERT(fc); - _ctf_field_class_array_base_fini((void *) fc); + _ctf_field_class_array_base_fini(&fc->base); g_free(fc); } @@ -602,7 +678,7 @@ static inline void _ctf_field_class_sequence_destroy(struct ctf_field_class_sequence *fc) { BT_ASSERT(fc); - _ctf_field_class_array_base_fini((void *) fc); + _ctf_field_class_array_base_fini(&fc->base); if (fc->length_ref) { g_string_free(fc->length_ref, TRUE); @@ -652,28 +728,28 @@ void ctf_field_class_destroy(struct ctf_field_class *fc) switch (fc->type) { case CTF_FIELD_CLASS_TYPE_INT: - _ctf_field_class_int_destroy((void *) fc); + _ctf_field_class_int_destroy(ctf_field_class_as_int(fc)); break; case CTF_FIELD_CLASS_TYPE_ENUM: - _ctf_field_class_enum_destroy((void *) fc); + _ctf_field_class_enum_destroy(ctf_field_class_as_enum(fc)); break; case CTF_FIELD_CLASS_TYPE_FLOAT: - _ctf_field_class_float_destroy((void *) fc); + _ctf_field_class_float_destroy(ctf_field_class_as_float(fc)); break; case CTF_FIELD_CLASS_TYPE_STRING: - _ctf_field_class_string_destroy((void *) fc); + _ctf_field_class_string_destroy(ctf_field_class_as_string(fc)); break; case CTF_FIELD_CLASS_TYPE_STRUCT: - _ctf_field_class_struct_destroy((void *) fc); + _ctf_field_class_struct_destroy(ctf_field_class_as_struct(fc)); break; case CTF_FIELD_CLASS_TYPE_ARRAY: - _ctf_field_class_array_destroy((void *) fc); + _ctf_field_class_array_destroy(ctf_field_class_as_array(fc)); break; case CTF_FIELD_CLASS_TYPE_SEQUENCE: - _ctf_field_class_sequence_destroy((void *) fc); + _ctf_field_class_sequence_destroy(ctf_field_class_as_sequence(fc)); break; case CTF_FIELD_CLASS_TYPE_VARIANT: - _ctf_field_class_variant_destroy((void *) fc); + _ctf_field_class_variant_destroy(ctf_field_class_as_variant(fc)); break; default: bt_common_abort(); @@ -729,8 +805,12 @@ void ctf_field_class_enum_map_range(struct ctf_field_class_enum *fc, { struct ctf_field_class_enum_mapping *mapping = NULL; struct ctf_range range = { - .lower.u = u_lower, - .upper.u = u_upper, + .lower = { + .u = u_lower, + }, + .upper = { + .u = u_upper, + }, }; uint64_t i; @@ -824,9 +904,9 @@ ctf_field_class_struct_borrow_member_int_field_class_by_name( { struct ctf_field_class_int *int_fc = NULL; - int_fc = (void *) + int_fc = ctf_field_class_as_int( ctf_field_class_struct_borrow_member_field_class_by_name( - struct_fc, name); + struct_fc, name)); if (!int_fc) { goto end; } @@ -988,7 +1068,7 @@ struct ctf_field_class *ctf_field_class_compound_borrow_field_class_by_index( { struct ctf_named_field_class *named_fc = ctf_field_class_struct_borrow_member_by_index( - (void *) comp_fc, index); + (struct ctf_field_class_struct *) comp_fc, index); BT_ASSERT_DBG(named_fc); fc = named_fc->fc; @@ -998,7 +1078,7 @@ struct ctf_field_class *ctf_field_class_compound_borrow_field_class_by_index( { struct ctf_named_field_class *named_fc = ctf_field_class_variant_borrow_option_by_index( - (void *) comp_fc, index); + (struct ctf_field_class_variant *) comp_fc, index); BT_ASSERT_DBG(named_fc); fc = named_fc->fc; @@ -1007,7 +1087,8 @@ struct ctf_field_class *ctf_field_class_compound_borrow_field_class_by_index( case CTF_FIELD_CLASS_TYPE_ARRAY: case CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct ctf_field_class_array_base *array_fc = (void *) comp_fc; + struct ctf_field_class_array_base *array_fc = + (struct ctf_field_class_array_base *) comp_fc; fc = array_fc->elem_fc; break; @@ -1027,14 +1108,16 @@ uint64_t ctf_field_class_compound_get_field_class_count(struct ctf_field_class * switch (fc->type) { case CTF_FIELD_CLASS_TYPE_STRUCT: { - struct ctf_field_class_struct *struct_fc = (void *) fc; + struct ctf_field_class_struct *struct_fc = + (struct ctf_field_class_struct *) fc; field_count = struct_fc->members->len; break; } case CTF_FIELD_CLASS_TYPE_VARIANT: { - struct ctf_field_class_variant *var_fc = (void *) fc; + struct ctf_field_class_variant *var_fc = + (struct ctf_field_class_variant *) fc; field_count = var_fc->options->len; break; @@ -1064,7 +1147,8 @@ int64_t ctf_field_class_compound_get_field_class_index_from_orig_name( switch (fc->type) { case CTF_FIELD_CLASS_TYPE_STRUCT: { - struct ctf_field_class_struct *struct_fc = (void *) fc; + struct ctf_field_class_struct *struct_fc = + (struct ctf_field_class_struct *) fc; for (i = 0; i < struct_fc->members->len; i++) { struct ctf_named_field_class *named_fc = @@ -1081,7 +1165,8 @@ int64_t ctf_field_class_compound_get_field_class_index_from_orig_name( } case CTF_FIELD_CLASS_TYPE_VARIANT: { - struct ctf_field_class_variant *var_fc = (void *) fc; + struct ctf_field_class_variant *var_fc + = (struct ctf_field_class_variant *) fc; for (i = 0; i < var_fc->options->len; i++) { struct ctf_named_field_class *named_fc = @@ -1241,7 +1326,7 @@ void ctf_field_class_int_copy_content( struct ctf_field_class_int *dst_fc, struct ctf_field_class_int *src_fc) { - ctf_field_class_bit_array_copy_content((void *) dst_fc, (void *) src_fc); + ctf_field_class_bit_array_copy_content(&dst_fc->base, &src_fc->base); dst_fc->meaning = src_fc->meaning; dst_fc->is_signed = src_fc->is_signed; dst_fc->disp_base = src_fc->disp_base; @@ -1269,7 +1354,7 @@ struct ctf_field_class_enum *_ctf_field_class_enum_copy( uint64_t i; BT_ASSERT(copy_fc); - ctf_field_class_int_copy_content((void *) copy_fc, (void *) fc); + ctf_field_class_int_copy_content(©_fc->base, &fc->base); for (i = 0; i < fc->mappings->len; i++) { uint64_t range_i; @@ -1299,7 +1384,7 @@ struct ctf_field_class_float *_ctf_field_class_float_copy( struct ctf_field_class_float *copy_fc = ctf_field_class_float_create(); BT_ASSERT(copy_fc); - ctf_field_class_bit_array_copy_content((void *) copy_fc, (void *) fc); + ctf_field_class_bit_array_copy_content(©_fc->base, &fc->base); return copy_fc; } @@ -1406,7 +1491,7 @@ struct ctf_field_class_array *_ctf_field_class_array_copy( struct ctf_field_class_array *copy_fc = ctf_field_class_array_create(); BT_ASSERT(copy_fc); - ctf_field_class_array_base_copy_content((void *) copy_fc, (void *) fc); + ctf_field_class_array_base_copy_content(©_fc->base, &fc->base); copy_fc->length = fc->length; return copy_fc; } @@ -1419,7 +1504,7 @@ struct ctf_field_class_sequence *_ctf_field_class_sequence_copy( ctf_field_class_sequence_create(); BT_ASSERT(copy_fc); - ctf_field_class_array_base_copy_content((void *) copy_fc, (void *) fc); + ctf_field_class_array_base_copy_content(©_fc->base, &fc->base); ctf_field_path_copy_content(©_fc->length_path, &fc->length_path); g_string_assign(copy_fc->length_ref, fc->length_ref->str); copy_fc->stored_length_index = fc->stored_length_index; @@ -1442,28 +1527,28 @@ struct ctf_field_class *ctf_field_class_copy(struct ctf_field_class *fc) switch (fc->type) { case CTF_FIELD_CLASS_TYPE_INT: - copy_fc = (void *) _ctf_field_class_int_copy((void *) fc); + copy_fc = &_ctf_field_class_int_copy(ctf_field_class_as_int (fc))->base.base; break; case CTF_FIELD_CLASS_TYPE_ENUM: - copy_fc = (void *) _ctf_field_class_enum_copy((void *) fc); + copy_fc = &_ctf_field_class_enum_copy(ctf_field_class_as_enum (fc))->base.base.base; break; case CTF_FIELD_CLASS_TYPE_FLOAT: - copy_fc = (void *) _ctf_field_class_float_copy((void *) fc); + copy_fc = &_ctf_field_class_float_copy(ctf_field_class_as_float (fc))->base.base; break; case CTF_FIELD_CLASS_TYPE_STRING: - copy_fc = (void *) _ctf_field_class_string_copy((void *) fc); + copy_fc = &_ctf_field_class_string_copy(ctf_field_class_as_string (fc))->base; break; case CTF_FIELD_CLASS_TYPE_STRUCT: - copy_fc = (void *) _ctf_field_class_struct_copy((void *) fc); + copy_fc = &_ctf_field_class_struct_copy(ctf_field_class_as_struct (fc))->base; break; case CTF_FIELD_CLASS_TYPE_ARRAY: - copy_fc = (void *) _ctf_field_class_array_copy((void *) fc); + copy_fc = &_ctf_field_class_array_copy(ctf_field_class_as_array(fc))->base.base; break; case CTF_FIELD_CLASS_TYPE_SEQUENCE: - copy_fc = (void *) _ctf_field_class_sequence_copy((void *) fc); + copy_fc = &_ctf_field_class_sequence_copy(ctf_field_class_as_sequence (fc))->base.base; break; case CTF_FIELD_CLASS_TYPE_VARIANT: - copy_fc = (void *) _ctf_field_class_variant_copy((void *) fc); + copy_fc = &_ctf_field_class_variant_copy(ctf_field_class_as_variant (fc))->base; break; default: bt_common_abort(); @@ -1570,7 +1655,7 @@ struct ctf_event_class *ctf_stream_class_borrow_event_class_by_id( struct ctf_stream_class *sc, uint64_t type) { BT_ASSERT_DBG(sc); - return g_hash_table_lookup(sc->event_classes_by_id, + return (struct ctf_event_class *) g_hash_table_lookup(sc->event_classes_by_id, GUINT_TO_POINTER((guint) type)); } @@ -1716,7 +1801,8 @@ struct ctf_stream_class *ctf_trace_class_borrow_stream_class_by_id( BT_ASSERT_DBG(tc); for (i = 0; i < tc->stream_classes->len; i++) { - struct ctf_stream_class *sc = tc->stream_classes->pdata[i]; + struct ctf_stream_class *sc = + (struct ctf_stream_class *) tc->stream_classes->pdata[i]; if (sc->id == id) { ret_sc = sc; @@ -1739,7 +1825,8 @@ struct ctf_clock_class *ctf_trace_class_borrow_clock_class_by_name( BT_ASSERT_DBG(name); for (i = 0; i < tc->clock_classes->len; i++) { - struct ctf_clock_class *cc = tc->clock_classes->pdata[i]; + struct ctf_clock_class *cc = + (struct ctf_clock_class *) tc->clock_classes->pdata[i]; BT_ASSERT_DBG(cc->name); if (strcmp(cc->name->str, name) == 0) { diff --git a/src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.c b/src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.cpp similarity index 98% rename from src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.c rename to src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.cpp index 64fbb183..d0cd0304 100644 --- a/src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.c +++ b/src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.cpp @@ -10,7 +10,7 @@ #define BT_LOG_TAG "PLUGIN/CTF/META/DECODER-DECODE-PACKET" #include "logging/comp-logging.h" -#include "decoder-packetized-file-stream-to-buf.h" +#include "decoder-packetized-file-stream-to-buf.hpp" #include #include @@ -24,10 +24,10 @@ #include #include -#include "ast.h" -#include "decoder.h" -#include "scanner.h" -#include "logging.h" +#include "ast.hpp" +#include "decoder.hpp" +#include "scanner.hpp" +#include "logging.hpp" #define TSDL_MAGIC 0x75d11d57 diff --git a/src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.h b/src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.hpp similarity index 100% rename from src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.h rename to src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.hpp diff --git a/src/plugins/ctf/common/metadata/decoder.c b/src/plugins/ctf/common/metadata/decoder.cpp similarity index 98% rename from src/plugins/ctf/common/metadata/decoder.c rename to src/plugins/ctf/common/metadata/decoder.cpp index f2a140b7..31019dd2 100644 --- a/src/plugins/ctf/common/metadata/decoder.c +++ b/src/plugins/ctf/common/metadata/decoder.cpp @@ -22,12 +22,12 @@ #include #include -#include "ast.h" -#include "decoder.h" -#include "scanner.h" -#include "logging.h" -#include "parser-wrap.h" -#include "decoder-packetized-file-stream-to-buf.h" +#include "ast.hpp" +#include "decoder.hpp" +#include "scanner.hpp" +#include "logging.hpp" +#include "parser-wrap.hpp" +#include "decoder-packetized-file-stream-to-buf.hpp" #define TSDL_MAGIC 0x75d11d57 diff --git a/src/plugins/ctf/common/metadata/decoder.h b/src/plugins/ctf/common/metadata/decoder.hpp similarity index 99% rename from src/plugins/ctf/common/metadata/decoder.h rename to src/plugins/ctf/common/metadata/decoder.hpp index 7c5a8b7e..d8803d84 100644 --- a/src/plugins/ctf/common/metadata/decoder.h +++ b/src/plugins/ctf/common/metadata/decoder.hpp @@ -9,6 +9,7 @@ #include #include +#include #include diff --git a/src/plugins/ctf/common/metadata/lexer.l b/src/plugins/ctf/common/metadata/lexer.lpp similarity index 98% rename from src/plugins/ctf/common/metadata/lexer.l rename to src/plugins/ctf/common/metadata/lexer.lpp index 849d016b..27fea430 100644 --- a/src/plugins/ctf/common/metadata/lexer.l +++ b/src/plugins/ctf/common/metadata/lexer.lpp @@ -9,13 +9,13 @@ #define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level #define BT_LOG_TAG "PLUGIN-CTF-METADATA-LEXER" -#include "logging.h" +#include "logging.hpp" #include #include -#include "scanner.h" -#include "parser-wrap.h" -#include "ast.h" +#include "scanner.hpp" +#include "parser-wrap.hpp" +#include "ast.hpp" #define YY_FATAL_ERROR(_msg) BT_LOGF_STR(_msg) diff --git a/src/plugins/ctf/common/metadata/logging.c b/src/plugins/ctf/common/metadata/logging.cpp similarity index 100% rename from src/plugins/ctf/common/metadata/logging.c rename to src/plugins/ctf/common/metadata/logging.cpp diff --git a/src/plugins/ctf/common/metadata/logging.h b/src/plugins/ctf/common/metadata/logging.hpp similarity index 100% rename from src/plugins/ctf/common/metadata/logging.h rename to src/plugins/ctf/common/metadata/logging.hpp diff --git a/src/plugins/ctf/common/metadata/objstack.c b/src/plugins/ctf/common/metadata/objstack.cpp similarity index 90% rename from src/plugins/ctf/common/metadata/objstack.c rename to src/plugins/ctf/common/metadata/objstack.cpp index a730589d..0be8dbf7 100644 --- a/src/plugins/ctf/common/metadata/objstack.c +++ b/src/plugins/ctf/common/metadata/objstack.cpp @@ -8,9 +8,9 @@ #define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level #define BT_LOG_TAG "PLUGIN/CTF/META/OBJSTACK" -#include "logging.h" +#include "logging.hpp" -#include "objstack.h" +#include "objstack.hpp" #include #include "common/list.h" @@ -38,12 +38,12 @@ struct objstack *objstack_create(void) struct objstack *objstack; struct objstack_node *node; - objstack = calloc(1, sizeof(*objstack)); + objstack = (struct objstack *) calloc(1, sizeof(*objstack)); if (!objstack) { BT_LOGE_STR("Failed to allocate one object stack."); return NULL; } - node = calloc(sizeof(struct objstack_node) + OBJSTACK_INIT_LEN, + node = (objstack_node *) calloc(sizeof(struct objstack_node) + OBJSTACK_INIT_LEN, sizeof(char)); if (!node) { BT_LOGE_STR("Failed to allocate one object stack node."); @@ -95,7 +95,7 @@ struct objstack_node *objstack_append_node(struct objstack *objstack) struct objstack_node, node); /* Allocate new node with double of size of last node */ - new_node = calloc(sizeof(struct objstack_node) + (last_node->len << 1), + new_node = (objstack_node *) calloc(sizeof(struct objstack_node) + (last_node->len << 1), sizeof(char)); if (!new_node) { BT_LOGE_STR("Failed to allocate one object stack node."); diff --git a/src/plugins/ctf/common/metadata/objstack.h b/src/plugins/ctf/common/metadata/objstack.hpp similarity index 100% rename from src/plugins/ctf/common/metadata/objstack.h rename to src/plugins/ctf/common/metadata/objstack.hpp diff --git a/src/plugins/ctf/common/metadata/parser-wrap.h b/src/plugins/ctf/common/metadata/parser-wrap.hpp similarity index 96% rename from src/plugins/ctf/common/metadata/parser-wrap.h rename to src/plugins/ctf/common/metadata/parser-wrap.hpp index 4976264d..6300b250 100644 --- a/src/plugins/ctf/common/metadata/parser-wrap.h +++ b/src/plugins/ctf/common/metadata/parser-wrap.hpp @@ -22,7 +22,7 @@ #endif #define ALLOW_INCLUDE_PARSER_H -#include "parser.h" +#include "parser.hpp" #undef ALLOW_INCLUDE_PARSER_H #endif diff --git a/src/plugins/ctf/common/metadata/parser.y b/src/plugins/ctf/common/metadata/parser.ypp similarity index 99% rename from src/plugins/ctf/common/metadata/parser.y rename to src/plugins/ctf/common/metadata/parser.ypp index cb4eb74f..b644b5d1 100644 --- a/src/plugins/ctf/common/metadata/parser.y +++ b/src/plugins/ctf/common/metadata/parser.ypp @@ -9,7 +9,7 @@ #define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level #define BT_LOG_TAG "PLUGIN/CTF/META/PARSER" -#include "logging.h" +#include "logging.hpp" #include #include @@ -22,11 +22,11 @@ #include #include "common/list.h" #include "common/assert.h" -#include "scanner.h" -#include "ast.h" -#include "objstack.h" +#include "scanner.hpp" +#include "ast.hpp" +#include "objstack.hpp" -#include "parser-wrap.h" +#include "parser-wrap.hpp" /* Join two lists, put "add" at the end of "head". */ static inline void @@ -54,33 +54,35 @@ int yyget_lineno(yyscan_t yyscanner); BT_HIDDEN char *yyget_text(yyscan_t yyscanner); -static const char *node_type_to_str[] = { -#define ENTRY(S) [S] = #S, - FOREACH_CTF_NODES(ENTRY) -#undef ENTRY -}; - /* * Static node for out of memory errors. Only "type" is used. lineno is * always left at 0. The rest of the node content can be overwritten, * but is never used. */ static struct ctf_node error_node = { + .parent = nullptr, + .siblings = {}, + .tmp_head = {}, + .lineno = 0, + .visited = 0, .type = NODE_ERROR, }; BT_HIDDEN const char *node_type(struct ctf_node *node) { - if (node->type < NR_NODE_TYPES) - return node_type_to_str[node->type]; - else - return NULL; + switch (node->type) { +#define ENTRY(S) case S: return #S; + FOREACH_CTF_NODES(ENTRY) +#undef ENTRY + }; + + bt_common_abort(); } void setstring(struct ctf_scanner *scanner, YYSTYPE *lvalp, const char *src) { - lvalp->s = objstack_alloc(scanner->objstack, strlen(src) + 1); + lvalp->s = (char *) objstack_alloc(scanner->objstack, strlen(src) + 1); strcpy(lvalp->s, src); } @@ -263,7 +265,7 @@ int import_string(struct ctf_scanner *scanner, YYSTYPE *lvalp, size_t len; len = strlen(src) + 1; - lvalp->s = objstack_alloc(scanner->objstack, len); + lvalp->s = (char *) objstack_alloc(scanner->objstack, len); if (src[0] == 'L') { // TODO: import wide string _BT_LOGE_APPEND_CAUSE_LINENO(yyget_lineno(scanner), @@ -293,7 +295,7 @@ static void push_scope(struct ctf_scanner *scanner) struct ctf_scanner_scope *ns; BT_LOGT("Pushing scope: scanner-addr=%p", scanner); - ns = malloc(sizeof(struct ctf_scanner_scope)); + ns = (ctf_scanner_scope *) malloc(sizeof(struct ctf_scanner_scope)); init_scope(ns, scanner->cs); scanner->cs = ns; } @@ -350,7 +352,7 @@ static struct ctf_node *make_node(struct ctf_scanner *scanner, { struct ctf_node *node; - node = objstack_alloc(scanner->objstack, sizeof(*node)); + node = (ctf_node *) objstack_alloc(scanner->objstack, sizeof(*node)); if (!node) { _BT_LOGE_APPEND_CAUSE_LINENO(yyget_lineno(scanner->scanner), "failed to allocate one stack entry: " @@ -936,7 +938,7 @@ static struct ctf_ast *ctf_ast_alloc(struct ctf_scanner *scanner) { struct ctf_ast *ast; - ast = objstack_alloc(scanner->objstack, sizeof(*ast)); + ast = (ctf_ast *) objstack_alloc(scanner->objstack, sizeof(*ast)); if (!ast) return NULL; ast->root.type = NODE_ROOT; @@ -963,7 +965,7 @@ struct ctf_scanner *ctf_scanner_alloc(void) struct ctf_scanner *scanner; int ret; - scanner = malloc(sizeof(*scanner)); + scanner = (ctf_scanner *) malloc(sizeof(*scanner)); if (!scanner) return NULL; memset(scanner, 0, sizeof(*scanner)); diff --git a/src/plugins/ctf/common/metadata/scanner-symbols.h b/src/plugins/ctf/common/metadata/scanner-symbols.hpp similarity index 100% rename from src/plugins/ctf/common/metadata/scanner-symbols.h rename to src/plugins/ctf/common/metadata/scanner-symbols.hpp diff --git a/src/plugins/ctf/common/metadata/scanner.h b/src/plugins/ctf/common/metadata/scanner.hpp similarity index 98% rename from src/plugins/ctf/common/metadata/scanner.h rename to src/plugins/ctf/common/metadata/scanner.hpp index 1a1d9d90..d1ab1d90 100644 --- a/src/plugins/ctf/common/metadata/scanner.h +++ b/src/plugins/ctf/common/metadata/scanner.hpp @@ -9,7 +9,7 @@ #include #include "common/macros.h" -#include "ast.h" +#include "ast.hpp" #ifndef YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T diff --git a/src/plugins/ctf/common/metadata/visitor-generate-ir.c b/src/plugins/ctf/common/metadata/visitor-generate-ir.cpp similarity index 97% rename from src/plugins/ctf/common/metadata/visitor-generate-ir.c rename to src/plugins/ctf/common/metadata/visitor-generate-ir.cpp index ca87aad6..970b838c 100644 --- a/src/plugins/ctf/common/metadata/visitor-generate-ir.c +++ b/src/plugins/ctf/common/metadata/visitor-generate-ir.cpp @@ -28,12 +28,12 @@ #include "compat/endian.h" #include -#include "logging.h" -#include "scanner.h" -#include "ast.h" -#include "decoder.h" -#include "ctf-meta.h" -#include "ctf-meta-visitors.h" +#include "logging.hpp" +#include "scanner.hpp" +#include "ast.hpp" +#include "decoder.hpp" +#include "ctf-meta.hpp" +#include "ctf-meta-visitors.hpp" /* Bit value (left shift) */ #define _BV(_val) (1 << (_val)) @@ -315,7 +315,7 @@ struct ctf_field_class *ctx_decl_scope_lookup_prefix_alias( } while (cur_scope && cur_levels < levels) { - decl = g_hash_table_lookup(cur_scope->decl_map, + decl = (ctf_field_class *) g_hash_table_lookup(cur_scope->decl_map, (gconstpointer) GUINT_TO_POINTER(qname)); if (decl) { /* Caller's reference */ @@ -369,8 +369,8 @@ struct ctf_field_class_enum *ctx_decl_scope_lookup_enum(struct ctf_visitor_gener struct ctx_decl_scope *scope, const char *name, int levels, bool copy) { - return (void *) ctx_decl_scope_lookup_prefix_alias(ctx, scope, - _PREFIX_ENUM, name, levels, copy); + return ctf_field_class_as_enum(ctx_decl_scope_lookup_prefix_alias(ctx, scope, + _PREFIX_ENUM, name, levels, copy)); } /** @@ -388,8 +388,8 @@ struct ctf_field_class_struct *ctx_decl_scope_lookup_struct(struct ctf_visitor_g struct ctx_decl_scope *scope, const char *name, int levels, bool copy) { - return (void *) ctx_decl_scope_lookup_prefix_alias(ctx, scope, - _PREFIX_STRUCT, name, levels, copy); + return ctf_field_class_as_struct(ctx_decl_scope_lookup_prefix_alias(ctx, scope, + _PREFIX_STRUCT, name, levels, copy)); } /** @@ -407,8 +407,8 @@ struct ctf_field_class_variant *ctx_decl_scope_lookup_variant(struct ctf_visitor struct ctx_decl_scope *scope, const char *name, int levels, bool copy) { - return (void *) ctx_decl_scope_lookup_prefix_alias(ctx, scope, - _PREFIX_VARIANT, name, levels, copy); + return ctf_field_class_as_variant(ctx_decl_scope_lookup_prefix_alias(ctx, scope, + _PREFIX_VARIANT, name, levels, copy)); } /** @@ -465,7 +465,7 @@ int ctx_decl_scope_register_alias(struct ctf_visitor_generate_ir *ctx, struct ctx_decl_scope *scope, const char *name, struct ctf_field_class *decl) { return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_ALIAS, - name, (void *) decl); + name, decl); } /** @@ -482,7 +482,7 @@ int ctx_decl_scope_register_enum(struct ctf_visitor_generate_ir *ctx, struct ctf_field_class_enum *decl) { return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_ENUM, - name, (void *) decl); + name, &decl->base.base.base); } /** @@ -499,7 +499,7 @@ int ctx_decl_scope_register_struct(struct ctf_visitor_generate_ir *ctx, struct ctf_field_class_struct *decl) { return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_STRUCT, - name, (void *) decl); + name, &decl->base); } /** @@ -516,7 +516,7 @@ int ctx_decl_scope_register_variant(struct ctf_visitor_generate_ir *ctx, struct ctf_field_class_variant *decl) { return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_VARIANT, - name, (void *) decl); + name, &decl->base); } /** @@ -1210,7 +1210,7 @@ int visit_field_class_declarator(struct ctf_visitor_generate_ir *ctx, if (nested_decl->type == CTF_FIELD_CLASS_TYPE_INT) { /* Pointer: force integer's base to 16 */ struct ctf_field_class_int *int_fc = - (void *) nested_decl; + ctf_field_class_as_int(nested_decl); int_fc->disp_base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL; @@ -1282,7 +1282,7 @@ int visit_field_class_declarator(struct ctf_visitor_generate_ir *ctx, first->u.unary_expression.u.unsigned_constant; array_decl->base.elem_fc = nested_decl; nested_decl = NULL; - decl = (void *) array_decl; + decl = &array_decl->base.base; break; } case UNARY_STRING: @@ -1340,7 +1340,7 @@ int visit_field_class_declarator(struct ctf_visitor_generate_ir *ctx, (uint64_t) env_entry->value.i; array_decl->base.elem_fc = nested_decl; nested_decl = NULL; - decl = (void *) array_decl; + decl = &array_decl->base.base; } else { seq_decl = ctf_field_class_sequence_create(); BT_ASSERT(seq_decl); @@ -1348,7 +1348,7 @@ int visit_field_class_declarator(struct ctf_visitor_generate_ir *ctx, nested_decl = NULL; g_string_assign(seq_decl->length_ref, length_name); - decl = (void *) seq_decl; + decl = &seq_decl->base.base; } g_free(length_name); @@ -1529,7 +1529,7 @@ int visit_field_class_def(struct ctf_visitor_generate_ir *ctx, /* Do not allow field class def and alias of untagged variants */ if (class_decl->type == CTF_FIELD_CLASS_TYPE_VARIANT) { struct ctf_field_class_variant *var_fc = - (void *) class_decl; + ctf_field_class_as_variant(class_decl); if (var_fc->tag_path.path->len == 0) { _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter, @@ -1586,7 +1586,8 @@ int visit_field_class_alias(struct ctf_visitor_generate_ir *ctx, struct ctf_node /* Do not allow field class def and alias of untagged variants */ if (class_decl->type == CTF_FIELD_CLASS_TYPE_VARIANT) { - struct ctf_field_class_variant *var_fc = (void *) class_decl; + struct ctf_field_class_variant *var_fc = + ctf_field_class_as_variant(class_decl); if (var_fc->tag_path.path->len == 0) { _BT_COMP_LOGE_APPEND_CAUSE_NODE(target, @@ -1817,7 +1818,7 @@ int visit_struct_decl(struct ctf_visitor_generate_ir *ctx, const char *name, return 0; error: - ctf_field_class_destroy((void *) *struct_decl); + ctf_field_class_destroy(&(*struct_decl)->base); *struct_decl = NULL; return ret; } @@ -1915,9 +1916,9 @@ int visit_variant_decl(struct ctf_visitor_generate_ir *ctx, const char *name, return 0; error: - ctf_field_class_destroy((void *) untagged_variant_decl); + ctf_field_class_destroy(&untagged_variant_decl->base); untagged_variant_decl = NULL; - ctf_field_class_destroy((void *) *variant_decl); + ctf_field_class_destroy(&(*variant_decl)->base); *variant_decl = NULL; return ret; } @@ -1939,11 +1940,15 @@ int visit_enum_decl_entry(struct ctf_visitor_generate_ir *ctx, struct ctf_node * struct ctf_node *iter; struct uori start = { .is_signed = false, - .value.u = 0, + .value = { + .u = 0, + }, }; struct uori end = { .is_signed = false, - .value.u = 0, + .value = { + .u = 0, + }, }; const char *label = enumerator->u.enumerator.id; struct bt_list_head *values = &enumerator->u.enumerator.values; @@ -2053,7 +2058,9 @@ int visit_enum_decl(struct ctf_visitor_generate_ir *ctx, const char *name, struct ctf_node *iter; struct uori last_value = { .is_signed = false, - .value.u = 0, + .value = { + .u = 0, + }, }; if (name) { @@ -2067,22 +2074,25 @@ int visit_enum_decl(struct ctf_visitor_generate_ir *ctx, const char *name, } if (!container_cls) { - integer_decl = (void *) ctx_decl_scope_lookup_alias(ctx, - ctx->current_scope, "int", -1, true); + integer_decl = ctf_field_class_as_int(ctx_decl_scope_lookup_alias(ctx, + ctx->current_scope, "int", -1, true)); if (!integer_decl) { _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot find implicit `int` field class alias for enumeration field class."); ret = -EINVAL; goto error; } } else { + ctf_field_class *decl; + ret = visit_field_class_declarator(ctx, container_cls, - &qdummy_id, NULL, (void *) &integer_decl, - NULL); + &qdummy_id, NULL, &decl, NULL); if (ret) { - BT_ASSERT(!integer_decl); + BT_ASSERT(!decl); ret = -EINVAL; goto error; } + + integer_decl = ctf_field_class_as_int(decl); } BT_ASSERT(integer_decl); @@ -2098,8 +2108,8 @@ int visit_enum_decl(struct ctf_visitor_generate_ir *ctx, const char *name, BT_ASSERT(*enum_decl); (*enum_decl)->base.base.base.alignment = integer_decl->base.base.alignment; - ctf_field_class_int_copy_content((void *) *enum_decl, - (void *) integer_decl); + ctf_field_class_int_copy_content( + &(*enum_decl)->base, integer_decl); last_value.is_signed = (*enum_decl)->base.is_signed; bt_list_for_each_entry(iter, enumerator_list, siblings) { @@ -2127,11 +2137,11 @@ int visit_enum_decl(struct ctf_visitor_generate_ir *ctx, const char *name, goto end; error: - ctf_field_class_destroy((void *) *enum_decl); + ctf_field_class_destroy(&(*enum_decl)->base.base.base); *enum_decl = NULL; end: - ctf_field_class_destroy((void *) integer_decl); + ctf_field_class_destroy(&integer_decl->base.base); integer_decl = NULL; return ret; } @@ -2541,7 +2551,7 @@ int visit_integer_decl(struct ctf_visitor_generate_ir *ctx, return 0; error: - ctf_field_class_destroy((void *) *integer_decl); + ctf_field_class_destroy(&(*integer_decl)->base.base); *integer_decl = NULL; return ret; } @@ -2725,7 +2735,7 @@ int visit_floating_point_number_decl(struct ctf_visitor_generate_ir *ctx, return 0; error: - ctf_field_class_destroy((void *) *float_decl); + ctf_field_class_destroy(&(*float_decl)->base.base); *float_decl = NULL; return ret; } @@ -2821,7 +2831,7 @@ int visit_string_decl(struct ctf_visitor_generate_ir *ctx, return 0; error: - ctf_field_class_destroy((void *) *string_decl); + ctf_field_class_destroy(&(*string_decl)->base); *string_decl = NULL; return ret; } @@ -2854,60 +2864,90 @@ int visit_field_class_specifier_list(struct ctf_visitor_generate_ir *ctx, node = first->u.field_class_specifier.node; switch (first->u.field_class_specifier.type) { - case TYPESPEC_INTEGER: + case TYPESPEC_INTEGER: { + ctf_field_class_int *int_decl; + ret = visit_integer_decl(ctx, &node->u.integer.expressions, - (void *) decl); + &int_decl); if (ret) { - BT_ASSERT(!*decl); + BT_ASSERT(!int_decl); goto error; } + + *decl = &int_decl->base.base; break; - case TYPESPEC_FLOATING_POINT: + } + case TYPESPEC_FLOATING_POINT: { + ctf_field_class_float *float_decl; + ret = visit_floating_point_number_decl(ctx, - &node->u.floating_point.expressions, (void *) decl); + &node->u.floating_point.expressions, &float_decl); if (ret) { - BT_ASSERT(!*decl); + BT_ASSERT(!float_decl); goto error; } + + *decl = &float_decl->base.base; break; - case TYPESPEC_STRING: + } + case TYPESPEC_STRING: { + ctf_field_class_string *string_decl; + ret = visit_string_decl(ctx, - &node->u.string.expressions, (void *) decl); + &node->u.string.expressions, &string_decl); if (ret) { - BT_ASSERT(!*decl); + BT_ASSERT(!string_decl); goto error; } + + *decl = &string_decl->base; break; - case TYPESPEC_STRUCT: + } + case TYPESPEC_STRUCT: { + ctf_field_class_struct *struct_decl; + ret = visit_struct_decl(ctx, node->u._struct.name, &node->u._struct.declaration_list, node->u._struct.has_body, - &node->u._struct.min_align, (void *) decl); + &node->u._struct.min_align, &struct_decl); if (ret) { - BT_ASSERT(!*decl); + BT_ASSERT(!struct_decl); goto error; } + + *decl = &struct_decl->base; break; - case TYPESPEC_VARIANT: + } + case TYPESPEC_VARIANT: { + ctf_field_class_variant *variant_decl; + ret = visit_variant_decl(ctx, node->u.variant.name, node->u.variant.choice, &node->u.variant.declaration_list, - node->u.variant.has_body, (void *) decl); + node->u.variant.has_body, &variant_decl); if (ret) { - BT_ASSERT(!*decl); + BT_ASSERT(!variant_decl); goto error; } + + *decl = &variant_decl->base; break; - case TYPESPEC_ENUM: + } + case TYPESPEC_ENUM: { + ctf_field_class_enum *enum_decl; + ret = visit_enum_decl(ctx, node->u._enum.enum_id, node->u._enum.container_field_class, &node->u._enum.enumerator_list, - node->u._enum.has_body, (void *) decl); + node->u._enum.has_body, &enum_decl); if (ret) { - BT_ASSERT(!*decl); + BT_ASSERT(!enum_decl); goto error; } + + *decl = &enum_decl->base.base.base; break; + } case TYPESPEC_VOID: case TYPESPEC_CHAR: case TYPESPEC_SHORT: @@ -2943,7 +2983,7 @@ int visit_field_class_specifier_list(struct ctf_visitor_generate_ir *ctx, return 0; error: - ctf_field_class_destroy((void *) *decl); + ctf_field_class_destroy(*decl); *decl = NULL; return ret; } @@ -3083,7 +3123,7 @@ int visit_event_decl_entry(struct ctf_visitor_generate_ir *ctx, struct ctf_node } else if (strcmp(left, "loglevel") == 0) { uint64_t loglevel_value; bool is_log_level_known = true; - bt_event_class_log_level log_level = -1; + bt_event_class_log_level log_level; if (_IS_SET(set, _EVENT_LOG_LEVEL_SET)) { _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "loglevel", @@ -3315,7 +3355,7 @@ int visit_event_decl(struct ctf_visitor_generate_ir *ctx, struct ctf_node *node) break; case 1: /* Single stream class: get its ID */ - stream_class = ctx->ctf_tc->stream_classes->pdata[0]; + stream_class = (ctf_stream_class *) ctx->ctf_tc->stream_classes->pdata[0]; stream_id = stream_class->id; break; default: @@ -3390,7 +3430,7 @@ int auto_map_field_to_trace_clock_class(struct ctf_visitor_generate_ir *ctx, struct ctf_field_class *fc) { struct ctf_clock_class *clock_class_to_map_to = NULL; - struct ctf_field_class_int *int_fc = (void *) fc; + struct ctf_field_class_int *int_fc = ctf_field_class_as_int(fc); int ret = 0; uint64_t clock_class_count; @@ -3430,7 +3470,7 @@ int auto_map_field_to_trace_clock_class(struct ctf_visitor_generate_ir *ctx, * Only one clock class exists in the trace at this point: use * this one. */ - clock_class_to_map_to = ctx->ctf_tc->clock_classes->pdata[0]; + clock_class_to_map_to = (ctf_clock_class *) ctx->ctf_tc->clock_classes->pdata[0]; break; default: /* @@ -3456,8 +3496,8 @@ int auto_map_fields_to_trace_clock_class(struct ctf_visitor_generate_ir *ctx, { int ret = 0; uint64_t i, count; - struct ctf_field_class_struct *struct_fc = (void *) root_fc; - struct ctf_field_class_variant *var_fc = (void *) root_fc; + struct ctf_field_class_struct *struct_fc = (ctf_field_class_struct *) root_fc; + struct ctf_field_class_variant *var_fc = (ctf_field_class_variant *) root_fc; if (!root_fc) { goto end; @@ -3735,7 +3775,7 @@ int visit_stream_decl(struct ctf_visitor_generate_ir *ctx, struct ctf_node *node } named_fc = ctf_field_class_struct_borrow_member_by_name( - (void *) ctx->ctf_tc->packet_header_fc, "stream_id"); + ctf_field_class_as_struct(ctx->ctf_tc->packet_header_fc), "stream_id"); if (!named_fc) { _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Stream class has a `id` attribute, " diff --git a/src/plugins/ctf/common/metadata/visitor-parent-links.c b/src/plugins/ctf/common/metadata/visitor-parent-links.cpp similarity index 99% rename from src/plugins/ctf/common/metadata/visitor-parent-links.c rename to src/plugins/ctf/common/metadata/visitor-parent-links.cpp index 5afcb0e6..f34df9f5 100644 --- a/src/plugins/ctf/common/metadata/visitor-parent-links.c +++ b/src/plugins/ctf/common/metadata/visitor-parent-links.cpp @@ -21,9 +21,9 @@ #include #include "common/macros.h" #include "common/list.h" -#include "scanner.h" -#include "ast.h" -#include "logging.h" +#include "scanner.hpp" +#include "ast.hpp" +#include "logging.hpp" static int ctf_visitor_unary_expression(int depth, struct ctf_node *node, diff --git a/src/plugins/ctf/common/metadata/visitor-semantic-validator.c b/src/plugins/ctf/common/metadata/visitor-semantic-validator.cpp similarity index 99% rename from src/plugins/ctf/common/metadata/visitor-semantic-validator.c rename to src/plugins/ctf/common/metadata/visitor-semantic-validator.cpp index 4ac2a060..14025eb7 100644 --- a/src/plugins/ctf/common/metadata/visitor-semantic-validator.c +++ b/src/plugins/ctf/common/metadata/visitor-semantic-validator.cpp @@ -20,9 +20,9 @@ #include #include #include "common/list.h" -#include "scanner.h" -#include "ast.h" -#include "logging.h" +#include "scanner.hpp" +#include "ast.hpp" +#include "logging.hpp" #define _bt_list_first_entry(ptr, type, member) \ bt_list_entry((ptr)->next, type, member) diff --git a/src/plugins/ctf/common/msg-iter/Makefile.am b/src/plugins/ctf/common/msg-iter/Makefile.am index 3682a747..d963df77 100644 --- a/src/plugins/ctf/common/msg-iter/Makefile.am +++ b/src/plugins/ctf/common/msg-iter/Makefile.am @@ -3,5 +3,5 @@ noinst_LTLIBRARIES = libctf-msg-iter.la libctf_msg_iter_la_SOURCES = \ - msg-iter.c \ - msg-iter.h + msg-iter.cpp \ + msg-iter.hpp diff --git a/src/plugins/ctf/common/msg-iter/msg-iter.c b/src/plugins/ctf/common/msg-iter/msg-iter.cpp similarity index 98% rename from src/plugins/ctf/common/msg-iter/msg-iter.c rename to src/plugins/ctf/common/msg-iter/msg-iter.cpp index b56cf0c1..fd0cbf24 100644 --- a/src/plugins/ctf/common/msg-iter/msg-iter.c +++ b/src/plugins/ctf/common/msg-iter/msg-iter.cpp @@ -24,8 +24,8 @@ #include #include -#include "msg-iter.h" -#include "../bfcr/bfcr.h" +#include "msg-iter.hpp" +#include "../bfcr/bfcr.hpp" struct ctf_msg_iter; @@ -445,7 +445,7 @@ enum ctf_msg_iter_status msg_iter_status_from_m_status( enum ctf_msg_iter_medium_status m_status) { /* They are the same */ - return (int) m_status; + return (ctf_msg_iter_status) m_status; } static inline @@ -728,7 +728,7 @@ enum ctf_msg_iter_status switch_packet_state(struct ctf_msg_iter *msg_it) status = CTF_MSG_ITER_STATUS_OK; goto end; } else if (medium_status != CTF_MSG_ITER_MEDIUM_STATUS_OK) { - status = (int) medium_status; + status = msg_iter_status_from_m_status(medium_status); goto end; } @@ -865,7 +865,7 @@ enum ctf_msg_iter_status set_current_stream_class(struct ctf_msg_iter *msg_it) goto end; } - new_stream_class = msg_it->meta.tc->stream_classes->pdata[0]; + new_stream_class = (ctf_stream_class *) msg_it->meta.tc->stream_classes->pdata[0]; msg_it->cur_stream_class_id = new_stream_class->id; } @@ -1254,7 +1254,7 @@ enum ctf_msg_iter_status set_current_event_class(struct ctf_msg_iter *msg_it) goto end; } - new_event_class = msg_it->meta.sc->event_classes->pdata[0]; + new_event_class = (ctf_event_class *) msg_it->meta.sc->event_classes->pdata[0]; msg_it->cur_event_class_id = new_event_class->id; } @@ -1925,12 +1925,12 @@ static enum bt_bfcr_status bfcr_unsigned_int_cb(uint64_t value, struct ctf_field_class *fc, void *data) { - struct ctf_msg_iter *msg_it = data; + ctf_msg_iter *msg_it = (ctf_msg_iter *) data; bt_self_component *self_comp = msg_it->self_comp; enum bt_bfcr_status status = BT_BFCR_STATUS_OK; bt_field *field = NULL; - struct ctf_field_class_int *int_fc = (void *) fc; + ctf_field_class_int *int_fc = ctf_field_class_as_int(fc); BT_COMP_LOGT("Unsigned integer function called from BFCR: " "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, " @@ -2014,11 +2014,11 @@ enum bt_bfcr_status bfcr_unsigned_int_char_cb(uint64_t value, struct ctf_field_class *fc, void *data) { int ret; - struct ctf_msg_iter *msg_it = data; + ctf_msg_iter *msg_it = (ctf_msg_iter *) data; bt_self_component *self_comp = msg_it->self_comp; enum bt_bfcr_status status = BT_BFCR_STATUS_OK; bt_field *string_field = NULL; - struct ctf_field_class_int *int_fc = (void *) fc; + ctf_field_class_int *int_fc = ctf_field_class_as_int(fc); char str[2] = {'\0', '\0'}; BT_COMP_LOGT("Unsigned integer character function called from BFCR: " @@ -2068,8 +2068,8 @@ enum bt_bfcr_status bfcr_signed_int_cb(int64_t value, { enum bt_bfcr_status status = BT_BFCR_STATUS_OK; bt_field *field = NULL; - struct ctf_msg_iter *msg_it = data; - struct ctf_field_class_int *int_fc = (void *) fc; + ctf_msg_iter *msg_it = (ctf_msg_iter *) data; + ctf_field_class_int *int_fc = ctf_field_class_as_int(fc); BT_COMP_LOGT("Signed integer function called from BFCR: " "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, " @@ -2104,7 +2104,7 @@ enum bt_bfcr_status bfcr_floating_point_cb(double value, { enum bt_bfcr_status status = BT_BFCR_STATUS_OK; bt_field *field = NULL; - struct ctf_msg_iter *msg_it = data; + ctf_msg_iter *msg_it = (ctf_msg_iter *) data; bt_field_class_type type; BT_COMP_LOGT("Floating point number function called from BFCR: " @@ -2138,7 +2138,7 @@ enum bt_bfcr_status bfcr_string_begin_cb( struct ctf_field_class *fc, void *data) { bt_field *field = NULL; - struct ctf_msg_iter *msg_it = data; + ctf_msg_iter *msg_it = (ctf_msg_iter *) data; BT_COMP_LOGT("String (beginning) function called from BFCR: " "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, " @@ -2173,7 +2173,7 @@ enum bt_bfcr_status bfcr_string_cb(const char *value, { enum bt_bfcr_status status = BT_BFCR_STATUS_OK; bt_field *field = NULL; - struct ctf_msg_iter *msg_it = data; + ctf_msg_iter *msg_it = (ctf_msg_iter *) data; bt_self_component *self_comp = msg_it->self_comp; int ret; @@ -2209,7 +2209,7 @@ static enum bt_bfcr_status bfcr_string_end_cb( struct ctf_field_class *fc, void *data) { - struct ctf_msg_iter *msg_it = data; + ctf_msg_iter *msg_it = (ctf_msg_iter *) data; BT_COMP_LOGT("String (end) function called from BFCR: " "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, " @@ -2234,7 +2234,7 @@ static enum bt_bfcr_status bfcr_compound_begin_cb( struct ctf_field_class *fc, void *data) { - struct ctf_msg_iter *msg_it = data; + ctf_msg_iter *msg_it = (ctf_msg_iter *) data; bt_field *field; BT_COMP_LOGT("Compound (beginning) function called from BFCR: " @@ -2266,7 +2266,7 @@ enum bt_bfcr_status bfcr_compound_begin_cb( */ if (fc->type == CTF_FIELD_CLASS_TYPE_ARRAY || fc->type == CTF_FIELD_CLASS_TYPE_SEQUENCE) { - struct ctf_field_class_array_base *array_fc = (void *) fc; + ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc); if (array_fc->is_text) { BT_ASSERT_DBG(bt_field_get_class_type(field) == @@ -2286,7 +2286,7 @@ static enum bt_bfcr_status bfcr_compound_end_cb( struct ctf_field_class *fc, void *data) { - struct ctf_msg_iter *msg_it = data; + ctf_msg_iter *msg_it = (ctf_msg_iter *) data; BT_COMP_LOGT("Compound (end) function called from BFCR: " "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, " @@ -2307,7 +2307,7 @@ enum bt_bfcr_status bfcr_compound_end_cb( */ if (fc->type == CTF_FIELD_CLASS_TYPE_ARRAY || fc->type == CTF_FIELD_CLASS_TYPE_SEQUENCE) { - struct ctf_field_class_array_base *array_fc = (void *) fc; + ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc); if (array_fc->is_text) { BT_ASSERT_DBG(bt_field_get_class_type( @@ -2334,9 +2334,9 @@ static int64_t bfcr_get_sequence_length_cb(struct ctf_field_class *fc, void *data) { bt_field *seq_field; - struct ctf_msg_iter *msg_it = data; + ctf_msg_iter *msg_it = (ctf_msg_iter *) data; bt_self_component *self_comp = msg_it->self_comp; - struct ctf_field_class_sequence *seq_fc = (void *) fc; + struct ctf_field_class_sequence *seq_fc = ctf_field_class_as_sequence(fc); int64_t length; int ret; @@ -2382,8 +2382,8 @@ struct ctf_field_class *bfcr_borrow_variant_selected_field_class_cb( int ret; uint64_t i; int64_t option_index = -1; - struct ctf_msg_iter *msg_it = data; - struct ctf_field_class_variant *var_fc = (void *) fc; + ctf_msg_iter *msg_it = (ctf_msg_iter *) data; + ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc); struct ctf_named_field_class *selected_option = NULL; bt_self_component *self_comp = msg_it->self_comp; struct ctf_field_class *ret_fc = NULL; @@ -3077,7 +3077,7 @@ enum ctf_msg_iter_status read_packet_header_context_fields( int ret; enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK; - status = decode_until_state(msg_it, STATE_EMIT_MSG_PACKET_BEGINNING, -1); + status = decode_until_state(msg_it, STATE_EMIT_MSG_PACKET_BEGINNING, (state) -1); if (status != CTF_MSG_ITER_STATUS_OK) { goto end; } @@ -3144,7 +3144,7 @@ enum ctf_msg_iter_status ctf_msg_iter_curr_packet_first_event_clock_snapshot( struct ctf_msg_iter *msg_it, uint64_t *first_clock_snapshot) { return clock_snapshot_at_msg_iter_state(msg_it, - STATE_AFTER_EVENT_HEADER, -1, first_clock_snapshot); + STATE_AFTER_EVENT_HEADER, (state) -1, first_clock_snapshot); } BT_HIDDEN diff --git a/src/plugins/ctf/common/msg-iter/msg-iter.h b/src/plugins/ctf/common/msg-iter/msg-iter.hpp similarity index 99% rename from src/plugins/ctf/common/msg-iter/msg-iter.h rename to src/plugins/ctf/common/msg-iter/msg-iter.hpp index edba6847..393da16b 100644 --- a/src/plugins/ctf/common/msg-iter/msg-iter.h +++ b/src/plugins/ctf/common/msg-iter/msg-iter.hpp @@ -17,7 +17,7 @@ #include #include "common/macros.h" -#include "../metadata/ctf-meta.h" +#include "../metadata/ctf-meta.hpp" /** * @file ctf-msg-iter.h diff --git a/src/plugins/ctf/common/print.h b/src/plugins/ctf/common/print.hpp similarity index 100% rename from src/plugins/ctf/common/print.h rename to src/plugins/ctf/common/print.hpp diff --git a/src/plugins/ctf/fs-sink/Makefile.am b/src/plugins/ctf/fs-sink/Makefile.am index 5303df76..ef6e3992 100644 --- a/src/plugins/ctf/fs-sink/Makefile.am +++ b/src/plugins/ctf/fs-sink/Makefile.am @@ -4,14 +4,14 @@ noinst_LTLIBRARIES = libbabeltrace2-plugin-ctf-fs-sink.la libbabeltrace2_plugin_ctf_fs_sink_la_LIBADD = libbabeltrace2_plugin_ctf_fs_sink_la_SOURCES = \ - fs-sink.c \ - fs-sink.h \ - fs-sink-ctf-meta.h \ - translate-trace-ir-to-ctf-ir.c \ - translate-trace-ir-to-ctf-ir.h \ - translate-ctf-ir-to-tsdl.c \ - translate-ctf-ir-to-tsdl.h \ - fs-sink-stream.c \ - fs-sink-stream.h \ - fs-sink-trace.c \ - fs-sink-trace.h + fs-sink.cpp \ + fs-sink.hpp \ + fs-sink-ctf-meta.hpp \ + translate-trace-ir-to-ctf-ir.cpp \ + translate-trace-ir-to-ctf-ir.hpp \ + translate-ctf-ir-to-tsdl.cpp \ + translate-ctf-ir-to-tsdl.hpp \ + fs-sink-stream.cpp \ + fs-sink-stream.hpp \ + fs-sink-trace.cpp \ + fs-sink-trace.hpp diff --git a/src/plugins/ctf/fs-sink/fs-sink-ctf-meta.h b/src/plugins/ctf/fs-sink/fs-sink-ctf-meta.hpp similarity index 81% rename from src/plugins/ctf/fs-sink/fs-sink-ctf-meta.h rename to src/plugins/ctf/fs-sink/fs-sink-ctf-meta.hpp index e2045da3..8e30ab90 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-ctf-meta.h +++ b/src/plugins/ctf/fs-sink/fs-sink-ctf-meta.hpp @@ -109,6 +109,109 @@ struct fs_sink_ctf_field_class_sequence { bool length_is_before; }; +static inline +fs_sink_ctf_field_class_bit_array *fs_sink_ctf_field_class_as_bit_array( + fs_sink_ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || (fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_BIT_ARRAY || + fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_INT || + fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL || + fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT)); + + return (fs_sink_ctf_field_class_bit_array *) fc; +} + +static inline +fs_sink_ctf_field_class_bool *fs_sink_ctf_field_class_as_bool( + fs_sink_ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL); + + return (fs_sink_ctf_field_class_bool *) fc; +} + +static inline +fs_sink_ctf_field_class_int *fs_sink_ctf_field_class_as_int( + fs_sink_ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_INT); + + return (fs_sink_ctf_field_class_int *) fc; +} + +static inline +fs_sink_ctf_field_class_float *fs_sink_ctf_field_class_as_float( + fs_sink_ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT); + + return (fs_sink_ctf_field_class_float *) fc; +} + +static inline +fs_sink_ctf_field_class_string *fs_sink_ctf_field_class_as_string( + fs_sink_ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_STRING); + + return (fs_sink_ctf_field_class_string *) fc; +} + +static inline +fs_sink_ctf_field_class_struct *fs_sink_ctf_field_class_as_struct( + fs_sink_ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT); + + return (fs_sink_ctf_field_class_struct *) fc; +} + +static inline +fs_sink_ctf_field_class_array_base *fs_sink_ctf_field_class_as_array_base( + fs_sink_ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || (fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY || + fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE)); + + return (fs_sink_ctf_field_class_array_base *) fc; +} + +static inline +fs_sink_ctf_field_class_array *fs_sink_ctf_field_class_as_array( + fs_sink_ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY); + + return (fs_sink_ctf_field_class_array *) fc; +} + +static inline +fs_sink_ctf_field_class_sequence *fs_sink_ctf_field_class_as_sequence( + fs_sink_ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE); + + return (fs_sink_ctf_field_class_sequence *) fc; +} + +static inline +fs_sink_ctf_field_class_option *fs_sink_ctf_field_class_as_option( + fs_sink_ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION); + + return (fs_sink_ctf_field_class_option *) fc; +} + +static inline +fs_sink_ctf_field_class_variant *fs_sink_ctf_field_class_as_variant( + fs_sink_ctf_field_class *fc) +{ + BT_ASSERT_DBG(!fc || fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT); + + return (fs_sink_ctf_field_class_variant *) fc; +} + struct fs_sink_ctf_stream_class; struct fs_sink_ctf_event_class { @@ -197,7 +300,7 @@ void _fs_sink_ctf_field_class_bit_array_init( const bt_field_class *ir_fc, unsigned int size, uint64_t index_in_parent) { - _fs_sink_ctf_field_class_init((void *) fc, type, ir_fc, + _fs_sink_ctf_field_class_init(&fc->base, type, ir_fc, size % 8 == 0 ? 8 : 1, index_in_parent); fc->size = size; } @@ -209,7 +312,7 @@ void _fs_sink_ctf_field_class_int_init(struct fs_sink_ctf_field_class_int *fc, { bt_field_class_type ir_fc_type = bt_field_class_get_type(ir_fc); - _fs_sink_ctf_field_class_bit_array_init((void *) fc, type, ir_fc, + _fs_sink_ctf_field_class_bit_array_init(&fc->base, type, ir_fc, (unsigned int) bt_field_class_integer_get_field_value_range( ir_fc), index_in_parent); @@ -250,7 +353,7 @@ fs_sink_ctf_field_class_bit_array_create( g_new0(struct fs_sink_ctf_field_class_bit_array, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_bit_array_init((void *) fc, + _fs_sink_ctf_field_class_bit_array_init(fc, FS_SINK_CTF_FIELD_CLASS_TYPE_BIT_ARRAY, ir_fc, (unsigned int) bt_field_class_bit_array_get_length(ir_fc), index_in_parent); @@ -270,7 +373,7 @@ struct fs_sink_ctf_field_class_bool *fs_sink_ctf_field_class_bool_create( * CTF 1.8 has no boolean field class type, so this component * translates it to an 8-bit unsigned integer field class. */ - _fs_sink_ctf_field_class_bit_array_init((void *) fc, + _fs_sink_ctf_field_class_bit_array_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL, ir_fc, 8, index_in_parent); return fc; @@ -297,7 +400,7 @@ struct fs_sink_ctf_field_class_float *fs_sink_ctf_field_class_float_create( g_new0(struct fs_sink_ctf_field_class_float, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_bit_array_init((void *) fc, + _fs_sink_ctf_field_class_bit_array_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT, ir_fc, bt_field_class_get_type(ir_fc) == @@ -314,7 +417,7 @@ struct fs_sink_ctf_field_class_string *fs_sink_ctf_field_class_string_create( g_new0(struct fs_sink_ctf_field_class_string, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_init((void *) fc, + _fs_sink_ctf_field_class_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_STRING, ir_fc, 8, index_in_parent); return fc; @@ -328,7 +431,7 @@ struct fs_sink_ctf_field_class_struct *fs_sink_ctf_field_class_struct_create_emp g_new0(struct fs_sink_ctf_field_class_struct, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_init((void *) fc, + _fs_sink_ctf_field_class_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT, ir_fc, 1, index_in_parent); fc->members = g_array_new(FALSE, TRUE, sizeof(struct fs_sink_ctf_named_field_class)); @@ -344,7 +447,7 @@ struct fs_sink_ctf_field_class_option *fs_sink_ctf_field_class_option_create_emp g_new0(struct fs_sink_ctf_field_class_option, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_init((void *) fc, + _fs_sink_ctf_field_class_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION, ir_fc, 1, index_in_parent); fc->tag_ref = g_string_new(NULL); @@ -360,7 +463,7 @@ struct fs_sink_ctf_field_class_variant *fs_sink_ctf_field_class_variant_create_e g_new0(struct fs_sink_ctf_field_class_variant, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_init((void *) fc, + _fs_sink_ctf_field_class_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT, ir_fc, 1, index_in_parent); fc->options = g_array_new(FALSE, TRUE, @@ -382,7 +485,7 @@ struct fs_sink_ctf_field_class_array *fs_sink_ctf_field_class_array_create_empty g_new0(struct fs_sink_ctf_field_class_array, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_init((void *) fc, + _fs_sink_ctf_field_class_init(&fc->base.base, FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY, ir_fc, 1, index_in_parent); fc->length = bt_field_class_array_static_get_length(ir_fc); @@ -397,7 +500,7 @@ struct fs_sink_ctf_field_class_sequence *fs_sink_ctf_field_class_sequence_create g_new0(struct fs_sink_ctf_field_class_sequence, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_init((void *) fc, + _fs_sink_ctf_field_class_init(&fc->base.base, FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE, ir_fc, 1, index_in_parent); fc->length_ref = g_string_new(NULL); @@ -426,19 +529,19 @@ void _fs_sink_ctf_field_class_fini(struct fs_sink_ctf_field_class *fc) static inline void _fs_sink_ctf_field_class_bit_array_destroy( - struct fs_sink_ctf_field_class_int *fc) + struct fs_sink_ctf_field_class_bit_array *fc) { BT_ASSERT(fc); - _fs_sink_ctf_field_class_fini((void *) fc); + _fs_sink_ctf_field_class_fini(&fc->base); g_free(fc); } static inline void _fs_sink_ctf_field_class_bool_destroy( - struct fs_sink_ctf_field_class_int *fc) + struct fs_sink_ctf_field_class_bool *fc) { BT_ASSERT(fc); - _fs_sink_ctf_field_class_fini((void *) fc); + _fs_sink_ctf_field_class_fini(&fc->base.base); g_free(fc); } @@ -447,7 +550,7 @@ void _fs_sink_ctf_field_class_int_destroy( struct fs_sink_ctf_field_class_int *fc) { BT_ASSERT(fc); - _fs_sink_ctf_field_class_fini((void *) fc); + _fs_sink_ctf_field_class_fini(&fc->base.base); g_free(fc); } @@ -456,7 +559,7 @@ void _fs_sink_ctf_field_class_float_destroy( struct fs_sink_ctf_field_class_float *fc) { BT_ASSERT(fc); - _fs_sink_ctf_field_class_fini((void *) fc); + _fs_sink_ctf_field_class_fini(&fc->base.base); g_free(fc); } @@ -465,7 +568,7 @@ void _fs_sink_ctf_field_class_string_destroy( struct fs_sink_ctf_field_class_string *fc) { BT_ASSERT(fc); - _fs_sink_ctf_field_class_fini((void *) fc); + _fs_sink_ctf_field_class_fini(&fc->base); g_free(fc); } @@ -474,7 +577,7 @@ void _fs_sink_ctf_field_class_struct_destroy( struct fs_sink_ctf_field_class_struct *fc) { BT_ASSERT(fc); - _fs_sink_ctf_field_class_fini((void *) fc); + _fs_sink_ctf_field_class_fini(&fc->base); if (fc->members) { uint64_t i; @@ -499,7 +602,7 @@ void _fs_sink_ctf_field_class_array_base_fini( struct fs_sink_ctf_field_class_array_base *fc) { BT_ASSERT(fc); - _fs_sink_ctf_field_class_fini((void *) fc); + _fs_sink_ctf_field_class_fini(&fc->base); fs_sink_ctf_field_class_destroy(fc->elem_fc); fc->elem_fc = NULL; } @@ -509,7 +612,7 @@ void _fs_sink_ctf_field_class_array_destroy( struct fs_sink_ctf_field_class_array *fc) { BT_ASSERT(fc); - _fs_sink_ctf_field_class_array_base_fini((void *) fc); + _fs_sink_ctf_field_class_array_base_fini(&fc->base); g_free(fc); } @@ -518,7 +621,7 @@ void _fs_sink_ctf_field_class_sequence_destroy( struct fs_sink_ctf_field_class_sequence *fc) { BT_ASSERT(fc); - _fs_sink_ctf_field_class_array_base_fini((void *) fc); + _fs_sink_ctf_field_class_array_base_fini(&fc->base); if (fc->length_ref) { g_string_free(fc->length_ref, TRUE); @@ -533,7 +636,7 @@ void _fs_sink_ctf_field_class_option_destroy( struct fs_sink_ctf_field_class_option *fc) { BT_ASSERT(fc); - _fs_sink_ctf_field_class_fini((void *) fc); + _fs_sink_ctf_field_class_fini(&fc->base); fs_sink_ctf_field_class_destroy(fc->content_fc); if (fc->tag_ref) { @@ -549,7 +652,7 @@ void _fs_sink_ctf_field_class_variant_destroy( struct fs_sink_ctf_field_class_variant *fc) { BT_ASSERT(fc); - _fs_sink_ctf_field_class_fini((void *) fc); + _fs_sink_ctf_field_class_fini(&fc->base); if (fc->options) { uint64_t i; @@ -583,34 +686,34 @@ void fs_sink_ctf_field_class_destroy(struct fs_sink_ctf_field_class *fc) switch (fc->type) { case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL: - _fs_sink_ctf_field_class_bool_destroy((void *) fc); + _fs_sink_ctf_field_class_bool_destroy(fs_sink_ctf_field_class_as_bool(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_BIT_ARRAY: - _fs_sink_ctf_field_class_bit_array_destroy((void *) fc); + _fs_sink_ctf_field_class_bit_array_destroy(fs_sink_ctf_field_class_as_bit_array(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_INT: - _fs_sink_ctf_field_class_int_destroy((void *) fc); + _fs_sink_ctf_field_class_int_destroy(fs_sink_ctf_field_class_as_int(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT: - _fs_sink_ctf_field_class_float_destroy((void *) fc); + _fs_sink_ctf_field_class_float_destroy(fs_sink_ctf_field_class_as_float(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_STRING: - _fs_sink_ctf_field_class_string_destroy((void *) fc); + _fs_sink_ctf_field_class_string_destroy(fs_sink_ctf_field_class_as_string(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT: - _fs_sink_ctf_field_class_struct_destroy((void *) fc); + _fs_sink_ctf_field_class_struct_destroy(fs_sink_ctf_field_class_as_struct(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY: - _fs_sink_ctf_field_class_array_destroy((void *) fc); + _fs_sink_ctf_field_class_array_destroy(fs_sink_ctf_field_class_as_array(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE: - _fs_sink_ctf_field_class_sequence_destroy((void *) fc); + _fs_sink_ctf_field_class_sequence_destroy(fs_sink_ctf_field_class_as_sequence(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION: - _fs_sink_ctf_field_class_option_destroy((void *) fc); + _fs_sink_ctf_field_class_option_destroy(fs_sink_ctf_field_class_as_option(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT: - _fs_sink_ctf_field_class_variant_destroy((void *) fc); + _fs_sink_ctf_field_class_variant_destroy(fs_sink_ctf_field_class_as_variant(fc)); break; default: bt_common_abort(); @@ -686,9 +789,9 @@ fs_sink_ctf_field_class_struct_borrow_member_int_field_class_by_name( { struct fs_sink_ctf_field_class_int *int_fc = NULL; - int_fc = (void *) + int_fc = fs_sink_ctf_field_class_as_int( fs_sink_ctf_field_class_struct_borrow_member_field_class_by_name( - struct_fc, name); + struct_fc, name)); if (!int_fc) { goto end; } diff --git a/src/plugins/ctf/fs-sink/fs-sink-stream.c b/src/plugins/ctf/fs-sink/fs-sink-stream.cpp similarity index 90% rename from src/plugins/ctf/fs-sink/fs-sink-stream.c rename to src/plugins/ctf/fs-sink/fs-sink-stream.cpp index b14e6d55..da0a6083 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-stream.c +++ b/src/plugins/ctf/fs-sink/fs-sink-stream.cpp @@ -17,10 +17,10 @@ #include "ctfser/ctfser.h" #include "compat/endian.h" -#include "fs-sink.h" -#include "fs-sink-trace.h" -#include "fs-sink-stream.h" -#include "translate-trace-ir-to-ctf-ir.h" +#include "fs-sink.hpp" +#include "fs-sink-trace.hpp" +#include "fs-sink-stream.hpp" +#include "translate-trace-ir-to-ctf-ir.hpp" BT_HIDDEN void fs_sink_stream_destroy(struct fs_sink_stream *stream) @@ -53,7 +53,7 @@ bool stream_file_name_exists(struct fs_sink_trace *trace, const char *name) g_hash_table_iter_init(&iter, trace->streams); while (g_hash_table_iter_next(&iter, &key, &value)) { - struct fs_sink_stream *stream = value; + struct fs_sink_stream *stream = (fs_sink_stream *) value; if (strcmp(name, stream->file_name->str) == 0) { exists = true; @@ -184,7 +184,7 @@ int write_field(struct fs_sink_stream *stream, static inline int write_bool_field(struct fs_sink_stream *stream, - struct fs_sink_ctf_field_class_int *fc, const bt_field *field) + struct fs_sink_ctf_field_class_bool *fc, const bt_field *field) { /* * CTF 1.8 has no boolean field class type, so this component @@ -258,7 +258,7 @@ int write_string_field(struct fs_sink_stream *stream, } static inline -int write_array_field_elements(struct fs_sink_stream *stream, +int write_array_base_field_elements(struct fs_sink_stream *stream, struct fs_sink_ctf_field_class_array_base *fc, const bt_field *field) { @@ -295,7 +295,7 @@ int write_sequence_field(struct fs_sink_stream *stream, } } - ret = write_array_field_elements(stream, (void *) fc, field); + ret = write_array_base_field_elements(stream, &fc->base, field); end: return ret; @@ -403,34 +403,44 @@ int write_field(struct fs_sink_stream *stream, switch (fc->type) { case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL: - ret = write_bool_field(stream, (void *) fc, field); + ret = write_bool_field(stream, + fs_sink_ctf_field_class_as_bool(fc), field); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_BIT_ARRAY: - ret = write_bit_array_field(stream, (void *) fc, field); + ret = write_bit_array_field(stream, + fs_sink_ctf_field_class_as_bit_array(fc), field); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_INT: - ret = write_int_field(stream, (void *) fc, field); + ret = write_int_field(stream, + fs_sink_ctf_field_class_as_int(fc), field); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT: - ret = write_float_field(stream, (void *) fc, field); + ret = write_float_field(stream, + fs_sink_ctf_field_class_as_float(fc), field); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_STRING: - ret = write_string_field(stream, (void *) fc, field); + ret = write_string_field(stream, + fs_sink_ctf_field_class_as_string(fc), field); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT: - ret = write_struct_field(stream, (void *) fc, field, true); + ret = write_struct_field(stream, + fs_sink_ctf_field_class_as_struct(fc), field, true); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY: - ret = write_array_field_elements(stream, (void *) fc, field); + ret = write_array_base_field_elements(stream, + fs_sink_ctf_field_class_as_array_base(fc), field); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE: - ret = write_sequence_field(stream, (void *) fc, field); + ret = write_sequence_field(stream, + fs_sink_ctf_field_class_as_sequence(fc), field); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION: - ret = write_option_field(stream, (void *) fc, field); + ret = write_option_field(stream, + fs_sink_ctf_field_class_as_option(fc), field); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT: - ret = write_variant_field(stream, (void *) fc, field); + ret = write_variant_field(stream, + fs_sink_ctf_field_class_as_variant(fc), field); break; default: bt_common_abort(); @@ -485,7 +495,7 @@ int fs_sink_stream_write_event(struct fs_sink_stream *stream, field = bt_event_borrow_common_context_field_const(event); BT_ASSERT_DBG(field); ret = write_struct_field(stream, - (void *) stream->sc->event_common_context_fc, + fs_sink_ctf_field_class_as_struct(stream->sc->event_common_context_fc), field, true); if (G_UNLIKELY(ret)) { goto end; @@ -496,7 +506,8 @@ int fs_sink_stream_write_event(struct fs_sink_stream *stream, if (ec->spec_context_fc) { field = bt_event_borrow_specific_context_field_const(event); BT_ASSERT_DBG(field); - ret = write_struct_field(stream, (void *) ec->spec_context_fc, + ret = write_struct_field(stream, + fs_sink_ctf_field_class_as_struct(ec->spec_context_fc), field, true); if (G_UNLIKELY(ret)) { goto end; @@ -507,7 +518,8 @@ int fs_sink_stream_write_event(struct fs_sink_stream *stream, if (ec->payload_fc) { field = bt_event_borrow_payload_field_const(event); BT_ASSERT_DBG(field); - ret = write_struct_field(stream, (void *) ec->payload_fc, + ret = write_struct_field(stream, + fs_sink_ctf_field_class_as_struct(ec->payload_fc), field, true); if (G_UNLIKELY(ret)) { goto end; @@ -581,7 +593,7 @@ int write_packet_context(struct fs_sink_stream *stream) stream->packet_state.packet); BT_ASSERT(packet_context_field); ret = write_struct_field(stream, - (void *) stream->sc->packet_context_fc, + fs_sink_ctf_field_class_as_struct(stream->sc->packet_context_fc), packet_context_field, false); if (ret) { goto end; @@ -640,7 +652,7 @@ int fs_sink_stream_open_packet(struct fs_sink_stream *stream, bt_stream_class_get_id(stream->sc->ir_sc), 8, 64, BYTE_ORDER); if (ret) { BT_COMP_LOGE("Error writing packet header stream class id: " - "stream-file-name=%s, stream-class-id=%"PRIu64, + "stream-file-name=%s, stream-class-id=%" PRIu64, stream->file_name->str, bt_stream_class_get_id(stream->sc->ir_sc)); goto end; @@ -651,7 +663,7 @@ int fs_sink_stream_open_packet(struct fs_sink_stream *stream, bt_stream_get_id(stream->ir_stream), 8, 64, BYTE_ORDER); if (ret) { BT_COMP_LOGE("Error writing packet header stream id: " - "stream-file-name=%s, stream-id=%"PRIu64, + "stream-file-name=%s, stream-id=%" PRIu64, stream->file_name->str, bt_stream_get_id(stream->ir_stream)); goto end; diff --git a/src/plugins/ctf/fs-sink/fs-sink-stream.h b/src/plugins/ctf/fs-sink/fs-sink-stream.hpp similarity index 99% rename from src/plugins/ctf/fs-sink/fs-sink-stream.h rename to src/plugins/ctf/fs-sink/fs-sink-stream.hpp index a6acdd56..3a1e1707 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-stream.h +++ b/src/plugins/ctf/fs-sink/fs-sink-stream.hpp @@ -14,7 +14,7 @@ #include #include -#include "fs-sink-ctf-meta.h" +#include "fs-sink-ctf-meta.hpp" struct fs_sink_trace; diff --git a/src/plugins/ctf/fs-sink/fs-sink-trace.c b/src/plugins/ctf/fs-sink/fs-sink-trace.cpp similarity index 98% rename from src/plugins/ctf/fs-sink/fs-sink-trace.c rename to src/plugins/ctf/fs-sink/fs-sink-trace.cpp index 60f668ea..2be7d5ef 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-trace.c +++ b/src/plugins/ctf/fs-sink/fs-sink-trace.cpp @@ -16,11 +16,11 @@ #include "common/assert.h" #include "ctfser/ctfser.h" -#include "translate-trace-ir-to-ctf-ir.h" -#include "translate-ctf-ir-to-tsdl.h" -#include "fs-sink.h" -#include "fs-sink-trace.h" -#include "fs-sink-stream.h" +#include "translate-trace-ir-to-ctf-ir.hpp" +#include "translate-ctf-ir-to-tsdl.hpp" +#include "fs-sink.hpp" +#include "fs-sink-trace.hpp" +#include "fs-sink-stream.hpp" /* * Sanitizes `path` so as to: @@ -554,7 +554,7 @@ end: static void ir_trace_destruction_listener(const bt_trace *ir_trace, void *data) { - struct fs_sink_trace *trace = data; + struct fs_sink_trace *trace = (fs_sink_trace *) data; /* * Prevent bt_trace_remove_destruction_listener() from being diff --git a/src/plugins/ctf/fs-sink/fs-sink-trace.h b/src/plugins/ctf/fs-sink/fs-sink-trace.hpp similarity index 98% rename from src/plugins/ctf/fs-sink/fs-sink-trace.h rename to src/plugins/ctf/fs-sink/fs-sink-trace.hpp index 89c38efd..ae33573e 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-trace.h +++ b/src/plugins/ctf/fs-sink/fs-sink-trace.hpp @@ -13,7 +13,7 @@ #include #include -#include "fs-sink-ctf-meta.h" +#include "fs-sink-ctf-meta.hpp" struct fs_sink_comp; diff --git a/src/plugins/ctf/fs-sink/fs-sink.c b/src/plugins/ctf/fs-sink/fs-sink.cpp similarity index 96% rename from src/plugins/ctf/fs-sink/fs-sink.c rename to src/plugins/ctf/fs-sink/fs-sink.cpp index 4b077507..42a616c9 100644 --- a/src/plugins/ctf/fs-sink/fs-sink.c +++ b/src/plugins/ctf/fs-sink/fs-sink.cpp @@ -17,12 +17,12 @@ #include "ctfser/ctfser.h" #include "plugins/common/param-validation/param-validation.h" -#include "fs-sink.h" -#include "fs-sink-trace.h" -#include "fs-sink-stream.h" -#include "fs-sink-ctf-meta.h" -#include "translate-trace-ir-to-ctf-ir.h" -#include "translate-ctf-ir-to-tsdl.h" +#include "fs-sink.hpp" +#include "fs-sink-trace.hpp" +#include "fs-sink-stream.hpp" +#include "fs-sink-ctf-meta.hpp" +#include "translate-trace-ir-to-ctf-ir.hpp" +#include "translate-ctf-ir-to-tsdl.hpp" static const char * const in_port_name = "in"; @@ -49,12 +49,17 @@ end: return status; } -static struct bt_param_validation_map_value_entry_descr fs_sink_params_descr[] = { - { "path", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_MANDATORY, { .type = BT_VALUE_TYPE_STRING } }, - { "assume-single-trace", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, - { "ignore-discarded-events", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, - { "ignore-discarded-packets", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, - { "quiet", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, +static bt_param_validation_map_value_entry_descr fs_sink_params_descr[] = { + { "path", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_MANDATORY, + { bt_param_validation_value_descr::string_t } }, + { "assume-single-trace", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, + { bt_param_validation_value_descr::bool_t } }, + { "ignore-discarded-events", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, + { bt_param_validation_value_descr::bool_t } }, + { "ignore-discarded-packets", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, + { bt_param_validation_value_descr::bool_t } }, + { "quiet", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, + { bt_param_validation_value_descr::bool_t } }, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END }; @@ -202,7 +207,7 @@ bt_component_class_initialize_method_status ctf_fs_sink_init( add_port_status = bt_self_component_sink_add_input_port( self_comp_sink, in_port_name, NULL, NULL); if (add_port_status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) { - status = (int) add_port_status; + status = (bt_component_class_initialize_method_status) add_port_status; BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Failed to add input port."); goto end; } @@ -225,7 +230,7 @@ struct fs_sink_stream *borrow_stream(struct fs_sink_comp *fs_sink, struct fs_sink_trace *trace; struct fs_sink_stream *stream = NULL; - trace = g_hash_table_lookup(fs_sink->traces, ir_trace); + trace = (fs_sink_trace *) g_hash_table_lookup(fs_sink->traces, ir_trace); if (G_UNLIKELY(!trace)) { if (fs_sink->assume_single_trace && g_hash_table_size(fs_sink->traces) > 0) { @@ -242,7 +247,7 @@ struct fs_sink_stream *borrow_stream(struct fs_sink_comp *fs_sink, } } - stream = g_hash_table_lookup(trace->streams, ir_stream); + stream = (fs_sink_stream *) g_hash_table_lookup(trace->streams, ir_stream); if (G_UNLIKELY(!stream)) { stream = fs_sink_stream_create(trace, ir_stream); if (!stream) { @@ -1008,7 +1013,7 @@ bt_component_class_sink_consume_method_status ctf_fs_sink_consume( uint64_t msg_count = 0; bt_message_array_const msgs; - fs_sink = bt_self_component_get_data( + fs_sink = (fs_sink_comp *) bt_self_component_get_data( bt_self_component_sink_as_self_component(self_comp)); BT_ASSERT_DBG(fs_sink); BT_ASSERT_DBG(fs_sink->upstream_iter); @@ -1017,7 +1022,7 @@ bt_component_class_sink_consume_method_status ctf_fs_sink_consume( next_status = bt_message_iterator_next( fs_sink->upstream_iter, &msgs, &msg_count); if (next_status < 0) { - status = (int) next_status; + status = (bt_component_class_sink_consume_method_status) next_status; BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp, "Failed to get next message from upstream iterator."); goto end; @@ -1112,7 +1117,7 @@ ctf_fs_sink_graph_is_configured( bt_component_class_sink_graph_is_configured_method_status status; bt_message_iterator_create_from_sink_component_status msg_iter_status; - struct fs_sink_comp *fs_sink = bt_self_component_get_data( + fs_sink_comp *fs_sink = (fs_sink_comp *) bt_self_component_get_data( bt_self_component_sink_as_self_component(self_comp)); msg_iter_status = @@ -1121,7 +1126,7 @@ ctf_fs_sink_graph_is_configured( bt_self_component_sink_borrow_input_port_by_name( self_comp, in_port_name), &fs_sink->upstream_iter); if (msg_iter_status != BT_MESSAGE_ITERATOR_CREATE_FROM_SINK_COMPONENT_STATUS_OK) { - status = (int) msg_iter_status; + status = (bt_component_class_sink_graph_is_configured_method_status) msg_iter_status; BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp, "Failed to create upstream iterator."); goto end; @@ -1135,7 +1140,7 @@ end: BT_HIDDEN void ctf_fs_sink_finalize(bt_self_component_sink *self_comp) { - struct fs_sink_comp *fs_sink = bt_self_component_get_data( + fs_sink_comp *fs_sink = (fs_sink_comp *) bt_self_component_get_data( bt_self_component_sink_as_self_component(self_comp)); destroy_fs_sink_comp(fs_sink); diff --git a/src/plugins/ctf/fs-sink/fs-sink.h b/src/plugins/ctf/fs-sink/fs-sink.hpp similarity index 100% rename from src/plugins/ctf/fs-sink/fs-sink.h rename to src/plugins/ctf/fs-sink/fs-sink.hpp diff --git a/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c b/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.cpp similarity index 95% rename from src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c rename to src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.cpp index 85f6bee7..c93db6a6 100644 --- a/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c +++ b/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.cpp @@ -4,7 +4,7 @@ * Copyright 2019 Philippe Proulx */ -#include "translate-ctf-ir-to-tsdl.h" +#include "translate-ctf-ir-to-tsdl.hpp" #include #include "common/macros.h" @@ -15,7 +15,7 @@ #include "common/assert.h" #include "compat/endian.h" -#include "fs-sink-ctf-meta.h" +#include "fs-sink-ctf-meta.hpp" struct ctx { unsigned int indent_level; @@ -334,7 +334,7 @@ void append_float_field_class(struct ctx *ctx, static void append_string_field_class(struct ctx *ctx, - struct fs_sink_ctf_field_class_float *fc) + struct fs_sink_ctf_field_class_string *fc) { g_string_append(ctx->tsdl, "string { encoding = UTF8; }"); } @@ -360,14 +360,14 @@ void append_member(struct ctx *ctx, const char *name, if (fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY) { struct fs_sink_ctf_field_class_array *array_fc = - (void *) fc; + fs_sink_ctf_field_class_as_array(fc); g_string_append_printf(lengths, "[%" PRIu64 "]", array_fc->length); fc = array_fc->base.elem_fc; } else { struct fs_sink_ctf_field_class_sequence *seq_fc = - (void *) fc; + fs_sink_ctf_field_class_as_sequence(fc); g_string_append_printf(lengths, "[%s]", seq_fc->length_ref->str); @@ -407,7 +407,7 @@ void append_struct_field_class_members(struct ctx *ctx, */ if (fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE) { struct fs_sink_ctf_field_class_sequence *seq_fc = - (void *) fc; + fs_sink_ctf_field_class_as_sequence(fc); if (seq_fc->length_is_before) { append_indent(ctx); @@ -418,7 +418,7 @@ void append_struct_field_class_members(struct ctx *ctx, } } else if (fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION) { struct fs_sink_ctf_field_class_option *opt_fc = - (void *) fc; + fs_sink_ctf_field_class_as_option(fc); /* * CTF 1.8 does not support the option field @@ -454,7 +454,7 @@ void append_struct_field_class_members(struct ctx *ctx, opt_fc->tag_ref->str); } else if (fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT) { struct fs_sink_ctf_field_class_variant *var_fc = - (void *) fc; + fs_sink_ctf_field_class_as_variant(fc); if (var_fc->tag_is_before) { append_indent(ctx); @@ -549,28 +549,28 @@ void append_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class *fc) { switch (fc->type) { case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL: - append_bool_field_class(ctx, (void *) fc); + append_bool_field_class(ctx, fs_sink_ctf_field_class_as_bool(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_BIT_ARRAY: - append_bit_array_field_class(ctx, (void *) fc); + append_bit_array_field_class(ctx, fs_sink_ctf_field_class_as_bit_array(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_INT: - append_integer_field_class(ctx, (void *) fc); + append_integer_field_class(ctx, fs_sink_ctf_field_class_as_int(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT: - append_float_field_class(ctx, (void *) fc); + append_float_field_class(ctx, fs_sink_ctf_field_class_as_float(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_STRING: - append_string_field_class(ctx, (void *) fc); + append_string_field_class(ctx, fs_sink_ctf_field_class_as_string(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT: - append_struct_field_class(ctx, (void *) fc); + append_struct_field_class(ctx, fs_sink_ctf_field_class_as_struct(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION: - append_option_field_class(ctx, (void *) fc); + append_option_field_class(ctx, fs_sink_ctf_field_class_as_option(fc)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT: - append_variant_field_class(ctx, (void *) fc); + append_variant_field_class(ctx, fs_sink_ctf_field_class_as_variant(fc)); break; default: bt_common_abort(); @@ -815,9 +815,9 @@ void append_stream_class(struct ctx *ctx, if (sc->packet_context_fc) { append_struct_field_class_members(ctx, - (void *) sc->packet_context_fc); + fs_sink_ctf_field_class_as_struct(sc->packet_context_fc)); fs_sink_ctf_field_class_struct_align_at_least( - (void *) sc->packet_context_fc, 8); + fs_sink_ctf_field_class_as_struct(sc->packet_context_fc), 8); } /* End packet context field class */ @@ -850,8 +850,7 @@ void append_stream_class(struct ctx *ctx, if (sc->event_common_context_fc) { append_indent(ctx); g_string_append(ctx->tsdl, "event.context := "); - append_field_class(ctx, - (void *) sc->event_common_context_fc); + append_field_class(ctx, sc->event_common_context_fc); g_string_append(ctx->tsdl, ";\n"); } @@ -860,7 +859,8 @@ void append_stream_class(struct ctx *ctx, /* Event classes */ for (i = 0; i < sc->event_classes->len; i++) { - append_event_class(ctx, sc->event_classes->pdata[i]); + append_event_class(ctx, + (fs_sink_ctf_event_class *) sc->event_classes->pdata[i]); } } @@ -972,6 +972,7 @@ void translate_trace_ctf_ir_to_tsdl(struct fs_sink_ctf_trace *trace, /* Stream classes and their event classes */ for (i = 0; i < trace->stream_classes->len; i++) { - append_stream_class(&ctx, trace->stream_classes->pdata[i]); + append_stream_class(&ctx, + (fs_sink_ctf_stream_class *) trace->stream_classes->pdata[i]); } } diff --git a/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.h b/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.hpp similarity index 93% rename from src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.h rename to src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.hpp index 151e3c6f..b8a73e74 100644 --- a/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.h +++ b/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.hpp @@ -10,7 +10,7 @@ #include #include "common/macros.h" -#include "fs-sink-ctf-meta.h" +#include "fs-sink-ctf-meta.hpp" BT_HIDDEN void translate_trace_ctf_ir_to_tsdl(struct fs_sink_ctf_trace *trace, diff --git a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp similarity index 94% rename from src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c rename to src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp index 19ca9dcd..a2009949 100644 --- a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c +++ b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp @@ -9,7 +9,7 @@ #define BT_LOG_TAG "PLUGIN/SINK.CTF.FS/TRANSLATE-TRACE-IR-TO-CTF-IR" #include "logging/comp-logging.h" -#include "translate-trace-ir-to-ctf-ir.h" +#include "translate-trace-ir-to-ctf-ir.hpp" #include #include "common/macros.h" @@ -20,8 +20,8 @@ #include #include -#include "fs-sink.h" -#include "fs-sink-ctf-meta.h" +#include "fs-sink.hpp" +#include "fs-sink-ctf-meta.hpp" struct field_path_elem { uint64_t index_in_parent; @@ -317,21 +317,21 @@ int create_relative_field_ref(struct ctx *ctx, BT_ASSERT(bt_field_path_item_get_type(fp_item) == BT_FIELD_PATH_ITEM_TYPE_INDEX); named_fc = fs_sink_ctf_field_class_struct_borrow_member_by_index( - (void *) tgt_fc, + fs_sink_ctf_field_class_as_struct(tgt_fc), bt_field_path_item_index_get_index(fp_item)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT: BT_ASSERT(bt_field_path_item_get_type(fp_item) == BT_FIELD_PATH_ITEM_TYPE_INDEX); named_fc = fs_sink_ctf_field_class_variant_borrow_option_by_index( - (void *) tgt_fc, + fs_sink_ctf_field_class_as_variant(tgt_fc), bt_field_path_item_index_get_index(fp_item)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY: case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE: { struct fs_sink_ctf_field_class_array_base *array_base_fc = - (void *) tgt_fc; + fs_sink_ctf_field_class_as_array_base(tgt_fc); BT_ASSERT(bt_field_path_item_get_type(fp_item) == BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT); @@ -383,10 +383,10 @@ int create_relative_field_ref(struct ctx *ctx, } if (fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT) { - struct_fc = (void *) fc; + struct_fc = fs_sink_ctf_field_class_as_struct(fc); len = struct_fc->members->len; } else { - var_fc = (void *) fc; + var_fc = fs_sink_ctf_field_class_as_variant(fc); len = var_fc->options->len; } @@ -486,14 +486,14 @@ int create_absolute_field_ref(struct ctx *ctx, BT_ASSERT(bt_field_path_item_get_type(fp_item) == BT_FIELD_PATH_ITEM_TYPE_INDEX); named_fc = fs_sink_ctf_field_class_struct_borrow_member_by_index( - (void *) fc, + fs_sink_ctf_field_class_as_struct(fc), bt_field_path_item_index_get_index(fp_item)); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT: BT_ASSERT(bt_field_path_item_get_type(fp_item) == BT_FIELD_PATH_ITEM_TYPE_INDEX); named_fc = fs_sink_ctf_field_class_variant_borrow_option_by_index( - (void *) fc, + fs_sink_ctf_field_class_as_variant(fc), bt_field_path_item_index_get_index(fp_item)); break; default: @@ -588,13 +588,14 @@ void append_to_parent_field_class(struct ctx *ctx, switch (parent_fc->type) { case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT: - fs_sink_ctf_field_class_struct_append_member((void *) parent_fc, + fs_sink_ctf_field_class_struct_append_member( + fs_sink_ctf_field_class_as_struct(parent_fc), cur_path_stack_top(ctx)->name->str, fc); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION: { struct fs_sink_ctf_field_class_option *opt_fc = - (void *) parent_fc; + fs_sink_ctf_field_class_as_option(parent_fc); BT_ASSERT(!opt_fc->content_fc); opt_fc->content_fc = fc; @@ -602,14 +603,15 @@ void append_to_parent_field_class(struct ctx *ctx, break; } case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT: - fs_sink_ctf_field_class_variant_append_option((void *) parent_fc, + fs_sink_ctf_field_class_variant_append_option( + fs_sink_ctf_field_class_as_variant(parent_fc), cur_path_stack_top(ctx)->name->str, fc); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY: case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE: { struct fs_sink_ctf_field_class_array_base *array_base_fc = - (void *) parent_fc; + fs_sink_ctf_field_class_as_array_base(parent_fc); BT_ASSERT(!array_base_fc->elem_fc); array_base_fc->elem_fc = fc; @@ -631,13 +633,14 @@ void update_parent_field_class_alignment(struct ctx *ctx, switch (parent_fc->type) { case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT: fs_sink_ctf_field_class_struct_align_at_least( - (void *) parent_fc, alignment); + fs_sink_ctf_field_class_as_struct(parent_fc), + alignment); break; case FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY: case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE: { struct fs_sink_ctf_field_class_array_base *array_base_fc = - (void *) parent_fc; + fs_sink_ctf_field_class_as_array_base(parent_fc); array_base_fc->base.alignment = alignment; break; @@ -667,7 +670,7 @@ int translate_structure_field_class_members(struct ctx *ctx, memb_ir_fc = bt_field_class_structure_member_borrow_field_class_const( member); ret = cur_path_stack_push(ctx, i, name, true, memb_ir_fc, - (void *) struct_fc); + &struct_fc->base); if (ret) { BT_COMP_LOGE("Cannot translate structure field class member: " "name=\"%s\"", name); @@ -698,7 +701,7 @@ int translate_structure_field_class(struct ctx *ctx) cur_path_stack_top(ctx)->index_in_parent); BT_ASSERT(fc); - append_to_parent_field_class(ctx, (void *) fc); + append_to_parent_field_class(ctx, &fc->base); ret = translate_structure_field_class_members(ctx, fc, fc->base.ir_fc); if (ret) { goto end; @@ -787,7 +790,8 @@ int maybe_protect_variant_option_name(const bt_field_class *ir_var_fc, int ret = 0; uint64_t i; bt_field_class_type ir_var_fc_type; - const void *opt_ranges = NULL; + const bt_integer_range_set_unsigned *opt_ranges_unsigned = NULL; + const bt_integer_range_set_signed *opt_ranges_signed = NULL; const char *mapping_label = NULL; const char *ir_opt_name; const bt_field_class_variant_option *base_var_opt; @@ -822,14 +826,14 @@ int maybe_protect_variant_option_name(const bt_field_class *ir_var_fc, const bt_field_class_variant_with_selector_field_integer_unsigned_option *var_opt = bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const( ir_var_fc, opt_i); - opt_ranges = + opt_ranges_unsigned = bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const( var_opt); } else { const bt_field_class_variant_with_selector_field_integer_signed_option *var_opt = bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const( ir_var_fc, opt_i); - opt_ranges = + opt_ranges_signed = bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const( var_opt); } @@ -847,7 +851,7 @@ int maybe_protect_variant_option_name(const bt_field_class *ir_var_fc, mapping_ranges = bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const( mapping); - if (bt_integer_range_set_unsigned_is_equal(opt_ranges, + if (bt_integer_range_set_unsigned_is_equal(opt_ranges_unsigned, mapping_ranges)) { /* We have a winner */ mapping_base = @@ -868,7 +872,7 @@ int maybe_protect_variant_option_name(const bt_field_class *ir_var_fc, mapping_ranges = bt_field_class_enumeration_signed_mapping_borrow_ranges_const( mapping); - if (bt_integer_range_set_signed_is_equal(opt_ranges, + if (bt_integer_range_set_signed_is_equal(opt_ranges_signed, mapping_ranges)) { /* We have a winner */ mapping_base = @@ -941,9 +945,9 @@ int translate_option_field_class(struct ctx *ctx) * The "tag" is always generated/before in that case (an 8-bit * unsigned enumeration field class). */ - append_to_parent_field_class(ctx, (void *) fc); + append_to_parent_field_class(ctx, &fc->base); ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, content_ir_fc, - (void *) fc); + &fc->base); if (ret) { BT_COMP_LOGE_STR("Cannot translate option field class content."); goto end; @@ -1089,7 +1093,7 @@ validate_opts: } append_to_parent: - append_to_parent_field_class(ctx, (void *) fc); + append_to_parent_field_class(ctx, &fc->base); for (i = 0; i < opt_count; i++) { const bt_field_class_variant_option *opt; @@ -1112,7 +1116,7 @@ append_to_parent: * point. */ ret = cur_path_stack_push(ctx, i, prot_opt_name, false, - opt_ir_fc, (void *) fc); + opt_ir_fc, &fc->base); if (ret) { BT_COMP_LOGE("Cannot translate variant field class option: " "name=\"%s\"", prot_opt_name); @@ -1151,9 +1155,9 @@ int translate_static_array_field_class(struct ctx *ctx) int ret; BT_ASSERT(fc); - append_to_parent_field_class(ctx, (void *) fc); + append_to_parent_field_class(ctx, &fc->base.base); ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, elem_ir_fc, - (void *) fc); + &fc->base.base); if (ret) { BT_COMP_LOGE_STR("Cannot translate static array field class element."); goto end; @@ -1195,9 +1199,9 @@ int translate_dynamic_array_field_class(struct ctx *ctx) fc->length_ref, &fc->length_is_before, NULL); } - append_to_parent_field_class(ctx, (void *) fc); + append_to_parent_field_class(ctx, &fc->base.base); ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, elem_ir_fc, - (void *) fc); + &fc->base.base); if (ret) { BT_COMP_LOGE_STR("Cannot translate dynamic array field class element."); goto end; @@ -1225,7 +1229,7 @@ int translate_bool_field_class(struct ctx *ctx) cur_path_stack_top(ctx)->index_in_parent); BT_ASSERT(fc); - append_to_parent_field_class(ctx, (void *) fc); + append_to_parent_field_class(ctx, &fc->base.base); return 0; } @@ -1238,7 +1242,7 @@ int translate_bit_array_field_class(struct ctx *ctx) cur_path_stack_top(ctx)->index_in_parent); BT_ASSERT(fc); - append_to_parent_field_class(ctx, (void *) fc); + append_to_parent_field_class(ctx, &fc->base); return 0; } @@ -1251,7 +1255,7 @@ int translate_integer_field_class(struct ctx *ctx) cur_path_stack_top(ctx)->index_in_parent); BT_ASSERT(fc); - append_to_parent_field_class(ctx, (void *) fc); + append_to_parent_field_class(ctx, &fc->base.base); return 0; } @@ -1264,7 +1268,7 @@ int translate_real_field_class(struct ctx *ctx) cur_path_stack_top(ctx)->index_in_parent); BT_ASSERT(fc); - append_to_parent_field_class(ctx, (void *) fc); + append_to_parent_field_class(ctx, &fc->base.base); return 0; } @@ -1277,7 +1281,7 @@ int translate_string_field_class(struct ctx *ctx) cur_path_stack_top(ctx)->index_in_parent); BT_ASSERT(fc); - append_to_parent_field_class(ctx, (void *) fc); + append_to_parent_field_class(ctx, &fc->base); return 0; } @@ -1336,7 +1340,7 @@ int set_field_ref(struct fs_sink_ctf_field_class *fc, const char *fc_name, bool is_before; const char *tgt_type; struct fs_sink_ctf_field_class_struct *parent_struct_fc = - (void *) parent_fc; + fs_sink_ctf_field_class_as_struct(parent_fc); uint64_t i; unsigned int suffix = 0; @@ -1365,7 +1369,8 @@ int set_field_ref(struct fs_sink_ctf_field_class *fc, const char *fc_name, * The "tag" is always generated/before in that case (an * 8-bit unsigned enumeration field class). */ - struct fs_sink_ctf_field_class_option *opt_fc = (void *) fc; + struct fs_sink_ctf_field_class_option *opt_fc = + fs_sink_ctf_field_class_as_option(fc); field_ref = opt_fc->tag_ref; is_before = true; @@ -1374,7 +1379,8 @@ int set_field_ref(struct fs_sink_ctf_field_class *fc, const char *fc_name, } case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE: { - struct fs_sink_ctf_field_class_sequence *seq_fc = (void *) fc; + struct fs_sink_ctf_field_class_sequence *seq_fc = + fs_sink_ctf_field_class_as_sequence(fc); field_ref = seq_fc->length_ref; is_before = seq_fc->length_is_before; @@ -1383,7 +1389,8 @@ int set_field_ref(struct fs_sink_ctf_field_class *fc, const char *fc_name, } case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT: { - struct fs_sink_ctf_field_class_variant *var_fc = (void *) fc; + struct fs_sink_ctf_field_class_variant *var_fc = + fs_sink_ctf_field_class_as_variant(fc); field_ref = var_fc->tag_ref; is_before = var_fc->tag_is_before; @@ -1461,7 +1468,8 @@ int set_field_refs(struct fs_sink_ctf_field_class * const fc, switch (fc_type) { case FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION: { - struct fs_sink_ctf_field_class_option *opt_fc = (void *) fc; + struct fs_sink_ctf_field_class_option *opt_fc = + fs_sink_ctf_field_class_as_option(fc); ret = set_field_ref(fc, fc_name, parent_fc); if (ret) { @@ -1485,10 +1493,10 @@ int set_field_refs(struct fs_sink_ctf_field_class * const fc, struct fs_sink_ctf_named_field_class *named_fc; if (fc_type == FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT) { - struct_fc = (void *) fc; + struct_fc = fs_sink_ctf_field_class_as_struct(fc); len = struct_fc->members->len; } else { - var_fc = (void *) fc; + var_fc = fs_sink_ctf_field_class_as_variant(fc); len = var_fc->options->len; ret = set_field_ref(fc, fc_name, parent_fc); if (ret) { @@ -1518,7 +1526,7 @@ int set_field_refs(struct fs_sink_ctf_field_class * const fc, case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE: { struct fs_sink_ctf_field_class_array_base *array_base_fc = - (void *) fc; + fs_sink_ctf_field_class_as_array_base(fc); if (fc_type == FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE) { ret = set_field_ref(fc, fc_name, parent_fc); @@ -1567,8 +1575,8 @@ int translate_scope_field_class(struct ctx *ctx, bt_field_path_scope scope, BT_ASSERT(bt_field_class_get_type(ir_fc) == BT_FIELD_CLASS_TYPE_STRUCTURE); BT_ASSERT(fc); - *fc = (void *) fs_sink_ctf_field_class_struct_create_empty( - ir_fc, UINT64_C(-1)); + *fc = &fs_sink_ctf_field_class_struct_create_empty( + ir_fc, UINT64_C(-1))->base; BT_ASSERT(*fc); ctx->cur_scope = scope; BT_ASSERT(ctx->cur_path->len == 0); @@ -1579,7 +1587,8 @@ int translate_scope_field_class(struct ctx *ctx, bt_field_path_scope scope, goto end; } - ret = translate_structure_field_class_members(ctx, (void *) *fc, ir_fc); + ret = translate_structure_field_class_members(ctx, + fs_sink_ctf_field_class_as_struct(*fc), ir_fc); if (ret) { BT_COMP_LOGE("Cannot translate scope structure field class: " "scope=%d", scope); @@ -1667,7 +1676,8 @@ int try_translate_event_class_trace_ir_to_ctf_ir( BT_ASSERT(ir_ec); /* Check in hash table first */ - *out_ec = g_hash_table_lookup(sc->event_classes_from_ir, ir_ec); + *out_ec = (fs_sink_ctf_event_class *) g_hash_table_lookup( + sc->event_classes_from_ir, ir_ec); if (G_LIKELY(*out_ec)) { goto end; } @@ -1687,7 +1697,7 @@ bool default_clock_class_name_exists(struct fs_sink_ctf_trace *trace, for (i = 0; i < trace->stream_classes->len; i++) { struct fs_sink_ctf_stream_class *sc = - trace->stream_classes->pdata[i]; + (fs_sink_ctf_stream_class *) trace->stream_classes->pdata[i]; if (sc->default_clock_class_name->len == 0) { /* No default clock class */ @@ -1780,7 +1790,7 @@ int translate_stream_class(struct fs_sink_comp *fs_sink, * in the packet context. */ fs_sink_ctf_field_class_struct_align_at_least( - (void *) (*out_sc)->packet_context_fc, 8); + fs_sink_ctf_field_class_as_struct((*out_sc)->packet_context_fc), 8); } ret = translate_scope_field_class(&ctx, BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT, @@ -1816,7 +1826,7 @@ int try_translate_stream_class_trace_ir_to_ctf_ir( BT_ASSERT(ir_sc); for (i = 0; i < trace->stream_classes->len; i++) { - *out_sc = trace->stream_classes->pdata[i]; + *out_sc = (fs_sink_ctf_stream_class *) trace->stream_classes->pdata[i]; if ((*out_sc)->ir_sc == ir_sc) { goto end; diff --git a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.h b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.hpp similarity index 94% rename from src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.h rename to src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.hpp index 3f038739..76213de1 100644 --- a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.h +++ b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.hpp @@ -10,8 +10,8 @@ #include "common/macros.h" #include -#include "fs-sink.h" -#include "fs-sink-ctf-meta.h" +#include "fs-sink.hpp" +#include "fs-sink-ctf-meta.hpp" BT_HIDDEN int try_translate_event_class_trace_ir_to_ctf_ir( diff --git a/src/plugins/ctf/fs-src/Makefile.am b/src/plugins/ctf/fs-src/Makefile.am index b59c7620..cb990b69 100644 --- a/src/plugins/ctf/fs-src/Makefile.am +++ b/src/plugins/ctf/fs-src/Makefile.am @@ -3,14 +3,14 @@ noinst_LTLIBRARIES = libbabeltrace2-plugin-ctf-fs-src.la libbabeltrace2_plugin_ctf_fs_src_la_SOURCES = \ - data-stream-file.c \ - data-stream-file.h \ - file.c \ - file.h \ - fs.c \ - fs.h \ - lttng-index.h \ - metadata.c \ - metadata.h \ - query.h \ - query.c + data-stream-file.cpp \ + data-stream-file.hpp \ + file.cpp \ + file.hpp \ + fs.cpp \ + fs.hpp \ + lttng-index.hpp \ + metadata.cpp \ + metadata.hpp \ + query.hpp \ + query.cpp diff --git a/src/plugins/ctf/fs-src/data-stream-file.c b/src/plugins/ctf/fs-src/data-stream-file.cpp similarity index 97% rename from src/plugins/ctf/fs-src/data-stream-file.c rename to src/plugins/ctf/fs-src/data-stream-file.cpp index 7d4ccf5a..8608ff71 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.c +++ b/src/plugins/ctf/fs-src/data-stream-file.cpp @@ -21,11 +21,11 @@ #include "compat/endian.h" #include #include "common/common.h" -#include "file.h" -#include "metadata.h" -#include "../common/msg-iter/msg-iter.h" +#include "file.hpp" +#include "metadata.hpp" +#include "../common/msg-iter/msg-iter.hpp" #include "common/assert.h" -#include "data-stream-file.h" +#include "data-stream-file.hpp" #include static inline @@ -195,7 +195,7 @@ enum ctf_msg_iter_medium_status medop_request_bytes( { enum ctf_msg_iter_medium_status status = CTF_MSG_ITER_MEDIUM_STATUS_OK; - struct ctf_fs_ds_file *ds_file = data; + struct ctf_fs_ds_file *ds_file = (struct ctf_fs_ds_file *) data; bt_self_component *self_comp = ds_file->self_comp; bt_logging_level log_level = ds_file->log_level; @@ -248,7 +248,7 @@ static bt_stream *medop_borrow_stream(bt_stream_class *stream_class, int64_t stream_id, void *data) { - struct ctf_fs_ds_file *ds_file = data; + struct ctf_fs_ds_file *ds_file = (struct ctf_fs_ds_file *) data; bt_stream_class *ds_file_stream_class; bt_stream *stream = NULL; @@ -272,7 +272,7 @@ end: static enum ctf_msg_iter_medium_status medop_seek(off_t offset, void *data) { - struct ctf_fs_ds_file *ds_file = data; + struct ctf_fs_ds_file *ds_file = (struct ctf_fs_ds_file *) data; BT_ASSERT(offset >= 0); BT_ASSERT(offset < ds_file->file->size); @@ -282,9 +282,10 @@ enum ctf_msg_iter_medium_status medop_seek(off_t offset, void *data) BT_HIDDEN struct ctf_msg_iter_medium_ops ctf_fs_ds_file_medops = { - .request_bytes = medop_request_bytes, - .borrow_stream = medop_borrow_stream, - .seek = medop_seek, + medop_request_bytes, + medop_seek, + nullptr, + medop_borrow_stream, }; struct ctf_fs_ds_group_medops_data { @@ -318,7 +319,7 @@ enum ctf_msg_iter_medium_status medop_group_request_bytes( size_t *buffer_sz, void *void_data) { - struct ctf_fs_ds_group_medops_data *data = void_data; + struct ctf_fs_ds_group_medops_data *data = (struct ctf_fs_ds_group_medops_data *) void_data; /* Return bytes from the current file. */ return medop_request_bytes(request_sz, buffer_addr, buffer_sz, data->file); @@ -330,7 +331,7 @@ bt_stream *medop_group_borrow_stream( int64_t stream_id, void *void_data) { - struct ctf_fs_ds_group_medops_data *data = void_data; + struct ctf_fs_ds_group_medops_data *data = (struct ctf_fs_ds_group_medops_data *) void_data; return medop_borrow_stream(stream_class, stream_id, data->file); } @@ -390,7 +391,7 @@ end: static enum ctf_msg_iter_medium_status medop_group_switch_packet(void *void_data) { - struct ctf_fs_ds_group_medops_data *data = void_data; + struct ctf_fs_ds_group_medops_data *data = (struct ctf_fs_ds_group_medops_data *) void_data; struct ctf_fs_ds_index_entry *index_entry; enum ctf_msg_iter_medium_status status; @@ -405,7 +406,7 @@ enum ctf_msg_iter_medium_status medop_group_switch_packet(void *void_data) * Otherwise, look up the next index entry / packet and prepare it * for reading. */ - index_entry = g_ptr_array_index( + index_entry = (struct ctf_fs_ds_index_entry *) g_ptr_array_index( data->ds_file_group->index->entries, data->next_index_entry_index); @@ -488,14 +489,15 @@ void ctf_fs_ds_group_medops_data_reset(struct ctf_fs_ds_group_medops_data *data) struct ctf_msg_iter_medium_ops ctf_fs_ds_group_medops = { .request_bytes = medop_group_request_bytes, - .borrow_stream = medop_group_borrow_stream, - .switch_packet = medop_group_switch_packet, /* * We don't support seeking using this medops. It would probably be * possible, but it's not needed at the moment. */ .seek = NULL, + + .switch_packet = medop_group_switch_packet, + .borrow_stream = medop_group_borrow_stream, }; static diff --git a/src/plugins/ctf/fs-src/data-stream-file.h b/src/plugins/ctf/fs-src/data-stream-file.hpp similarity index 97% rename from src/plugins/ctf/fs-src/data-stream-file.h rename to src/plugins/ctf/fs-src/data-stream-file.hpp index ec28e0d5..9bd1e501 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.h +++ b/src/plugins/ctf/fs-src/data-stream-file.hpp @@ -13,8 +13,8 @@ #include "common/macros.h" #include -#include "../common/msg-iter/msg-iter.h" -#include "lttng-index.h" +#include "../common/msg-iter/msg-iter.hpp" +#include "lttng-index.hpp" struct ctf_fs_component; struct ctf_fs_file; diff --git a/src/plugins/ctf/fs-src/file.c b/src/plugins/ctf/fs-src/file.cpp similarity index 99% rename from src/plugins/ctf/fs-src/file.c rename to src/plugins/ctf/fs-src/file.cpp index b705ca42..42b865a8 100644 --- a/src/plugins/ctf/fs-src/file.c +++ b/src/plugins/ctf/fs-src/file.cpp @@ -14,7 +14,7 @@ #include #include #include -#include "file.h" +#include "file.hpp" BT_HIDDEN void ctf_fs_file_destroy(struct ctf_fs_file *file) diff --git a/src/plugins/ctf/fs-src/file.h b/src/plugins/ctf/fs-src/file.hpp similarity index 96% rename from src/plugins/ctf/fs-src/file.h rename to src/plugins/ctf/fs-src/file.hpp index c127e6c0..e828423d 100644 --- a/src/plugins/ctf/fs-src/file.h +++ b/src/plugins/ctf/fs-src/file.hpp @@ -10,7 +10,7 @@ #include #include #include "common/macros.h" -#include "fs.h" +#include "fs.hpp" BT_HIDDEN void ctf_fs_file_destroy(struct ctf_fs_file *file); diff --git a/src/plugins/ctf/fs-src/fs.c b/src/plugins/ctf/fs-src/fs.cpp similarity index 93% rename from src/plugins/ctf/fs-src/fs.c rename to src/plugins/ctf/fs-src/fs.cpp index f3104b80..0e6e96e2 100644 --- a/src/plugins/ctf/fs-src/fs.c +++ b/src/plugins/ctf/fs-src/fs.cpp @@ -19,14 +19,14 @@ #include "common/assert.h" #include #include -#include "fs.h" -#include "metadata.h" -#include "data-stream-file.h" -#include "file.h" -#include "../common/metadata/decoder.h" -#include "../common/metadata/ctf-meta-configure-ir-trace.h" -#include "../common/msg-iter/msg-iter.h" -#include "query.h" +#include "fs.hpp" +#include "metadata.hpp" +#include "data-stream-file.hpp" +#include "file.hpp" +#include "../common/metadata/decoder.hpp" +#include "../common/metadata/ctf-meta-configure-ir-trace.hpp" +#include "../common/msg-iter/msg-iter.hpp" +#include "query.hpp" #include "plugins/common/param-validation/param-validation.h" struct tracer_info { @@ -113,7 +113,7 @@ bt_message_iterator_class_next_method_status ctf_fs_iterator_next( { bt_message_iterator_class_next_method_status status; struct ctf_fs_msg_iter_data *msg_iter_data = - bt_self_message_iterator_get_data(iterator); + (struct ctf_fs_msg_iter_data *) bt_self_message_iterator_get_data(iterator); uint64_t i = 0; if (G_UNLIKELY(msg_iter_data->next_saved_error)) { @@ -172,7 +172,7 @@ bt_message_iterator_class_seek_beginning_method_status ctf_fs_iterator_seek_beginning(bt_self_message_iterator *it) { struct ctf_fs_msg_iter_data *msg_iter_data = - bt_self_message_iterator_get_data(it); + (struct ctf_fs_msg_iter_data *) bt_self_message_iterator_get_data(it); BT_ASSERT(msg_iter_data); @@ -186,7 +186,7 @@ BT_HIDDEN void ctf_fs_iterator_finalize(bt_self_message_iterator *it) { ctf_fs_msg_iter_data_destroy( - bt_self_message_iterator_get_data(it)); + (struct ctf_fs_msg_iter_data *) bt_self_message_iterator_get_data(it)); } static @@ -222,7 +222,7 @@ bt_message_iterator_class_initialize_method_status ctf_fs_iterator_init( bt_self_component *self_comp = bt_self_message_iterator_borrow_component(self_msg_iter); - port_data = bt_self_component_port_get_data( + port_data = (struct ctf_fs_port_data *) bt_self_component_port_get_data( bt_self_component_port_output_as_self_component_port( self_port)); BT_ASSERT(port_data); @@ -342,13 +342,13 @@ void port_data_destroy(struct ctf_fs_port_data *port_data) static void port_data_destroy_notifier(void *data) { - port_data_destroy(data); + port_data_destroy((struct ctf_fs_port_data *) data); } static void ctf_fs_trace_destroy_notifier(void *data) { - struct ctf_fs_trace *trace = data; + struct ctf_fs_trace *trace = (struct ctf_fs_trace *) data; ctf_fs_trace_destroy(trace); } @@ -381,7 +381,7 @@ end: void ctf_fs_finalize(bt_self_component_source *component) { - ctf_fs_destroy(bt_self_component_get_data( + ctf_fs_destroy((struct ctf_fs_component *) bt_self_component_get_data( bt_self_component_source_as_self_component(component))); } @@ -422,7 +422,7 @@ gchar *ctf_fs_make_port_name(struct ctf_fs_ds_file_group *ds_file_group) } else { BT_ASSERT(ds_file_group->ds_file_infos->len == 1); struct ctf_fs_ds_file_info *ds_file_info = - g_ptr_array_index(ds_file_group->ds_file_infos, 0); + (struct ctf_fs_ds_file_info *) g_ptr_array_index(ds_file_group->ds_file_infos, 0); g_string_append_printf(name, " | %s", ds_file_info->path->str); } @@ -491,7 +491,7 @@ int create_ports_for_trace(struct ctf_fs_component *ctf_fs, /* Create one output port for each stream file group */ for (i = 0; i < ctf_fs_trace->ds_file_groups->len; i++) { struct ctf_fs_ds_file_group *ds_file_group = - g_ptr_array_index(ctf_fs_trace->ds_file_groups, i); + (struct ctf_fs_ds_file_group *) g_ptr_array_index(ctf_fs_trace->ds_file_groups, i); ret = create_one_port_for_trace(ctf_fs, ctf_fs_trace, ds_file_group, self_comp_src); @@ -632,7 +632,7 @@ void ds_file_group_insert_ds_file_info_sorted( /* Find the spot where to insert this ds_file_info. */ for (i = 0; i < ds_file_group->ds_file_infos->len; i++) { struct ctf_fs_ds_file_info *other_ds_file_info = - g_ptr_array_index(ds_file_group->ds_file_infos, i); + (struct ctf_fs_ds_file_info *) g_ptr_array_index(ds_file_group->ds_file_infos, i); if (ds_file_info->begin_ns < other_ds_file_info->begin_ns) { break; @@ -685,7 +685,7 @@ void ds_index_insert_ds_index_entry_sorted( /* Find the spot where to insert this index entry. */ for (i = 0; i < index->entries->len; i++) { - other_entry = g_ptr_array_index(index->entries, i); + other_entry = (struct ctf_fs_ds_index_entry *) g_ptr_array_index(index->entries, i); if (entry->timestamp_begin_ns <= other_entry->timestamp_begin_ns) { break; @@ -714,7 +714,7 @@ void merge_ctf_fs_ds_indexes(struct ctf_fs_ds_index *dest, struct ctf_fs_ds_inde for (i = 0; i < src->entries->len; i++) { struct ctf_fs_ds_index_entry *entry = - g_ptr_array_index(src->entries, i); + (struct ctf_fs_ds_index_entry *) g_ptr_array_index(src->entries, i); /* * Ownership of the ctf_fs_ds_index_entry is transferred to @@ -846,7 +846,7 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, /* Find an existing stream file group with this ID */ for (i = 0; i < ctf_fs_trace->ds_file_groups->len; i++) { - ds_file_group = g_ptr_array_index( + ds_file_group = (struct ctf_fs_ds_file_group *) g_ptr_array_index( ctf_fs_trace->ds_file_groups, i); if (ds_file_group->sc == sc && @@ -1241,7 +1241,8 @@ unsigned int metadata_count_stream_and_event_classes(struct ctf_fs_trace *trace) guint i; for (i = 0; i < trace->metadata->tc->stream_classes->len; i++) { - struct ctf_stream_class *sc = trace->metadata->tc->stream_classes->pdata[i]; + struct ctf_stream_class *sc = + (struct ctf_stream_class *) trace->metadata->tc->stream_classes->pdata[i]; num += sc->event_classes->len; } @@ -1260,7 +1261,7 @@ void merge_ctf_fs_ds_file_groups(struct ctf_fs_ds_file_group *dest, struct ctf_f for (i = 0; i < src->ds_file_infos->len; i++) { struct ctf_fs_ds_file_info *ds_file_info = - g_ptr_array_index(src->ds_file_infos, i); + (struct ctf_fs_ds_file_info *) g_ptr_array_index(src->ds_file_infos, i); /* Ownership of the ds_file_info is transferred to dest. */ g_ptr_array_index(src->ds_file_infos, i) = NULL; @@ -1291,7 +1292,8 @@ int merge_matching_ctf_fs_ds_file_groups( const guint dest_len = dest->len; for (s_i = 0; s_i < src->len; s_i++) { - struct ctf_fs_ds_file_group *src_group = g_ptr_array_index(src, s_i); + struct ctf_fs_ds_file_group *src_group = + (struct ctf_fs_ds_file_group *) g_ptr_array_index(src, s_i); struct ctf_fs_ds_file_group *dest_group = NULL; /* A stream instance without ID can't match a stream in the other trace. */ @@ -1300,7 +1302,8 @@ int merge_matching_ctf_fs_ds_file_groups( /* Let's search for a matching ds_file_group in the destination. */ for (d_i = 0; d_i < dest_len; d_i++) { - struct ctf_fs_ds_file_group *candidate_dest = g_ptr_array_index(dest, d_i); + struct ctf_fs_ds_file_group *candidate_dest = + (struct ctf_fs_ds_file_group *) g_ptr_array_index(dest, d_i); /* Can't match a stream instance without ID. */ if (candidate_dest->stream_id == -1) { @@ -1586,7 +1589,7 @@ int fix_index_lttng_event_after_packet_bug(struct ctf_fs_trace *trace) struct ctf_fs_ds_index *index; struct ctf_fs_ds_file_group *ds_file_group = - g_ptr_array_index(ds_file_groups, ds_file_group_i); + (struct ctf_fs_ds_file_group *) g_ptr_array_index(ds_file_groups, ds_file_group_i); BT_ASSERT(ds_file_group); index = ds_file_group->index; @@ -1603,8 +1606,8 @@ int fix_index_lttng_event_after_packet_bug(struct ctf_fs_trace *trace) entry_i++) { struct ctf_fs_ds_index_entry *curr_entry, *next_entry; - curr_entry = g_ptr_array_index(index->entries, entry_i); - next_entry = g_ptr_array_index(index->entries, entry_i + 1); + curr_entry = (ctf_fs_ds_index_entry *) g_ptr_array_index(index->entries, entry_i); + next_entry = (ctf_fs_ds_index_entry *) g_ptr_array_index(index->entries, entry_i + 1); /* * 1. Set the current index entry `end` timestamp to @@ -1618,7 +1621,7 @@ int fix_index_lttng_event_after_packet_bug(struct ctf_fs_trace *trace) * 2. Fix the last entry by decoding the last event of the last * packet. */ - last_entry = g_ptr_array_index(index->entries, + last_entry = (ctf_fs_ds_index_entry *) g_ptr_array_index(index->entries, index->entries->len - 1); BT_ASSERT(last_entry); @@ -1669,8 +1672,8 @@ int fix_index_barectf_event_before_packet_bug(struct ctf_fs_trace *trace) ds_file_group_i++) { guint entry_i; struct ctf_clock_class *default_cc; - struct ctf_fs_ds_file_group *ds_file_group = - g_ptr_array_index(ds_file_groups, ds_file_group_i); + ctf_fs_ds_file_group *ds_file_group = + (ctf_fs_ds_file_group *) g_ptr_array_index(ds_file_groups, ds_file_group_i); struct ctf_fs_ds_index *index = ds_file_group->index; @@ -1687,9 +1690,10 @@ int fix_index_barectf_event_before_packet_bug(struct ctf_fs_trace *trace) */ for (entry_i = 1; entry_i < index->entries->len; entry_i++) { - struct ctf_fs_ds_index_entry *curr_entry, *prev_entry; - prev_entry = g_ptr_array_index(index->entries, entry_i - 1); - curr_entry = g_ptr_array_index(index->entries, entry_i); + ctf_fs_ds_index_entry *prev_entry = + (ctf_fs_ds_index_entry *) g_ptr_array_index(index->entries, entry_i - 1); + ctf_fs_ds_index_entry *curr_entry = + (ctf_fs_ds_index_entry *) g_ptr_array_index(index->entries, entry_i); /* * 2. Set the current entry `begin` timestamp to the * timestamp of the first event of the current packet. @@ -1744,11 +1748,10 @@ int fix_index_lttng_crash_quirk(struct ctf_fs_trace *trace) ds_file_group_idx++) { guint entry_idx; struct ctf_clock_class *default_cc; - struct ctf_fs_ds_index_entry *last_entry; struct ctf_fs_ds_index *index; - struct ctf_fs_ds_file_group *ds_file_group = - g_ptr_array_index(ds_file_groups, ds_file_group_idx); + ctf_fs_ds_file_group *ds_file_group = + (ctf_fs_ds_file_group *) g_ptr_array_index(ds_file_groups, ds_file_group_idx); BT_ASSERT(ds_file_group); index = ds_file_group->index; @@ -1760,8 +1763,9 @@ int fix_index_lttng_crash_quirk(struct ctf_fs_trace *trace) BT_ASSERT(index->entries); BT_ASSERT(index->entries->len > 0); - last_entry = g_ptr_array_index(index->entries, - index->entries->len - 1); + ctf_fs_ds_index_entry *last_entry = + (ctf_fs_ds_index_entry *) g_ptr_array_index(index->entries, + index->entries->len - 1); BT_ASSERT(last_entry); @@ -1786,9 +1790,10 @@ int fix_index_lttng_crash_quirk(struct ctf_fs_trace *trace) /* Iterate over all entries but the last one. */ for (entry_idx = 0; entry_idx < index->entries->len - 1; entry_idx++) { - struct ctf_fs_ds_index_entry *curr_entry, *next_entry; - curr_entry = g_ptr_array_index(index->entries, entry_idx); - next_entry = g_ptr_array_index(index->entries, entry_idx + 1); + ctf_fs_ds_index_entry *curr_entry = + (ctf_fs_ds_index_entry *) g_ptr_array_index(index->entries, entry_idx); + ctf_fs_ds_index_entry *next_entry = + (ctf_fs_ds_index_entry *) g_ptr_array_index(index->entries, entry_idx + 1); if (curr_entry->timestamp_end == 0 && curr_entry->timestamp_begin != 0) { @@ -2032,15 +2037,19 @@ end: static gint compare_ds_file_groups_by_first_path(gconstpointer a, gconstpointer b) { - struct ctf_fs_ds_file_group * const *ds_file_group_a = a; - struct ctf_fs_ds_file_group * const *ds_file_group_b = b; - const struct ctf_fs_ds_file_info *first_ds_file_info_a; - const struct ctf_fs_ds_file_info *first_ds_file_info_b; + ctf_fs_ds_file_group * const *ds_file_group_a = + (ctf_fs_ds_file_group **) a; + ctf_fs_ds_file_group * const *ds_file_group_b = + (ctf_fs_ds_file_group **) b; BT_ASSERT((*ds_file_group_a)->ds_file_infos->len > 0); BT_ASSERT((*ds_file_group_b)->ds_file_infos->len > 0); - first_ds_file_info_a = (*ds_file_group_a)->ds_file_infos->pdata[0]; - first_ds_file_info_b = (*ds_file_group_b)->ds_file_infos->pdata[0]; + + const ctf_fs_ds_file_info *first_ds_file_info_a = + (const ctf_fs_ds_file_info *) (*ds_file_group_a)->ds_file_infos->pdata[0]; + const ctf_fs_ds_file_info *first_ds_file_info_b = + (const ctf_fs_ds_file_info *) (*ds_file_group_b)->ds_file_infos->pdata[0]; + return strcmp(first_ds_file_info_a->path->str, first_ds_file_info_b->path->str); } @@ -2111,7 +2120,7 @@ int ctf_fs_component_create_ctf_fs_trace( /* Create a separate ctf_fs_trace object for each path. */ for (i = 0; i < paths->len; i++) { - const char *path = g_ptr_array_index(paths, i); + const char *path = (const char *) g_ptr_array_index(paths, i); ret = ctf_fs_component_create_ctf_fs_trace_one_path(ctf_fs, path, trace_name, traces, self_comp, self_comp_class); @@ -2169,7 +2178,7 @@ int ctf_fs_component_create_ctf_fs_trace( ctf_fs->trace = trace; } else { /* Just one trace, it may or may not have a UUID, both are fine. */ - ctf_fs->trace = traces->pdata[0]; + ctf_fs->trace = (ctf_fs_trace *) traces->pdata[0]; traces->pdata[0] = NULL; } @@ -2227,7 +2236,7 @@ GString *get_stream_instance_unique_name( * the stream's unique name. */ BT_ASSERT(ds_file_group->ds_file_infos->len > 0); - ds_file_info = g_ptr_array_index(ds_file_group->ds_file_infos, 0); + ds_file_info = (ctf_fs_ds_file_info *) g_ptr_array_index(ds_file_group->ds_file_infos, 0); g_string_assign(name, ds_file_info->path->str); end: @@ -2246,8 +2255,8 @@ int create_streams_for_trace(struct ctf_fs_trace *ctf_fs_trace) bt_self_component *self_comp = ctf_fs_trace->self_comp; for (i = 0; i < ctf_fs_trace->ds_file_groups->len; i++) { - struct ctf_fs_ds_file_group *ds_file_group = - g_ptr_array_index(ctf_fs_trace->ds_file_groups, i); + ctf_fs_ds_file_group *ds_file_group = + (ctf_fs_ds_file_group *) g_ptr_array_index(ctf_fs_trace->ds_file_groups, i); name = get_stream_instance_unique_name(ds_file_group); if (!name) { @@ -2310,23 +2319,23 @@ end: return ret; } -static const struct bt_param_validation_value_descr inputs_elem_descr = { - .type = BT_VALUE_TYPE_STRING, +static const bt_param_validation_value_descr inputs_elem_descr{ + bt_param_validation_value_descr::string_t }; -static const struct bt_param_validation_map_value_entry_descr fs_params_entries_descr[] = { - { "inputs", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_MANDATORY, { - BT_VALUE_TYPE_ARRAY, - .array = { - .min_length = 1, - .max_length = BT_PARAM_VALIDATION_INFINITE, - .element_type = &inputs_elem_descr, - } - }}, - { "trace-name", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_STRING } }, - { "clock-class-offset-s", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_SIGNED_INTEGER } }, - { "clock-class-offset-ns", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_SIGNED_INTEGER } }, - { "force-clock-class-origin-unix-epoch", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, + +static bt_param_validation_map_value_entry_descr fs_params_entries_descr[] = { + {"inputs", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_MANDATORY, + {bt_param_validation_value_descr::array_t, 1, + BT_PARAM_VALIDATION_INFINITE, inputs_elem_descr}}, + {"trace-name", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, + {bt_param_validation_value_descr::string_t}}, + { "clock-class-offset-s", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, + { bt_param_validation_value_descr::signed_integer_t }}, + { "clock-class-offset-ns", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, + { bt_param_validation_value_descr::signed_integer_t }}, + { "force-clock-class-origin-unix-epoch", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, + { bt_param_validation_value_descr::bool_t }}, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END }; diff --git a/src/plugins/ctf/fs-src/fs.h b/src/plugins/ctf/fs-src/fs.hpp similarity index 98% rename from src/plugins/ctf/fs-src/fs.h rename to src/plugins/ctf/fs-src/fs.hpp index e7cffe51..da8a3cbc 100644 --- a/src/plugins/ctf/fs-src/fs.h +++ b/src/plugins/ctf/fs-src/fs.hpp @@ -13,9 +13,9 @@ #include #include "common/macros.h" #include -#include "data-stream-file.h" -#include "metadata.h" -#include "../common/metadata/decoder.h" +#include "data-stream-file.hpp" +#include "metadata.hpp" +#include "../common/metadata/decoder.hpp" BT_HIDDEN extern bool ctf_fs_debug; diff --git a/src/plugins/ctf/fs-src/lttng-index.h b/src/plugins/ctf/fs-src/lttng-index.hpp similarity index 100% rename from src/plugins/ctf/fs-src/lttng-index.h rename to src/plugins/ctf/fs-src/lttng-index.hpp diff --git a/src/plugins/ctf/fs-src/metadata.c b/src/plugins/ctf/fs-src/metadata.cpp similarity index 83% rename from src/plugins/ctf/fs-src/metadata.c rename to src/plugins/ctf/fs-src/metadata.cpp index e517ff8d..51bd5b96 100644 --- a/src/plugins/ctf/fs-src/metadata.c +++ b/src/plugins/ctf/fs-src/metadata.cpp @@ -19,10 +19,10 @@ #include "compat/memstream.h" #include -#include "fs.h" -#include "file.h" -#include "metadata.h" -#include "../common/metadata/decoder.h" +#include "fs.hpp" +#include "file.hpp" +#include "metadata.hpp" +#include "../common/metadata/decoder.hpp" BT_HIDDEN FILE *ctf_fs_metadata_open_file(const char *trace_path) @@ -78,17 +78,17 @@ int ctf_fs_metadata_set_trace_class( { int ret = 0; struct ctf_fs_file *file = NULL; - struct ctf_metadata_decoder_config decoder_config = { - .log_level = ctf_fs_trace->log_level, - .self_comp = self_comp, - .clock_class_offset_s = config ? config->clock_class_offset_s : 0, - .clock_class_offset_ns = config ? config->clock_class_offset_ns : 0, - .force_clock_class_origin_unix_epoch = - config ? config->force_clock_class_origin_unix_epoch : false, - .create_trace_class = true, - }; bt_logging_level log_level = ctf_fs_trace->log_level; + ctf_metadata_decoder_config decoder_config{}; + decoder_config.log_level = ctf_fs_trace->log_level, + decoder_config.self_comp = self_comp, + decoder_config.clock_class_offset_s = config ? config->clock_class_offset_s : 0, + decoder_config.clock_class_offset_ns = config ? config->clock_class_offset_ns : 0, + decoder_config.force_clock_class_origin_unix_epoch = + config ? config->force_clock_class_origin_unix_epoch : false, + decoder_config.create_trace_class = true, + file = get_file(ctf_fs_trace->path->str, log_level, self_comp); if (!file) { BT_COMP_LOGE("Cannot create metadata file object."); diff --git a/src/plugins/ctf/fs-src/metadata.h b/src/plugins/ctf/fs-src/metadata.hpp similarity index 100% rename from src/plugins/ctf/fs-src/metadata.h rename to src/plugins/ctf/fs-src/metadata.hpp diff --git a/src/plugins/ctf/fs-src/query.c b/src/plugins/ctf/fs-src/query.cpp similarity index 96% rename from src/plugins/ctf/fs-src/query.c rename to src/plugins/ctf/fs-src/query.cpp index adc8f4d1..04d5aab8 100644 --- a/src/plugins/ctf/fs-src/query.c +++ b/src/plugins/ctf/fs-src/query.cpp @@ -10,7 +10,7 @@ #define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/QUERY" #include "logging/log.h" -#include "query.h" +#include "query.hpp" #include #include #include @@ -18,20 +18,20 @@ #include #include #include "common/assert.h" -#include "metadata.h" -#include "../common/metadata/decoder.h" +#include "metadata.hpp" +#include "../common/metadata/decoder.hpp" #include "common/common.h" #include "common/macros.h" #include -#include "fs.h" +#include "fs.hpp" #include "logging/comp-logging.h" #define METADATA_TEXT_SIG "/* CTF 1.8" struct range { - int64_t begin_ns; - int64_t end_ns; - bool set; + int64_t begin_ns = 0; + int64_t end_ns = 0; + bool set = false; }; BT_HIDDEN @@ -52,7 +52,7 @@ bt_component_class_query_method_status metadata_info_query( const char *path; bool is_packetized; struct ctf_metadata_decoder *decoder = NULL; - struct ctf_metadata_decoder_config decoder_cfg = { 0 }; + ctf_metadata_decoder_config decoder_cfg{}; enum ctf_metadata_decoder_status decoder_status; result = bt_value_map_create(); @@ -295,9 +295,9 @@ int populate_trace_info(const struct ctf_fs_trace *trace, bt_value *trace_info, for (group_idx = 0; group_idx < trace->ds_file_groups->len; group_idx++) { bt_value *group_info; - struct range group_range = { .set = false }; - struct ctf_fs_ds_file_group *group = g_ptr_array_index( - trace->ds_file_groups, group_idx); + range group_range; + ctf_fs_ds_file_group *group = + (ctf_fs_ds_file_group *) g_ptr_array_index(trace->ds_file_groups, group_idx); append_status = bt_value_array_append_empty_map_element( file_groups, &group_info); @@ -441,7 +441,7 @@ bt_component_class_query_method_status support_info_query( metadata_file = g_fopen(metadata_path, "rb"); if (metadata_file) { - struct ctf_metadata_decoder_config metadata_decoder_config = { 0 }; + ctf_metadata_decoder_config metadata_decoder_config{}; enum ctf_metadata_decoder_status decoder_status; bt_uuid_t uuid; @@ -487,7 +487,7 @@ create_result: insert_entry_status = bt_value_map_insert_real_entry(result, "weight", weight); if (insert_entry_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { - status = (int) insert_entry_status; + status = (bt_component_class_query_method_status) insert_entry_status; goto end; } @@ -497,7 +497,7 @@ create_result: if (weight > 0 && has_uuid) { insert_entry_status = bt_value_map_insert_string_entry(result, "group", uuid_str); if (insert_entry_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { - status = (int) insert_entry_status; + status = (bt_component_class_query_method_status) insert_entry_status; goto end; } } diff --git a/src/plugins/ctf/fs-src/query.h b/src/plugins/ctf/fs-src/query.hpp similarity index 100% rename from src/plugins/ctf/fs-src/query.h rename to src/plugins/ctf/fs-src/query.hpp diff --git a/src/plugins/ctf/lttng-live/Makefile.am b/src/plugins/ctf/lttng-live/Makefile.am index 07071520..53761a71 100644 --- a/src/plugins/ctf/lttng-live/Makefile.am +++ b/src/plugins/ctf/lttng-live/Makefile.am @@ -1,15 +1,15 @@ # SPDX-License-Identifier: MIT libbabeltrace2_plugin_ctf_lttng_live_la_SOURCES = \ - lttng-live.c \ - lttng-live.h \ - data-stream.c \ - data-stream.h \ - metadata.c \ - metadata.h \ - viewer-connection.c \ - viewer-connection.h \ - lttng-viewer-abi.h + lttng-live.cpp \ + lttng-live.hpp \ + data-stream.cpp \ + data-stream.hpp \ + metadata.cpp \ + metadata.hpp \ + viewer-connection.cpp \ + viewer-connection.hpp \ + lttng-viewer-abi.hpp libbabeltrace2_plugin_ctf_lttng_live_la_LIBADD = diff --git a/src/plugins/ctf/lttng-live/data-stream.c b/src/plugins/ctf/lttng-live/data-stream.cpp similarity index 93% rename from src/plugins/ctf/lttng-live/data-stream.c rename to src/plugins/ctf/lttng-live/data-stream.cpp index e8f00d7f..50071a09 100644 --- a/src/plugins/ctf/lttng-live/data-stream.c +++ b/src/plugins/ctf/lttng-live/data-stream.cpp @@ -20,10 +20,10 @@ #include -#include "../common/msg-iter/msg-iter.h" +#include "../common/msg-iter/msg-iter.hpp" #include "common/assert.h" #include "compat/mman.h" -#include "data-stream.h" +#include "data-stream.hpp" #define STREAM_NAME_PREFIX "stream-" @@ -34,7 +34,7 @@ enum ctf_msg_iter_medium_status medop_request_bytes( { enum ctf_msg_iter_medium_status status = CTF_MSG_ITER_MEDIUM_STATUS_OK; - struct lttng_live_stream_iterator *stream = data; + lttng_live_stream_iterator *stream = (lttng_live_stream_iterator *) data; struct lttng_live_trace *trace = stream->trace; struct lttng_live_session *session = trace->session; struct lttng_live_msg_iter *live_msg_iter = session->lttng_live_msg_iter; @@ -73,7 +73,7 @@ static bt_stream *medop_borrow_stream(bt_stream_class *stream_class, int64_t stream_id, void *data) { - struct lttng_live_stream_iterator *lttng_live_stream = data; + lttng_live_stream_iterator *lttng_live_stream = (lttng_live_stream_iterator *) data; bt_logging_level log_level = lttng_live_stream->log_level; bt_self_component *self_comp = lttng_live_stream->self_comp; @@ -118,9 +118,10 @@ end: } static struct ctf_msg_iter_medium_ops medops = { - .request_bytes = medop_request_bytes, - .seek = NULL, - .borrow_stream = medop_borrow_stream, + medop_request_bytes, + nullptr, + nullptr, + medop_borrow_stream, }; BT_HIDDEN @@ -139,19 +140,19 @@ enum lttng_live_iterator_status lttng_live_lazy_msg_init( } BT_COMP_LOGD("Lazily initializing self message iterator for live session: " - "session-id=%"PRIu64", self-msg-iter-addr=%p", session->id, + "session-id=%" PRIu64 ", self-msg-iter-addr=%p", session->id, self_msg_iter); for (trace_idx = 0; trace_idx < session->traces->len; trace_idx++) { struct lttng_live_trace *trace = - g_ptr_array_index(session->traces, trace_idx); + (lttng_live_trace *) g_ptr_array_index(session->traces, trace_idx); for (stream_iter_idx = 0; stream_iter_idx < trace->stream_iterators->len; stream_iter_idx++) { struct ctf_trace_class *ctf_tc; struct lttng_live_stream_iterator *stream_iter = - g_ptr_array_index(trace->stream_iterators, + (lttng_live_stream_iterator *) g_ptr_array_index(trace->stream_iterators, stream_iter_idx); if (stream_iter->msg_iter) { @@ -160,7 +161,7 @@ enum lttng_live_iterator_status lttng_live_lazy_msg_init( ctf_tc = ctf_metadata_decoder_borrow_ctf_trace_class( trace->metadata->decoder); BT_COMP_LOGD("Creating CTF message iterator: " - "session-id=%"PRIu64", ctf-tc-addr=%p, " + "session-id=%" PRIu64 ", ctf-tc-addr=%p, " "stream-iter-name=%s, self-msg-iter-addr=%p", session->id, ctf_tc, stream_iter->name->str, self_msg_iter); stream_iter->msg_iter = ctf_msg_iter_create(ctf_tc, diff --git a/src/plugins/ctf/lttng-live/data-stream.h b/src/plugins/ctf/lttng-live/data-stream.hpp similarity index 90% rename from src/plugins/ctf/lttng-live/data-stream.h rename to src/plugins/ctf/lttng-live/data-stream.hpp index d2c588e8..5c9e9a69 100644 --- a/src/plugins/ctf/lttng-live/data-stream.h +++ b/src/plugins/ctf/lttng-live/data-stream.hpp @@ -12,8 +12,8 @@ #include -#include "../common/msg-iter/msg-iter.h" -#include "lttng-live.h" +#include "../common/msg-iter/msg-iter.hpp" +#include "lttng-live.hpp" enum lttng_live_iterator_status lttng_live_lazy_msg_init( struct lttng_live_session *session, diff --git a/src/plugins/ctf/lttng-live/lttng-live.c b/src/plugins/ctf/lttng-live/lttng-live.cpp similarity index 97% rename from src/plugins/ctf/lttng-live/lttng-live.c rename to src/plugins/ctf/lttng-live/lttng-live.cpp index 6c412dd8..79875326 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.c +++ b/src/plugins/ctf/lttng-live/lttng-live.cpp @@ -27,9 +27,9 @@ #include "plugins/common/muxing/muxing.h" #include "plugins/common/param-validation/param-validation.h" -#include "data-stream.h" -#include "metadata.h" -#include "lttng-live.h" +#include "data-stream.hpp" +#include "metadata.hpp" +#include "lttng-live.hpp" #define MAX_QUERY_SIZE (256*1024) #define URL_PARAM "url" @@ -138,7 +138,7 @@ struct lttng_live_trace *lttng_live_session_borrow_trace_by_id(struct lttng_live for (trace_idx = 0; trace_idx < session->traces->len; trace_idx++) { struct lttng_live_trace *trace = - g_ptr_array_index(session->traces, trace_idx); + (lttng_live_trace *) g_ptr_array_index(session->traces, trace_idx); if (trace->id == trace_id) { ret_trace = trace; goto end; @@ -155,7 +155,7 @@ void lttng_live_destroy_trace(struct lttng_live_trace *trace) bt_logging_level log_level = trace->log_level; bt_self_component *self_comp = trace->self_comp; - BT_COMP_LOGD("Destroying live trace: trace-id=%"PRIu64, trace->id); + BT_COMP_LOGD("Destroying live trace: trace-id=%" PRIu64, trace->id); BT_ASSERT(trace->stream_iterators); g_ptr_array_free(trace->stream_iterators, TRUE); @@ -176,7 +176,7 @@ struct lttng_live_trace *lttng_live_create_trace(struct lttng_live_session *sess bt_self_component *self_comp = session->self_comp; BT_COMP_LOGD("Creating live trace: " - "session-id=%"PRIu64", trace-id=%"PRIu64, + "session-id=%" PRIu64 ", trace-id=%" PRIu64, session->id, trace_id); trace = g_new0(struct lttng_live_trace, 1); if (!trace) { @@ -279,7 +279,7 @@ void lttng_live_destroy_session(struct lttng_live_session *session) log_level = session->log_level; self_comp = session->self_comp; BT_COMP_LOGD("Destroying live session: " - "session-id=%"PRIu64", session-name=\"%s\"", + "session-id=%" PRIu64 ", session-name=\"%s\"", session->id, session->session_name->str); if (session->id != -1ULL) { if (lttng_live_session_detach(session)) { @@ -343,7 +343,8 @@ void lttng_live_msg_iter_finalize(bt_self_message_iterator *self_msg_iter) BT_ASSERT(self_msg_iter); - lttng_live_msg_iter = bt_self_message_iterator_get_data(self_msg_iter); + lttng_live_msg_iter = (struct lttng_live_msg_iter *) + bt_self_message_iterator_get_data(self_msg_iter); BT_ASSERT(lttng_live_msg_iter); lttng_live_msg_iter_destroy(lttng_live_msg_iter); } @@ -515,7 +516,7 @@ enum lttng_live_iterator_status lttng_live_get_session( trace_idx = 0; while (trace_idx < session->traces->len) { struct lttng_live_trace *trace = - g_ptr_array_index(session->traces, trace_idx); + (lttng_live_trace *) g_ptr_array_index(session->traces, trace_idx); status = lttng_live_metadata_update(trace); switch (status) { @@ -529,7 +530,7 @@ enum lttng_live_iterator_status lttng_live_get_session( default: BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Error updating trace metadata: " - "stream-iter-status=%s, trace-id=%"PRIu64, + "stream-iter-status=%s, trace-id=%" PRIu64, lttng_live_iterator_status_string(status), trace->id); goto end; @@ -557,14 +558,14 @@ void lttng_live_force_new_streams_and_metadata(struct lttng_live_msg_iter *lttng for (session_idx = 0; session_idx < lttng_live_msg_iter->sessions->len; session_idx++) { struct lttng_live_session *session = - g_ptr_array_index(lttng_live_msg_iter->sessions, session_idx); + (lttng_live_session *) g_ptr_array_index(lttng_live_msg_iter->sessions, session_idx); BT_COMP_LOGD("Force marking session as needing new streams: " "session-id=%" PRIu64, session->id); session->new_streams_needed = true; for (trace_idx = 0; trace_idx < session->traces->len; trace_idx++) { struct lttng_live_trace *trace = - g_ptr_array_index(session->traces, trace_idx); + (lttng_live_trace *) g_ptr_array_index(session->traces, trace_idx); BT_COMP_LOGD("Force marking trace metadata state as needing an update: " "session-id=%" PRIu64 ", trace-id=%" PRIu64, session->id, trace->id); @@ -628,7 +629,7 @@ lttng_live_iterator_handle_new_streams_and_metadata( for (session_idx = 0; session_idx < lttng_live_msg_iter->sessions->len; session_idx++) { - session = g_ptr_array_index(lttng_live_msg_iter->sessions, + session = (lttng_live_session *) g_ptr_array_index(lttng_live_msg_iter->sessions, session_idx); status = lttng_live_get_session(lttng_live_msg_iter, session); switch (status) { @@ -842,7 +843,7 @@ enum lttng_live_iterator_status lttng_live_iterator_next_handle_one_active_data_ for (session_idx = 0; session_idx < lttng_live_msg_iter->sessions->len; session_idx++) { struct lttng_live_session *session = - g_ptr_array_index(lttng_live_msg_iter->sessions, session_idx); + (lttng_live_session *) g_ptr_array_index(lttng_live_msg_iter->sessions, session_idx); if (session->new_streams_needed) { BT_COMP_LOGD("Need an update for streams: " @@ -853,7 +854,7 @@ enum lttng_live_iterator_status lttng_live_iterator_next_handle_one_active_data_ for (trace_idx = 0; trace_idx < session->traces->len; trace_idx++) { struct lttng_live_trace *trace = - g_ptr_array_index(session->traces, trace_idx); + (lttng_live_trace *) g_ptr_array_index(session->traces, trace_idx); if (trace->metadata_stream_state == LTTNG_LIVE_METADATA_STREAM_STATE_NEEDED) { BT_COMP_LOGD("Need an update for metadata stream: " "session-id=%" PRIu64 ", trace-id=%" PRIu64, @@ -1290,7 +1291,7 @@ enum lttng_live_iterator_status next_stream_iterator_for_trace( BT_ASSERT_DBG(live_trace->stream_iterators); BT_COMP_LOGD("Finding the next stream iterator for trace: " - "trace-id=%"PRIu64, live_trace->id); + "trace-id=%" PRIu64, live_trace->id); /* * Update the current message of every stream iterators of this trace. * The current msg of every stream must have a timestamp equal or @@ -1301,7 +1302,7 @@ enum lttng_live_iterator_status next_stream_iterator_for_trace( while (stream_iter_idx < live_trace->stream_iterators->len) { bool stream_iter_is_ended = false; struct lttng_live_stream_iterator *stream_iter = - g_ptr_array_index(live_trace->stream_iterators, + (lttng_live_stream_iterator *) g_ptr_array_index(live_trace->stream_iterators, stream_iter_idx); /* @@ -1462,7 +1463,7 @@ enum lttng_live_iterator_status next_stream_iterator_for_session( struct lttng_live_stream_iterator *youngest_candidate_stream_iter = NULL; BT_COMP_LOGD("Finding the next stream iterator for session: " - "session-id=%"PRIu64, session->id); + "session-id=%" PRIu64, session->id); /* * Make sure we are attached to the session and look for new streams * and metadata. @@ -1480,7 +1481,7 @@ enum lttng_live_iterator_status next_stream_iterator_for_session( bool trace_is_ended = false; struct lttng_live_stream_iterator *stream_iter; struct lttng_live_trace *trace = - g_ptr_array_index(session->traces, trace_idx); + (lttng_live_trace *) g_ptr_array_index(session->traces, trace_idx); stream_iter_status = next_stream_iterator_for_trace( lttng_live_msg_iter, trace, &stream_iter); @@ -1574,7 +1575,7 @@ bt_message_iterator_class_next_method_status lttng_live_msg_iter_next( bt_message_iterator_class_next_method_status status; enum lttng_live_viewer_status viewer_status; struct lttng_live_msg_iter *lttng_live_msg_iter = - bt_self_message_iterator_get_data(self_msg_it); + (struct lttng_live_msg_iter *) bt_self_message_iterator_get_data(self_msg_it); struct lttng_live_component *lttng_live = lttng_live_msg_iter->lttng_live_comp; bt_self_component *self_comp = lttng_live_msg_iter->self_comp; @@ -1671,7 +1672,7 @@ bt_message_iterator_class_next_method_status lttng_live_msg_iter_next( session_idx = 0; while (session_idx < lttng_live_msg_iter->sessions->len) { struct lttng_live_session *session = - g_ptr_array_index(lttng_live_msg_iter->sessions, + (lttng_live_session *) g_ptr_array_index(lttng_live_msg_iter->sessions, session_idx); /* Find the best candidate message to send downstream. */ @@ -1864,7 +1865,7 @@ bt_message_iterator_class_initialize_method_status lttng_live_msg_iter_init( bt_self_component *self_comp = bt_self_message_iterator_borrow_component(self_msg_it); - lttng_live = bt_self_component_get_data(self_comp); + lttng_live = (lttng_live_component *) bt_self_component_get_data(self_comp); log_level = lttng_live->log_level; self_comp = lttng_live->self_comp; @@ -1957,7 +1958,8 @@ end: } static struct bt_param_validation_map_value_entry_descr list_sessions_params[] = { - { URL_PARAM, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_MANDATORY, { .type = BT_VALUE_TYPE_STRING } }, + { URL_PARAM, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_MANDATORY, + { bt_param_validation_value_descr::string_t } }, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END }; @@ -2160,8 +2162,9 @@ void lttng_live_component_destroy_data(struct lttng_live_component *lttng_live) BT_HIDDEN void lttng_live_component_finalize(bt_self_component_source *component) { - void *data = bt_self_component_get_data( - bt_self_component_source_as_self_component(component)); + lttng_live_component *data = + (lttng_live_component *) bt_self_component_get_data( + bt_self_component_source_as_self_component(component)); if (!data) { return; @@ -2188,8 +2191,8 @@ enum session_not_found_action parse_session_not_found_action_param( return action; } -static struct bt_param_validation_value_descr inputs_elem_descr = { - .type = BT_VALUE_TYPE_STRING, +static bt_param_validation_value_descr inputs_elem_descr{ + bt_param_validation_value_descr::string_t, }; static const char *sess_not_found_action_choices[] = { @@ -2199,14 +2202,12 @@ static const char *sess_not_found_action_choices[] = { }; static struct bt_param_validation_map_value_entry_descr params_descr[] = { - { INPUTS_PARAM, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_MANDATORY, { BT_VALUE_TYPE_ARRAY, .array = { - .min_length = 1, - .max_length = 1, - .element_type = &inputs_elem_descr, - } } }, - { SESS_NOT_FOUND_ACTION_PARAM, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { BT_VALUE_TYPE_STRING, .string = { - .choices = sess_not_found_action_choices, - } } }, + { INPUTS_PARAM, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_MANDATORY, + { bt_param_validation_value_descr::array_t, + 1, 1, inputs_elem_descr } }, + { SESS_NOT_FOUND_ACTION_PARAM, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, + { bt_param_validation_value_descr::string_t, + sess_not_found_action_choices } }, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END }; @@ -2309,7 +2310,7 @@ bt_component_class_initialize_method_status lttng_live_component_init( add_port_status = bt_self_component_source_add_output_port( self_comp_src, "out", NULL, NULL); if (add_port_status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) { - ret = (int) add_port_status; + ret = (bt_component_class_initialize_method_status) add_port_status; goto end; } diff --git a/src/plugins/ctf/lttng-live/lttng-live.h b/src/plugins/ctf/lttng-live/lttng-live.hpp similarity index 98% rename from src/plugins/ctf/lttng-live/lttng-live.h rename to src/plugins/ctf/lttng-live/lttng-live.hpp index d0d5b153..c965b8c7 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.h +++ b/src/plugins/ctf/lttng-live/lttng-live.hpp @@ -19,9 +19,9 @@ #include #include "common/macros.h" -#include "../common/metadata/decoder.h" -#include "../common/msg-iter/msg-iter.h" -#include "viewer-connection.h" +#include "../common/metadata/decoder.hpp" +#include "../common/msg-iter/msg-iter.hpp" +#include "viewer-connection.hpp" struct lttng_live_component; struct lttng_live_session; diff --git a/src/plugins/ctf/lttng-live/lttng-viewer-abi.h b/src/plugins/ctf/lttng-live/lttng-viewer-abi.hpp similarity index 100% rename from src/plugins/ctf/lttng-live/lttng-viewer-abi.h rename to src/plugins/ctf/lttng-live/lttng-viewer-abi.hpp diff --git a/src/plugins/ctf/lttng-live/metadata.c b/src/plugins/ctf/lttng-live/metadata.cpp similarity index 95% rename from src/plugins/ctf/lttng-live/metadata.c rename to src/plugins/ctf/lttng-live/metadata.cpp index 711f3ca5..feaf0afd 100644 --- a/src/plugins/ctf/lttng-live/metadata.c +++ b/src/plugins/ctf/lttng-live/metadata.cpp @@ -19,9 +19,9 @@ #include "compat/memstream.h" #include -#include "metadata.h" -#include "../common/metadata/decoder.h" -#include "../common/metadata/ctf-meta-configure-ir-trace.h" +#include "metadata.hpp" +#include "../common/metadata/decoder.hpp" +#include "../common/metadata/ctf-meta-configure-ir-trace.hpp" #define TSDL_MAGIC 0x75d11d57 @@ -178,7 +178,7 @@ enum lttng_live_iterator_status lttng_live_metadata_update( break; case LTTNG_LIVE_GET_ONE_METADATA_STATUS_CLOSED: BT_COMP_LOGD("Metadata stream was closed by the Relay, the trace is no longer active: " - "trace-id=%"PRIu64", metadata-stream-id=%"PRIu64, + "trace-id=%" PRIu64 ", metadata-stream-id=%" PRIu64, trace->id, metadata->stream_id); /* * The stream was closed and we received everything @@ -192,7 +192,7 @@ enum lttng_live_iterator_status lttng_live_metadata_update( case LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR: BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Error getting one trace metadata packet: " - "trace-id=%"PRIu64, trace->id); + "trace-id=%" PRIu64, trace->id); goto error; default: bt_common_abort(); @@ -308,13 +308,13 @@ int lttng_live_metadata_create_stream(struct lttng_live_session *session, bt_logging_level log_level = session->log_level; struct lttng_live_metadata *metadata = NULL; struct lttng_live_trace *trace; - struct ctf_metadata_decoder_config cfg = { - .log_level = session->log_level, - .self_comp = session->self_comp, - .clock_class_offset_s = 0, - .clock_class_offset_ns = 0, - .create_trace_class = true, - }; + + ctf_metadata_decoder_config cfg{}; + cfg.log_level = session->log_level; + cfg.self_comp = session->self_comp; + cfg.clock_class_offset_s = 0; + cfg.clock_class_offset_ns = 0; + cfg.create_trace_class = true; metadata = g_new0(struct lttng_live_metadata, 1); if (!metadata) { diff --git a/src/plugins/ctf/lttng-live/metadata.h b/src/plugins/ctf/lttng-live/metadata.hpp similarity index 95% rename from src/plugins/ctf/lttng-live/metadata.h rename to src/plugins/ctf/lttng-live/metadata.hpp index 47de805f..08a1fb63 100644 --- a/src/plugins/ctf/lttng-live/metadata.h +++ b/src/plugins/ctf/lttng-live/metadata.hpp @@ -10,7 +10,7 @@ #include #include -#include "lttng-live.h" +#include "lttng-live.hpp" int lttng_live_metadata_create_stream(struct lttng_live_session *session, uint64_t ctf_trace_id, uint64_t stream_id, diff --git a/src/plugins/ctf/lttng-live/viewer-connection.c b/src/plugins/ctf/lttng-live/viewer-connection.cpp similarity index 98% rename from src/plugins/ctf/lttng-live/viewer-connection.c rename to src/plugins/ctf/lttng-live/viewer-connection.cpp index 3548b639..73677fa2 100644 --- a/src/plugins/ctf/lttng-live/viewer-connection.c +++ b/src/plugins/ctf/lttng-live/viewer-connection.cpp @@ -26,11 +26,11 @@ #include "common/common.h" #include -#include "lttng-live.h" -#include "viewer-connection.h" -#include "lttng-viewer-abi.h" -#include "data-stream.h" -#include "metadata.h" +#include "lttng-live.hpp" +#include "viewer-connection.hpp" +#include "lttng-viewer-abi.hpp" +#include "data-stream.hpp" +#include "metadata.hpp" #define viewer_handle_send_recv_status(_self_comp, _self_comp_class, \ _status, _action, _msg_str) \ @@ -111,6 +111,13 @@ const char *lttng_viewer_next_index_return_code_string( bt_common_abort(); } +static +const char *lttng_viewer_next_index_return_code_string(uint32_t code) +{ + return lttng_viewer_next_index_return_code_string( + (lttng_viewer_next_index_return_code) code); +} + static const char *lttng_viewer_get_packet_return_code_string( enum lttng_viewer_get_packet_return_code code) @@ -129,6 +136,13 @@ const char *lttng_viewer_get_packet_return_code_string( bt_common_abort(); }; +static +const char *lttng_viewer_get_packet_return_code_string(uint32_t code) +{ + return lttng_viewer_get_packet_return_code_string( + (lttng_viewer_get_packet_return_code) code); +} + static const char *lttng_viewer_seek_string(enum lttng_viewer_seek seek) { @@ -218,7 +232,7 @@ enum lttng_live_viewer_status lttng_live_recv( * Receive a message from the Relay. */ do { - received = bt_socket_recv(sock, buf + total_received, to_receive, 0); + received = bt_socket_recv(sock, (char *) buf + total_received, to_receive, 0); if (received == BT_SOCKET_ERROR) { if (bt_socket_interrupted()) { if (lttng_live_graph_is_canceled(lttng_live_msg_iter)) { @@ -301,7 +315,7 @@ enum lttng_live_viewer_status lttng_live_send( ssize_t total_sent = 0; do { - ssize_t sent = bt_socket_send_nosigpipe(sock, buf + total_sent, + ssize_t sent = bt_socket_send_nosigpipe(sock, (char *) buf + total_sent, to_send); if (sent == BT_SOCKET_ERROR) { if (bt_socket_interrupted()) { @@ -1254,7 +1268,7 @@ enum lttng_live_viewer_status lttng_live_session_detach( * tearing down the graph after an error. */ if (!session->attached || viewer_connection->control_sock == BT_INVALID_SOCKET) { - return 0; + return LTTNG_LIVE_VIEWER_STATUS_OK; } BT_COMP_LOGD("Detaching from session: cmd=%s, session-id=%" PRIu64, @@ -1465,7 +1479,7 @@ void lttng_live_need_new_streams(struct lttng_live_msg_iter *lttng_live_msg_iter for (session_idx = 0; session_idx < lttng_live_msg_iter->sessions->len; session_idx++) { struct lttng_live_session *session = - g_ptr_array_index(lttng_live_msg_iter->sessions, session_idx); + (lttng_live_session *) g_ptr_array_index(lttng_live_msg_iter->sessions, session_idx); BT_COMP_LOGD("Marking session as needing new streams: " "session-id=%" PRIu64, session->id); session->new_streams_needed = true; diff --git a/src/plugins/ctf/lttng-live/viewer-connection.h b/src/plugins/ctf/lttng-live/viewer-connection.hpp similarity index 100% rename from src/plugins/ctf/lttng-live/viewer-connection.h rename to src/plugins/ctf/lttng-live/viewer-connection.hpp diff --git a/src/plugins/ctf/plugin.c b/src/plugins/ctf/plugin.cpp similarity index 96% rename from src/plugins/ctf/plugin.c rename to src/plugins/ctf/plugin.cpp index 925b0f9f..eeab90e2 100644 --- a/src/plugins/ctf/plugin.c +++ b/src/plugins/ctf/plugin.cpp @@ -8,9 +8,9 @@ #include -#include "fs-src/fs.h" -#include "fs-sink/fs-sink.h" -#include "lttng-live/lttng-live.h" +#include "fs-src/fs.hpp" +#include "fs-sink/fs-sink.hpp" +#include "lttng-live/lttng-live.hpp" #ifndef BT_BUILT_IN_PLUGINS BT_PLUGIN_MODULE(); -- 2.34.1