From 78ac3a7dcde59c85dfe6835e71eb7a10d78c1e82 Mon Sep 17 00:00:00 2001 From: Erica Bugden Date: Wed, 21 Aug 2024 13:53:12 -0400 Subject: [PATCH] debug-info: Compile as C++ Justifications ============== Leave `crc32.h` and `crc32.c` as C code: The file is code external to the project and it is typical to never modify these files. However, when compiling alonside C++ code we must explicitly specify that it is C code so that the compiler knows to refer to function names with the non-mangled symbol name. Specifying that `crc32.h` is C in the file was less intrusive compared to translating the whole file to C++. Change-Id: I5e8823ceca994c035de6ebba5df22b2c3d11a02b Signed-off-by: Erica Bugden Reviewed-on: https://review.lttng.org/c/babeltrace/+/13225 Reviewed-by: Simon Marchi --- src/Makefile.am | 38 ++++---- src/fd-cache/{fd-cache.c => fd-cache.cpp} | 14 +-- src/fd-cache/{fd-cache.h => fd-cache.hpp} | 8 +- .../debug-info/{bin-info.c => bin-info.cpp} | 12 +-- .../debug-info/{bin-info.h => bin-info.hpp} | 10 ++- src/plugins/lttng-utils/debug-info/crc32.h | 8 ++ .../{debug-info.c => debug-info.cpp} | 86 ++++++++++--------- .../{debug-info.h => debug-info.hpp} | 8 +- .../debug-info/{dwarf.c => dwarf.cpp} | 4 +- .../debug-info/{dwarf.h => dwarf.hpp} | 8 +- ...-ir-data-copy.c => trace-ir-data-copy.cpp} | 16 ++-- ...-ir-data-copy.h => trace-ir-data-copy.hpp} | 10 ++- ...race-ir-mapping.c => trace-ir-mapping.cpp} | 22 ++--- ...race-ir-mapping.h => trace-ir-mapping.hpp} | 16 ++-- ...data-copy.c => trace-ir-metadata-copy.cpp} | 40 +++++---- ...data-copy.h => trace-ir-metadata-copy.hpp} | 10 ++- ...=> trace-ir-metadata-field-class-copy.cpp} | 30 ++++--- ...=> trace-ir-metadata-field-class-copy.hpp} | 10 ++- .../debug-info/{utils.c => utils.cpp} | 6 +- .../debug-info/{utils.h => utils.hpp} | 8 +- .../lttng-utils/{plugin.c => plugin.cpp} | 4 +- .../flt.lttng-utils.debug-info/Makefile.am | 4 +- .../{test-bin-info.c => test-bin-info.cpp} | 4 +- .../{test-dwarf.c => test-dwarf.cpp} | 4 +- 24 files changed, 215 insertions(+), 165 deletions(-) rename src/fd-cache/{fd-cache.c => fd-cache.cpp} (92%) rename src/fd-cache/{fd-cache.h => fd-cache.hpp} (81%) rename src/plugins/lttng-utils/debug-info/{bin-info.c => bin-info.cpp} (99%) rename src/plugins/lttng-utils/debug-info/{bin-info.h => bin-info.hpp} (96%) rename src/plugins/lttng-utils/debug-info/{debug-info.c => debug-info.cpp} (95%) rename src/plugins/lttng-utils/debug-info/{debug-info.h => debug-info.hpp} (91%) rename src/plugins/lttng-utils/debug-info/{dwarf.c => dwarf.cpp} (99%) rename src/plugins/lttng-utils/debug-info/{dwarf.h => dwarf.hpp} (96%) rename src/plugins/lttng-utils/debug-info/{trace-ir-data-copy.c => trace-ir-data-copy.cpp} (96%) rename src/plugins/lttng-utils/debug-info/{trace-ir-data-copy.h => trace-ir-data-copy.hpp} (93%) rename src/plugins/lttng-utils/debug-info/{trace-ir-mapping.c => trace-ir-mapping.cpp} (97%) rename src/plugins/lttng-utils/debug-info/{trace-ir-mapping.h => trace-ir-mapping.hpp} (96%) rename src/plugins/lttng-utils/debug-info/{trace-ir-metadata-copy.c => trace-ir-metadata-copy.cpp} (94%) rename src/plugins/lttng-utils/debug-info/{trace-ir-metadata-copy.h => trace-ir-metadata-copy.hpp} (94%) rename src/plugins/lttng-utils/debug-info/{trace-ir-metadata-field-class-copy.c => trace-ir-metadata-field-class-copy.cpp} (97%) rename src/plugins/lttng-utils/debug-info/{trace-ir-metadata-field-class-copy.h => trace-ir-metadata-field-class-copy.hpp} (86%) rename src/plugins/lttng-utils/debug-info/{utils.c => utils.cpp} (96%) rename src/plugins/lttng-utils/debug-info/{utils.h => utils.hpp} (72%) rename src/plugins/lttng-utils/{plugin.c => plugin.cpp} (96%) rename tests/plugins/flt.lttng-utils.debug-info/{test-bin-info.c => test-bin-info.cpp} (99%) rename tests/plugins/flt.lttng-utils.debug-info/{test-dwarf.c => test-dwarf.cpp} (98%) diff --git a/src/Makefile.am b/src/Makefile.am index 10d97d83..39d3ce5f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -243,8 +243,8 @@ ctfser_libctfser_la_SOURCES = \ ctfser/ctfser.h fd_cache_libfd_cache_la_SOURCES = \ - fd-cache/fd-cache.c \ - fd-cache/fd-cache.h + fd-cache/fd-cache.cpp \ + fd-cache/fd-cache.hpp logging_liblogging_la_SOURCES = \ logging/comp-logging.h \ @@ -381,24 +381,24 @@ if ENABLE_DEBUG_INFO noinst_LTLIBRARIES += plugins/lttng-utils/debug-info/libdebug-info.la plugins_lttng_utils_debug_info_libdebug_info_la_SOURCES = \ - plugins/lttng-utils/debug-info/bin-info.c \ - plugins/lttng-utils/debug-info/bin-info.h \ + plugins/lttng-utils/debug-info/bin-info.cpp \ + plugins/lttng-utils/debug-info/bin-info.hpp \ plugins/lttng-utils/debug-info/crc32.c \ plugins/lttng-utils/debug-info/crc32.h \ - plugins/lttng-utils/debug-info/debug-info.c \ - plugins/lttng-utils/debug-info/debug-info.h \ - plugins/lttng-utils/debug-info/dwarf.c \ - plugins/lttng-utils/debug-info/dwarf.h \ - plugins/lttng-utils/debug-info/trace-ir-data-copy.c \ - plugins/lttng-utils/debug-info/trace-ir-data-copy.h \ - plugins/lttng-utils/debug-info/trace-ir-mapping.c \ - plugins/lttng-utils/debug-info/trace-ir-mapping.h \ - plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c \ - plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h \ - plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c \ - plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.h \ - plugins/lttng-utils/debug-info/utils.c \ - plugins/lttng-utils/debug-info/utils.h + plugins/lttng-utils/debug-info/debug-info.cpp \ + plugins/lttng-utils/debug-info/debug-info.hpp \ + plugins/lttng-utils/debug-info/dwarf.cpp \ + plugins/lttng-utils/debug-info/dwarf.hpp \ + plugins/lttng-utils/debug-info/trace-ir-data-copy.cpp \ + plugins/lttng-utils/debug-info/trace-ir-data-copy.hpp \ + plugins/lttng-utils/debug-info/trace-ir-mapping.cpp \ + plugins/lttng-utils/debug-info/trace-ir-mapping.hpp \ + plugins/lttng-utils/debug-info/trace-ir-metadata-copy.cpp \ + plugins/lttng-utils/debug-info/trace-ir-metadata-copy.hpp \ + plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.cpp \ + plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.hpp \ + plugins/lttng-utils/debug-info/utils.cpp \ + plugins/lttng-utils/debug-info/utils.hpp plugins_lttng_utils_debug_info_libdebug_info_la_LIBADD = \ fd-cache/libfd-cache.la @@ -825,7 +825,7 @@ plugin_LTLIBRARIES += \ plugins/lttng-utils/babeltrace-plugin-lttng-utils.la plugins_lttng_utils_babeltrace_plugin_lttng_utils_la_SOURCES = \ - plugins/lttng-utils/plugin.c + plugins/lttng-utils/plugin.cpp plugins_lttng_utils_babeltrace_plugin_lttng_utils_la_LDFLAGS = \ $(AM_LDFLAGS) \ diff --git a/src/fd-cache/fd-cache.c b/src/fd-cache/fd-cache.cpp similarity index 92% rename from src/fd-cache/fd-cache.c rename to src/fd-cache/fd-cache.cpp index f22e7eb5..4ccf41f9 100644 --- a/src/fd-cache/fd-cache.c +++ b/src/fd-cache/fd-cache.cpp @@ -6,6 +6,8 @@ * Babeltrace - File descriptor cache */ +/* clang-format off */ + #define BT_LOG_OUTPUT_LEVEL (fdc->log_level) #define BT_LOG_TAG "FD-CACHE" #include "logging/log.h" @@ -17,7 +19,7 @@ #include #include "common/assert.h" -#include "fd-cache.h" +#include "fd-cache.hpp" struct file_key { uint64_t dev; @@ -62,15 +64,15 @@ uint64_t hash_uint64_t(uint64_t x) { static guint file_key_hash(gconstpointer v) { - const struct file_key *fk = v; + const struct file_key *fk = static_cast(v); return hash_uint64_t(fk->dev) ^ hash_uint64_t(fk->ino); } static gboolean file_key_equal(gconstpointer v1, gconstpointer v2) { - const struct file_key *fk1 = v1; - const struct file_key *fk2 = v2; + const struct file_key *fk1 = static_cast(v1); + const struct file_key *fk2 = static_cast(v2); return (fk1->dev == fk2->dev) && (fk1->ino == fk2->ino); } @@ -78,7 +80,7 @@ gboolean file_key_equal(gconstpointer v1, gconstpointer v2) static void file_key_destroy(gpointer data) { - struct file_key *fk = data; + struct file_key *fk = static_cast(data); g_free(fk); } @@ -140,7 +142,7 @@ struct bt_fd_cache_handle *bt_fd_cache_get_handle(struct bt_fd_cache *fdc, fk.dev = statbuf.st_dev; fk.ino = statbuf.st_ino; - fd_internal = g_hash_table_lookup(fdc->cache, &fk); + fd_internal = static_cast(g_hash_table_lookup(fdc->cache, &fk)); if (!fd_internal) { struct file_key *file_key; diff --git a/src/fd-cache/fd-cache.h b/src/fd-cache/fd-cache.hpp similarity index 81% rename from src/fd-cache/fd-cache.h rename to src/fd-cache/fd-cache.hpp index a3593381..34cdf2f8 100644 --- a/src/fd-cache/fd-cache.h +++ b/src/fd-cache/fd-cache.hpp @@ -6,8 +6,10 @@ * Babeltrace - File descriptor cache */ -#ifndef BABELTRACE_FD_CACHE_FD_CACHE_H -#define BABELTRACE_FD_CACHE_FD_CACHE_H +/* clang-format off */ + +#ifndef BABELTRACE_FD_CACHE_FD_CACHE_HPP +#define BABELTRACE_FD_CACHE_FD_CACHE_HPP #include @@ -36,4 +38,4 @@ struct bt_fd_cache_handle *bt_fd_cache_get_handle(struct bt_fd_cache *fdc, void bt_fd_cache_put_handle(struct bt_fd_cache *fdc, struct bt_fd_cache_handle *handle); -#endif /* BABELTRACE_FD_CACHE_FD_CACHE_H */ +#endif /* BABELTRACE_FD_CACHE_FD_CACHE_HPP */ diff --git a/src/plugins/lttng-utils/debug-info/bin-info.c b/src/plugins/lttng-utils/debug-info/bin-info.cpp similarity index 99% rename from src/plugins/lttng-utils/debug-info/bin-info.c rename to src/plugins/lttng-utils/debug-info/bin-info.cpp index 99127291..8f9dfea5 100644 --- a/src/plugins/lttng-utils/debug-info/bin-info.c +++ b/src/plugins/lttng-utils/debug-info/bin-info.cpp @@ -6,6 +6,8 @@ * Copyright 2015 Antoine Busque */ +/* clang-format off */ + #define BT_COMP_LOG_SELF_COMP (bin->self_comp) #define BT_LOG_OUTPUT_LEVEL (bin->log_level) #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/BIN-INFO" @@ -27,10 +29,10 @@ #include "common/common.h" -#include "bin-info.h" +#include "bin-info.hpp" #include "crc32.h" -#include "dwarf.h" -#include "utils.h" +#include "dwarf.hpp" +#include "utils.hpp" /* * An address printed in hex is at most 20 bytes (16 for 64-bits + @@ -216,7 +218,7 @@ int is_build_id_note_section(Elf_Data *note_data) } /* Check the note name. */ - if (memcmp(note_data->d_buf + name_offset, BUILD_ID_NOTE_NAME, + if (memcmp(static_cast(note_data->d_buf) + name_offset, BUILD_ID_NOTE_NAME, note_header.n_namesz) != 0) { goto invalid; } @@ -258,7 +260,7 @@ int is_build_id_note_section_matching(Elf_Data *note_data, /* * Compare the binary build id with the supplied build id. */ - if (memcmp(build_id, note_data->d_buf + desc_offset, + if (memcmp(build_id, static_cast(note_data->d_buf) + desc_offset, build_id_len) == 0) { return 1; } diff --git a/src/plugins/lttng-utils/debug-info/bin-info.h b/src/plugins/lttng-utils/debug-info/bin-info.hpp similarity index 96% rename from src/plugins/lttng-utils/debug-info/bin-info.h rename to src/plugins/lttng-utils/debug-info/bin-info.hpp index 2a641691..ae489ae7 100644 --- a/src/plugins/lttng-utils/debug-info/bin-info.h +++ b/src/plugins/lttng-utils/debug-info/bin-info.hpp @@ -6,8 +6,10 @@ * Babeltrace - Executable and Shared Object Debug Info Reader */ -#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_BIN_INFO_H -#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_BIN_INFO_H +/* clang-format off */ + +#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_BIN_INFO_HPP +#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_BIN_INFO_HPP #include #include @@ -15,7 +17,7 @@ #include #include #include "common/macros.h" -#include "fd-cache/fd-cache.h" +#include "fd-cache/fd-cache.hpp" #define DEFAULT_DEBUG_DIR "/usr/lib/debug" #define DEBUG_SUBDIR ".debug" @@ -218,4 +220,4 @@ int bin_info_get_bin_loc(struct bin_info *bin, uint64_t addr, char **bin_loc); */ void source_location_destroy(struct source_location *src_loc); -#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_BIN_INFO_H */ +#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_BIN_INFO_HPP */ diff --git a/src/plugins/lttng-utils/debug-info/crc32.h b/src/plugins/lttng-utils/debug-info/crc32.h index 5dedda43..c964f583 100644 --- a/src/plugins/lttng-utils/debug-info/crc32.h +++ b/src/plugins/lttng-utils/debug-info/crc32.h @@ -12,6 +12,10 @@ #include #include "common/macros.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * Compute a 32-bit cyclic redundancy checksum for a given file. * @@ -24,4 +28,8 @@ */ int crc32(int fd, uint32_t *crc); +#ifdef __cplusplus +} +#endif + #endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_CRC32_H */ diff --git a/src/plugins/lttng-utils/debug-info/debug-info.c b/src/plugins/lttng-utils/debug-info/debug-info.cpp similarity index 95% rename from src/plugins/lttng-utils/debug-info/debug-info.c rename to src/plugins/lttng-utils/debug-info/debug-info.cpp index f8ef8182..409350b4 100644 --- a/src/plugins/lttng-utils/debug-info/debug-info.c +++ b/src/plugins/lttng-utils/debug-info/debug-info.cpp @@ -10,6 +10,8 @@ * Babeltrace - Debug Information State Tracker */ +/* clang-format off */ + #define BT_COMP_LOG_SELF_COMP self_comp #define BT_LOG_OUTPUT_LEVEL log_level #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO" @@ -21,14 +23,14 @@ #include "common/assert.h" #include "common/common.h" -#include "fd-cache/fd-cache.h" - -#include "bin-info.h" -#include "debug-info.h" -#include "trace-ir-data-copy.h" -#include "trace-ir-mapping.h" -#include "trace-ir-metadata-copy.h" -#include "utils.h" +#include "fd-cache/fd-cache.hpp" + +#include "bin-info.hpp" +#include "debug-info.hpp" +#include "trace-ir-data-copy.hpp" +#include "trace-ir-mapping.hpp" +#include "trace-ir-metadata-copy.hpp" +#include "utils.hpp" #include "plugins/common/param-validation/param-validation.h" #define DEFAULT_DEBUG_INFO_FIELD_NAME "debug_info" @@ -185,7 +187,7 @@ struct debug_info_source *debug_info_source_create_from_bin( if (src_loc) { debug_info_src->line_no = - g_strdup_printf("%"PRId64, src_loc->line_no); + g_strdup_printf("%" PRId64, src_loc->line_no); if (!debug_info_src->line_no) { BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Error occurred when setting `line_no` field."); @@ -292,7 +294,7 @@ struct proc_debug_info_sources *proc_debug_info_sources_ht_get_entry( *((int64_t *) key) = vpid; /* Exists? Return it */ - proc_dbg_info_src = g_hash_table_lookup(ht, key); + proc_dbg_info_src = static_cast(g_hash_table_lookup(ht, key)); if (proc_dbg_info_src) { goto end; } @@ -443,8 +445,8 @@ struct debug_info_source *proc_debug_info_sources_get_entry( *((uint64_t *) key) = ip; /* Look in IP to debug infos hash table first. */ - debug_info_src = g_hash_table_lookup( - proc_dbg_info_src->ip_to_debug_info_src, key); + debug_info_src = static_cast(g_hash_table_lookup( + proc_dbg_info_src->ip_to_debug_info_src, key)); if (debug_info_src) { goto end; } @@ -454,9 +456,9 @@ struct debug_info_source *proc_debug_info_sources_get_entry( while (g_hash_table_iter_next(&iter, &baddr, &value)) { - struct bin_info *bin = value; + struct bin_info *bin = static_cast(value); - if (!bin_info_has_address(value, ip)) { + if (!bin_info_has_address(bin, ip)) { continue; } @@ -597,8 +599,8 @@ void handle_event_statedump_build_id(struct debug_info *debug_info, goto end; } - bin = g_hash_table_lookup(proc_dbg_info_src->baddr_to_bin_info, - (gpointer) &baddr); + bin = static_cast(g_hash_table_lookup(proc_dbg_info_src->baddr_to_bin_info, + (gpointer) &baddr)); if (!bin) { /* * The build_id event comes after the bin has been @@ -666,8 +668,8 @@ void handle_event_statedump_debug_link(struct debug_info *debug_info, goto end; } - bin = g_hash_table_lookup(proc_dbg_info_src->baddr_to_bin_info, - (gpointer) &baddr); + bin = static_cast(g_hash_table_lookup(proc_dbg_info_src->baddr_to_bin_info, + (gpointer) &baddr)); if (!bin) { /* * The debug_link event comes after the bin has been @@ -743,7 +745,7 @@ void handle_bin_info_event(struct debug_info *debug_info, *((uint64_t *) key) = baddr; - bin = g_hash_table_lookup(proc_dbg_info_src->baddr_to_bin_info, key); + bin = static_cast(g_hash_table_lookup(proc_dbg_info_src->baddr_to_bin_info, key)); if (bin) { goto end; } @@ -837,7 +839,7 @@ end: static void trace_debug_info_remove_func(const bt_trace *in_trace, void *data) { - struct debug_info_msg_iter *debug_it = data; + struct debug_info_msg_iter *debug_it = static_cast(data); if (debug_it->debug_info_map) { gboolean ret; ret = g_hash_table_remove(debug_it->debug_info_map, @@ -866,7 +868,7 @@ void handle_event_statedump(struct debug_info_msg_iter *debug_it, trace = bt_stream_borrow_trace_const( bt_event_borrow_stream_const(event)); - debug_info = g_hash_table_lookup(debug_it->debug_info_map, trace); + debug_info = static_cast(g_hash_table_lookup(debug_it->debug_info_map, trace)); if (!debug_info) { bt_trace_add_listener_status add_listener_status; @@ -1179,9 +1181,9 @@ void fill_debug_info_event_if_needed(struct debug_info_msg_iter *debug_it, * Borrow the debug_info structure needed for the source * resolving. */ - debug_info = g_hash_table_lookup(debug_it->debug_info_map, + debug_info = static_cast(g_hash_table_lookup(debug_it->debug_info_map, bt_stream_borrow_trace_const( - bt_event_borrow_stream_const(in_event))); + bt_event_borrow_stream_const(in_event)))); if (debug_info) { /* @@ -1681,10 +1683,10 @@ const bt_message *handle_message(struct debug_info_msg_iter *debug_it, static struct bt_param_validation_map_value_entry_descr debug_info_params[] = { - { "debug-info-field-name", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_STRING } }, - { "debug-info-dir", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_STRING } }, - { "target-prefix", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_STRING } }, - { "full-path", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, + { "debug-info-field-name", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, bt_param_validation_value_descr::makeString() }, + { "debug-info-dir", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, bt_param_validation_value_descr::makeString() }, + { "target-prefix", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, bt_param_validation_value_descr::makeString() }, + { "full-path", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, bt_param_validation_value_descr::makeBool() }, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END }; @@ -1787,14 +1789,14 @@ bt_component_class_initialize_method_status debug_info_comp_init( add_port_status = bt_self_component_filter_add_input_port( self_comp_flt, "in", NULL, NULL); if (add_port_status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) { - status = (int) add_port_status; + status = static_cast(add_port_status); goto error; } add_port_status = bt_self_component_filter_add_output_port( self_comp_flt, "out", NULL, NULL); if (add_port_status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) { - status = (int) add_port_status; + status = static_cast(add_port_status); goto error; } @@ -1823,9 +1825,9 @@ end: void debug_info_comp_finalize(bt_self_component_filter *self_comp_flt) { struct debug_info_component *debug_info = - bt_self_component_get_data( + static_cast(bt_self_component_get_data( bt_self_component_filter_as_self_component( - self_comp_flt)); + self_comp_flt))); bt_logging_level log_level = debug_info->log_level; bt_self_component *self_comp = debug_info->self_comp; @@ -1855,10 +1857,10 @@ bt_message_iterator_class_next_method_status debug_info_msg_iter_next( self_comp = bt_self_message_iterator_borrow_component(self_msg_iter); BT_ASSERT_DBG(self_comp); - debug_info = bt_self_component_get_data(self_comp); + debug_info = static_cast(bt_self_component_get_data(self_comp)); BT_ASSERT_DBG(debug_info); - debug_info_msg_iter = bt_self_message_iterator_get_data(self_msg_iter); + debug_info_msg_iter = static_cast(bt_self_message_iterator_get_data(self_msg_iter)); BT_ASSERT_DBG(debug_info_msg_iter); upstream_iterator = debug_info_msg_iter->msg_iter; @@ -1874,7 +1876,7 @@ bt_message_iterator_class_next_method_status debug_info_msg_iter_next( * Convert the upstream message iterator status to a * self status. */ - status = (int) upstream_iterator_ret_status; + status = static_cast(upstream_iterator_ret_status); goto end; } @@ -1979,7 +1981,7 @@ bt_message_iterator_class_initialize_method_status debug_info_msg_iter_init( debug_info_msg_iter->self_comp = self_comp; debug_info_msg_iter->debug_info_component = - bt_self_component_get_data(self_comp); + static_cast(bt_self_component_get_data(self_comp)); /* Borrow the upstream input port. */ input_port = bt_self_component_filter_borrow_input_port_by_name( @@ -1994,7 +1996,7 @@ bt_message_iterator_class_initialize_method_status debug_info_msg_iter_init( msg_iter_status = bt_message_iterator_create_from_message_iterator( self_msg_iter, input_port, &upstream_iterator); if (msg_iter_status != BT_MESSAGE_ITERATOR_CREATE_FROM_MESSAGE_ITERATOR_STATUS_OK) { - status = (int) msg_iter_status; + status = static_cast(msg_iter_status); goto error; } @@ -2048,18 +2050,18 @@ debug_info_msg_iter_can_seek_beginning(bt_self_message_iterator *self_msg_iter, bt_bool *can_seek) { struct debug_info_msg_iter *debug_info_msg_iter = - bt_self_message_iterator_get_data(self_msg_iter); + static_cast(bt_self_message_iterator_get_data(self_msg_iter)); BT_ASSERT(debug_info_msg_iter); - return (int) bt_message_iterator_can_seek_beginning( - debug_info_msg_iter->msg_iter, can_seek); + return static_cast(bt_message_iterator_can_seek_beginning( + debug_info_msg_iter->msg_iter, can_seek)); } bt_message_iterator_class_seek_beginning_method_status debug_info_msg_iter_seek_beginning(bt_self_message_iterator *self_msg_iter) { struct debug_info_msg_iter *debug_info_msg_iter = - bt_self_message_iterator_get_data(self_msg_iter); + static_cast(bt_self_message_iterator_get_data(self_msg_iter)); bt_message_iterator_class_seek_beginning_method_status status = BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK; bt_message_iterator_seek_beginning_status seek_beg_status; @@ -2070,7 +2072,7 @@ debug_info_msg_iter_seek_beginning(bt_self_message_iterator *self_msg_iter) seek_beg_status = bt_message_iterator_seek_beginning( debug_info_msg_iter->msg_iter); if (seek_beg_status != BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_OK) { - status = (int) seek_beg_status; + status = static_cast(seek_beg_status); goto end; } @@ -2086,7 +2088,7 @@ void debug_info_msg_iter_finalize(bt_self_message_iterator *it) { struct debug_info_msg_iter *debug_info_msg_iter; - debug_info_msg_iter = bt_self_message_iterator_get_data(it); + debug_info_msg_iter = static_cast(bt_self_message_iterator_get_data(it)); BT_ASSERT(debug_info_msg_iter); debug_info_msg_iter_destroy(debug_info_msg_iter); diff --git a/src/plugins/lttng-utils/debug-info/debug-info.h b/src/plugins/lttng-utils/debug-info/debug-info.hpp similarity index 91% rename from src/plugins/lttng-utils/debug-info/debug-info.h rename to src/plugins/lttng-utils/debug-info/debug-info.hpp index 5877a056..94183e6a 100644 --- a/src/plugins/lttng-utils/debug-info/debug-info.h +++ b/src/plugins/lttng-utils/debug-info/debug-info.hpp @@ -8,8 +8,10 @@ * Babeltrace - Debug information Plugin */ -#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_DEBUG_INFO_H -#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_DEBUG_INFO_H +/* clang-format off */ + +#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_DEBUG_INFO_HPP +#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_DEBUG_INFO_HPP #include #include @@ -55,4 +57,4 @@ bt_message_iterator_class_seek_beginning_method_status debug_info_msg_iter_seek_ void debug_info_msg_iter_finalize(bt_self_message_iterator *it); -#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_DEBUG_INFO_H */ +#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_DEBUG_INFO_HPP */ diff --git a/src/plugins/lttng-utils/debug-info/dwarf.c b/src/plugins/lttng-utils/debug-info/dwarf.cpp similarity index 99% rename from src/plugins/lttng-utils/debug-info/dwarf.c rename to src/plugins/lttng-utils/debug-info/dwarf.cpp index 20c605c8..be5dfdec 100644 --- a/src/plugins/lttng-utils/debug-info/dwarf.c +++ b/src/plugins/lttng-utils/debug-info/dwarf.cpp @@ -6,11 +6,13 @@ * Babeltrace - DWARF Information Reader */ +/* clang-format off */ + #include #include -#include "dwarf.h" +#include "dwarf.hpp" struct bt_dwarf_cu *bt_dwarf_cu_create(Dwarf *dwarf_info) { diff --git a/src/plugins/lttng-utils/debug-info/dwarf.h b/src/plugins/lttng-utils/debug-info/dwarf.hpp similarity index 96% rename from src/plugins/lttng-utils/debug-info/dwarf.h rename to src/plugins/lttng-utils/debug-info/dwarf.hpp index 288eb9c2..3bf593bb 100644 --- a/src/plugins/lttng-utils/debug-info/dwarf.h +++ b/src/plugins/lttng-utils/debug-info/dwarf.hpp @@ -6,8 +6,10 @@ * Babeltrace - DWARF Information Reader */ -#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_DWARF_H -#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_DWARF_H +/* clang-format off */ + +#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_DWARF_HPP +#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_DWARF_HPP #include #include @@ -201,4 +203,4 @@ int bt_dwarf_die_get_call_line(struct bt_dwarf_die *die, int bt_dwarf_die_contains_addr(struct bt_dwarf_die *die, uint64_t addr, bool *contains); -#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_DWARF_H */ +#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_DWARF_HPP */ diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.cpp similarity index 96% rename from src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c rename to src/plugins/lttng-utils/debug-info/trace-ir-data-copy.cpp index 51f76c00..810e84d0 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.cpp @@ -7,6 +7,8 @@ * Babeltrace - Trace IR data object copy */ +/* clang-format off */ + #define BT_COMP_LOG_SELF_COMP self_comp #define BT_LOG_OUTPUT_LEVEL log_level #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-DATA-COPY" @@ -18,7 +20,7 @@ #include "common/assert.h" #include "common/common.h" -#include "trace-ir-data-copy.h" +#include "trace-ir-data-copy.hpp" enum debug_info_trace_ir_mapping_status copy_trace_content( const bt_trace *in_trace, bt_trace *out_trace, @@ -41,7 +43,7 @@ enum debug_info_trace_ir_mapping_status copy_trace_content( BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot set trace's name: " "out-t-addr=%p, name=\"%s\"", out_trace, trace_name); - status = (int) set_name_status; + status = static_cast(set_name_status); goto end; } } @@ -94,7 +96,7 @@ enum debug_info_trace_ir_mapping_status copy_trace_content( BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot copy trace's environment: " "out-t-addr=%p, name=\"%s\"", out_trace, trace_name); - status = (int) set_env_status; + status = static_cast(set_env_status); goto end; } } @@ -126,7 +128,7 @@ enum debug_info_trace_ir_mapping_status copy_stream_content( BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot set stream's name: " "stream-addr=%p, name=\"%s\"", out_stream, stream_name); - status = (int) set_name_status; + status = static_cast(set_name_status); goto end; } } @@ -288,7 +290,7 @@ enum debug_info_trace_ir_mapping_status copy_field_content( BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot set string field's value: " "out-str-f-addr=%p, str=\"%s\"" PRId64, out_field, str); - status = (int) set_value_status; + status = static_cast(set_value_status); goto end; } } else if (in_fc_type == BT_FIELD_CLASS_TYPE_STRUCTURE) { @@ -354,7 +356,7 @@ enum debug_info_trace_ir_mapping_status copy_field_content( "Cannot set dynamic array field's length field: " "out-arr-f-addr=%p, arr-length=%" PRIu64, out_field, array_len); - status = (int) set_len_status; + status = static_cast(set_len_status); goto end; } } @@ -418,7 +420,7 @@ enum debug_info_trace_ir_mapping_status copy_field_content( "Cannot select variant field's option field: " "out-var-f-addr=%p, opt-index=%" PRId64, out_field, in_selected_option_idx); - status = (int) sel_opt_status; + status = static_cast(sel_opt_status); goto end; } diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.hpp similarity index 93% rename from src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h rename to src/plugins/lttng-utils/debug-info/trace-ir-data-copy.hpp index 847befa1..f00c19f5 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h +++ b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.hpp @@ -7,13 +7,15 @@ * Babeltrace - Trace IR data object copy */ -#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_DATA_COPY_H -#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_DATA_COPY_H +/* clang-format off */ + +#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_DATA_COPY_HPP +#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_DATA_COPY_HPP #include #include "common/macros.h" -#include "trace-ir-mapping.h" +#include "trace-ir-mapping.hpp" enum debug_info_trace_ir_mapping_status copy_trace_content( const bt_trace *in_trace, bt_trace *out_trace, @@ -31,4 +33,4 @@ enum debug_info_trace_ir_mapping_status copy_field_content( const bt_field *in_field, bt_field *out_field, bt_logging_level log_level, bt_self_component *self_comp); -#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_DATA_COPY_H */ +#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_DATA_COPY_HPP */ diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.c b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.cpp similarity index 97% rename from src/plugins/lttng-utils/debug-info/trace-ir-mapping.c rename to src/plugins/lttng-utils/debug-info/trace-ir-mapping.cpp index 5c805f2d..815bb82f 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.cpp @@ -9,6 +9,8 @@ * trace */ +/* clang-format off */ + #define BT_COMP_LOG_SELF_COMP (ir_maps->self_comp) #define BT_LOG_OUTPUT_LEVEL (ir_maps->log_level) #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-MAPPING" @@ -17,10 +19,10 @@ #include "common/assert.h" #include -#include "debug-info.h" -#include "trace-ir-data-copy.h" -#include "trace-ir-mapping.h" -#include "trace-ir-metadata-copy.h" +#include "debug-info.hpp" +#include "trace-ir-data-copy.hpp" +#include "trace-ir-mapping.hpp" +#include "trace-ir-metadata-copy.hpp" static bt_trace_class *create_new_mapped_trace_class(struct trace_ir_maps *ir_maps, @@ -143,8 +145,8 @@ bt_stream_class *trace_ir_mapping_borrow_mapped_stream_class( struct trace_ir_metadata_maps *md_maps = borrow_metadata_maps_from_input_stream_class(ir_maps, in_stream_class); - return g_hash_table_lookup(md_maps->stream_class_map, - (gpointer) in_stream_class); + return static_cast(g_hash_table_lookup(md_maps->stream_class_map, + (gpointer) in_stream_class)); } bt_stream_class *trace_ir_mapping_create_new_mapped_stream_class( @@ -212,7 +214,7 @@ bt_stream *borrow_mapped_stream(struct trace_ir_data_maps *d_maps, BT_ASSERT_DBG(d_maps); BT_ASSERT_DBG(in_stream); - return g_hash_table_lookup(d_maps->stream_map, (gpointer) in_stream); + return static_cast(g_hash_table_lookup(d_maps->stream_map, (gpointer) in_stream)); } bt_stream *trace_ir_mapping_create_new_mapped_stream( @@ -312,8 +314,8 @@ static inline bt_event_class *borrow_mapped_event_class(struct trace_ir_metadata_maps *md_maps, const bt_event_class *in_event_class) { - return g_hash_table_lookup(md_maps->event_class_map, - (gpointer) in_event_class); + return static_cast(g_hash_table_lookup(md_maps->event_class_map, + (gpointer) in_event_class)); } bt_event_class *trace_ir_mapping_create_new_mapped_event_class( @@ -405,7 +407,7 @@ bt_packet *borrow_mapped_packet(struct trace_ir_data_maps *d_maps, BT_ASSERT_DBG(d_maps); BT_ASSERT_DBG(in_packet); - return g_hash_table_lookup(d_maps->packet_map, (gpointer) in_packet); + return static_cast(g_hash_table_lookup(d_maps->packet_map, (gpointer) in_packet)); } bt_packet *trace_ir_mapping_create_new_mapped_packet( diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.hpp similarity index 96% rename from src/plugins/lttng-utils/debug-info/trace-ir-mapping.h rename to src/plugins/lttng-utils/debug-info/trace-ir-mapping.hpp index b4d7445b..c728543e 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h +++ b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.hpp @@ -4,8 +4,10 @@ * Copyright 2019 Francis Deslauriers francis.deslauriers@efficios.com> */ -#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_MAPPING_H -#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_MAPPING_H +/* clang-format off */ + +#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_MAPPING_HPP +#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_MAPPING_HPP #include @@ -13,7 +15,7 @@ #include "common/macros.h" #include -#include "debug-info.h" +#include "debug-info.hpp" enum debug_info_trace_ir_mapping_status { DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK = 0, @@ -188,7 +190,7 @@ struct trace_ir_data_maps *borrow_data_maps_from_input_trace( BT_ASSERT(in_trace); struct trace_ir_data_maps *d_maps = - g_hash_table_lookup(ir_maps->data_maps, (gpointer) in_trace); + static_cast(g_hash_table_lookup(ir_maps->data_maps, (gpointer) in_trace)); if (!d_maps) { d_maps = trace_ir_data_maps_create(ir_maps, in_trace); g_hash_table_insert(ir_maps->data_maps, (gpointer) in_trace, d_maps); @@ -228,8 +230,8 @@ struct trace_ir_metadata_maps *borrow_metadata_maps_from_input_trace_class( BT_ASSERT(in_trace_class); struct trace_ir_metadata_maps *md_maps = - g_hash_table_lookup(ir_maps->metadata_maps, - (gpointer) in_trace_class); + static_cast(g_hash_table_lookup(ir_maps->metadata_maps, + (gpointer) in_trace_class)); if (!md_maps) { md_maps = trace_ir_metadata_maps_create(ir_maps, in_trace_class); g_hash_table_insert(ir_maps->metadata_maps, @@ -261,4 +263,4 @@ struct trace_ir_metadata_maps *borrow_metadata_maps_from_input_event_class( bt_event_class_borrow_stream_class_const(in_event_class)); } -#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_MAPPING_H */ +#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_MAPPING_HPP */ diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.cpp similarity index 94% rename from src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c rename to src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.cpp index 67f52845..c8f043c5 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.cpp @@ -8,6 +8,8 @@ * Babeltrace - Trace IR metadata object copy */ +/* clang-format off */ + #define BT_COMP_LOG_SELF_COMP self_comp #define BT_LOG_OUTPUT_LEVEL log_level #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-META-COPY" @@ -18,9 +20,9 @@ #include "common/assert.h" -#include "trace-ir-metadata-copy.h" -#include "trace-ir-metadata-field-class-copy.h" -#include "utils.h" +#include "trace-ir-metadata-copy.hpp" +#include "trace-ir-metadata-field-class-copy.hpp" +#include "utils.hpp" enum debug_info_trace_ir_mapping_status copy_trace_class_content( struct trace_ir_maps *ir_maps, @@ -98,7 +100,7 @@ enum debug_info_trace_ir_mapping_status copy_clock_class_content( "Error setting clock class' name: " "cc-addr=%p, name=%s", out_clock_class, clock_class_name); - status = (int) set_name_status; + status = static_cast(set_name_status); goto end; } } @@ -120,7 +122,7 @@ enum debug_info_trace_ir_mapping_status copy_clock_class_content( "Error setting clock class' description: " "cc-addr=%p, cc-desc=%s", out_clock_class, clock_class_description); - status = (int) set_desc_status; + status = static_cast(set_desc_status); goto end; } } @@ -155,8 +157,8 @@ bt_clock_class *borrow_mapped_clock_class( BT_ASSERT_DBG(md_maps); BT_ASSERT_DBG(in_clock_class); - return g_hash_table_lookup(md_maps->clock_class_map, - (gpointer) in_clock_class); + return static_cast(g_hash_table_lookup(md_maps->clock_class_map, + (gpointer) in_clock_class)); } static @@ -240,7 +242,7 @@ enum debug_info_trace_ir_mapping_status copy_stream_class_content( set_def_cc_status = bt_stream_class_set_default_clock_class( out_stream_class, out_clock_class); if (set_def_cc_status != BT_STREAM_CLASS_SET_DEFAULT_CLOCK_CLASS_STATUS_OK) { - status = (int) set_def_cc_status; + status = static_cast(set_def_cc_status); goto end; } } @@ -279,7 +281,7 @@ enum debug_info_trace_ir_mapping_status copy_stream_class_content( "Error set stream class name: " "out-sc-addr=%p, name=%s", out_stream_class, in_name); - status = (int) set_name_status; + status = static_cast(set_name_status); goto end; } } @@ -322,7 +324,7 @@ enum debug_info_trace_ir_mapping_status copy_stream_class_content( "Error setting stream class' packet context field class: " "out-sc-addr=%p, out-packet-ctx-fc-addr=%p", out_stream_class, out_packet_context_fc); - status = (int) set_fc_status; + status = static_cast(set_fc_status); goto end; } } @@ -362,7 +364,7 @@ enum debug_info_trace_ir_mapping_status copy_stream_class_content( "Error setting stream class' common context field class: " "out-sc-addr=%p, out-comm-ctx-fc-addr=%p", out_stream_class, out_common_context_fc); - status = (int) set_fc_status; + status = static_cast(set_fc_status); goto end; } } @@ -424,7 +426,7 @@ enum debug_info_trace_ir_mapping_status copy_event_class_content( if (set_name_status != BT_EVENT_CLASS_SET_NAME_STATUS_OK) { BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Error setting event class' name: ec-addr=%p, " "name=%s", out_event_class, in_event_class_name); - status = (int) set_name_status; + status = static_cast(set_name_status); goto end; } } @@ -453,7 +455,7 @@ enum debug_info_trace_ir_mapping_status copy_event_class_content( "Error setting event class' emf uri: " "out-ec-addr=%p, emf-uri=\"%s\"", out_event_class, in_emf_uri); - status = (int) set_emf_status; + status = static_cast(set_emf_status); goto end; } } @@ -497,7 +499,7 @@ enum debug_info_trace_ir_mapping_status copy_event_class_content( "Error setting event class' specific context field class:" "out-ec-addr=%p, out-spec-ctx-fc-addr=%p", out_event_class, out_specific_context_fc); - status = (int) set_fc_status; + status = static_cast(set_fc_status); goto end; } } @@ -533,7 +535,7 @@ enum debug_info_trace_ir_mapping_status copy_event_class_content( BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Error setting event class' payload field class: " "out-ec-addr=%p, out-payload-fc-addr=%p", out_event_class, out_payload_fc); - status = (int) set_fc_status; + status = static_cast(set_fc_status); goto end; } } @@ -629,7 +631,7 @@ copy_event_common_context_field_class_content( BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Failed to add a field to debug_info struct: " "field=\"bin\"."); - status = (int) append_member_status; + status = static_cast(append_member_status); goto error; } BT_FIELD_CLASS_PUT_REF_AND_RESET(bin_field_class); @@ -641,7 +643,7 @@ copy_event_common_context_field_class_content( BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Failed to add a field to debug_info struct: " "field=\"func\"."); - status = (int) append_member_status; + status = static_cast(append_member_status); goto error; } BT_FIELD_CLASS_PUT_REF_AND_RESET(func_field_class); @@ -653,7 +655,7 @@ copy_event_common_context_field_class_content( BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Failed to add a field to debug_info struct: " "field=\"src\"."); - status = (int) append_member_status; + status = static_cast(append_member_status); goto error; } BT_FIELD_CLASS_PUT_REF_AND_RESET(src_field_class); @@ -665,7 +667,7 @@ copy_event_common_context_field_class_content( BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK) { BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Failed to add debug_info field to event common context."); - status = (int) append_member_status; + status = static_cast(append_member_status); goto error; } BT_FIELD_CLASS_PUT_REF_AND_RESET(debug_field_class); diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.hpp similarity index 94% rename from src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h rename to src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.hpp index 06c99035..7f704b44 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.hpp @@ -8,12 +8,14 @@ * Babeltrace - Trace IR metadata object copy */ -#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_METADATA_COPY_H -#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_METADATA_COPY_H +/* clang-format off */ + +#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_METADATA_COPY_HPP +#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_METADATA_COPY_HPP #include #include "common/macros.h" -#include "trace-ir-mapping.h" +#include "trace-ir-mapping.hpp" enum debug_info_trace_ir_mapping_status copy_trace_class_content( struct trace_ir_maps *trace_ir_maps, @@ -47,4 +49,4 @@ bt_field_class *create_field_class_copy( struct trace_ir_metadata_maps *trace_ir_metadata_maps, const bt_field_class *in_field_class); -#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_METADATA_COPY_H */ +#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_METADATA_COPY_HPP */ diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.cpp similarity index 97% rename from src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c rename to src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.cpp index 7dbb262c..05a58eb1 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.cpp @@ -8,6 +8,8 @@ * Babeltrace - Trace IR field copy */ +/* clang-format off */ + #define BT_COMP_LOG_SELF_COMP (md_maps->self_comp) #define BT_LOG_OUTPUT_LEVEL (md_maps->log_level) #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-META-FC-COPY" @@ -18,8 +20,8 @@ #include "compat/compiler.h" #include -#include "trace-ir-metadata-copy.h" -#include "trace-ir-metadata-field-class-copy.h" +#include "trace-ir-metadata-copy.hpp" +#include "trace-ir-metadata-field-class-copy.hpp" /* * This function walks through the nested structures field class to resolve a @@ -233,7 +235,7 @@ enum debug_info_trace_ir_mapping_status field_class_unsigned_enumeration_copy( add_mapping_status = bt_field_class_enumeration_unsigned_add_mapping( out_field_class, label, range_set); if (add_mapping_status != BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_OK) { - status = (int) add_mapping_status; + status = static_cast(add_mapping_status); goto end; } } @@ -281,7 +283,7 @@ enum debug_info_trace_ir_mapping_status field_class_signed_enumeration_copy( add_mapping_status = bt_field_class_enumeration_signed_add_mapping( out_field_class, label, range_set); if (add_mapping_status != BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_OK) { - status = (int) add_mapping_status; + status = static_cast(add_mapping_status); goto end; } } @@ -388,7 +390,7 @@ enum debug_info_trace_ir_mapping_status field_class_structure_copy( "field-name=\"%s\"", i, in_member_fc, member_name); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_member_fc); - status = (int) append_member_status; + status = static_cast(append_member_status); goto end; } @@ -482,7 +484,7 @@ enum debug_info_trace_ir_mapping_status field_class_variant_copy( "out-option-name=\"%s\"", out_field_class, out_option_fc, option_name); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class); - status = (int) append_opt_status; + status = static_cast(append_opt_status); goto end; } } else if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD) { @@ -504,7 +506,7 @@ enum debug_info_trace_ir_mapping_status field_class_variant_copy( "out-option-name=\"%s\"", out_field_class, out_option_fc, option_name); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class); - status = (int) append_opt_status; + status = static_cast(append_opt_status); goto end; } } else { @@ -521,7 +523,7 @@ enum debug_info_trace_ir_mapping_status field_class_variant_copy( "out-option-name=\"%s\"", out_field_class, out_option_fc, option_name); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class); - status = (int) append_opt_status; + status = static_cast(append_opt_status); goto end; } } @@ -754,8 +756,8 @@ bt_field_class *create_field_class_copy_internal( md_maps); BT_ASSERT(in_length_fc); - out_length_fc = g_hash_table_lookup(md_maps->field_class_map, - in_length_fc); + out_length_fc = static_cast(g_hash_table_lookup(md_maps->field_class_map, + in_length_fc)); BT_ASSERT(out_length_fc); } @@ -803,8 +805,8 @@ bt_field_class *create_field_class_copy_internal( in_selector_fc = resolve_field_path_to_field_class( in_selector_fp, md_maps); BT_ASSERT(in_selector_fc); - out_selector_fc = g_hash_table_lookup( - md_maps->field_class_map, in_selector_fc); + out_selector_fc = static_cast(g_hash_table_lookup( + md_maps->field_class_map, in_selector_fc)); BT_ASSERT(out_selector_fc); if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD) { @@ -851,8 +853,8 @@ bt_field_class *create_field_class_copy_internal( in_sel_fc = resolve_field_path_to_field_class(sel_fp, md_maps); BT_ASSERT(in_sel_fc); - out_sel_fc = g_hash_table_lookup( - md_maps->field_class_map, in_sel_fc); + out_sel_fc = static_cast(g_hash_table_lookup( + md_maps->field_class_map, in_sel_fc)); BT_ASSERT(out_sel_fc); } diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.h b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.hpp similarity index 86% rename from src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.h rename to src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.hpp index 84802c9d..a5272543 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.h +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.hpp @@ -7,12 +7,14 @@ * Babeltrace - Trace IR metadata field class copy */ -#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_METADATA_FIELD_CLASS_COPY_H -#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_METADATA_FIELD_CLASS_COPY_H +/* clang-format off */ + +#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_METADATA_FIELD_CLASS_COPY_HPP +#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_METADATA_FIELD_CLASS_COPY_HPP #include #include "common/macros.h" -#include "trace-ir-mapping.h" +#include "trace-ir-mapping.hpp" enum debug_info_trace_ir_mapping_status copy_field_class_content_internal( struct trace_ir_metadata_maps *trace_ir_metadata_maps, @@ -23,4 +25,4 @@ bt_field_class *create_field_class_copy_internal( struct trace_ir_metadata_maps *trace_ir_metadata_maps, const bt_field_class *in_field_class); -#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_METADATA_FIELD_CLASS_COPY_H */ +#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_TRACE_IR_METADATA_FIELD_CLASS_COPY_HPP */ diff --git a/src/plugins/lttng-utils/debug-info/utils.c b/src/plugins/lttng-utils/debug-info/utils.cpp similarity index 96% rename from src/plugins/lttng-utils/debug-info/utils.c rename to src/plugins/lttng-utils/debug-info/utils.cpp index 3c160bc4..ae009047 100644 --- a/src/plugins/lttng-utils/debug-info/utils.c +++ b/src/plugins/lttng-utils/debug-info/utils.cpp @@ -6,13 +6,15 @@ * Babeltrace - Debug info utilities */ +/* clang-format off */ + #include #include #include -#include "debug-info.h" -#include "utils.h" +#include "debug-info.hpp" +#include "utils.hpp" const char *get_filename_from_path(const char *path) { diff --git a/src/plugins/lttng-utils/debug-info/utils.h b/src/plugins/lttng-utils/debug-info/utils.hpp similarity index 72% rename from src/plugins/lttng-utils/debug-info/utils.h rename to src/plugins/lttng-utils/debug-info/utils.hpp index 4d9310d9..c5e4162a 100644 --- a/src/plugins/lttng-utils/debug-info/utils.h +++ b/src/plugins/lttng-utils/debug-info/utils.hpp @@ -6,8 +6,10 @@ * Babeltrace - Debug Info Utilities */ -#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_UTILS_H -#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_UTILS_H +/* clang-format off */ + +#ifndef BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_UTILS_HPP +#define BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_UTILS_HPP #include @@ -25,4 +27,4 @@ bool is_event_common_ctx_dbg_info_compatible( const bt_field_class *in_field_class, const char *debug_info_field_class_name); -#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_UTILS_H */ +#endif /* BABELTRACE_PLUGINS_LTTNG_UTILS_DEBUG_INFO_UTILS_HPP */ diff --git a/src/plugins/lttng-utils/plugin.c b/src/plugins/lttng-utils/plugin.cpp similarity index 96% rename from src/plugins/lttng-utils/plugin.c rename to src/plugins/lttng-utils/plugin.cpp index 241c313f..42150a59 100644 --- a/src/plugins/lttng-utils/plugin.c +++ b/src/plugins/lttng-utils/plugin.cpp @@ -6,8 +6,10 @@ * Babeltrace Debug Info Plug-in */ +/* clang-format off */ + #include -#include "debug-info/debug-info.h" +#include "debug-info/debug-info.hpp" #ifndef BT_BUILT_IN_PLUGINS BT_PLUGIN_MODULE(); diff --git a/tests/plugins/flt.lttng-utils.debug-info/Makefile.am b/tests/plugins/flt.lttng-utils.debug-info/Makefile.am index 4a58bfca..4e986205 100644 --- a/tests/plugins/flt.lttng-utils.debug-info/Makefile.am +++ b/tests/plugins/flt.lttng-utils.debug-info/Makefile.am @@ -33,7 +33,7 @@ test_dwarf_LDADD = \ $(top_builddir)/src/common/libcommon.la \ $(ELFUTILS_LIBS) \ $(LIBTAP) -test_dwarf_SOURCES = test-dwarf.c +test_dwarf_SOURCES = test-dwarf.cpp test_bin_info_LDADD = \ $(top_builddir)/src/plugins/lttng-utils/debug-info/libdebug-info.la \ @@ -43,7 +43,7 @@ test_bin_info_LDADD = \ $(top_builddir)/src/lib/libbabeltrace2.la \ $(ELFUTILS_LIBS) \ $(LIBTAP) -test_bin_info_SOURCES = test-bin-info.c +test_bin_info_SOURCES = test-bin-info.cpp nodist_EXTRA_test_bin_info_SOURCES = dummy.cpp endif # ENABLE_DEBUG_INFO diff --git a/tests/plugins/flt.lttng-utils.debug-info/test-bin-info.c b/tests/plugins/flt.lttng-utils.debug-info/test-bin-info.cpp similarity index 99% rename from tests/plugins/flt.lttng-utils.debug-info/test-bin-info.c rename to tests/plugins/flt.lttng-utils.debug-info/test-bin-info.cpp index 3e6e7a66..093de38f 100644 --- a/tests/plugins/flt.lttng-utils.debug-info/test-bin-info.c +++ b/tests/plugins/flt.lttng-utils.debug-info/test-bin-info.cpp @@ -8,6 +8,8 @@ * Babeltrace SO info tests */ +/* clang-format off */ + #define BT_LOG_OUTPUT_LEVEL ((bt_logging_level) BT_LOG_WARNING) #define BT_LOG_TAG "TEST/BIN-INFO" #include "logging/log.h" @@ -20,7 +22,7 @@ #include "common/macros.h" #include "common/assert.h" -#include +#include #include "tap/tap.h" diff --git a/tests/plugins/flt.lttng-utils.debug-info/test-dwarf.c b/tests/plugins/flt.lttng-utils.debug-info/test-dwarf.cpp similarity index 98% rename from tests/plugins/flt.lttng-utils.debug-info/test-dwarf.c rename to tests/plugins/flt.lttng-utils.debug-info/test-dwarf.cpp index e50d1c44..7ab92f0e 100644 --- a/tests/plugins/flt.lttng-utils.debug-info/test-dwarf.c +++ b/tests/plugins/flt.lttng-utils.debug-info/test-dwarf.cpp @@ -7,13 +7,15 @@ * Babeltrace bt_dwarf (DWARF utilities) tests */ +/* clang-format off */ + #include #include #include #include #include #include -#include +#include #include "tap/tap.h" #define NR_TESTS 17 -- 2.34.1