diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_binder_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_binder_event_formatter.cpp index 3511e46ab0227d1f9a84437d198d857320bd90b5..e30afbd375176807a711d6a3b95d9d546b091c5e 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_binder_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_binder_event_formatter.cpp @@ -28,7 +28,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_alloc_lru_end_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_alloc_lru_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_alloc_lru_end: proc=%d page_index=%" PRIu64 "", msg.proc(), msg.page_index()); if (len >= BUFFER_SIZE - 1) { @@ -36,6 +36,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_alloc_lru_end) msg had " "be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_alloc_lru_end) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -44,7 +50,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_alloc_lru_start_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_alloc_lru_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_alloc_lru_start: proc=%d page_index=%" PRIu64 "", msg.proc(), msg.page_index()); if (len >= BUFFER_SIZE - 1) { @@ -52,6 +58,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_alloc_lru_start) msg " "had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_alloc_lru_start) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -60,7 +72,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_alloc_page_end_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_alloc_page_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_alloc_page_end: proc=%d page_index=%" PRIu64 "", msg.proc(), msg.page_index()); if (len >= BUFFER_SIZE - 1) { @@ -68,6 +80,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_alloc_page_end) msg had " "be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_alloc_page_end) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -76,7 +94,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_alloc_page_start_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_alloc_page_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_alloc_page_start: proc=%d page_index=%" PRIu64 "", msg.proc(), msg.page_index()); if (len >= BUFFER_SIZE - 1) { @@ -84,6 +102,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_alloc_page_start) msg " "had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_alloc_page_start) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -91,13 +115,19 @@ REGISTER_FTRACE_EVENT_FORMATTER( binder_command, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_command_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_command_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_command: cmd=0x%x", msg.cmd()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(binder_command) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_command) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -106,7 +136,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_free_lru_end_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_free_lru_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_free_lru_end: proc=%d page_index=%" PRIu64 "", msg.proc(), msg.page_index()); if (len >= BUFFER_SIZE - 1) { @@ -114,6 +144,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_free_lru_end) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_free_lru_end) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -122,7 +158,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_free_lru_start_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_free_lru_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_free_lru_start: proc=%d page_index=%" PRIu64 "", msg.proc(), msg.page_index()); if (len >= BUFFER_SIZE - 1) { @@ -130,6 +166,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_free_lru_start) msg had " "be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_free_lru_start) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -137,7 +179,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( binder_ioctl, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_ioctl_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_ioctl_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_ioctl: cmd=0x%x arg=0x%" PRIx64 "", msg.cmd(), msg.arg()); if (len >= BUFFER_SIZE - 1) { @@ -145,6 +187,10 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_ioctl) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(binder_ioctl) msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -153,13 +199,19 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_ioctl_done_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_ioctl_done_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_ioctl_done: ret=%d", msg.ret()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(binder_ioctl_done) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_ioctl_done) " + "msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -167,13 +219,17 @@ REGISTER_FTRACE_EVENT_FORMATTER( binder_lock, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_lock_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_lock_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_lock: tag=%s", msg.tag().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(binder_lock) msg " "had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(binder_lock) msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -181,13 +237,19 @@ REGISTER_FTRACE_EVENT_FORMATTER( binder_locked, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_locked_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_locked_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_locked: tag=%s", msg.tag().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(binder_locked) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_locked) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -195,13 +257,19 @@ REGISTER_FTRACE_EVENT_FORMATTER( binder_read_done, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_read_done_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_read_done_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_read_done: ret=%d", msg.ret()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(binder_read_done) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_read_done) " + "msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -209,13 +277,19 @@ REGISTER_FTRACE_EVENT_FORMATTER( binder_return, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_return_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_return_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_return: cmd=0x%x", msg.cmd()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(binder_return) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_return) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -224,7 +298,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_transaction_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_transaction_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_transaction: transaction=%d dest_node=%d dest_proc=%d " "dest_thread=%d reply=%d flags=0x%x code=0x%x", @@ -235,6 +309,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_transaction) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_transaction) " + "msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -243,16 +323,22 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_transaction_alloc_buf_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_transaction_alloc_buf_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_transaction_alloc_buf: transaction=%d data_size=%" PRIu64 " offsets_size=%" PRIu64 - " extra_buffers_size=%" PRIu64 "", + " extra_buffers_size=%" PRIu64 "", msg.debug_id(), msg.data_size(), msg.offsets_size(), msg.extra_buffers_size()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(binder_transaction_alloc_buf) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_transaction_alloc_buf) " + "msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -261,10 +347,10 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_transaction_buffer_release_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_transaction_buffer_release_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_transaction_buffer_release: transaction=%d data_size=%" PRIu64 - " offsets_size=%" PRIu64 " extra_buffers_size=%" PRIu64 "", + " offsets_size=%" PRIu64 " extra_buffers_size=%" PRIu64 "", msg.debug_id(), msg.data_size(), msg.offsets_size(), msg.extra_buffers_size()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, @@ -272,6 +358,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "event(binder_transaction_buffer_release) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_transaction_buffer_release) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -282,7 +374,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_transaction_failed_buffer_release_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_transaction_failed_buffer_release: transaction=%d " "data_size=%" PRIu64 " offsets_size=%" PRIu64 " extra_buffers_size=%" PRIu64 "", @@ -293,6 +385,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "event(binder_transaction_failed_buffer_" "release) msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_transaction_failed_buffer_release) " + "msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -301,7 +399,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_transaction_node_to_ref_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_transaction_node_to_ref_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_transaction_node_to_ref: transaction=%d node=%d " @@ -313,6 +411,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "event(binder_transaction_node_to_ref) msg " "had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_transaction_node_to_ref) " + "msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -321,7 +425,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_transaction_received_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_transaction_received_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_transaction_received: transaction=%d", msg.debug_id()); if (len >= BUFFER_SIZE - 1) { @@ -329,6 +433,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_transaction_received) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_transaction_received) " + "msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -337,7 +447,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_transaction_ref_to_node_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_transaction_ref_to_node_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_transaction_ref_to_node: transaction=%d node=%d " @@ -349,6 +459,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "event(binder_transaction_ref_to_node) msg " "had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_transaction_ref_to_node) " + "msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -357,7 +473,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_transaction_ref_to_ref_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_transaction_ref_to_ref_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_transaction_ref_to_ref: transaction=%d node=%d src_ref=%d " "src_desc=%d ==> dest_ref=%d dest_desc=%d", @@ -368,6 +484,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_transaction_ref_to_ref) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_transaction_ref_to_ref) " + "msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -375,13 +497,19 @@ REGISTER_FTRACE_EVENT_FORMATTER( binder_unlock, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_unlock_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_unlock_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_unlock: tag=%s", msg.tag().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(binder_unlock) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_unlock) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -390,7 +518,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_unmap_kernel_end_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_unmap_kernel_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_unmap_kernel_end: proc=%d page_index=%" PRIu64 "", msg.proc(), msg.page_index()); if (len >= BUFFER_SIZE - 1) { @@ -398,6 +526,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_unmap_kernel_end) msg " "had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_unmap_kernel_end) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -406,7 +540,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_unmap_kernel_start_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_unmap_kernel_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_unmap_kernel_start: proc=%d page_index=%" PRIu64 "", msg.proc(), msg.page_index()); if (len >= BUFFER_SIZE - 1) { @@ -414,6 +548,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_unmap_kernel_start) msg " "had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_unmap_kernel_start) " + "msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -422,7 +562,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_unmap_user_end_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_unmap_user_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_unmap_user_end: proc=%d page_index=%" PRIu64 "", msg.proc(), msg.page_index()); if (len >= BUFFER_SIZE - 1) { @@ -430,6 +570,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_unmap_user_end) msg had " "be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_unmap_user_end) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -438,7 +584,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_unmap_user_start_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_unmap_user_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_unmap_user_start: proc=%d page_index=%" PRIu64 "", msg.proc(), msg.page_index()); if (len >= BUFFER_SIZE - 1) { @@ -446,6 +592,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_unmap_user_start) msg " "had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_unmap_user_start) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -454,7 +606,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_update_page_range_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_update_page_range_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_update_page_range: proc=%d allocate=%d offset=%" PRIu64 " size=%" PRIu64 "", msg.proc(), msg.allocate(), msg.offset(), msg.size()); @@ -463,6 +615,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_update_page_range) msg " "had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_update_page_range) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -471,7 +629,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_wait_for_work_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_wait_for_work_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_wait_for_work: proc_work=%d " "transaction_stack=%d thread_todo=%d", @@ -481,6 +639,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( "maybe, the contents of print event(binder_wait_for_work) msg had " "be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_wait_for_work) msg " + "snprintf_s format error "); + return ""; + } return std::string(buffer); }); @@ -489,13 +653,19 @@ REGISTER_FTRACE_EVENT_FORMATTER( [](const ForStandard::FtraceEvent &event) -> bool { return event.has_binder_write_done_format(); }, [](const ForStandard::FtraceEvent &event) -> std::string { auto msg = event.binder_write_done_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "binder_write_done: ret=%d", msg.ret()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(binder_write_done) " "msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(binder_write_done) " + "msg snprintf_s format error "); + return ""; + } return std::string(buffer); }); } // namespace diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_block_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_block_event_formatter.cpp index 60f1b3a19ae65964433231a753ad9d3fa5019b37..2460fb445d86b6ee78a795e005e88a2243284a78 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_block_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_block_event_formatter.cpp @@ -24,94 +24,109 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( block_bio_backmerge, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_bio_backmerge_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_bio_backmerge_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_bio_backmerge_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_bio_backmerge: %d,%d %s %" PRIu64 " + %u [%s]", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.rwbs().c_str(), msg.sector(), msg.nr_sector(), msg.comm().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_bio_backmerge) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_bio_backmerge) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_bio_backmerge) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - block_bio_bounce, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_bio_bounce_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + block_bio_bounce, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_bio_bounce_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_bio_bounce_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_bio_bounce: %d,%d %s %" PRIu64 " + %u [%s]", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.rwbs().c_str(), msg.sector(), msg.nr_sector(), msg.comm().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_bio_bounce) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_bio_bounce) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_bio_bounce) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( block_bio_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_bio_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_bio_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_bio_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_bio_complete: %d,%d %s %" PRIu64 " + %u [%d]", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.rwbs().c_str(), msg.sector(), msg.nr_sector(), msg.error()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_bio_complete) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_bio_complete) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_bio_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( block_bio_frontmerge, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_bio_frontmerge_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_bio_frontmerge_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_bio_frontmerge_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_bio_frontmerge: %d,%d %s %" PRIu64 " + %u [%s]", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.rwbs().c_str(), msg.sector(), msg.nr_sector(), msg.comm().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_bio_frontmerge) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(block_bio_frontmerge) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_bio_frontmerge) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - block_bio_queue, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_bio_queue_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + block_bio_queue, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_bio_queue_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_bio_queue_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_bio_queue: %d,%d %s %" PRIu64 " + %u [%s]", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.rwbs().c_str(), msg.sector(), msg.nr_sector(), msg.comm().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_bio_queue) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_bio_queue) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_bio_queue) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - block_bio_remap, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_bio_remap_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + block_bio_remap, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_bio_remap_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_bio_remap_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_bio_remap: %d,%d %s %" PRIu64 " + %u <- (%d,%d) %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), @@ -119,117 +134,137 @@ REGISTER_FTRACE_EVENT_FORMATTER( ((unsigned int)((msg.old_dev()) & ((1U << 20) - 1))), msg.old_sector()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_bio_remap) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_bio_remap) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_bio_remap) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( block_dirty_buffer, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_dirty_buffer_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_dirty_buffer_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_dirty_buffer_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_dirty_buffer: %d,%d sector=%" PRIu64 " size=%" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.sector(), msg.size()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_dirty_buffer) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_dirty_buffer) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_dirty_buffer) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - block_getrq, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_getrq_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + block_getrq, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_getrq_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_getrq_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_getrq: %d,%d %s %" PRIu64 " + %u [%s]", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.rwbs().c_str(), msg.sector(), msg.nr_sector(), msg.comm().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_getrq) msg " - "had be cut off in outfile"); + "maybe, the contents of print event(block_getrq) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_getrq) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - block_plug, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_plug_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + block_plug, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_plug_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_plug_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_plug: [%s]", msg.comm().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_plug) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(block_plug) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_plug) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( block_rq_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_rq_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_rq_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_rq_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_rq_complete: %d,%d %s (%s) %" PRIu64 " + %u [%d]", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.rwbs().c_str(), msg.cmd().c_str(), msg.sector(), msg.nr_sector(), msg.error()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_rq_complete) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_rq_complete) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_rq_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - block_rq_insert, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_rq_insert_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + block_rq_insert, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_rq_insert_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_rq_insert_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_rq_insert: %d,%d %s %u (%s) %" PRIu64 " + %u [%s]", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.rwbs().c_str(), msg.bytes(), msg.cmd().c_str(), msg.sector(), msg.nr_sector(), msg.comm().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_rq_insert) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_rq_insert) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_rq_insert) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - block_rq_issue, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_rq_issue_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + block_rq_issue, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_rq_issue_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_rq_issue_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_rq_issue: %d,%d %s %u (%s) %" PRIu64 " + %u [%s]", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.rwbs().c_str(), msg.bytes(), msg.cmd().c_str(), msg.sector(), msg.nr_sector(), msg.comm().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_rq_issue) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_rq_issue) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_rq_issue) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - block_rq_remap, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_rq_remap_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + block_rq_remap, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_rq_remap_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_rq_remap_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_rq_remap: %d,%d %s %" PRIu64 " + %u <- (%d,%d) %" PRIu64 " %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), @@ -237,75 +272,90 @@ REGISTER_FTRACE_EVENT_FORMATTER( ((unsigned int)((msg.old_dev()) & ((1U << 20) - 1))), msg.old_sector(), msg.nr_bios()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_rq_remap) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_rq_remap) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_rq_remap) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - block_rq_requeue, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_rq_requeue_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + block_rq_requeue, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_rq_requeue_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_rq_requeue_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_rq_requeue: %d,%d %s (%s) %" PRIu64 " + %u [%d]", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.rwbs().c_str(), msg.cmd().c_str(), msg.sector(), msg.nr_sector(), 0); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_rq_requeue) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_rq_requeue) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_rq_requeue) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - block_split, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_split_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + block_split, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_split_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_split_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_split: %d,%d %s %" PRIu64 " / %" PRIu64 " [%s]", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.rwbs().c_str(), msg.sector(), msg.new_sector(), msg.comm().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_split) msg " - "had be cut off in outfile"); + "maybe, the contents of print event(block_split) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_split) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( block_touch_buffer, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_touch_buffer_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_touch_buffer_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_touch_buffer_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_touch_buffer: %d,%d sector=%" PRIu64 " size=%" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.sector(), msg.size()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_touch_buffer) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_touch_buffer) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_touch_buffer) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - block_unplug, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_block_unplug_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + block_unplug, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_block_unplug_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.block_unplug_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "block_unplug: [%s] %d", msg.comm().c_str(), msg.nr_rq()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(block_unplug) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(block_unplug) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(block_unplug) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_cgroup_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_cgroup_event_formatter.cpp index f8030814e07efa8f95831aa1cab41c24d407ad53..c7d2e9244869aaffbe769e59f877970ecf6bd0d2 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_cgroup_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_cgroup_event_formatter.cpp @@ -24,213 +24,252 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( cgroup_attach_task, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_attach_task_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_attach_task_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_attach_task_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_attach_task: dst_root=%d dst_id=%" PRIu64 " dst_level=%d dst_path=%s pid=%d comm=%s", msg.dst_root(), msg.dst_id(), msg.dst_level(), msg.dst_path().c_str(), msg.pid(), msg.comm().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_attach_task) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(cgroup_attach_task) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_attach_task) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( cgroup_destroy_root, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_destroy_root_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_destroy_root_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_destroy_root_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_destroy_root: root=%d ss_mask=%#x name=%s", msg.root(), msg.ss_mask(), msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_destroy_root) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(cgroup_destroy_root) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_destroy_root) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - cgroup_freeze, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_freeze_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + cgroup_freeze, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_freeze_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_freeze_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_freeze: root=%d id=%" PRIu64 " level=%d path=%s", msg.root(), msg.id(), msg.level(), msg.path().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_freeze) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(cgroup_freeze) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_freeze) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - cgroup_mkdir, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_mkdir_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + cgroup_mkdir, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_mkdir_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_mkdir_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_mkdir: root=%d id=%" PRIu64 " level=%d path=%s", msg.root(), msg.id(), msg.level(), msg.path().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_mkdir) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(cgroup_mkdir) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_mkdir) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( cgroup_notify_frozen, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_notify_frozen_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_notify_frozen_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_notify_frozen_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_notify_frozen: root=%d id=%" PRIu64 " level=%d path=%s val=%d", msg.root(), msg.id(), msg.level(), msg.path().c_str(), msg.val()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_notify_frozen) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(cgroup_notify_frozen) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_notify_frozen) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( cgroup_notify_populated, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_notify_populated_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_notify_populated_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_notify_populated_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_notify_populated: root=%d id=%" PRIu64 " level=%d path=%s val=%d", msg.root(), msg.id(), msg.level(), msg.path().c_str(), msg.val()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_notify_populated) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(cgroup_notify_populated) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_notify_populated) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - cgroup_release, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_release_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + cgroup_release, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_release_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_release_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_release: root=%d id=%" PRIu64 " level=%d path=%s", msg.root(), msg.id(), msg.level(), msg.path().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_release) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(cgroup_release) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_release) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - cgroup_remount, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_remount_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + cgroup_remount, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_remount_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_remount_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_remount: root=%d ss_mask=%#x name=%s", msg.root(), msg.ss_mask(), msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_remount) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(cgroup_remount) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_remount) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - cgroup_rename, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_rename_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + cgroup_rename, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_rename_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_rename_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_rename: root=%d id=%" PRIu64 " level=%d path=%s", msg.root(), msg.id(), msg.level(), msg.path().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_rename) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(cgroup_rename) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_rename) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - cgroup_rmdir, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_rmdir_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + cgroup_rmdir, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_rmdir_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_rmdir_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_rmdir: root=%d id=%" PRIu64 " level=%d path=%s", msg.root(), msg.id(), msg.level(), msg.path().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_rmdir) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(cgroup_rmdir) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_rmdir) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( cgroup_setup_root, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_setup_root_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_setup_root_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_setup_root_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_setup_root: root=%d ss_mask=%#x name=%s", msg.root(), msg.ss_mask(), msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_setup_root) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(cgroup_setup_root) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_setup_root) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( cgroup_transfer_tasks, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_transfer_tasks_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_transfer_tasks_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_transfer_tasks_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_transfer_tasks: dst_root=%d dst_id=%" PRIu64 " dst_level=%d dst_path=%s pid=%d comm=%s", msg.dst_root(), msg.dst_id(), msg.dst_level(), msg.dst_path().c_str(), msg.pid(), msg.comm().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_transfer_tasks) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(cgroup_transfer_tasks) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_transfer_tasks) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - cgroup_unfreeze, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cgroup_unfreeze_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + cgroup_unfreeze, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cgroup_unfreeze_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cgroup_unfreeze_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cgroup_unfreeze: root=%d id=%" PRIu64 " level=%d path=%s", msg.root(), msg.id(), msg.level(), msg.path().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cgroup_unfreeze) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(cgroup_unfreeze) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cgroup_unfreeze) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_clk_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_clk_event_formatter.cpp index 71297800a17f77ce3b965313aaf530238eee7e25..06bb5e5560af0e5d537c5116e974fa6e2e027f62 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_clk_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_clk_event_formatter.cpp @@ -23,210 +23,251 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - clk_disable, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_disable_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + clk_disable, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_disable_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_disable_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_disable: %s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_disable) msg " - "had be cut off in outfile"); + "maybe, the contents of print event(clk_disable) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_disable) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( clk_disable_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_disable_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_disable_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_disable_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_disable_complete: %s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_disable_complete) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(clk_disable_complete) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_disable_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - clk_enable, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_enable_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + clk_enable, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_enable_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_enable_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_enable: %s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_enable) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(clk_enable) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_enable) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( clk_enable_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_enable_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_enable_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_enable_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_enable_complete: %s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_enable_complete) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(clk_enable_complete) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_enable_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - clk_prepare, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_prepare_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + clk_prepare, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_prepare_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_prepare_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_prepare: %s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_prepare) msg " - "had be cut off in outfile"); + "maybe, the contents of print event(clk_prepare) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_prepare) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( clk_prepare_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_prepare_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_prepare_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_prepare_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_prepare_complete: %s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_prepare_complete) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(clk_prepare_complete) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_prepare_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - clk_set_parent, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_set_parent_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + clk_set_parent, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_set_parent_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_set_parent_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_set_parent: %s %s", msg.name().c_str(), msg.pname().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_set_parent) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(clk_set_parent) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_set_parent) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( clk_set_parent_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_set_parent_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_set_parent_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_set_parent_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_set_parent_complete: %s %s", msg.name().c_str(), msg.pname().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_set_parent_complete) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(clk_set_parent_complete) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_set_parent_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - clk_set_phase, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_set_phase_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + clk_set_phase, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_set_phase_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_set_phase_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_set_phase: %s %d", msg.name().c_str(), (int)msg.phase()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_set_phase) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(clk_set_phase) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_set_phase) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( clk_set_phase_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_set_phase_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_set_phase_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_set_phase_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_set_phase_complete: %s %d", msg.name().c_str(), (int)msg.phase()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_set_phase_complete) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(clk_set_phase_complete) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_set_phase_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - clk_set_rate, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_set_rate_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + clk_set_rate, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_set_rate_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_set_rate_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_set_rate: %s %lu", msg.name().c_str(), (unsigned long)msg.rate()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_set_rate) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(clk_set_rate) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_set_rate) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( clk_set_rate_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_set_rate_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_set_rate_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_set_rate_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_set_rate_complete: %s %lu", msg.name().c_str(), (unsigned long)msg.rate()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_set_rate_complete) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(clk_set_rate_complete) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_set_rate_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - clk_unprepare, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_unprepare_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + clk_unprepare, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_unprepare_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_unprepare_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_unprepare: %s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_unprepare) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(clk_unprepare) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_unprepare) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( clk_unprepare_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clk_unprepare_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clk_unprepare_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clk_unprepare_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clk_unprepare_complete: %s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clk_unprepare_complete) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(clk_unprepare_complete) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clk_unprepare_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_compaction_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_compaction_event_formatter.cpp index ba17e04322874a995b868ee84b413d6edef57867..4ac6f9740c4d36a80b0c2933a5bb857d2c6eec5b 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_compaction_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_compaction_event_formatter.cpp @@ -25,38 +25,46 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( mm_compaction_isolate_freepages, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_compaction_isolate_freepages_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_compaction_isolate_freepages_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_compaction_isolate_freepages_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_compaction_isolate_freepages: range=(0x%" PRIx64 " ~ 0x%" PRIx64 - ") nr_scanned==0x%" PRIu64 " nr_taken==0x%" PRIu64 "", + ") nr_scanned==0x%" PRIu64 " nr_taken==0x%" PRIu64 "", msg.start_pfn(), msg.end_pfn(), msg.nr_scanned(), msg.nr_taken()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(mm_compaction_isolate_freepages) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print " - "event(mm_compaction_isolate_freepages) " - "msg had be cut off in outfile"); + "the contents of event(mm_compaction_isolate_freepages) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_compaction_isolate_migratepages, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_compaction_isolate_migratepages_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_compaction_isolate_migratepages_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_compaction_isolate_migratepages_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_compaction_isolate_migratepages: range=(0x%" PRIx64 " ~ 0x%" PRIx64 - ") nr_scanned==0x%" PRIu64 " nr_taken==0x%" PRIu64 "", + ") nr_scanned==0x%" PRIu64 " nr_taken==0x%" PRIu64 "", msg.start_pfn(), msg.end_pfn(), msg.nr_scanned(), msg.nr_taken()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(mm_compaction_isolate_migratepages) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print " - "event(mm_compaction_isolate_migratepages) " - "msg had be cut off in outfile"); + "the contents of event(mm_compaction_isolate_migratepages) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_cpuhp_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_cpuhp_event_formatter.cpp index 6dd6f417feca8dc05b2558257dabfd931c58a6a2..14c2288db5535d06f4d73e65d77374dd291d4663 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_cpuhp_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_cpuhp_event_formatter.cpp @@ -23,13 +23,13 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - cpuhp_enter, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cpuhp_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + cpuhp_enter, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cpuhp_enter_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cpuhp_enter_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.fun()) > 0) { functionStr = kernelSymbols[msg.fun()]; } @@ -42,37 +42,42 @@ REGISTER_FTRACE_EVENT_FORMATTER( } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cpuhp_enter) msg " - "had be cut off in outfile"); + "maybe, the contents of print event(cpuhp_enter) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cpuhp_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - cpuhp_exit, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cpuhp_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + cpuhp_exit, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cpuhp_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cpuhp_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cpuhp_exit: cpu: %04u state: %3d step: %3d ret: %d", msg.cpu(), msg.state(), msg.idx(), msg.ret()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cpuhp_exit) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(cpuhp_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cpuhp_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( cpuhp_multi_enter, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cpuhp_multi_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cpuhp_multi_enter_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cpuhp_multi_enter_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.fun()) > 0) { functionStr = kernelSymbols[msg.fun()]; } @@ -87,8 +92,11 @@ REGISTER_FTRACE_EVENT_FORMATTER( } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cpuhp_multi_enter) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(cpuhp_multi_enter) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cpuhp_multi_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_dma_fence_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_dma_fence_event_formatter.cpp index 1ae67aad056093475710dc7d14c7c7a76a84100e..80ab03c0f4c608bdef4e3ca899dd6fde2fb0072c 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_dma_fence_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_dma_fence_event_formatter.cpp @@ -24,117 +24,138 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( dma_fence_destroy, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_dma_fence_destroy_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_dma_fence_destroy_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.dma_fence_destroy_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "dma_fence_destroy: driver=%s timeline=%s context=%u seqno=%u", msg.driver().c_str(), msg.timeline().c_str(), msg.context(), msg.seqno()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(dma_fence_destroy) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(dma_fence_destroy) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(dma_fence_destroy) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - dma_fence_emit, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_dma_fence_emit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + dma_fence_emit, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_dma_fence_emit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.dma_fence_emit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "dma_fence_emit: driver=%s timeline=%s context=%u seqno=%u", msg.driver().c_str(), msg.timeline().c_str(), msg.context(), msg.seqno()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(dma_fence_emit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(dma_fence_emit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(dma_fence_emit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( dma_fence_enable_signal, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_dma_fence_enable_signal_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_dma_fence_enable_signal_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.dma_fence_enable_signal_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "dma_fence_enable_signal: driver=%s timeline=%s context=%u seqno=%u", msg.driver().c_str(), msg.timeline().c_str(), msg.context(), msg.seqno()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(dma_fence_enable_signal) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(dma_fence_enable_signal) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(dma_fence_enable_signal) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - dma_fence_init, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_dma_fence_init_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + dma_fence_init, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_dma_fence_init_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.dma_fence_init_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "dma_fence_init: driver=%s timeline=%s context=%u seqno=%u", msg.driver().c_str(), msg.timeline().c_str(), msg.context(), msg.seqno()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(dma_fence_init) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(dma_fence_init) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(dma_fence_init) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( dma_fence_signaled, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_dma_fence_signaled_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_dma_fence_signaled_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.dma_fence_signaled_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "dma_fence_signaled: driver=%s timeline=%s context=%u seqno=%u", msg.driver().c_str(), msg.timeline().c_str(), msg.context(), msg.seqno()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(dma_fence_signaled) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(dma_fence_signaled) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(dma_fence_signaled) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( dma_fence_wait_end, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_dma_fence_wait_end_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_dma_fence_wait_end_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.dma_fence_wait_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "dma_fence_wait_end: driver=%s timeline=%s context=%u seqno=%u", msg.driver().c_str(), msg.timeline().c_str(), msg.context(), msg.seqno()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(dma_fence_wait_end) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(dma_fence_wait_end) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(dma_fence_wait_end) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( dma_fence_wait_start, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_dma_fence_wait_start_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_dma_fence_wait_start_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.dma_fence_wait_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "dma_fence_wait_start: driver=%s timeline=%s context=%u seqno=%u", msg.driver().c_str(), msg.timeline().c_str(), msg.context(), msg.seqno()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(dma_fence_wait_start) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(dma_fence_wait_start) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(dma_fence_wait_start) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_ext4_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_ext4_event_formatter.cpp index 1f0340f20e701426814e4384830acc1c74b19e83..3427195c8047040e35fcee9e0a4236fdc11e968c 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_ext4_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_ext4_event_formatter.cpp @@ -24,28 +24,31 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( ext4_alloc_da_blocks, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_alloc_da_blocks_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_alloc_da_blocks_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_alloc_da_blocks_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_alloc_da_blocks: dev %d,%d ino %" PRIu64 " reserved_data_blocks %u", - ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), - msg.ino(), msg.data_blocks()); + ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), + msg.ino(), msg.data_blocks()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_alloc_da_blocks) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(ext4_alloc_da_blocks) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_alloc_da_blocks) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_allocate_blocks, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_allocate_blocks_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_allocate_blocks_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_allocate_blocks_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_allocate_blocks: dev %d,%d ino %" PRIu64 " flags %s len %u block %" PRIu64 " lblk %u goal %" PRIu64 @@ -59,185 +62,219 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.len(), msg.block(), msg.logical(), msg.goal(), msg.lleft(), msg.lright(), msg.pleft(), msg.pright()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_allocate_blocks) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(ext4_allocate_blocks) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_allocate_blocks) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_allocate_inode, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_allocate_inode_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_allocate_inode_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_allocate_inode_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_allocate_inode: dev %d,%d ino %" PRIu64 " dir %" PRIu64 " mode 0%o", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.dir(), msg.mode()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_allocate_inode) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_allocate_inode) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_allocate_inode) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_begin_ordered_truncate, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_begin_ordered_truncate_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_begin_ordered_truncate_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_begin_ordered_truncate_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_begin_ordered_truncate: dev %d,%d ino %" PRIu64 " new_size %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.new_size()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_begin_ordered_truncate) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_begin_ordered_truncate) " - "msg had be cut off in outfile"); + "the contents of event(ext4_begin_ordered_truncate) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_collapse_range, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_collapse_range_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_collapse_range_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_collapse_range_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_collapse_range: dev %d,%d ino %" PRIu64 " offset %" PRIu64 " len %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.offset(), msg.len()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_collapse_range) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_collapse_range) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_collapse_range) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_da_release_space, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_da_release_space_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_da_release_space_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_da_release_space_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_da_release_space: dev %d,%d ino %" PRIu64 " mode 0%o i_blocks %" PRIu64 - " freed_blocks %d reserved_data_blocks %d", + " freed_blocks %d reserved_data_blocks %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.mode(), msg.i_blocks(), msg.freed_blocks(), msg.reserved_data_blocks()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_da_release_space) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_da_release_space) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_da_release_space) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_da_reserve_space, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_da_reserve_space_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_da_reserve_space_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_da_reserve_space_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_da_reserve_space: dev %d,%d ino %" PRIu64 " mode 0%o i_blocks %" PRIu64 - " reserved_data_blocks %d", + " reserved_data_blocks %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.mode(), msg.i_blocks(), msg.reserved_data_blocks()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_da_reserve_space) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_da_reserve_space) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_da_reserve_space) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_da_update_reserve_space, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_da_update_reserve_space_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_da_update_reserve_space_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_da_update_reserve_space_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_da_update_reserve_space: dev %d,%d ino %" PRIu64 " mode 0%o i_blocks %" PRIu64 - " used_blocks %d reserved_data_blocks %d quota_claim %d", + " used_blocks %d reserved_data_blocks %d quota_claim %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.mode(), msg.i_blocks(), msg.used_blocks(), msg.reserved_data_blocks(), msg.quota_claim()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_da_update_reserve_space) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_da_update_reserve_space) " - "msg had be cut off in outfile"); + "the contents of event(ext4_da_update_reserve_space) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_da_write_begin, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_da_write_begin_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_da_write_begin_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_da_write_begin_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_da_write_begin: dev %d,%d ino %" PRIu64 " pos %" PRIu64 " len %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.pos(), msg.len()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_da_write_begin) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_da_write_begin) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_da_write_begin) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_da_write_end, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_da_write_end_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_da_write_end_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_da_write_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_da_write_end: dev %d,%d ino %" PRIu64 " pos %" PRIu64 " len %u copied %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.pos(), msg.len(), msg.copied()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_da_write_end) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_da_write_end) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_da_write_end) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_da_write_pages, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_da_write_pages_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_da_write_pages_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_da_write_pages_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_da_write_pages: dev %d,%d ino %" PRIu64 " first_page %" PRIu64 - " nr_to_write %" PRIu64 " sync_mode %d", + " nr_to_write %" PRIu64 " sync_mode %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.first_page(), msg.nr_to_write(), msg.sync_mode()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_da_write_pages) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_da_write_pages) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_da_write_pages) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_da_write_pages_extent, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_da_write_pages_extent_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_da_write_pages_extent_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_da_write_pages_extent_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_da_write_pages_extent: dev %d,%d ino %" PRIu64 " lblk %" PRIu64 " len %u flags %s", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), @@ -245,70 +282,86 @@ REGISTER_FTRACE_EVENT_FORMATTER( __print_flags(msg.flags(), "", {((((1UL))) << (5)), "N"}, {((((1UL))) << (4)), "M"}, {((((1UL))) << (11)), "U"}, {((((1UL))) << (9)), "B"})); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_da_write_pages_extent) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_da_write_pages_extent) " - "msg had be cut off in outfile"); + "the contents of event(ext4_da_write_pages_extent) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_discard_blocks, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_discard_blocks_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_discard_blocks_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_discard_blocks_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_discard_blocks: dev %d,%d blk %" PRIu64 " count %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.blk(), msg.count()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_discard_blocks) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_discard_blocks) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_discard_blocks) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_discard_preallocations, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_discard_preallocations_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_discard_preallocations_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_discard_preallocations_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_discard_preallocations: dev %d,%d ino %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_discard_preallocations) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_discard_preallocations) " - "msg had be cut off in outfile"); + "the contents of event(ext4_discard_preallocations) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_drop_inode, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_drop_inode_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_drop_inode, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_drop_inode_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_drop_inode_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_drop_inode: dev %d,%d ino %" PRIu64 " drop %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.drop()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_drop_inode) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_drop_inode) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_drop_inode) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_es_cache_extent, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_es_cache_extent_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_es_cache_extent_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_es_cache_extent_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_es_cache_extent: dev %d,%d ino %" PRIu64 " es [%u/%u) mapped %" PRIu64 " status %s", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), @@ -317,18 +370,21 @@ REGISTER_FTRACE_EVENT_FORMATTER( {(1 << 3), "H"}, {(1 << 4), "R"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_es_cache_extent) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(ext4_es_cache_extent) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_es_cache_extent) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_es_insert_extent, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_es_insert_extent_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_es_insert_extent_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_es_insert_extent_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_es_insert_extent: dev %d,%d ino %" PRIu64 " es [%u/%u) mapped %" PRIu64 " status %s", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), @@ -336,37 +392,45 @@ REGISTER_FTRACE_EVENT_FORMATTER( __print_flags(msg.status(), "", {(1 << 0), "W"}, {(1 << 1), "U"}, {(1 << 2), "D"}, {(1 << 3), "H"}, {(1 << 4), "R"})); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_es_insert_extent) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_es_insert_extent) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_es_insert_extent) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_es_lookup_extent_enter, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_es_lookup_extent_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_es_lookup_extent_enter_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_es_lookup_extent_enter_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_es_lookup_extent_enter: dev %d,%d ino %" PRIu64 " lblk %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.lblk()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_es_lookup_extent_enter) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_es_lookup_extent_enter) " - "msg had be cut off in outfile"); + "the contents of event(ext4_es_lookup_extent_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_es_lookup_extent_exit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_es_lookup_extent_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_es_lookup_extent_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_es_lookup_extent_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_es_lookup_extent_exit: dev %d,%d ino %" PRIu64 " found %d [%u/%u) %" PRIu64 " %s", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), @@ -374,175 +438,209 @@ REGISTER_FTRACE_EVENT_FORMATTER( __print_flags(msg.found() ? msg.status() : 0, "", {(1 << 0), "W"}, {(1 << 1), "U"}, {(1 << 2), "D"}, {(1 << 3), "H"}, {(1 << 4), "R"})); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_es_lookup_extent_exit) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_es_lookup_extent_exit) " - "msg had be cut off in outfile"); + "the contents of event(ext4_es_lookup_extent_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_es_remove_extent, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_es_remove_extent_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_es_remove_extent_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_es_remove_extent_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_es_remove_extent: dev %d,%d ino %" PRIu64 " es [%" PRIu64 "/%" PRIu64 ")", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.lblk(), msg.len()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_es_remove_extent) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_es_remove_extent) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_es_remove_extent) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_es_shrink, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_es_shrink_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_es_shrink, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_es_shrink_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_es_shrink_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_es_shrink: dev %d,%d nr_shrunk %d, scan_time %" PRIu64 " nr_skipped %d retried %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.nr_shrunk(), msg.scan_time(), msg.nr_skipped(), msg.retried()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_es_shrink) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_es_shrink) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_es_shrink) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_es_shrink_count, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_es_shrink_count_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_es_shrink_count_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_es_shrink_count_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_es_shrink_count: dev %d,%d nr_to_scan %d cache_cnt %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.nr_to_scan(), msg.cache_cnt()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_es_shrink_count) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(ext4_es_shrink_count) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_es_shrink_count) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_es_shrink_scan_enter, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_es_shrink_scan_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_es_shrink_scan_enter_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_es_shrink_scan_enter_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_es_shrink_scan_enter: dev %d,%d nr_to_scan %d cache_cnt %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.nr_to_scan(), msg.cache_cnt()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_es_shrink_scan_enter) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_es_shrink_scan_enter) msg " - "had be cut off in outfile"); + "the contents of event(ext4_es_shrink_scan_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_es_shrink_scan_exit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_es_shrink_scan_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_es_shrink_scan_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_es_shrink_scan_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_es_shrink_scan_exit: dev %d,%d nr_shrunk %d cache_cnt %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.nr_shrunk(), msg.cache_cnt()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_es_shrink_scan_exit) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_es_shrink_scan_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_es_shrink_scan_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_evict_inode, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_evict_inode_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_evict_inode, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_evict_inode_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_evict_inode_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_evict_inode: dev %d,%d ino %" PRIu64 " nlink %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.nlink()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_evict_inode) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_evict_inode) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_evict_inode) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_ext_convert_to_initialized_enter, - [](const ForStandard::FtraceEvent &event) -> bool { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ext_convert_to_initialized_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ext_convert_to_initialized_enter_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ext_convert_to_initialized_enter: dev %d,%d ino %" PRIu64 - " m_lblk %u m_len %u u_lblk %u u_len %u u_pblk %" PRIu64 "", + " m_lblk %u m_len %u u_lblk %u u_len %u u_pblk %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.m_lblk(), msg.m_len(), msg.u_lblk(), msg.u_len(), msg.u_pblk()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print " - "event(ext4_ext_convert_to_initialized_" - "enter) msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_ext_convert_to_initialized_enter) msg had be " + "cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN( + LOG_CORE, "the contents of event(ext4_ext_convert_to_initialized_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_ext_convert_to_initialized_fastpath, - [](const ForStandard::FtraceEvent &event) -> bool { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ext_convert_to_initialized_fastpath_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ext_convert_to_initialized_fastpath_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ext_convert_to_initialized_fastpath: dev %d,%d ino %" PRIu64 - " m_lblk %u m_len %u u_lblk %u u_len %u u_pblk %" PRIu64 - " i_lblk %u i_len %u i_pblk %" PRIu64 " ", + " m_lblk %u m_len %u u_lblk %u u_len %u u_pblk %" PRIu64 + " i_lblk %u i_len %u i_pblk %" PRIu64 " ", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.m_lblk(), msg.m_len(), msg.u_lblk(), msg.u_len(), msg.u_pblk(), msg.i_lblk(), msg.i_len(), msg.i_pblk()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print " - "event(ext4_ext_convert_to_initialized_" - "fastpath) msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_ext_convert_to_initialized_fastpath) msg had be " + "cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN( + LOG_CORE, + "the contents of event(ext4_ext_convert_to_initialized_fastpath) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_ext_handle_unwritten_extents, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_ext_handle_unwritten_extents_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ext_handle_unwritten_extents_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ext_handle_unwritten_extents_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ext_handle_unwritten_extents: dev %d,%d ino %" PRIu64 " m_lblk %u m_pblk %" PRIu64 - " m_len %u flags %s allocated %d newblock %" PRIu64 "", + " m_len %u flags %s allocated %d newblock %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), (unsigned)msg.lblk(), msg.pblk(), msg.len(), __print_flags(msg.flags(), "|", {0x0001, "CREATE"}, {0x0002, "UNWRIT"}, {0x0004, "DELALLOC"}, @@ -551,38 +649,45 @@ REGISTER_FTRACE_EVENT_FORMATTER( {0x0400, "IO_SUBMIT"}, {0x40000000, "EX_NOCACHE"}), (unsigned int)msg.allocated(), msg.newblk()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_ext_handle_unwritten_extents) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print " - "event(ext4_ext_handle_unwritten_extents) " - "msg had be cut off in outfile"); + "the contents of event(ext4_ext_handle_unwritten_extents) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_ext_load_extent, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_ext_load_extent_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ext_load_extent_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ext_load_extent_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ext_load_extent: dev %d,%d ino %" PRIu64 " lblk %u pblk %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.lblk(), msg.pblk()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_ext_load_extent) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(ext4_ext_load_extent) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_ext_load_extent) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_ext_map_blocks_enter, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_ext_map_blocks_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ext_map_blocks_enter_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ext_map_blocks_enter_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ext_map_blocks_enter: dev %d,%d ino %" PRIu64 " lblk %u len %u flags %s", @@ -593,23 +698,28 @@ REGISTER_FTRACE_EVENT_FORMATTER( {0x0040, "NO_NORMALIZE"}, {0x0100, "CONVERT_UNWRITTEN"}, {0x0200, "ZERO"}, {0x0400, "IO_SUBMIT"}, {0x40000000, "EX_NOCACHE"})); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_ext_map_blocks_enter) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_ext_map_blocks_enter) msg " - "had be cut off in outfile"); + "the contents of event(ext4_ext_map_blocks_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_ext_map_blocks_exit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_ext_map_blocks_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ext_map_blocks_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ext_map_blocks_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ext_map_blocks_exit: dev %d,%d ino %" PRIu64 " flags %s lblk %u pblk %" PRIu64 - " len %u mflags %s ret %d", + " len %u mflags %s ret %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), __print_flags(msg.flags(), "|", {0x0001, "CREATE"}, {0x0002, "UNWRIT"}, {0x0004, "DELALLOC"}, {0x0008, "PRE_IO"}, {0x0010, "CONVERT"}, {0x0020, "METADATA_NOFAIL"}, @@ -620,73 +730,87 @@ REGISTER_FTRACE_EVENT_FORMATTER( {((((1UL))) << (11)), "U"}, {((((1UL))) << (9)), "B"}), msg.ret()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_ext_map_blocks_exit) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_ext_map_blocks_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_ext_map_blocks_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_ext_remove_space, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_ext_remove_space_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ext_remove_space_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ext_remove_space_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ext_remove_space: dev %d,%d ino %" PRIu64 " since %u end %u depth %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), (unsigned)msg.start(), (unsigned)msg.end(), msg.depth()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_ext_remove_space) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_ext_remove_space) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_ext_remove_space) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_ext_remove_space_done, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_ext_remove_space_done_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ext_remove_space_done_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ext_remove_space_done_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ext_remove_space_done: dev %d,%d ino %" PRIu64 - " since %u end %u depth %d partial%" PRIu64 " remaining_entries %u", + " since %u end %u depth %d partial%" PRIu64 " remaining_entries %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), (unsigned)msg.start(), (unsigned)msg.end(), msg.depth(), msg.partial(), (unsigned short)msg.eh_entries()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_ext_remove_space_done) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_ext_remove_space_done) " - "msg had be cut off in outfile"); + "the contents of event(ext4_ext_remove_space_done) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_ext_rm_idx, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_ext_rm_idx_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_ext_rm_idx, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ext_rm_idx_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ext_rm_idx_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ext_rm_idx: dev %d,%d ino %" PRIu64 " index_pblk %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.pblk()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_ext_rm_idx) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_ext_rm_idx) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_ext_rm_idx) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_ext_rm_leaf, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_ext_rm_leaf_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_ext_rm_leaf, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ext_rm_leaf_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ext_rm_leaf_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ext_rm_leaf: dev %d,%d ino %" PRIu64 " start_lblk %u last_extent [%u(%" PRIu64 "), %u]partial%" PRIu64 "", @@ -695,36 +819,42 @@ REGISTER_FTRACE_EVENT_FORMATTER( (unsigned short)msg.ee_len(), msg.partial()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_ext_rm_leaf) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_ext_rm_leaf) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_ext_rm_leaf) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_ext_show_extent, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_ext_show_extent_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ext_show_extent_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ext_show_extent_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ext_show_extent: dev %d,%d ino %" PRIu64 " lblk %u pblk %" PRIu64 " len %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), (unsigned)msg.lblk(), msg.pblk(), (unsigned short)msg.len()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_ext_show_extent) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(ext4_ext_show_extent) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_ext_show_extent) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_fallocate_enter, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_fallocate_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_fallocate_enter_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_fallocate_enter_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_fallocate_enter: dev %d,%d ino %" PRIu64 " offset %" PRIu64 " len %" PRIu64 " mode %s", @@ -734,52 +864,61 @@ REGISTER_FTRACE_EVENT_FORMATTER( {0x04, "NO_HIDE_STALE"}, {0x08, "COLLAPSE_RANGE"}, {0x10, "ZERO_RANGE"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_fallocate_enter) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(ext4_fallocate_enter) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_fallocate_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_fallocate_exit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_fallocate_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_fallocate_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_fallocate_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_fallocate_exit: dev %d,%d ino %" PRIu64 " pos %" PRIu64 " blocks %u ret %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.pos(), msg.blocks(), msg.ret()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_fallocate_exit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_fallocate_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_fallocate_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_forget, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_forget_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_forget, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_forget_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_forget_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_forget: dev %d,%d ino %" PRIu64 " mode 0%o is_metadata %d block %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.mode(), msg.is_metadata(), msg.block()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_forget) msg " - "had be cut off in outfile"); + "maybe, the contents of print event(ext4_forget) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_forget) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_free_blocks, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_free_blocks_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_free_blocks, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_free_blocks_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_free_blocks_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_free_blocks: dev %d,%d ino %" PRIu64 " mode 0%o block %" PRIu64 " count %" PRIu64 " flags %s", @@ -789,40 +928,46 @@ REGISTER_FTRACE_EVENT_FORMATTER( {0x0008, "NO_QUOTA"}, {0x0010, "1ST_CLUSTER"}, {0x0020, "LAST_CLUSTER"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_free_blocks) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_free_blocks) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_free_blocks) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_free_inode, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_free_inode_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_free_inode, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_free_inode_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_free_inode_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_free_inode: dev %d,%d ino %" PRIu64 " mode 0%o uid %u gid %u blocks %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.mode(), msg.uid(), msg.gid(), msg.blocks()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_free_inode) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_free_inode) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_free_inode) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_get_implied_cluster_alloc_exit, - [](const ForStandard::FtraceEvent &event) -> bool { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_get_implied_cluster_alloc_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_get_implied_cluster_alloc_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "ext4_get_implied_cluster_alloc_exit: dev %d,%d m_lblk %u m_pblk " - "%" PRIu64 " m_len %u m_flags %s ret %d", + "ext4_get_implied_cluster_alloc_exit: dev %d,%d m_lblk %u m_pblk %" PRIu64 + " m_len %u m_flags %s ret %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.lblk(), msg.pblk(), msg.len(), __print_flags(msg.flags(), "", {((((1UL))) << (5)), "N"}, {((((1UL))) << (4)), "M"}, @@ -830,19 +975,23 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.ret()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print " - "event(ext4_get_implied_cluster_alloc_exit)" - " msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_get_implied_cluster_alloc_exit) msg had be cut " + "off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN( + LOG_CORE, "the contents of event(ext4_get_implied_cluster_alloc_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_ind_map_blocks_enter, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_ind_map_blocks_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ind_map_blocks_enter_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ind_map_blocks_enter_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ind_map_blocks_enter: dev %d,%d ino %" PRIu64 " lblk %u len %u flags %s", @@ -853,23 +1002,28 @@ REGISTER_FTRACE_EVENT_FORMATTER( {0x0040, "NO_NORMALIZE"}, {0x0100, "CONVERT_UNWRITTEN"}, {0x0200, "ZERO"}, {0x0400, "IO_SUBMIT"}, {0x40000000, "EX_NOCACHE"})); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_ind_map_blocks_enter) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_ind_map_blocks_enter) msg " - "had be cut off in outfile"); + "the contents of event(ext4_ind_map_blocks_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_ind_map_blocks_exit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_ind_map_blocks_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_ind_map_blocks_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_ind_map_blocks_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_ind_map_blocks_exit: dev %d,%d ino %" PRIu64 " flags %s lblk %u pblk %" PRIu64 - " len %u mflags %s ret %d", + " len %u mflags %s ret %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), __print_flags(msg.flags(), "|", {0x0001, "CREATE"}, {0x0002, "UNWRIT"}, {0x0004, "DELALLOC"}, {0x0008, "PRE_IO"}, {0x0010, "CONVERT"}, {0x0020, "METADATA_NOFAIL"}, @@ -880,176 +1034,213 @@ REGISTER_FTRACE_EVENT_FORMATTER( {((((1UL))) << (11)), "U"}, {((((1UL))) << (9)), "B"}), msg.ret()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_ind_map_blocks_exit) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_ind_map_blocks_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_ind_map_blocks_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_insert_range, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_insert_range_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_insert_range_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_insert_range_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_insert_range: dev %d,%d ino %" PRIu64 " offset %" PRIu64 " len %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.offset(), msg.len()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_insert_range) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_insert_range) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_insert_range) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_journal_start_reserved, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_journal_start_reserved_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_journal_start_reserved_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_journal_start_reserved_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_journal_start_reserved: dev %d,%d blocks, %d caller %p", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), - msg.blocks(), (void *)msg.ip()); + msg.blocks(), (void*)msg.ip()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_journal_start_reserved) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_journal_start_reserved) " - "msg had be cut off in outfile"); + "the contents of event(ext4_journal_start_reserved) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_journalled_write_end, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_journalled_write_end_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_journalled_write_end_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_journalled_write_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_journalled_write_end: dev %d,%d ino %" PRIu64 " pos %" PRIu64 " len %u copied %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.pos(), msg.len(), msg.copied()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_journalled_write_end) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_journalled_write_end) msg " - "had be cut off in outfile"); + "the contents of event(ext4_journalled_write_end) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_load_inode, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_load_inode_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_load_inode, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_load_inode_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_load_inode_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_load_inode: dev %d,%d ino %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_load_inode) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_load_inode) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_load_inode) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_load_inode_bitmap, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_load_inode_bitmap_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_load_inode_bitmap_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_load_inode_bitmap_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_load_inode_bitmap: dev %d,%d group %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.group()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_load_inode_bitmap) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_load_inode_bitmap) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_load_inode_bitmap) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_mark_inode_dirty, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_mark_inode_dirty_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_mark_inode_dirty_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_mark_inode_dirty_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_mark_inode_dirty: dev %d,%d ino %" PRIu64 " caller %p", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), - msg.ino(), (void *)msg.ip()); + msg.ino(), (void*)msg.ip()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_mark_inode_dirty) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_mark_inode_dirty) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_mark_inode_dirty) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_mb_bitmap_load, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_mb_bitmap_load_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_mb_bitmap_load_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_mb_bitmap_load_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_mb_bitmap_load: dev %d,%d group %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.group()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_mb_bitmap_load) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_mb_bitmap_load) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_mb_bitmap_load) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_mb_buddy_bitmap_load, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_mb_buddy_bitmap_load_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_mb_buddy_bitmap_load_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_mb_buddy_bitmap_load_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_mb_buddy_bitmap_load: dev %d,%d group %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.group()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_mb_buddy_bitmap_load) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_mb_buddy_bitmap_load) msg " - "had be cut off in outfile"); + "the contents of event(ext4_mb_buddy_bitmap_load) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_mb_discard_preallocations, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_mb_discard_preallocations_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_mb_discard_preallocations_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_mb_discard_preallocations_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_mb_discard_preallocations: dev %d,%d needed %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.needed()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_mb_discard_preallocations) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print " - "event(ext4_mb_discard_preallocations) msg " - "had be cut off in outfile"); + "the contents of event(ext4_mb_discard_preallocations) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_mb_new_group_pa, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_mb_new_group_pa_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_mb_new_group_pa_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_mb_new_group_pa_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_mb_new_group_pa: dev %d,%d ino %" PRIu64 " pstart %" PRIu64 " len %u lstart %" PRIu64 "", @@ -1057,18 +1248,21 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.pa_pstart(), msg.pa_len(), msg.pa_lstart()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_mb_new_group_pa) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(ext4_mb_new_group_pa) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_mb_new_group_pa) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_mb_new_inode_pa, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_mb_new_inode_pa_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_mb_new_inode_pa_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_mb_new_inode_pa_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_mb_new_inode_pa: dev %d,%d ino %" PRIu64 " pstart %" PRIu64 " len %u lstart %" PRIu64 "", @@ -1076,59 +1270,67 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.pa_pstart(), msg.pa_len(), msg.pa_lstart()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_mb_new_inode_pa) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(ext4_mb_new_inode_pa) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_mb_new_inode_pa) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_mb_release_group_pa, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_mb_release_group_pa_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_mb_release_group_pa_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_mb_release_group_pa_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_mb_release_group_pa: dev %d,%d pstart %" PRIu64 " len %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.pa_pstart(), msg.pa_len()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_mb_release_group_pa) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_mb_release_group_pa) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_mb_release_group_pa) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_mb_release_inode_pa, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_mb_release_inode_pa_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_mb_release_inode_pa_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_mb_release_inode_pa_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_mb_release_inode_pa: dev %d,%d ino %" PRIu64 " block %" PRIu64 " count %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.block(), msg.count()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_mb_release_inode_pa) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_mb_release_inode_pa) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_mb_release_inode_pa) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_mballoc_alloc, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_mballoc_alloc_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_mballoc_alloc_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_mballoc_alloc_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_mballoc_alloc: dev %d,%d inode %" PRIu64 - " orig %u/%d/%u@%u goal %u/%d/%u@%u result %u/%d/%u@%u blks %u grps " - "%u cr %s flags %s tail %u broken %u", + " orig %u/%d/%u@%u goal %u/%d/%u@%u result %u/%d/%u@%u blks %u grps %u cr %s flags %s tail %u broken %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.orig_group(), msg.orig_start(), msg.orig_len(), msg.orig_logical(), msg.goal_group(), msg.goal_start(), msg.goal_len(), msg.goal_logical(), msg.result_group(), msg.result_start(), msg.result_len(), @@ -1143,91 +1345,108 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.tail(), msg.buddy() ? 1 << msg.buddy() : 0); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_mballoc_alloc) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_mballoc_alloc) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_mballoc_alloc) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_mballoc_discard, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_mballoc_discard_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_mballoc_discard_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_mballoc_discard_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_mballoc_discard: dev %d,%d inode %" PRIu64 " extent %u/%d/%d ", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.result_group(), msg.result_start(), msg.result_len()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_mballoc_discard) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(ext4_mballoc_discard) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_mballoc_discard) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_mballoc_free, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_mballoc_free_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_mballoc_free_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_mballoc_free_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_mballoc_free: dev %d,%d inode %" PRIu64 " extent %u/%d/%d ", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.result_group(), msg.result_start(), msg.result_len()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_mballoc_free) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_mballoc_free) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_mballoc_free) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_mballoc_prealloc, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_mballoc_prealloc_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_mballoc_prealloc_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_mballoc_prealloc_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_mballoc_prealloc: dev %d,%d inode %" PRIu64 " orig %u/%d/%u@%u result %u/%d/%u@%u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.orig_group(), msg.orig_start(), msg.orig_len(), msg.orig_logical(), msg.result_group(), msg.result_start(), msg.result_len(), msg.result_logical()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_mballoc_prealloc) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_mballoc_prealloc) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_mballoc_prealloc) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_other_inode_update_time, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_other_inode_update_time_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_other_inode_update_time_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_other_inode_update_time_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_other_inode_update_time: dev %d,%d orig_ino %" PRIu64 " ino %" PRIu64 - " mode 0%o uid %u gid %u", + " mode 0%o uid %u gid %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.orig_ino(), msg.ino(), msg.mode(), msg.uid(), msg.gid()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_other_inode_update_time) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_other_inode_update_time) " - "msg had be cut off in outfile"); + "the contents of event(ext4_other_inode_update_time) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_punch_hole, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_punch_hole_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_punch_hole, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_punch_hole_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_punch_hole_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_punch_hole: dev %d,%d ino %" PRIu64 " offset %" PRIu64 " len %" PRIu64 " mode %s", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), @@ -1236,35 +1455,43 @@ REGISTER_FTRACE_EVENT_FORMATTER( {0x04, "NO_HIDE_STALE"}, {0x08, "COLLAPSE_RANGE"}, {0x10, "ZERO_RANGE"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_punch_hole) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_punch_hole) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_punch_hole) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_read_block_bitmap_load, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_read_block_bitmap_load_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_read_block_bitmap_load_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_read_block_bitmap_load_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_read_block_bitmap_load: dev %d,%d group %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.group()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(ext4_read_block_bitmap_load) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_read_block_bitmap_load) " - "msg had be cut off in outfile"); + "the contents of event(ext4_read_block_bitmap_load) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_remove_blocks, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_remove_blocks_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_remove_blocks_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_remove_blocks_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_remove_blocks: dev %d,%d ino %" PRIu64 " extent [%u(%" PRIu64 "), %u]from %u to %u partial%" PRIu64 "", @@ -1273,18 +1500,21 @@ REGISTER_FTRACE_EVENT_FORMATTER( (unsigned)msg.from(), (unsigned)msg.to(), msg.partial()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_remove_blocks) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_remove_blocks) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_remove_blocks) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_request_blocks, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_request_blocks_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_request_blocks_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_request_blocks_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_request_blocks: dev %d,%d ino %" PRIu64 " flags %s len %u lblk %u goal %" PRIu64 @@ -1298,265 +1528,309 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.len(), msg.logical(), msg.goal(), msg.lleft(), msg.lright(), msg.pleft(), msg.pright()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_request_blocks) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_request_blocks) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_request_blocks) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_request_inode, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_request_inode_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_request_inode_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_request_inode_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_request_inode: dev %d,%d dir %" PRIu64 " mode 0%o", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.dir(), msg.mode()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_request_inode) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_request_inode) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_request_inode) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_sync_file_enter, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_sync_file_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_sync_file_enter_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_sync_file_enter_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_sync_file_enter: dev %d,%d ino %" PRIu64 " parent %" PRIu64 " datasync %d ", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.parent(), msg.datasync()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_sync_file_enter) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(ext4_sync_file_enter) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_sync_file_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_sync_file_exit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_sync_file_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_sync_file_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_sync_file_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_sync_file_exit: dev %d,%d ino %" PRIu64 " ret %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.ret()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_sync_file_exit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_sync_file_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_sync_file_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_sync_fs, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_sync_fs_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_sync_fs, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_sync_fs_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_sync_fs_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_sync_fs: dev %d,%d wait %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.wait()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_sync_fs) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_sync_fs) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_sync_fs) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_trim_all_free, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_trim_all_free_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_trim_all_free_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_trim_all_free_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_trim_all_free: dev %d,%d group %u, start %d, len %d", msg.dev_major(), msg.dev_minor(), msg.group(), msg.start(), msg.len()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_trim_all_free) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_trim_all_free) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_trim_all_free) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_trim_extent, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_trim_extent_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_trim_extent, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_trim_extent_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_trim_extent_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_trim_extent: dev %d,%d group %u, start %d, len %d", msg.dev_major(), msg.dev_minor(), msg.group(), msg.start(), msg.len()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_trim_extent) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_trim_extent) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_trim_extent) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_truncate_enter, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_truncate_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_truncate_enter_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_truncate_enter_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_truncate_enter: dev %d,%d ino %" PRIu64 " blocks %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.blocks()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_truncate_enter) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_truncate_enter) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_truncate_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_truncate_exit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_truncate_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_truncate_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_truncate_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_truncate_exit: dev %d,%d ino %" PRIu64 " blocks %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.blocks()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_truncate_exit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_truncate_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_truncate_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_unlink_enter, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_unlink_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_unlink_enter_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_unlink_enter_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_unlink_enter: dev %d,%d ino %" PRIu64 " size %" PRIu64 " parent %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.size(), msg.parent()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_unlink_enter) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_unlink_enter) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_unlink_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_unlink_exit, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_unlink_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_unlink_exit, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_unlink_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_unlink_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_unlink_exit: dev %d,%d ino %" PRIu64 " ret %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.ret()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_unlink_exit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_unlink_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_unlink_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_write_begin, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_write_begin_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_write_begin, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_write_begin_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_write_begin_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_write_begin: dev %d,%d ino %" PRIu64 " pos %" PRIu64 " len %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.pos(), msg.len()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_write_begin) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_write_begin) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_write_begin) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_write_end, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_write_end_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_write_end, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_write_end_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_write_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_write_end: dev %d,%d ino %" PRIu64 " pos %" PRIu64 " len %u copied %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.pos(), msg.len(), msg.copied()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_write_end) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_write_end) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_write_end) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_writepages, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_writepages_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_writepages, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_writepages_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_writepages_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_writepages: dev %d,%d ino %" PRIu64 " nr_to_write %" PRIu64 " pages_skipped %" PRIu64 - " range_start %" PRIu64 " range_end %" PRIu64 - " sync_mode %d for_kupdate %d range_cyclic %d " - "writeback_index %" PRIu64 "", + " range_start %" PRIu64 " range_end %" PRIu64 + " sync_mode %d for_kupdate %d range_cyclic %d writeback_index %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.nr_to_write(), msg.pages_skipped(), msg.range_start(), msg.range_end(), msg.sync_mode(), msg.for_kupdate(), msg.range_cyclic(), msg.writeback_index()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_writepages) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_writepages) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_writepages) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( ext4_writepages_result, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_writepages_result_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_writepages_result_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_writepages_result_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_writepages_result: dev %d,%d ino %" PRIu64 - " ret %d pages_written %d pages_skipped %" PRIu64 " sync_mode %d writeback_index %" PRIu64 "", + " ret %d pages_written %d pages_skipped %" PRIu64 " sync_mode %d writeback_index %" PRIu64 "", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), msg.ino(), msg.ret(), msg.pages_written(), msg.pages_skipped(), msg.sync_mode(), msg.writeback_index()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_writepages_result) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(ext4_writepages_result) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_writepages_result) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ext4_zero_range, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ext4_zero_range_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ext4_zero_range, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ext4_zero_range_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ext4_zero_range_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ext4_zero_range: dev %d,%d ino %" PRIu64 " offset %" PRIu64 " len %" PRIu64 " mode %s", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), @@ -1565,8 +1839,11 @@ REGISTER_FTRACE_EVENT_FORMATTER( {0x04, "NO_HIDE_STALE"}, {0x08, "COLLAPSE_RANGE"}, {0x10, "ZERO_RANGE"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ext4_zero_range) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(ext4_zero_range) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ext4_zero_range) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_f2fs_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_f2fs_event_formatter.cpp index b8c57ac7bb907f160b7661a44764339601132a34..275bf895c58014d95add800d2c31472698993883 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_f2fs_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_f2fs_event_formatter.cpp @@ -25,35 +25,37 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( f2fs_sync_file_enter, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_f2fs_sync_file_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_f2fs_sync_file_enter_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.f2fs_sync_file_enter_format(); - char buffer[BUFFER_SIZE]; - int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "f2fs_sync_file_enter: dev = (%d,%d), ino = %lu, pino = " - "%lu, i_mode = 0x%x, i_size = %" PRIu64 ", i_nlink = %u, i_blocks = %" PRIu64 - ", i_advise = 0x%x", - ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), - (unsigned long)msg.ino(), (unsigned long)msg.pino(), msg.mode(), msg.size(), - (unsigned int)msg.nlink(), msg.blocks(), (unsigned char)msg.advise()); + char buffer[BUFFER_SIZE] = {0}; + int len = + snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, + "f2fs_sync_file_enter: dev = (%d,%d), ino = %lu, pino = %lu, i_mode = 0x%x, i_size = %" PRIu64 + ", i_nlink = %u, i_blocks = %" PRIu64 ", i_advise = 0x%x", + ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), + (unsigned long)msg.ino(), (unsigned long)msg.pino(), msg.mode(), msg.size(), + (unsigned int)msg.nlink(), msg.blocks(), (unsigned char)msg.advise()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(f2fs_sync_file_enter) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(f2fs_sync_file_enter) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(f2fs_sync_file_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( f2fs_sync_file_exit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_f2fs_sync_file_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_f2fs_sync_file_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.f2fs_sync_file_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "f2fs_sync_file_exit: dev = (%d,%d), ino = %lu, cp_reason: %s, " - "datasync = %d, ret = %d", + "f2fs_sync_file_exit: dev = (%d,%d), ino = %lu, cp_reason: %s, datasync = %d, ret = %d", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), (unsigned long)msg.ino(), __print_symbolic(msg.cp_reason(), {CP_NO_NEEDED, "no needed"}, {CP_NON_REGULAR, "non regular"}, @@ -64,42 +66,51 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.datasync(), msg.ret()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(f2fs_sync_file_exit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(f2fs_sync_file_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(f2fs_sync_file_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - f2fs_write_begin, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_f2fs_write_begin_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + f2fs_write_begin, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_f2fs_write_begin_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.f2fs_write_begin_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "f2fs_write_begin: dev = (%d,%d), ino = %lu, pos = %" PRIu64 ", len = %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), (unsigned long)msg.ino(), msg.pos(), msg.len()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(f2fs_write_begin) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(f2fs_write_begin) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(f2fs_write_begin) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - f2fs_write_end, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_f2fs_write_end_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + f2fs_write_end, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_f2fs_write_end_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.f2fs_write_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "f2fs_write_end: dev = (%d,%d), ino = %lu, pos = %" PRIu64 ", len = %u, copied = %u", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), (unsigned long)msg.ino(), msg.pos(), msg.len(), msg.copied()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(f2fs_write_end) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(f2fs_write_end) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(f2fs_write_end) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_filelock_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_filelock_event_formatter.cpp index 1bc4f32435c3bf916b43769445d76d01ecef289c..af6c1bcb5eae92237da41d021aacf5a6d38eb7af 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_filelock_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_filelock_event_formatter.cpp @@ -24,15 +24,14 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( break_lease_block, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_break_lease_block_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_break_lease_block_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.break_lease_block_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "break_lease_block: fl=%p dev=0x%x:0x%x ino=0x%" PRIx64 - " fl_blocker=%p fl_owner=%p fl_flags=%s fl_type=%s " - "fl_break_time=%" PRIu64 " fl_downgrade_time=%" PRIu64 "", + " fl_blocker=%p fl_owner=%p fl_flags=%s fl_type=%s fl_break_time=%" PRIu64 " fl_downgrade_time=%" PRIu64 "", msg.fl(), ((unsigned int)((msg.s_dev()) >> 20)), ((unsigned int)((msg.s_dev()) & ((1U << 20) - 1))), msg.i_ino(), msg.fl_next(), msg.fl_owner(), __print_flags(msg.fl_flags(), "|", {1, "FL_POSIX"}, {2, "FL_FLOCK"}, {4, "FL_DELEG"}, {8, "FL_ACCESS"}, @@ -42,23 +41,25 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.fl_downgrade_time()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(break_lease_block) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(break_lease_block) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(break_lease_block) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( break_lease_noblock, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_break_lease_noblock_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_break_lease_noblock_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.break_lease_noblock_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "break_lease_noblock: fl=%p dev=0x%x:0x%x ino=0x%" PRIx64 - " fl_blocker=%p fl_owner=%p fl_flags=%s fl_type=%s " - "fl_break_time=%" PRIu64 " fl_downgrade_time=%" PRIu64 "", + " fl_blocker=%p fl_owner=%p fl_flags=%s fl_type=%s fl_break_time=%" PRIu64 " fl_downgrade_time=%" PRIu64 "", msg.fl(), ((unsigned int)((msg.s_dev()) >> 20)), ((unsigned int)((msg.s_dev()) & ((1U << 20) - 1))), msg.i_ino(), msg.fl_next(), msg.fl_owner(), __print_flags(msg.fl_flags(), "|", {1, "FL_POSIX"}, {2, "FL_FLOCK"}, {4, "FL_DELEG"}, {8, "FL_ACCESS"}, @@ -68,23 +69,25 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.fl_downgrade_time()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(break_lease_noblock) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(break_lease_noblock) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(break_lease_noblock) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( break_lease_unblock, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_break_lease_unblock_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_break_lease_unblock_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.break_lease_unblock_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "break_lease_unblock: fl=%p dev=0x%x:0x%x ino=0x%" PRIx64 - " fl_blocker=%p fl_owner=%p fl_flags=%s fl_type=%s " - "fl_break_time=%" PRIu64 " fl_downgrade_time=%" PRIu64 "", + " fl_blocker=%p fl_owner=%p fl_flags=%s fl_type=%s fl_break_time=%" PRIu64 " fl_downgrade_time=%" PRIu64 "", msg.fl(), ((unsigned int)((msg.s_dev()) >> 20)), ((unsigned int)((msg.s_dev()) & ((1U << 20) - 1))), msg.i_ino(), msg.fl_next(), msg.fl_owner(), __print_flags(msg.fl_flags(), "|", {1, "FL_POSIX"}, {2, "FL_FLOCK"}, {4, "FL_DELEG"}, {8, "FL_ACCESS"}, @@ -94,18 +97,21 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.fl_downgrade_time()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(break_lease_unblock) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(break_lease_unblock) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(break_lease_unblock) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( generic_add_lease, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_generic_add_lease_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_generic_add_lease_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.generic_add_lease_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "generic_add_lease: dev=0x%x:0x%x ino=0x%" PRIx64 @@ -118,23 +124,25 @@ REGISTER_FTRACE_EVENT_FORMATTER( __print_symbolic(msg.fl_type(), {0, "F_RDLCK"}, {1, "F_WRLCK"}, {2, "F_UNLCK"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(generic_add_lease) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(generic_add_lease) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(generic_add_lease) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( generic_delete_lease, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_generic_delete_lease_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_generic_delete_lease_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.generic_delete_lease_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "generic_delete_lease: fl=%p dev=0x%x:0x%x ino=0x%" PRIx64 - " fl_blocker=%p fl_owner=%p fl_flags=%s fl_type=%s " - "fl_break_time=%" PRIu64 " fl_downgrade_time=%" PRIu64 "", + " fl_blocker=%p fl_owner=%p fl_flags=%s fl_type=%s fl_break_time=%" PRIu64 " fl_downgrade_time=%" PRIu64 "", msg.fl(), ((unsigned int)((msg.s_dev()) >> 20)), ((unsigned int)((msg.s_dev()) & ((1U << 20) - 1))), msg.i_ino(), msg.fl_next(), msg.fl_owner(), __print_flags(msg.fl_flags(), "|", {1, "FL_POSIX"}, {2, "FL_FLOCK"}, {4, "FL_DELEG"}, {8, "FL_ACCESS"}, @@ -144,22 +152,24 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.fl_downgrade_time()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(generic_delete_lease) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(generic_delete_lease) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(generic_delete_lease) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - time_out_leases, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_time_out_leases_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + time_out_leases, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_time_out_leases_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.time_out_leases_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "time_out_leases: fl=%p dev=0x%x:0x%x ino=0x%" PRIx64 - " fl_blocker=%p fl_owner=%p fl_flags=%s fl_type=%s " - "fl_break_time=%" PRIu64 " fl_downgrade_time=%" PRIu64 "", + " fl_blocker=%p fl_owner=%p fl_flags=%s fl_type=%s fl_break_time=%" PRIu64 " fl_downgrade_time=%" PRIu64 "", msg.fl(), ((unsigned int)((msg.s_dev()) >> 20)), ((unsigned int)((msg.s_dev()) & ((1U << 20) - 1))), msg.i_ino(), msg.fl_next(), msg.fl_owner(), __print_flags(msg.fl_flags(), "|", {1, "FL_POSIX"}, {2, "FL_FLOCK"}, {4, "FL_DELEG"}, {8, "FL_ACCESS"}, @@ -169,8 +179,11 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.fl_downgrade_time()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(time_out_leases) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(time_out_leases) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(time_out_leases) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_filemap_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_filemap_event_formatter.cpp index aebe28348dd1398ab171c57c7201545bc6e9fa93..5d5e30a36058724705fe0cb3a83e6027d3073b14 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_filemap_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_filemap_event_formatter.cpp @@ -24,75 +24,92 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( file_check_and_advance_wb_err, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_file_check_and_advance_wb_err_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_file_check_and_advance_wb_err_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.file_check_and_advance_wb_err_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "file_check_and_advance_wb_err: file=%p dev=%d:%d ino=0x%" PRIx64 " old=0x%x new=0x%x", msg.file(), ((unsigned int)((msg.s_dev()) >> 20)), ((unsigned int)((msg.s_dev()) & ((1U << 20) - 1))), msg.i_ino(), msg.old(), msg.seq_new()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(file_check_and_advance_wb_err) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(file_check_and_advance_wb_err) " - "msg had be cut off in outfile"); + "the contents of event(file_check_and_advance_wb_err) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( filemap_set_wb_err, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_filemap_set_wb_err_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_filemap_set_wb_err_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.filemap_set_wb_err_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "filemap_set_wb_err: dev=%d:%d ino=0x%" PRIx64 " errseq=0x%x", ((unsigned int)((msg.s_dev()) >> 20)), ((unsigned int)((msg.s_dev()) & ((1U << 20) - 1))), msg.i_ino(), msg.errseq()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(filemap_set_wb_err) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(filemap_set_wb_err) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(filemap_set_wb_err) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_filemap_add_to_page_cache, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_filemap_add_to_page_cache_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_filemap_add_to_page_cache_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_filemap_add_to_page_cache_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_filemap_add_to_page_cache: dev %" PRIu64 ":%" PRIu64 " ino %p page=%s pfn=%" PRIu64 - " ofs=%" PRIu64 "", + " ofs=%" PRIu64 "", (((msg.s_dev()) >> 20)), (((msg.s_dev()) & ((1U << 20) - 1))), msg.i_ino(), "0000000000000000", msg.pfn(), msg.index() << 12); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(mm_filemap_add_to_page_cache) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_filemap_add_to_page_cache) " - "msg had be cut off in outfile"); + "the contents of event(mm_filemap_add_to_page_cache) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_filemap_delete_from_page_cache, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_filemap_delete_from_page_cache_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_filemap_delete_from_page_cache_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_filemap_delete_from_page_cache_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_filemap_delete_from_page_cache: dev %" PRIu64 ":%" PRIu64 - " ino %p page=%s pfn=%" PRIu64 " ofs=%" PRIu64 "", + " ino %p page=%s pfn=%" PRIu64 " ofs=%" PRIu64 "", (((msg.s_dev()) >> 20)), (((msg.s_dev()) & ((1U << 20) - 1))), msg.i_ino(), "0000000000000000", msg.pfn(), msg.index() << 12); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(mm_filemap_delete_from_page_cache) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print " - "event(mm_filemap_delete_from_page_cache) " - "msg had be cut off in outfile"); + "the contents of event(mm_filemap_delete_from_page_cache) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_ftrace_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_ftrace_event_formatter.cpp index 43877bd3912ff99ef85c9ed04d59182460d675d3..1065110f538b21dc434aec0f1d5775f6c369769d 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_ftrace_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_ftrace_event_formatter.cpp @@ -23,13 +23,13 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - bputs, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_bputs_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + bputs, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_bputs_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.bputs_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.ip()) > 0) { functionStr = kernelSymbols[msg.ip()]; } @@ -37,56 +37,62 @@ REGISTER_FTRACE_EVENT_FORMATTER( len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "bputs: %s: %s", functionStr.c_str(), msg.str().c_str()); } else { - len = - snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "bputs: %p: %s", (void *)msg.ip(), msg.str().c_str()); + len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "bputs: %p: %s", (void*)msg.ip(), msg.str().c_str()); } if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(bputs) " - "msg had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(bputs) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(bputs) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - branch, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_branch_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + branch, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_branch_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.branch_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "branch: %u:%s:%s (%u)%s", msg.line(), msg.func().c_str(), msg.file().c_str(), msg.correct(), msg.constant() ? " CONSTANT" : ""); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(branch) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(branch) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(branch) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - context_switch, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_context_switch_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + context_switch, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_context_switch_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.context_switch_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "context_switch: %u:%u:%u ==> %u:%u:%u [%03u]", msg.prev_pid(), msg.prev_prio(), msg.prev_state(), msg.next_pid(), msg.next_prio(), msg.next_state(), msg.next_cpu()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(context_switch) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(context_switch) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(context_switch) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - funcgraph_entry, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_funcgraph_entry_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + funcgraph_entry, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_funcgraph_entry_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.funcgraph_entry_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.func()) > 0) { functionStr = kernelSymbols[msg.func()]; } @@ -94,25 +100,28 @@ REGISTER_FTRACE_EVENT_FORMATTER( len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "funcgraph_entry: --> %s (%d)", functionStr.c_str(), msg.depth()); } else { - len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "funcgraph_entry: --> %p (%d)", (void *)msg.func(), + len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "funcgraph_entry: --> %p (%d)", (void*)msg.func(), msg.depth()); } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(funcgraph_entry) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(funcgraph_entry) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(funcgraph_entry) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - funcgraph_exit, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_funcgraph_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + funcgraph_exit, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_funcgraph_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.funcgraph_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.func()) > 0) { functionStr = kernelSymbols[msg.func()]; } @@ -123,50 +132,55 @@ REGISTER_FTRACE_EVENT_FORMATTER( } else { len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "funcgraph_exit: <-- %p (%d) (start: %" PRIx64 " end: %" PRIx64 ") over: %d", - (void *)msg.func(), msg.depth(), msg.calltime(), msg.rettime(), msg.depth()); + (void*)msg.func(), msg.depth(), msg.calltime(), msg.rettime(), msg.depth()); } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(funcgraph_exit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(funcgraph_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(funcgraph_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - function, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_function_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + function, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_function_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.function_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.ip()) > 0) { functionStr = kernelSymbols[msg.ip()]; } if (functionStr != "") { len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "function: %s <-- %s", functionStr.c_str(), - (void *)msg.parent_ip()); + (void*)msg.parent_ip()); } else { - len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "function: %p <-- %p", (void *)msg.ip(), - (void *)msg.parent_ip()); + len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "function: %p <-- %p", (void*)msg.ip(), + (void*)msg.parent_ip()); } if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(function) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(function) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(function) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - kernel_stack, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_kernel_stack_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + kernel_stack, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_kernel_stack_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.kernel_stack_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string kernelSymbolsStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.caller()[0]) > 0) { kernelSymbolsStr = kernelSymbols[msg.caller()[0]]; } @@ -184,76 +198,87 @@ REGISTER_FTRACE_EVENT_FORMATTER( "kernel_stack: \t=> %p\n\t=> %p\n\t=> %p\n" "\t=> %p\n\t=> %p\n\t=> %p\n" "\t=> %p\n\t=> %p\n", - (void *)msg.caller()[0], (void *)msg.caller()[1], (void *)msg.caller()[2], - (void *)msg.caller()[3], (void *)msg.caller()[4], (void *)msg.caller()[5], - (void *)msg.caller()[6], (void *)msg.caller()[7]); + (void*)msg.caller()[0], (void*)msg.caller()[1], (void*)msg.caller()[2], + (void*)msg.caller()[3], (void*)msg.caller()[4], (void*)msg.caller()[5], + (void*)msg.caller()[6], (void*)msg.caller()[7]); } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(kernel_stack) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(kernel_stack) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(kernel_stack) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - mmiotrace_map, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mmiotrace_map_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + mmiotrace_map, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mmiotrace_map_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mmiotrace_map_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mmiotrace_map: %" PRIx64 " %" PRIx64 " %" PRIx64 " %d %x", msg.phys(), msg.virt(), msg.len(), msg.map_id(), msg.opcode()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mmiotrace_map) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(mmiotrace_map) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mmiotrace_map) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - mmiotrace_rw, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mmiotrace_rw_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + mmiotrace_rw, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mmiotrace_rw_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mmiotrace_rw_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mmiotrace_rw: %" PRIx64 " %" PRIx64 " %" PRIx64 " %d %x %x", msg.phys(), msg.value(), msg.pc(), msg.map_id(), msg.opcode(), msg.width()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mmiotrace_rw) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(mmiotrace_rw) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mmiotrace_rw) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - print, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_print_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + print, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_print_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.print_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; std::string fieldBuf = msg.buf(); if (fieldBuf.size() > 1 && fieldBuf[fieldBuf.size() - 1] == '\n') { fieldBuf = fieldBuf.substr(0, fieldBuf.size() - 1); } int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "print: %s", fieldBuf.c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(print) " - "msg had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(print) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(print) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - user_stack, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_user_stack_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + user_stack, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_user_stack_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.user_stack_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string kernelSymbolsStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.caller()[0]) > 0) { kernelSymbolsStr = kernelSymbols[msg.caller()[0]]; } @@ -271,30 +296,34 @@ REGISTER_FTRACE_EVENT_FORMATTER( "user_stack: \t=> %p\n\t=> %p\n\t=> %p\n" "\t=> %p\n\t=> %p\n\t=> %p\n" "\t=> %p\n\t=> %p\n", - (void *)msg.caller()[0], (void *)msg.caller()[1], (void *)msg.caller()[2], - (void *)msg.caller()[3], (void *)msg.caller()[4], (void *)msg.caller()[5], - (void *)msg.caller()[6], (void *)msg.caller()[7]); + (void*)msg.caller()[0], (void*)msg.caller()[1], (void*)msg.caller()[2], + (void*)msg.caller()[3], (void*)msg.caller()[4], (void*)msg.caller()[5], + (void*)msg.caller()[6], (void*)msg.caller()[7]); } if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(user_stack) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(user_stack) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(user_stack) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - wakeup, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_wakeup_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + wakeup, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_wakeup_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.wakeup_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "wakeup: %u:%u:%u ==+ %u:%u:%u [%03u]", msg.prev_pid(), msg.prev_prio(), msg.prev_state(), msg.next_pid(), msg.next_prio(), msg.next_state(), msg.next_cpu()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(wakeup) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(wakeup) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(wakeup) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_gpio_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_gpio_event_formatter.cpp index 249731ae491682b53e4f82ab12b05f95140819c6..733a6f7e13a28ff46053da03dbfc0400f42b1ca7 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_gpio_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_gpio_event_formatter.cpp @@ -23,31 +23,36 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - gpio_direction, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_gpio_direction_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + gpio_direction, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_gpio_direction_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.gpio_direction_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "gpio_direction: %u %3s (%d)", msg.gpio(), msg.in() ? "in" : "out", msg.err()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(gpio_direction) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(gpio_direction) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(gpio_direction) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - gpio_value, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_gpio_value_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + gpio_value, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_gpio_value_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.gpio_value_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "gpio_value: %u %3s %d", msg.gpio(), msg.get() ? "get" : "set", msg.value()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(gpio_value) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(gpio_value) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(gpio_value) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_gpu_mem_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_gpu_mem_event_formatter.cpp index 34aaa889225940bee5bd1011831e98fffc62c2d1..444dd7f92bbb7efe30950cbb13f44ebbf3b65502 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_gpu_mem_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_gpu_mem_event_formatter.cpp @@ -26,12 +26,16 @@ REGISTER_FTRACE_EVENT_FORMATTER( gpu_mem_total, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_gpu_mem_total_format(); }, [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.gpu_mem_total_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "gpu_mem_total: gpu_id=%u pid=%u size=%" PRIu64 "", msg.gpu_id(), msg.pid(), msg.size()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, "the contents of print event(gpu_mem_total) msg had be cut off in outfile"); } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of print event(gpu_mem_total) snprintf_s error!"); + return ""; + } return std::string(buffer); }); } // namespace diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_i2c_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_i2c_event_formatter.cpp index 0142a355c26e0800ee8556bb7d2ac17dba90593a..bc42034f1f6cb6e47edc4e3b56e7db7d9a278485 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_i2c_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_i2c_event_formatter.cpp @@ -23,63 +23,71 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - i2c_read, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_i2c_read_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + i2c_read, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_i2c_read_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.i2c_read_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "i2c_read: i2c-%d #%u a=%03x f=%04x l=%u", msg.adapter_nr(), msg.msg_nr(), msg.addr(), msg.flags(), msg.len()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(i2c_read) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(i2c_read) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(i2c_read) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - i2c_reply, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_i2c_reply_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + i2c_reply, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_i2c_reply_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.i2c_reply_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "i2c_reply: i2c-%d #%u a=%03x f=%04x l=%" PRId32 " [%" PRId32 "]", msg.adapter_nr(), msg.msg_nr(), msg.addr(), msg.flags(), msg.len(), msg.buf()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(i2c_reply) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(i2c_reply) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(i2c_reply) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - i2c_result, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_i2c_result_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + i2c_result, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_i2c_result_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.i2c_result_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "i2c_result: i2c-%d n=%u ret=%d", msg.adapter_nr(), msg.nr_msgs(), msg.ret()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(i2c_result) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(i2c_result) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(i2c_result) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - i2c_write, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_i2c_write_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + i2c_write, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_i2c_write_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.i2c_write_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "i2c_write: i2c-%d #%u a=%03x f=%04x l=%" PRId32 " [%" PRId32 "]", msg.adapter_nr(), msg.msg_nr(), msg.addr(), msg.flags(), msg.len(), msg.buf()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(i2c_write) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(i2c_write) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(i2c_write) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_ipi_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_ipi_event_formatter.cpp index 7eaf75326d68c0faf5224b30400a5eb8fc5f3116..64d65cc08f45b616b5b453c3898bf8cdfbaa8d69 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_ipi_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_ipi_event_formatter.cpp @@ -23,44 +23,50 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - ipi_entry, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ipi_entry_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ipi_entry, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ipi_entry_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ipi_entry_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ipi_entry: (%s)", msg.reason().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ipi_entry) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(ipi_entry) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ipi_entry) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ipi_exit, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ipi_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ipi_exit, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ipi_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ipi_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ipi_exit: (%s)", msg.reason().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ipi_exit) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(ipi_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ipi_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - ipi_raise, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_ipi_raise_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + ipi_raise, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_ipi_raise_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.ipi_raise_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "ipi_raise: target_mask=%" PRIu64 " (%s)", msg.target_cpus(), msg.reason().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(ipi_raise) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(ipi_raise) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(ipi_raise) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_irq_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_irq_event_formatter.cpp index 99b40024ebe1481e4f71db185b05f320b75e5fca..7a78fde216c03e52af03b1549c02d987c854c87a 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_irq_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_irq_event_formatter.cpp @@ -24,82 +24,97 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( irq_handler_entry, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_irq_handler_entry_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_irq_handler_entry_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.irq_handler_entry_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "irq_handler_entry: irq=%d name=%s", msg.irq(), msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(irq_handler_entry) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(irq_handler_entry) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(irq_handler_entry) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - irq_handler_exit, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_irq_handler_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + irq_handler_exit, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_irq_handler_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.irq_handler_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "irq_handler_exit: irq=%d ret=%s", msg.irq(), msg.ret() ? "handled" : "unhandled"); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(irq_handler_exit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(irq_handler_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(irq_handler_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - softirq_entry, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_softirq_entry_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + softirq_entry, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_softirq_entry_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.softirq_entry_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "softirq_entry: vec=%u [action=%s]", msg.vec(), __print_symbolic(msg.vec(), {0, "HI"}, {1, "TIMER"}, {2, "NET_TX"}, {3, "NET_RX"}, {4, "BLOCK"}, {5, "IRQ_POLL"}, {6, "TASKLET"}, {7, "SCHED"}, {8, "HRTIMER"}, {9, "RCU"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(softirq_entry) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(softirq_entry) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(softirq_entry) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - softirq_exit, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_softirq_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + softirq_exit, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_softirq_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.softirq_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "softirq_exit: vec=%u [action=%s]", msg.vec(), __print_symbolic(msg.vec(), {0, "HI"}, {1, "TIMER"}, {2, "NET_TX"}, {3, "NET_RX"}, {4, "BLOCK"}, {5, "IRQ_POLL"}, {6, "TASKLET"}, {7, "SCHED"}, {8, "HRTIMER"}, {9, "RCU"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(softirq_exit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(softirq_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(softirq_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - softirq_raise, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_softirq_raise_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + softirq_raise, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_softirq_raise_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.softirq_raise_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "softirq_raise: vec=%u [action=%s]", msg.vec(), __print_symbolic(msg.vec(), {0, "HI"}, {1, "TIMER"}, {2, "NET_TX"}, {3, "NET_RX"}, {4, "BLOCK"}, {5, "IRQ_POLL"}, {6, "TASKLET"}, {7, "SCHED"}, {8, "HRTIMER"}, {9, "RCU"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(softirq_raise) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(softirq_raise) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(softirq_raise) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_kmem_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_kmem_event_formatter.cpp index a26b4440157be8b5aebad734bd59c05e9df4a9c2..c7ffc3b4047783bd88b8521a7294e1d2c10d1b81 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_kmem_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_kmem_event_formatter.cpp @@ -24,25 +24,27 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - kfree, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_kfree_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + kfree, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_kfree_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.kfree_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "kfree: call_site=%p ptr=%p", msg.call_site(), msg.ptr()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(kfree) " - "msg had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(kfree) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(kfree) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - kmalloc, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_kmalloc_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + kmalloc, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_kmalloc_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.kmalloc_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "kmalloc: call_site=%p ptr=%p bytes_req=%" PRIu64 " bytes_alloc=%" PRIu64 @@ -108,18 +110,20 @@ REGISTER_FTRACE_EVENT_FORMATTER( : "none", msg.node(), (1 && (msg.gfp_flags() & (unsigned long)((gfp_t)0x400000u))) ? "true" : "false"); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(kmalloc) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(kmalloc) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(kmalloc) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - kmem_cache_alloc, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_kmem_cache_alloc_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + kmem_cache_alloc, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_kmem_cache_alloc_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.kmem_cache_alloc_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "kmem_cache_alloc: call_site=%p ptr=%p bytes_req=%" PRIu64 " bytes_alloc=%" PRIu64 @@ -186,143 +190,232 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.node(), msg.accounted() ? "true" : "false"); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(kmem_cache_alloc) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(kmem_cache_alloc) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(kmem_cache_alloc) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - kmem_cache_free, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_kmem_cache_free_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + kmem_cache_free, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_kmem_cache_free_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.kmem_cache_free_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "kmem_cache_free: call_site=%p ptr=%p", msg.call_site(), msg.ptr()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(kmem_cache_free) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(kmem_cache_free) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(kmem_cache_free) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - mm_page_alloc, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_page_alloc_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + mm_page_alloc, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_page_alloc_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_page_alloc_format(); - char buffer[BUFFER_SIZE]; - int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "mm_page_alloc: page=%s pfn=0x%" PRIx64 " order=%d migratetype=%d - gfp_flags = % s "0000000000000000"); + char buffer[BUFFER_SIZE] = {0}; + int len = snprintf_s( + buffer, BUFFER_SIZE, BUFFER_SIZE - 1, + "mm_page_alloc: page=%s pfn=0x%" PRIx64 " order=%d migratetype=%d gfp_flags=%s", "0000000000000000", + msg.pfn() != -1UL ? msg.pfn() : 0, msg.order(), msg.migratetype(), + (msg.gfp_flags()) + ? __print_flags( + msg.gfp_flags(), "|", + {(unsigned long)((((((((gfp_t)(0x400u | 0x800u)) | ((gfp_t)0x40u) | ((gfp_t)0x80u) | + ((gfp_t)0x100000u)) | + ((gfp_t)0x02u)) | + ((gfp_t)0x08u) | ((gfp_t)0)) | + ((gfp_t)0x40000u) | ((gfp_t)0x80000u) | ((gfp_t)0x2000u)) & + ~((gfp_t)(0x400u | 0x800u))) | + ((gfp_t)0x400u)), + "GFP_TRANSHUGE"}, + {(unsigned long)(((((((gfp_t)(0x400u | 0x800u)) | ((gfp_t)0x40u) | ((gfp_t)0x80u) | + ((gfp_t)0x100000u)) | + ((gfp_t)0x02u)) | + ((gfp_t)0x08u) | ((gfp_t)0)) | + ((gfp_t)0x40000u) | ((gfp_t)0x80000u) | ((gfp_t)0x2000u)) & + ~((gfp_t)(0x400u | 0x800u))), + "GFP_TRANSHUGE_LIGHT"}, + {(unsigned long)(((((gfp_t)(0x400u | 0x800u)) | ((gfp_t)0x40u) | ((gfp_t)0x80u) | + ((gfp_t)0x100000u)) | + ((gfp_t)0x02u)) | + ((gfp_t)0x08u) | ((gfp_t)0)), + "GFP_HIGHUSER_MOVABLE"}, + {(unsigned long)((((gfp_t)(0x400u | 0x800u)) | ((gfp_t)0x40u) | ((gfp_t)0x80u) | + ((gfp_t)0x100000u)) | + ((gfp_t)0x02u)), + "GFP_HIGHUSER"}, + {(unsigned long)(((gfp_t)(0x400u | 0x800u)) | ((gfp_t)0x40u) | ((gfp_t)0x80u) | + ((gfp_t)0x100000u)), + "GFP_USER"}, + {(unsigned long)((((gfp_t)(0x400u | 0x800u)) | ((gfp_t)0x40u) | ((gfp_t)0x80u)) | + ((gfp_t)0x400000u)), + "GFP_KERNEL_ACCOUNT"}, + {(unsigned long)(((gfp_t)(0x400u | 0x800u)) | ((gfp_t)0x40u) | ((gfp_t)0x80u)), "GFP_KERNEL"}, + {(unsigned long)(((gfp_t)(0x400u | 0x800u)) | ((gfp_t)0x40u)), "GFP_NOFS"}, + {(unsigned long)(((gfp_t)0x20u) | ((gfp_t)0x800u)), "GFP_ATOMIC"}, + {(unsigned long)(((gfp_t)(0x400u | 0x800u))), "GFP_NOIO"}, + {(unsigned long)(((gfp_t)0x800u)), "GFP_NOWAIT"}, {(unsigned long)((gfp_t)0x01u), "GFP_DMA"}, + {(unsigned long)((gfp_t)0x02u), "__GFP_HIGHMEM"}, {(unsigned long)((gfp_t)0x04u), "GFP_DMA32"}, + {(unsigned long)((gfp_t)0x20u), "__GFP_HIGH"}, {(unsigned long)((gfp_t)0x40u), "__GFP_IO"}, + {(unsigned long)((gfp_t)0x80u), "__GFP_FS"}, {(unsigned long)((gfp_t)0x2000u), "__GFP_NOWARN"}, + {(unsigned long)((gfp_t)0x4000u), "__GFP_RETRY_MAYFAIL"}, + {(unsigned long)((gfp_t)0x8000u), "__GFP_NOFAIL"}, + {(unsigned long)((gfp_t)0x10000u), "__GFP_NORETRY"}, + {(unsigned long)((gfp_t)0x40000u), "__GFP_COMP"}, {(unsigned long)((gfp_t)0x100u), "__GFP_ZERO"}, + {(unsigned long)((gfp_t)0x80000u), "__GFP_NOMEMALLOC"}, + {(unsigned long)((gfp_t)0x20000u), "__GFP_MEMALLOC"}, + {(unsigned long)((gfp_t)0x100000u), "__GFP_HARDWALL"}, + {(unsigned long)((gfp_t)0x200000u), "__GFP_THISNODE"}, + {(unsigned long)((gfp_t)0x10u), "__GFP_RECLAIMABLE"}, + {(unsigned long)((gfp_t)0x08u), "__GFP_MOVABLE"}, + {(unsigned long)((gfp_t)0x400000u), "__GFP_ACCOUNT"}, + {(unsigned long)((gfp_t)0x1000u), "__GFP_WRITE"}, + {(unsigned long)((gfp_t)(0x400u | 0x800u)), "__GFP_RECLAIM"}, + {(unsigned long)((gfp_t)0x400u), "__GFP_DIRECT_RECLAIM"}, + {(unsigned long)((gfp_t)0x800u), "__GFP_KSWAPD_RECLAIM"}, + {(unsigned long)((gfp_t)0x800000u), "__GFP_ZEROTAGS"}) + : "none"); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_page_alloc) msg " - "had be cut off in outfile"); + "maybe, the contents of print event(mm_page_alloc) msg had be cut off in outfile"); } - return std::string(buffer); + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_page_alloc) msg snprintf_s format error "); + return ""; + } + return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_page_alloc_extfrag, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_page_alloc_extfrag_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_page_alloc_extfrag_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_page_alloc_extfrag_format(); - char buffer[BUFFER_SIZE]; - int len = - snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "mm_page_alloc_extfrag: page=%s pfn=0x%" PRIx64 " - alloc_order = % d fallback_order = % d pageblock_order = % d alloc_migratetype = - % d fallback_migratetype = - % d fragmenting = - % d change_ownership = - % d "0000000000000000"); + char buffer[BUFFER_SIZE] = {0}; + int len = snprintf_s( + buffer, BUFFER_SIZE, BUFFER_SIZE - 1, + "mm_page_alloc_extfrag: page=%s pfn=0x%" PRIx64 + " alloc_order=%d fallback_order=%d pageblock_order=%d alloc_migratetype=%d " + "fallback_migratetype=%d fragmenting=%d change_ownership=%d", + "0000000000000000", msg.pfn(), msg.alloc_order(), msg.fallback_order(), 10, + msg.alloc_migratetype(), msg.fallback_migratetype(), msg.fallback_order() < 10, + msg.change_ownership()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_page_alloc_extfrag) " - "msg had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(mm_page_alloc_extfrag) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_page_alloc_extfrag) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_page_alloc_zone_locked, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_page_alloc_zone_locked_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_page_alloc_zone_locked_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_page_alloc_zone_locked_format(); - char buffer[BUFFER_SIZE]; - int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "mm_page_alloc_zone_locked: page=%s pfn=0x%" PRIx64 " order=%u - migratetype=%d percpu_refill=%d "0000000000000000"); - if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_page_alloc_zone_locked) msg had " - "be cut off in outfile"); - } - return std::string(buffer); + char buffer[BUFFER_SIZE] = {0}; + int len = snprintf_s( + buffer, BUFFER_SIZE, BUFFER_SIZE - 1, + "mm_page_alloc_zone_locked: page=%s pfn=0x%" PRIx64 " order=%u migratetype=%d percpu_refill=%d", + "0000000000000000", msg.pfn() != -1UL ? msg.pfn() : 0, msg.order(), msg.migratetype(), msg.percpu_refill()); + if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(mm_page_alloc_zone_locked) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, + "the contents of event(mm_page_alloc_zone_locked) msg snprintf_s format error "); + return ""; + } + return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - mm_page_free, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_page_free_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + mm_page_free, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_page_free_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_page_free_format(); - char buffer[BUFFER_SIZE]; - int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "mm_page_free: page=%s pfn=0x%" PRIx64 " order=%d "0000000000000000"); - if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_page_free) msg " - "had be cut off in outfile"); - } - return std::string(buffer); + char buffer[BUFFER_SIZE] = {0}; + int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_page_free: page=%s pfn=0x%" PRIx64 " order=%d", + "0000000000000000", msg.pfn(), msg.order()); + if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN(LOG_CORE, + "maybe, the contents of print event(mm_page_free) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_page_free) msg snprintf_s format error "); + return ""; + } + return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_page_free_batched, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_page_free_batched_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_page_free_batched_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_page_free_batched_format(); - char buffer[BUFFER_SIZE]; - int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "mm_page_free_batched: page=%s pfn=0x%" PRIx64 " order=0 "0000000000000000"); - if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_page_free_batched) " - "msg had be cut off in outfile"); - } - return std::string(buffer); + char buffer[BUFFER_SIZE] = {0}; + int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, + "mm_page_free_batched: page=%s pfn=0x%" PRIx64 " order=0", "0000000000000000", msg.pfn()); + if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN(LOG_CORE, + "maybe, the contents of print event(mm_page_free_batched) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_page_free_batched) msg snprintf_s format error "); + return ""; + } + return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_page_pcpu_drain, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_page_pcpu_drain_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_page_pcpu_drain_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_page_pcpu_drain_format(); - char buffer[BUFFER_SIZE]; - int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "mm_page_pcpu_drain: page=%s pfn=0x%" PRIx64 " order=%d migratetype=%d "0000000000000000"); - if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_page_pcpu_drain) " - "msg had be cut off in outfile"); - } - return std::string(buffer); + char buffer[BUFFER_SIZE] = {0}; + int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, + "mm_page_pcpu_drain: page=%s pfn=0x%" PRIx64 " order=%d migratetype=%d", + "0000000000000000", msg.pfn(), msg.order(), msg.migratetype()); + if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN(LOG_CORE, + "maybe, the contents of print event(mm_page_pcpu_drain) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_page_pcpu_drain) msg snprintf_s format error "); + return ""; + } + return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - rss_stat, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rss_stat_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + rss_stat, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rss_stat_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rss_stat_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "rss_stat: mm_id=%u curr=%d type=%s size=%" PRIu64 "B", msg.mm_id(), msg.curr(), __print_symbolic(msg.member(), {0, "MM_FILEPAGES"}, {1, "MM_ANONPAGES"}, {2, "MM_SWAPENTS"}, {3, "MM_SHMEMPAGES"}), msg.size()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rss_stat) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(rss_stat) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rss_stat) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_mmc_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_mmc_event_formatter.cpp index 7ccce5877e20494fa97c4ed4b0a396fe1a251b8c..98ebae71741fbd8845543a25b9818fdcdfea97dd 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_mmc_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_mmc_event_formatter.cpp @@ -23,19 +23,16 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - mmc_request_done, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mmc_request_done_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + mmc_request_done, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mmc_request_done_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mmc_request_done_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "mmc_request_done: %s: end struct mmc_request[%p]: cmd_opcode=%u " - "cmd_err=%d cmd_resp=0x%x 0x%x 0x%x 0x%x cmd_retries=%u " - "stop_opcode=%u stop_err=%d stop_resp=0x%x 0x%x 0x%x 0x%x " - "stop_retries=%u sbc_opcode=%u sbc_err=%d sbc_resp=0x%x 0x%x 0x%x " - "0x%x sbc_retries=%u bytes_xfered=%u data_err=%d tag=%d " - "can_retune=%u doing_retune=%u retune_now=%u need_retune=%d " - "hold_retune=%d retune_period=%u", + "mmc_request_done: %s: end struct mmc_request[%p]: cmd_opcode=%u cmd_err=%d cmd_resp=0x%x 0x%x 0x%x 0x%x " + "cmd_retries=%u stop_opcode=%u stop_err=%d stop_resp=0x%x 0x%x 0x%x 0x%x stop_retries=%u sbc_opcode=%u " + "sbc_err=%d sbc_resp=0x%x 0x%x 0x%x 0x%x sbc_retries=%u bytes_xfered=%u data_err=%d tag=%d can_retune=%u " + "doing_retune=%u retune_now=%u need_retune=%d hold_retune=%d retune_period=%u", msg.name().c_str(), msg.mrq(), msg.cmd_opcode(), msg.cmd_err(), msg.cmd_resp()[0], msg.cmd_resp()[1], msg.cmd_resp()[2], msg.cmd_resp()[3], msg.cmd_retries(), msg.stop_opcode(), msg.stop_err(), msg.stop_resp()[0], msg.stop_resp()[1], msg.stop_resp()[2], msg.stop_resp()[3], msg.stop_retries(), @@ -44,35 +41,39 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.retune_now(), msg.need_retune(), msg.hold_retune(), msg.retune_period()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mmc_request_done) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(mmc_request_done) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mmc_request_done) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mmc_request_start, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mmc_request_start_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mmc_request_start_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mmc_request_start_format(); - char buffer[BUFFER_SIZE]; - int len = - snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "mmc_request_start: %s: start struct mmc_request[%p]: cmd_opcode=%u " - "cmd_arg=0x%x cmd_flags=0x%x cmd_retries=%u stop_opcode=%u " - "stop_arg=0x%x stop_flags=0x%x stop_retries=%u sbc_opcode=%u " - "sbc_arg=0x%x sbc_flags=0x%x sbc_retires=%u blocks=%u block_size=%u " - "blk_addr=%u data_flags=0x%x tag=%d can_retune=%u doing_retune=%u " - "retune_now=%u need_retune=%d hold_retune=%d retune_period=%u", - msg.name().c_str(), msg.mrq(), msg.cmd_opcode(), msg.cmd_arg(), msg.cmd_flags(), - msg.cmd_retries(), msg.stop_opcode(), msg.stop_arg(), msg.stop_flags(), msg.stop_retries(), - msg.sbc_opcode(), msg.sbc_arg(), msg.sbc_flags(), msg.sbc_retries(), msg.blocks(), msg.blksz(), - msg.blk_addr(), msg.data_flags(), msg.tag(), msg.can_retune(), msg.doing_retune(), - msg.retune_now(), msg.need_retune(), msg.hold_retune(), msg.retune_period()); + char buffer[BUFFER_SIZE] = {0}; + int len = snprintf_s( + buffer, BUFFER_SIZE, BUFFER_SIZE - 1, + "mmc_request_start: %s: start struct mmc_request[%p]: cmd_opcode=%u cmd_arg=0x%x cmd_flags=0x%x " + "cmd_retries=%u stop_opcode=%u stop_arg=0x%x stop_flags=0x%x stop_retries=%u sbc_opcode=%u sbc_arg=0x%x " + "sbc_flags=0x%x sbc_retires=%u blocks=%u block_size=%u blk_addr=%u data_flags=0x%x tag=%d can_retune=%u " + "doing_retune=%u retune_now=%u need_retune=%d hold_retune=%d retune_period=%u", + msg.name().c_str(), msg.mrq(), msg.cmd_opcode(), msg.cmd_arg(), msg.cmd_flags(), msg.cmd_retries(), + msg.stop_opcode(), msg.stop_arg(), msg.stop_flags(), msg.stop_retries(), msg.sbc_opcode(), msg.sbc_arg(), + msg.sbc_flags(), msg.sbc_retries(), msg.blocks(), msg.blksz(), msg.blk_addr(), msg.data_flags(), msg.tag(), + msg.can_retune(), msg.doing_retune(), msg.retune_now(), msg.need_retune(), msg.hold_retune(), + msg.retune_period()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mmc_request_start) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(mmc_request_start) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mmc_request_start) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_net_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_net_event_formatter.cpp index fb9c7072dd5427f06ab3608c2922847e0d2667e3..de585d26735434faf27ef494a90562da31d4c51b 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_net_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_net_event_formatter.cpp @@ -24,180 +24,197 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( napi_gro_frags_entry, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_napi_gro_frags_entry_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_napi_gro_frags_entry_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.napi_gro_frags_entry_format(); - char buffer[BUFFER_SIZE]; - int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "napi_gro_frags_entry: dev=%s napi_id=%#x queue_mapping=%u " - "skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x " - "protocol=0x%04x ip_summed=%d hash=0x%08x l4_hash=%d len=%u " - "data_len=%u truesize=%u mac_header_valid=%d mac_header=%d " - "nr_frags=%d gso_size=%d gso_type=%#x", - msg.name().c_str(), msg.napi_id(), msg.queue_mapping(), msg.skbaddr(), msg.vlan_tagged(), - msg.vlan_proto(), msg.vlan_tci(), msg.protocol(), msg.ip_summed(), msg.hash(), - msg.l4_hash(), msg.len(), msg.data_len(), msg.truesize(), msg.mac_header_valid(), - msg.mac_header(), msg.nr_frags(), msg.gso_size(), msg.gso_type()); + char buffer[BUFFER_SIZE] = {0}; + int len = snprintf_s( + buffer, BUFFER_SIZE, BUFFER_SIZE - 1, + "napi_gro_frags_entry: dev=%s napi_id=%#x queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x " + "vlan_tci=0x%04x protocol=0x%04x ip_summed=%d hash=0x%08x l4_hash=%d len=%u data_len=%u truesize=%u " + "mac_header_valid=%d mac_header=%d nr_frags=%d gso_size=%d gso_type=%#x", + msg.name().c_str(), msg.napi_id(), msg.queue_mapping(), msg.skbaddr(), msg.vlan_tagged(), msg.vlan_proto(), + msg.vlan_tci(), msg.protocol(), msg.ip_summed(), msg.hash(), msg.l4_hash(), msg.len(), msg.data_len(), + msg.truesize(), msg.mac_header_valid(), msg.mac_header(), msg.nr_frags(), msg.gso_size(), msg.gso_type()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(napi_gro_frags_entry) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(napi_gro_frags_entry) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(napi_gro_frags_entry) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( napi_gro_receive_entry, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_napi_gro_receive_entry_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_napi_gro_receive_entry_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.napi_gro_receive_entry_format(); - char buffer[BUFFER_SIZE]; - int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "napi_gro_receive_entry: dev=%s napi_id=%#x queue_mapping=%u " - "skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x " - "protocol=0x%04x ip_summed=%d hash=0x%08x l4_hash=%d len=%u " - "data_len=%u truesize=%u mac_header_valid=%d mac_header=%d " - "nr_frags=%d gso_size=%d gso_type=%#x", - msg.name().c_str(), msg.napi_id(), msg.queue_mapping(), msg.skbaddr(), msg.vlan_tagged(), - msg.vlan_proto(), msg.vlan_tci(), msg.protocol(), msg.ip_summed(), msg.hash(), - msg.l4_hash(), msg.len(), msg.data_len(), msg.truesize(), msg.mac_header_valid(), - msg.mac_header(), msg.nr_frags(), msg.gso_size(), msg.gso_type()); + char buffer[BUFFER_SIZE] = {0}; + int len = snprintf_s( + buffer, BUFFER_SIZE, BUFFER_SIZE - 1, + "napi_gro_receive_entry: dev=%s napi_id=%#x queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x " + "vlan_tci=0x%04x protocol=0x%04x ip_summed=%d hash=0x%08x l4_hash=%d len=%u data_len=%u truesize=%u " + "mac_header_valid=%d mac_header=%d nr_frags=%d gso_size=%d gso_type=%#x", + msg.name().c_str(), msg.napi_id(), msg.queue_mapping(), msg.skbaddr(), msg.vlan_tagged(), msg.vlan_proto(), + msg.vlan_tci(), msg.protocol(), msg.ip_summed(), msg.hash(), msg.l4_hash(), msg.len(), msg.data_len(), + msg.truesize(), msg.mac_header_valid(), msg.mac_header(), msg.nr_frags(), msg.gso_size(), msg.gso_type()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(napi_gro_receive_entry) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(napi_gro_receive_entry) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(napi_gro_receive_entry) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - net_dev_queue, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_net_dev_queue_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + net_dev_queue, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_net_dev_queue_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.net_dev_queue_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "net_dev_queue: dev=%s skbaddr=%p len=%u", msg.name().c_str(), msg.skbaddr(), msg.len()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(net_dev_queue) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(net_dev_queue) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(net_dev_queue) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( net_dev_start_xmit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_net_dev_start_xmit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_net_dev_start_xmit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.net_dev_start_xmit_format(); - char buffer[BUFFER_SIZE]; - int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "net_dev_start_xmit: dev=%s queue_mapping=%u skbaddr=%p " - "vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x protocol=0x%04x " - "ip_summed=%d len=%u data_len=%u network_offset=%d " - "transport_offset_valid=%d transport_offset=%d tx_flags=%d " - "gso_size=%d gso_segs=%d gso_type=%#x", - msg.name().c_str(), msg.queue_mapping(), msg.skbaddr(), msg.vlan_tagged(), - msg.vlan_proto(), msg.vlan_tci(), msg.protocol(), msg.ip_summed(), msg.len(), - msg.data_len(), msg.network_offset(), msg.transport_offset_valid(), msg.transport_offset(), - msg.tx_flags(), msg.gso_size(), msg.gso_segs(), msg.gso_type()); + char buffer[BUFFER_SIZE] = {0}; + int len = + snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, + "net_dev_start_xmit: dev=%s queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x " + "vlan_tci=0x%04x protocol=0x%04x ip_summed=%d len=%u data_len=%u network_offset=%d " + "transport_offset_valid=%d transport_offset=%d tx_flags=%d gso_size=%d gso_segs=%d gso_type=%#x", + msg.name().c_str(), msg.queue_mapping(), msg.skbaddr(), msg.vlan_tagged(), msg.vlan_proto(), + msg.vlan_tci(), msg.protocol(), msg.ip_summed(), msg.len(), msg.data_len(), msg.network_offset(), + msg.transport_offset_valid(), msg.transport_offset(), msg.tx_flags(), msg.gso_size(), + msg.gso_segs(), msg.gso_type()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(net_dev_start_xmit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(net_dev_start_xmit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(net_dev_start_xmit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - net_dev_xmit, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_net_dev_xmit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + net_dev_xmit, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_net_dev_xmit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.net_dev_xmit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "net_dev_xmit: dev=%s skbaddr=%p len=%u rc=%d", msg.name().c_str(), msg.skbaddr(), msg.len(), msg.rc()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(net_dev_xmit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(net_dev_xmit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(net_dev_xmit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( netif_receive_skb, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_netif_receive_skb_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_netif_receive_skb_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.netif_receive_skb_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "netif_receive_skb: dev=%s skbaddr=%p len=%u", msg.name().c_str(), msg.skbaddr(), msg.len()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(netif_receive_skb) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(netif_receive_skb) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(netif_receive_skb) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( netif_receive_skb_entry, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_netif_receive_skb_entry_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_netif_receive_skb_entry_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.netif_receive_skb_entry_format(); - char buffer[BUFFER_SIZE]; - int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "netif_receive_skb_entry: dev=%s napi_id=%#x queue_mapping=%u " - "skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x " - "protocol=0x%04x ip_summed=%d hash=0x%08x l4_hash=%d len=%u " - "data_len=%u truesize=%u mac_header_valid=%d mac_header=%d " - "nr_frags=%d gso_size=%d gso_type=%#x", - msg.name().c_str(), msg.napi_id(), msg.queue_mapping(), msg.skbaddr(), msg.vlan_tagged(), - msg.vlan_proto(), msg.vlan_tci(), msg.protocol(), msg.ip_summed(), msg.hash(), - msg.l4_hash(), msg.len(), msg.data_len(), msg.truesize(), msg.mac_header_valid(), - msg.mac_header(), msg.nr_frags(), msg.gso_size(), msg.gso_type()); + char buffer[BUFFER_SIZE] = {0}; + int len = snprintf_s( + buffer, BUFFER_SIZE, BUFFER_SIZE - 1, + "netif_receive_skb_entry: dev=%s napi_id=%#x queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x " + "vlan_tci=0x%04x protocol=0x%04x ip_summed=%d hash=0x%08x l4_hash=%d len=%u data_len=%u truesize=%u " + "mac_header_valid=%d mac_header=%d nr_frags=%d gso_size=%d gso_type=%#x", + msg.name().c_str(), msg.napi_id(), msg.queue_mapping(), msg.skbaddr(), msg.vlan_tagged(), msg.vlan_proto(), + msg.vlan_tci(), msg.protocol(), msg.ip_summed(), msg.hash(), msg.l4_hash(), msg.len(), msg.data_len(), + msg.truesize(), msg.mac_header_valid(), msg.mac_header(), msg.nr_frags(), msg.gso_size(), msg.gso_type()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(netif_receive_skb_entry) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(netif_receive_skb_entry) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(netif_receive_skb_entry) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - netif_rx, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_netif_rx_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + netif_rx, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_netif_rx_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.netif_rx_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "netif_rx: dev=%s skbaddr=%p len=%u", msg.name().c_str(), msg.skbaddr(), msg.len()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(netif_rx) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(netif_rx) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(netif_rx) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - netif_rx_entry, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_netif_rx_entry_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + netif_rx_entry, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_netif_rx_entry_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.netif_rx_entry_format(); - char buffer[BUFFER_SIZE]; - int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "netif_rx_entry: dev=%s napi_id=%#x queue_mapping=%u skbaddr=%p " - "vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x protocol=0x%04x " - "ip_summed=%d hash=0x%08x l4_hash=%d len=%u data_len=%u truesize=%u " - "mac_header_valid=%d mac_header=%d nr_frags=%d gso_size=%d " - "gso_type=%#x", - msg.name().c_str(), msg.napi_id(), msg.queue_mapping(), msg.skbaddr(), msg.vlan_tagged(), - msg.vlan_proto(), msg.vlan_tci(), msg.protocol(), msg.ip_summed(), msg.hash(), - msg.l4_hash(), msg.len(), msg.data_len(), msg.truesize(), msg.mac_header_valid(), - msg.mac_header(), msg.nr_frags(), msg.gso_size(), msg.gso_type()); + char buffer[BUFFER_SIZE] = {0}; + int len = snprintf_s( + buffer, BUFFER_SIZE, BUFFER_SIZE - 1, + "netif_rx_entry: dev=%s napi_id=%#x queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x " + "vlan_tci=0x%04x protocol=0x%04x ip_summed=%d hash=0x%08x l4_hash=%d len=%u data_len=%u truesize=%u " + "mac_header_valid=%d mac_header=%d nr_frags=%d gso_size=%d gso_type=%#x", + msg.name().c_str(), msg.napi_id(), msg.queue_mapping(), msg.skbaddr(), msg.vlan_tagged(), msg.vlan_proto(), + msg.vlan_tci(), msg.protocol(), msg.ip_summed(), msg.hash(), msg.l4_hash(), msg.len(), msg.data_len(), + msg.truesize(), msg.mac_header_valid(), msg.mac_header(), msg.nr_frags(), msg.gso_size(), msg.gso_type()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(netif_rx_entry) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(netif_rx_entry) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(netif_rx_entry) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_oom_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_oom_event_formatter.cpp index b5a7a6fd53d4356d8442e25b45ccc4655c03a256..76d6860f17e102f23dfedf5f267480047f840445 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_oom_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_oom_event_formatter.cpp @@ -24,17 +24,20 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( oom_score_adj_update, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_oom_score_adj_update_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_oom_score_adj_update_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.oom_score_adj_update_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "oom_score_adj_update: pid=%d comm=%s oom_score_adj=%" PRId32 "", msg.pid(), msg.comm().c_str(), msg.oom_score_adj()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(oom_score_adj_update) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(oom_score_adj_update) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(oom_score_adj_update) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_pagemap_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_pagemap_event_formatter.cpp index d0d91f6faa2079285aca308340cd3549ba87b622..9b7ec1a8880ff476428654c2f4a7a577de6f672e 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_pagemap_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_pagemap_event_formatter.cpp @@ -23,25 +23,28 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - mm_lru_activate, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_lru_activate_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + mm_lru_activate, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_lru_activate_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_lru_activate_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_lru_activate: folio=%p pfn=0x%" PRIx64 "", msg.folio(), msg.pfn()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_lru_activate) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(mm_lru_activate) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_lru_activate) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - mm_lru_insertion, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_lru_insertion_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + mm_lru_insertion, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_lru_insertion_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_lru_insertion_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_lru_insertion: folio=%p pfn=0x%" PRIx64 " lru=%d flags=%s%s%s%s%s%s", msg.folio(), msg.pfn(), msg.lru(), msg.flags() & 0x0001u ? "M" : " ", msg.flags() & 0x0002u ? "a" : "f", @@ -49,8 +52,11 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.flags() & 0x0020u ? "d" : " ", msg.flags() & 0x0040u ? "B" : " "); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_lru_insertion) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(mm_lru_insertion) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_lru_insertion) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_power_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_power_event_formatter.cpp index 0de573c5de6c72cf3c3a6abeb1c36588cad45c8d..76cb2e20fed4f92c138b5c06054fbf5db9a525a4 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_power_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_power_event_formatter.cpp @@ -24,175 +24,208 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - clock_disable, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clock_disable_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + clock_disable, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clock_disable_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clock_disable_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clock_disable: %s state=%lu cpu_id=%lu", msg.name().c_str(), (unsigned long)msg.state(), (unsigned long)msg.cpu_id()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clock_disable) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(clock_disable) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clock_disable) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - clock_enable, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clock_enable_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + clock_enable, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clock_enable_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clock_enable_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clock_enable: %s state=%lu cpu_id=%lu", msg.name().c_str(), (unsigned long)msg.state(), (unsigned long)msg.cpu_id()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clock_enable) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(clock_enable) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clock_enable) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - clock_set_rate, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_clock_set_rate_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + clock_set_rate, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_clock_set_rate_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.clock_set_rate_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "clock_set_rate: %s state=%lu cpu_id=%lu", msg.name().c_str(), (unsigned long)msg.state(), (unsigned long)msg.cpu_id()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(clock_set_rate) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(clock_set_rate) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(clock_set_rate) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - cpu_frequency, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cpu_frequency_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + cpu_frequency, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cpu_frequency_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cpu_frequency_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cpu_frequency: state=%lu cpu_id=%lu", (unsigned long)msg.state(), (unsigned long)msg.cpu_id()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cpu_frequency) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(cpu_frequency) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cpu_frequency) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( cpu_frequency_limits, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cpu_frequency_limits_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cpu_frequency_limits_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cpu_frequency_limits_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cpu_frequency_limits: min=%lu max=%lu cpu_id=%lu", (unsigned long)msg.min_freq(), (unsigned long)msg.max_freq(), (unsigned long)msg.cpu_id()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cpu_frequency_limits) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(cpu_frequency_limits) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cpu_frequency_limits) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - cpu_idle, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_cpu_idle_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + cpu_idle, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_cpu_idle_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.cpu_idle_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "cpu_idle: state=%lu cpu_id=%lu", (unsigned long)msg.state(), (unsigned long)msg.cpu_id()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(cpu_idle) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(cpu_idle) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(cpu_idle) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( dev_pm_qos_add_request, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_dev_pm_qos_add_request_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_dev_pm_qos_add_request_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.dev_pm_qos_add_request_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "dev_pm_qos_add_request: device=%s type=%s new_value=%d", msg.name().c_str(), __print_symbolic(msg.type(), {DEV_PM_QOS_RESUME_LATENCY, "DEV_PM_QOS_RESUME_LATENCY"}, {DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS"}), msg.new_value()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(dev_pm_qos_add_request) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(dev_pm_qos_add_request) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(dev_pm_qos_add_request) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( dev_pm_qos_remove_request, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_dev_pm_qos_remove_request_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_dev_pm_qos_remove_request_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.dev_pm_qos_remove_request_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "dev_pm_qos_remove_request: device=%s type=%s new_value=%d", msg.name().c_str(), __print_symbolic(msg.type(), {DEV_PM_QOS_RESUME_LATENCY, "DEV_PM_QOS_RESUME_LATENCY"}, {DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS"}), msg.new_value()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(dev_pm_qos_remove_request) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(dev_pm_qos_remove_request) msg " - "had be cut off in outfile"); + "the contents of event(dev_pm_qos_remove_request) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( dev_pm_qos_update_request, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_dev_pm_qos_update_request_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_dev_pm_qos_update_request_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.dev_pm_qos_update_request_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "dev_pm_qos_update_request: device=%s type=%s new_value=%d", msg.name().c_str(), __print_symbolic(msg.type(), {DEV_PM_QOS_RESUME_LATENCY, "DEV_PM_QOS_RESUME_LATENCY"}, {DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS"}), msg.new_value()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(dev_pm_qos_update_request) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(dev_pm_qos_update_request) msg " - "had be cut off in outfile"); + "the contents of event(dev_pm_qos_update_request) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( device_pm_callback_end, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_device_pm_callback_end_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_device_pm_callback_end_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.device_pm_callback_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "device_pm_callback_end: %s %s, err=%d", msg.driver().c_str(), msg.device().c_str(), msg.error()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(device_pm_callback_end) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(device_pm_callback_end) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(device_pm_callback_end) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( device_pm_callback_start, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_device_pm_callback_start_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_device_pm_callback_start_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.device_pm_callback_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "device_pm_callback_start: %s %s, parent: %s, %s[%s]", msg.driver().c_str(), msg.device().c_str(), msg.parent().c_str(), msg.pm_ops().c_str(), @@ -200,51 +233,60 @@ REGISTER_FTRACE_EVENT_FORMATTER( {0x0008, "quiesce"}, {0x0004, "hibernate"}, {0x0020, "thaw"}, {0x0040, "restore"}, {0x0080, "recover"})); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(device_pm_callback_start) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(device_pm_callback_start) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(device_pm_callback_start) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( pm_qos_add_request, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_pm_qos_add_request_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_pm_qos_add_request_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.pm_qos_add_request_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "pm_qos_add_request: CPU_DMA_LATENCY value=%d", msg.value()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(pm_qos_add_request) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(pm_qos_add_request) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(pm_qos_add_request) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( pm_qos_remove_request, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_pm_qos_remove_request_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_pm_qos_remove_request_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.pm_qos_remove_request_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "pm_qos_remove_request: CPU_DMA_LATENCY value=%d", msg.value()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(pm_qos_remove_request) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(pm_qos_remove_request) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(pm_qos_remove_request) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( pm_qos_update_flags, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_pm_qos_update_flags_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_pm_qos_update_flags_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.pm_qos_update_flags_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "pm_qos_update_flags: action=%s prev_value=0x%x curr_value=0x%x", __print_symbolic(msg.action(), {PM_QOS_ADD_REQ, "ADD_REQ"}, @@ -252,34 +294,40 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.prev_value(), msg.curr_value()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(pm_qos_update_flags) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(pm_qos_update_flags) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(pm_qos_update_flags) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( pm_qos_update_request, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_pm_qos_update_request_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_pm_qos_update_request_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.pm_qos_update_request_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "pm_qos_update_request: CPU_DMA_LATENCY value=%d", msg.value()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(pm_qos_update_request) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(pm_qos_update_request) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(pm_qos_update_request) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( pm_qos_update_target, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_pm_qos_update_target_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_pm_qos_update_target_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.pm_qos_update_target_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "pm_qos_update_target: action=%s prev_value=%d curr_value=%d", __print_symbolic(msg.action(), {PM_QOS_ADD_REQ, "ADD_REQ"}, @@ -287,90 +335,108 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.prev_value(), msg.curr_value()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(pm_qos_update_target) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(pm_qos_update_target) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(pm_qos_update_target) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( power_domain_target, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_power_domain_target_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_power_domain_target_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.power_domain_target_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "power_domain_target: %s state=%lu cpu_id=%lu", msg.name().c_str(), (unsigned long)msg.state(), (unsigned long)msg.cpu_id()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(power_domain_target) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(power_domain_target) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(power_domain_target) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - pstate_sample, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_pstate_sample_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + pstate_sample, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_pstate_sample_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.pstate_sample_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "pstate_sample: core_busy=%lu scaled=%lu from=%lu to=%lu " - "mperf=%" PRIu64 " aperf=%" PRIu64 " tsc=%" PRIu64 " freq=%lu io_boost=%lu", + "pstate_sample: core_busy=%lu scaled=%lu from=%lu to=%lu mperf=%" PRIu64 " aperf=%" PRIu64 + " tsc=%" PRIu64 " freq=%lu io_boost=%lu", (unsigned long)msg.core_busy(), (unsigned long)msg.scaled_busy(), (unsigned long)msg.from(), (unsigned long)msg.to(), msg.mperf(), msg.aperf(), msg.tsc(), (unsigned long)msg.freq(), (unsigned long)msg.io_boost()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(pstate_sample) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(pstate_sample) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(pstate_sample) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - suspend_resume, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_suspend_resume_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + suspend_resume, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_suspend_resume_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.suspend_resume_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "suspend_resume: %s[%u] %s", msg.action().c_str(), (unsigned int)msg.val(), (msg.start()) ? "begin" : "end"); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(suspend_resume) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(suspend_resume) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(suspend_resume) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( wakeup_source_activate, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_wakeup_source_activate_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_wakeup_source_activate_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.wakeup_source_activate_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "wakeup_source_activate: %s state=0x%" PRIx64 "", msg.name().c_str(), msg.state()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(wakeup_source_activate) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(wakeup_source_activate) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(wakeup_source_activate) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( wakeup_source_deactivate, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_wakeup_source_deactivate_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_wakeup_source_deactivate_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.wakeup_source_deactivate_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "wakeup_source_deactivate: %s state=0x%" PRIx64 "", msg.name().c_str(), msg.state()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(wakeup_source_deactivate) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(wakeup_source_deactivate) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(wakeup_source_deactivate) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_printk_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_printk_event_formatter.cpp index ca240a13a14e6d816c155215b432a6dc146e7d88..e794c878800eb2a58dfeb0897de8edf9ff31ecb6 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_printk_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_printk_event_formatter.cpp @@ -23,15 +23,17 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - console, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_console_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + console, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_console_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.console_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "console: %s", msg.msg().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(console) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(console) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(console) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_raw_syscalls_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_raw_syscalls_event_formatter.cpp index 0c5d883a229337fb25447af02ef7763d7104f6be..c26f1bf918d2eb81dd070a88c48f359a8887d79e 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_raw_syscalls_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_raw_syscalls_event_formatter.cpp @@ -23,33 +23,37 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - sys_enter, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sys_enter_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sys_enter, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sys_enter_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sys_enter_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sys_enter: NR %" PRIu64 " (%" PRIx64 ", %" PRIx64 ", %" PRIx64 ", %" PRIx64 ", %" PRIx64 ", %" PRIx64 ")", msg.id(), msg.args()[0], msg.args()[1], msg.args()[2], msg.args()[3], msg.args()[4], msg.args()[5]); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sys_enter) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(sys_enter) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sys_enter) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - sys_exit, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sys_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sys_exit, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sys_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sys_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sys_exit: NR %" PRIu64 " = %" PRIu64 "", msg.id(), msg.ret()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sys_exit) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(sys_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sys_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_rcu_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_rcu_event_formatter.cpp index 5f66b5822aef68c1e165b4cd587e864dd54b4ab0..d8921fb40f9289fe3cd809071054383099edd502 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_rcu_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_rcu_event_formatter.cpp @@ -23,15 +23,18 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - rcu_utilization, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rcu_utilization_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + rcu_utilization, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rcu_utilization_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rcu_utilization_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "rcu_utilization: %s", msg.s().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rcu_utilization) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(rcu_utilization) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rcu_utilization) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_regulator_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_regulator_event_formatter.cpp index ce2b50521a1016904a5bb15226503a9b3a830fe4..de43ccec2e50003156282cc11a2e529d4dccb5d4 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_regulator_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_regulator_event_formatter.cpp @@ -24,176 +24,216 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( regulator_bypass_disable, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_regulator_bypass_disable_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_regulator_bypass_disable_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.regulator_bypass_disable_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "regulator_bypass_disable: name=%s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(regulator_bypass_disable) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(regulator_bypass_disable) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(regulator_bypass_disable) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( regulator_bypass_disable_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_regulator_bypass_disable_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_regulator_bypass_disable_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.regulator_bypass_disable_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "regulator_bypass_disable_complete: name=%s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(regulator_bypass_disable_complete) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print " - "event(regulator_bypass_disable_complete) " - "msg had be cut off in outfile"); + "the contents of event(regulator_bypass_disable_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( regulator_bypass_enable, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_regulator_bypass_enable_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_regulator_bypass_enable_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.regulator_bypass_enable_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "regulator_bypass_enable: name=%s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(regulator_bypass_enable) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(regulator_bypass_enable) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(regulator_bypass_enable) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( regulator_bypass_enable_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_regulator_bypass_enable_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_regulator_bypass_enable_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.regulator_bypass_enable_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "regulator_bypass_enable_complete: name=%s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(regulator_bypass_enable_complete) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print " - "event(regulator_bypass_enable_complete) " - "msg had be cut off in outfile"); + "the contents of event(regulator_bypass_enable_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( regulator_disable, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_regulator_disable_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_regulator_disable_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.regulator_disable_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "regulator_disable: name=%s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(regulator_disable) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(regulator_disable) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(regulator_disable) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( regulator_disable_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_regulator_disable_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_regulator_disable_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.regulator_disable_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "regulator_disable_complete: name=%s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(regulator_disable_complete) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(regulator_disable_complete) " - "msg had be cut off in outfile"); + "the contents of event(regulator_disable_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - regulator_enable, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_regulator_enable_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + regulator_enable, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_regulator_enable_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.regulator_enable_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "regulator_enable: name=%s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(regulator_enable) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(regulator_enable) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(regulator_enable) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( regulator_enable_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_regulator_enable_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_regulator_enable_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.regulator_enable_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "regulator_enable_complete: name=%s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(regulator_enable_complete) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(regulator_enable_complete) msg " - "had be cut off in outfile"); + "the contents of event(regulator_enable_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( regulator_enable_delay, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_regulator_enable_delay_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_regulator_enable_delay_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.regulator_enable_delay_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "regulator_enable_delay: name=%s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(regulator_enable_delay) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(regulator_enable_delay) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(regulator_enable_delay) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( regulator_set_voltage, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_regulator_set_voltage_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_regulator_set_voltage_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.regulator_set_voltage_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "regulator_set_voltage: name=%s (%d-%d)", msg.name().c_str(), (int)msg.min(), (int)msg.max()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(regulator_set_voltage) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(regulator_set_voltage) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(regulator_set_voltage) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( regulator_set_voltage_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_regulator_set_voltage_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_regulator_set_voltage_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.regulator_set_voltage_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "regulator_set_voltage_complete: name=%s, val=%u", msg.name().c_str(), (int)msg.val()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(regulator_set_voltage_complete) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print " - "event(regulator_set_voltage_complete) msg " - "had be cut off in outfile"); + "the contents of event(regulator_set_voltage_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_sched_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_sched_event_formatter.cpp index a76a4f86c31845d96b4615ccf3e8c8291b8205d5..8b284c79ff50a28eda4fac65066218840893fa77 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_sched_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_sched_event_formatter.cpp @@ -24,303 +24,353 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( sched_kthread_stop, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_kthread_stop_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_kthread_stop_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_kthread_stop_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_kthread_stop: comm=%s pid=%d", msg.comm().c_str(), msg.pid()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_kthread_stop) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_kthread_stop) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_kthread_stop) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( sched_kthread_stop_ret, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_kthread_stop_ret_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_kthread_stop_ret_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_kthread_stop_ret_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_kthread_stop_ret: ret=%d", msg.ret()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_kthread_stop_ret) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(sched_kthread_stop_ret) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_kthread_stop_ret) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( sched_migrate_task, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_migrate_task_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_migrate_task_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_migrate_task_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_migrate_task: comm=%s pid=%d prio=%d orig_cpu=%d dest_cpu=%d", msg.comm().c_str(), msg.pid(), msg.prio(), msg.orig_cpu(), msg.dest_cpu()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_migrate_task) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_migrate_task) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_migrate_task) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - sched_move_numa, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_move_numa_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sched_move_numa, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_move_numa_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_move_numa_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "sched_move_numa: pid=%d tgid=%d ngid=%d src_cpu=%d " - "src_nid=%d dst_cpu=%d dst_nid=%d", - msg.pid(), msg.tgid(), msg.ngid(), msg.src_cpu(), msg.src_nid(), msg.dst_cpu(), msg.dst_nid()); + "sched_move_numa: pid=%d tgid=%d ngid=%d src_cpu=%d src_nid=%d dst_cpu=%d dst_nid=%d", msg.pid(), + msg.tgid(), msg.ngid(), msg.src_cpu(), msg.src_nid(), msg.dst_cpu(), msg.dst_nid()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_move_numa) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_move_numa) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_move_numa) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - sched_pi_setprio, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_pi_setprio_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sched_pi_setprio, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_pi_setprio_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_pi_setprio_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_pi_setprio: comm=%s pid=%d oldprio=%d newprio=%d", msg.comm().c_str(), msg.pid(), msg.oldprio(), msg.newprio()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_pi_setprio) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_pi_setprio) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_pi_setprio) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( sched_process_exec, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_process_exec_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_process_exec_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_process_exec_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_process_exec: filename=%s pid=%d old_pid=%d", msg.filename().c_str(), msg.pid(), msg.old_pid()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_process_exec) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_process_exec) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_process_exec) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( sched_process_exit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_process_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_process_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_process_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_process_exit: comm=%s pid=%d prio=%d", msg.comm().c_str(), msg.pid(), msg.prio()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_process_exit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_process_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_process_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( sched_process_fork, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_process_fork_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_process_fork_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_process_fork_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_process_fork: comm=%s pid=%d child_comm=%s child_pid=%d", msg.parent_comm().c_str(), msg.parent_pid(), msg.child_comm().c_str(), msg.child_pid()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_process_fork) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_process_fork) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_process_fork) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( sched_process_free, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_process_free_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_process_free_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_process_free_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_process_free: comm=%s pid=%d prio=%d", msg.comm().c_str(), msg.pid(), msg.prio()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_process_free) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_process_free) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_process_free) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( sched_process_wait, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_process_wait_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_process_wait_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_process_wait_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_process_wait: comm=%s pid=%d prio=%d", msg.comm().c_str(), msg.pid(), msg.prio()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_process_wait) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_process_wait) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_process_wait) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( sched_stat_blocked, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_stat_blocked_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_stat_blocked_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_stat_blocked_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_stat_blocked: comm=%s pid=%d delay=%" PRIu64 " [ns]", msg.comm().c_str(), msg.pid(), msg.delay()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_stat_blocked) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_stat_blocked) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_stat_blocked) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( sched_stat_iowait, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_stat_iowait_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_stat_iowait_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_stat_iowait_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_stat_iowait: comm=%s pid=%d delay=%" PRIu64 " [ns]", msg.comm().c_str(), msg.pid(), msg.delay()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_stat_iowait) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_stat_iowait) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_stat_iowait) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( sched_stat_runtime, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_stat_runtime_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_stat_runtime_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_stat_runtime_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_stat_runtime: comm=%s pid=%d runtime=%" PRIu64 " [ns] vruntime=%" PRIu64 " [ns]", msg.comm().c_str(), msg.pid(), msg.runtime(), msg.vruntime()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_stat_runtime) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_stat_runtime) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_stat_runtime) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - sched_stat_sleep, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_stat_sleep_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sched_stat_sleep, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_stat_sleep_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_stat_sleep_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_stat_sleep: comm=%s pid=%d delay=%" PRIu64 " [ns]", msg.comm().c_str(), msg.pid(), msg.delay()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_stat_sleep) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_stat_sleep) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_stat_sleep) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - sched_stat_wait, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_stat_wait_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sched_stat_wait, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_stat_wait_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_stat_wait_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_stat_wait: comm=%s pid=%d delay=%" PRIu64 " [ns]", msg.comm().c_str(), msg.pid(), msg.delay()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_stat_wait) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_stat_wait) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_stat_wait) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - sched_stick_numa, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_stick_numa_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sched_stick_numa, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_stick_numa_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_stick_numa_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "sched_stick_numa: src_pid=%d src_tgid=%d src_ngid=%d src_cpu=%d " - "src_nid=%d dst_pid=%d dst_tgid=%d dst_ngid=%d dst_cpu=%d dst_nid=%d", + "sched_stick_numa: src_pid=%d src_tgid=%d src_ngid=%d src_cpu=%d src_nid=%d dst_pid=%d " + "dst_tgid=%d dst_ngid=%d dst_cpu=%d dst_nid=%d", msg.pid(), msg.tgid(), msg.ngid(), msg.src_cpu(), msg.src_nid(), msg.pid(), msg.tgid(), msg.ngid(), msg.dst_cpu(), msg.dst_nid()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_stick_numa) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_stick_numa) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_stick_numa) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - sched_swap_numa, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_swap_numa_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sched_swap_numa, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_swap_numa_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_swap_numa_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "sched_swap_numa: src_pid=%d src_tgid=%d src_ngid=%d src_cpu=%d " - "src_nid=%d dst_pid=%d dst_tgid=%d dst_ngid=%d dst_cpu=%d dst_nid=%d", + "sched_swap_numa: src_pid=%d src_tgid=%d src_ngid=%d src_cpu=%d src_nid=%d dst_pid=%d " + "dst_tgid=%d dst_ngid=%d dst_cpu=%d dst_nid=%d", msg.src_pid(), msg.src_tgid(), msg.src_ngid(), msg.src_cpu(), msg.src_nid(), msg.dst_pid(), msg.dst_tgid(), msg.dst_ngid(), msg.dst_cpu(), msg.dst_nid()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_swap_numa) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_swap_numa) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_swap_numa) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - sched_switch, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_switch_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sched_switch, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_switch_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_switch_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; if (msg.prev_state() > 0x0400) { len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "sched_switch: prev_comm=%s prev_pid=%d prev_prio=%d prev_state=? " - "==> next_comm=%s next_pid=%d next_prio=%d", + "sched_switch: prev_comm=%s prev_pid=%d prev_prio=%d prev_state=? ==> next_comm=%s " + "next_pid=%d next_prio=%d", msg.prev_comm().c_str(), msg.prev_pid(), msg.prev_prio(), msg.next_comm().c_str(), msg.next_pid(), msg.next_prio()); } else { len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "sched_switch: prev_comm=%s prev_pid=%d prev_prio=%d " - "prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d", + "sched_switch: prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d " + "next_prio=%d", msg.prev_comm().c_str(), msg.prev_pid(), msg.prev_prio(), (msg.prev_state() & ((((0x0000 | 0x0001 | 0x0002 | 0x0004 | 0x0008 | 0x0010 | 0x0020 | 0x0040) + 1) << 1) - 1)) @@ -338,86 +388,106 @@ REGISTER_FTRACE_EVENT_FORMATTER( } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_switch) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_switch) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_switch) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - sched_wait_task, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_wait_task_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sched_wait_task, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_wait_task_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_wait_task_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_wait_task: comm=%s pid=%d prio=%d", msg.comm().c_str(), msg.pid(), msg.prio()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_wait_task) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_wait_task) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_wait_task) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( sched_wake_idle_without_ipi, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_wake_idle_without_ipi_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_wake_idle_without_ipi_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_wake_idle_without_ipi_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_wake_idle_without_ipi: cpu=%d", msg.cpu()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(sched_wake_idle_without_ipi) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_wake_idle_without_ipi) " - "msg had be cut off in outfile"); + "the contents of event(sched_wake_idle_without_ipi) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - sched_wakeup, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_wakeup_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sched_wakeup, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_wakeup_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_wakeup_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_wakeup: comm=%s pid=%d prio=%d target_cpu=%03d", msg.comm().c_str(), msg.pid(), msg.prio(), msg.target_cpu()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_wakeup) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_wakeup) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_wakeup) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - sched_wakeup_new, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_wakeup_new_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sched_wakeup_new, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_wakeup_new_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_wakeup_new_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_wakeup_new: comm=%s pid=%d prio=%d target_cpu=%03d", msg.comm().c_str(), msg.pid(), msg.prio(), msg.target_cpu()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_wakeup_new) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_wakeup_new) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_wakeup_new) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - sched_waking, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_sched_waking_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + sched_waking, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_sched_waking_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.sched_waking_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "sched_waking: comm=%s pid=%d prio=%d target_cpu=%03d", msg.comm().c_str(), msg.pid(), msg.prio(), msg.target_cpu()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(sched_waking) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(sched_waking) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(sched_waking) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_signal_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_signal_event_formatter.cpp index a211a06029e6f5556ac12cb5913b9213715a44ec..631e11d1f018e5cc5fd593dacd944e773c18669b 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_signal_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_signal_event_formatter.cpp @@ -23,35 +23,39 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - signal_deliver, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_signal_deliver_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + signal_deliver, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_signal_deliver_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.signal_deliver_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "signal_deliver: sig=%d errno=%d code=%d sa_handler=%" PRIx64 " sa_flags=%" PRIx64 "", msg.sig(), msg.error_code(), msg.code(), msg.sig_handler(), msg.sig_flags()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(signal_deliver) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(signal_deliver) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(signal_deliver) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - signal_generate, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_signal_generate_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + signal_generate, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_signal_generate_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.signal_generate_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "signal_generate: sig=%d errno=%d code=%d comm=%s pid=%d " - "grp=%d res=%d", - msg.sig(), msg.error_code(), msg.code(), msg.comm().c_str(), msg.pid(), msg.group(), - msg.result()); + "signal_generate: sig=%d errno=%d code=%d comm=%s pid=%d grp=%d res=%d", msg.sig(), + msg.error_code(), msg.code(), msg.comm().c_str(), msg.pid(), msg.group(), msg.result()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(signal_generate) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(signal_generate) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(signal_generate) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_sunrpc_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_sunrpc_event_formatter.cpp index 4a558755836a8bda97842c6281211114de3b9e83..f85c66679d02ed698c5deb536ff4033913c237a8 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_sunrpc_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_sunrpc_event_formatter.cpp @@ -23,44 +23,50 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - rpc_call_status, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_call_status_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + rpc_call_status, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_call_status_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_call_status_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "rpc_call_status: task:%08x@%08x status=%d", msg.task_id(), msg.client_id(), msg.status()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_call_status) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(rpc_call_status) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rpc_call_status) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( rpc_connect_status, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_connect_status_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_connect_status_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_connect_status_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "rpc_connect_status: task:%08x@%08x status=%d", msg.task_id(), msg.client_id(), msg.status()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_connect_status) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(rpc_connect_status) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rpc_connect_status) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - rpc_socket_close, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_socket_close_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + rpc_socket_close, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_socket_close_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_socket_close_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "rpc_socket_close: socket:[%" PRIu64 - "] srcaddr=%pISpc dstaddr=%pISpc state=%u (%s) sk_state=%u (%s)", + "] srcaddr=%pISpc dstaddr=%pISpc state=%u (%s) sk_state=%u (%s)", msg.ino(), msg.saddr(), msg.daddr(), msg.socket_state(), __print_symbolic(msg.socket_state(), {0, "FREE"}, {1, "UNCONNECTED"}, {2, "CONNECTING"}, {3, "CONNECTED"}, {4, "DISCONNECTING"}), @@ -70,21 +76,24 @@ REGISTER_FTRACE_EVENT_FORMATTER( {8, "CLOSE_WAIT"}, {9, "LAST_ACK"}, {10, "LISTEN"}, {11, "CLOSING"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_socket_close) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(rpc_socket_close) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rpc_socket_close) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( rpc_socket_connect, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_socket_connect_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_socket_connect_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_socket_connect_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "rpc_socket_connect: error=%d socket:[%" PRIu64 - "] srcaddr=%pISpc dstaddr=%pISpc state=%u (%s) sk_state=%u (%s)", + "] srcaddr=%pISpc dstaddr=%pISpc state=%u (%s) sk_state=%u (%s)", msg.error(), msg.ino(), msg.saddr(), msg.daddr(), msg.socket_state(), __print_symbolic(msg.socket_state(), {0, "FREE"}, {1, "UNCONNECTED"}, {2, "CONNECTING"}, {3, "CONNECTED"}, {4, "DISCONNECTING"}), @@ -94,20 +103,23 @@ REGISTER_FTRACE_EVENT_FORMATTER( {8, "CLOSE_WAIT"}, {9, "LAST_ACK"}, {10, "LISTEN"}, {11, "CLOSING"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_socket_connect) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(rpc_socket_connect) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rpc_socket_connect) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - rpc_socket_error, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_socket_error_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + rpc_socket_error, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_socket_error_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_socket_error_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "rpc_socket_error: error=%d socket:[%" PRIu64 - "] srcaddr=%pISpc dstaddr=%pISpc state=%u (%s) sk_state=%u (%s)", + "] srcaddr=%pISpc dstaddr=%pISpc state=%u (%s) sk_state=%u (%s)", msg.error(), msg.ino(), msg.saddr(), msg.daddr(), msg.socket_state(), __print_symbolic(msg.socket_state(), {0, "FREE"}, {1, "UNCONNECTED"}, {2, "CONNECTING"}, {3, "CONNECTED"}, {4, "DISCONNECTING"}), @@ -117,21 +129,24 @@ REGISTER_FTRACE_EVENT_FORMATTER( {8, "CLOSE_WAIT"}, {9, "LAST_ACK"}, {10, "LISTEN"}, {11, "CLOSING"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_socket_error) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(rpc_socket_error) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rpc_socket_error) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( rpc_socket_reset_connection, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_socket_reset_connection_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_socket_reset_connection_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_socket_reset_connection_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "rpc_socket_reset_connection: error=%d socket:[%" PRIu64 - "] srcaddr=%pISpc dstaddr=%pISpc state=%u (%s) sk_state=%u (%s)", + "] srcaddr=%pISpc dstaddr=%pISpc state=%u (%s) sk_state=%u (%s)", msg.error(), msg.ino(), msg.saddr(), msg.daddr(), msg.socket_state(), __print_symbolic(msg.socket_state(), {0, "FREE"}, {1, "UNCONNECTED"}, {2, "CONNECTING"}, {3, "CONNECTED"}, {4, "DISCONNECTING"}), @@ -140,22 +155,27 @@ REGISTER_FTRACE_EVENT_FORMATTER( {4, "FIN_WAIT1"}, {5, "FIN_WAIT2"}, {6, "TIME_WAIT"}, {7, "CLOSE"}, {8, "CLOSE_WAIT"}, {9, "LAST_ACK"}, {10, "LISTEN"}, {11, "CLOSING"})); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(rpc_socket_reset_connection) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_socket_reset_connection) " - "msg had be cut off in outfile"); + "the contents of event(rpc_socket_reset_connection) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( rpc_socket_shutdown, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_socket_shutdown_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_socket_shutdown_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_socket_shutdown_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "rpc_socket_shutdown: socket:[%" PRIu64 - "] srcaddr=%pISpc dstaddr=%pISpc state=%u (%s) sk_state=%u (%s)", + "] srcaddr=%pISpc dstaddr=%pISpc state=%u (%s) sk_state=%u (%s)", msg.ino(), msg.saddr(), msg.daddr(), msg.socket_state(), __print_symbolic(msg.socket_state(), {0, "FREE"}, {1, "UNCONNECTED"}, {2, "CONNECTING"}, {3, "CONNECTED"}, {4, "DISCONNECTING"}), @@ -165,21 +185,24 @@ REGISTER_FTRACE_EVENT_FORMATTER( {8, "CLOSE_WAIT"}, {9, "LAST_ACK"}, {10, "LISTEN"}, {11, "CLOSING"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_socket_shutdown) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(rpc_socket_shutdown) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rpc_socket_shutdown) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( rpc_socket_state_change, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_socket_state_change_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_socket_state_change_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_socket_state_change_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "rpc_socket_state_change: socket:[%" PRIu64 - "] srcaddr=%pISpc dstaddr=%pISpc state=%u (%s) sk_state=%u (%s)", + "] srcaddr=%pISpc dstaddr=%pISpc state=%u (%s) sk_state=%u (%s)", msg.ino(), msg.saddr(), msg.daddr(), msg.socket_state(), __print_symbolic(msg.socket_state(), {0, "FREE"}, {1, "UNCONNECTED"}, {2, "CONNECTING"}, {3, "CONNECTED"}, {4, "DISCONNECTING"}), @@ -188,30 +211,32 @@ REGISTER_FTRACE_EVENT_FORMATTER( {4, "FIN_WAIT1"}, {5, "FIN_WAIT2"}, {6, "TIME_WAIT"}, {7, "CLOSE"}, {8, "CLOSE_WAIT"}, {9, "LAST_ACK"}, {10, "LISTEN"}, {11, "CLOSING"})); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_socket_state_change) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(rpc_socket_state_change) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rpc_socket_state_change) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - rpc_task_begin, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_task_begin_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + rpc_task_begin, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_task_begin_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_task_begin_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.action()) > 0) { functionStr = kernelSymbols[msg.action()]; } if (functionStr != "") { len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "rpc_task_begin: task:%08x@%08x flags=%s runstate=%s status=%d " - "action=%s", - msg.task_id(), msg.client_id(), + "rpc_task_begin: task:%08x@%08x flags=%s runstate=%s status=%d action=%s", msg.task_id(), + msg.client_id(), __print_flags(msg.flags(), "|", {0x0001, "ASYNC"}, {0x0002, "SWAPPER"}, {0x0004, "MOVEABLE"}, {0x0010, "NULLCREDS"}, {0x0020, "MAJORSEEN"}, {0x0080, "DYNAMIC"}, {0x0100, "NO_ROUND_ROBIN"}, {0x0200, "SOFT"}, {0x0400, "SOFTCONN"}, {0x0800, "SENT"}, @@ -223,9 +248,8 @@ REGISTER_FTRACE_EVENT_FORMATTER( } else { len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "rpc_task_begin: task:%08x@%08x flags=%s runstate=%s status=%d " - "action=%p", - msg.task_id(), msg.client_id(), + "rpc_task_begin: task:%08x@%08x flags=%s runstate=%s status=%d action=%p", msg.task_id(), + msg.client_id(), __print_flags(msg.flags(), "|", {0x0001, "ASYNC"}, {0x0002, "SWAPPER"}, {0x0004, "MOVEABLE"}, {0x0010, "NULLCREDS"}, {0x0020, "MAJORSEEN"}, {0x0080, "DYNAMIC"}, {0x0100, "NO_ROUND_ROBIN"}, {0x0200, "SOFT"}, {0x0400, "SOFTCONN"}, {0x0800, "SENT"}, @@ -237,30 +261,32 @@ REGISTER_FTRACE_EVENT_FORMATTER( } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_task_begin) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(rpc_task_begin) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rpc_task_begin) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( rpc_task_complete, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_task_complete_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_task_complete_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_task_complete_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.action()) > 0) { functionStr = kernelSymbols[msg.action()]; } if (functionStr != "") { len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "rpc_task_complete: task:%08x@%08x flags=%s runstate=%s status=%d " - "action=%s", - msg.task_id(), msg.client_id(), + "rpc_task_complete: task:%08x@%08x flags=%s runstate=%s status=%d action=%s", msg.task_id(), + msg.client_id(), __print_flags(msg.flags(), "|", {0x0001, "ASYNC"}, {0x0002, "SWAPPER"}, {0x0004, "MOVEABLE"}, {0x0010, "NULLCREDS"}, {0x0020, "MAJORSEEN"}, {0x0080, "DYNAMIC"}, {0x0100, "NO_ROUND_ROBIN"}, {0x0200, "SOFT"}, {0x0400, "SOFTCONN"}, {0x0800, "SENT"}, @@ -272,9 +298,8 @@ REGISTER_FTRACE_EVENT_FORMATTER( } else { len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "rpc_task_complete: task:%08x@%08x flags=%s runstate=%s status=%d " - "action=%p", - msg.task_id(), msg.client_id(), + "rpc_task_complete: task:%08x@%08x flags=%s runstate=%s status=%d action=%p", msg.task_id(), + msg.client_id(), __print_flags(msg.flags(), "|", {0x0001, "ASYNC"}, {0x0002, "SWAPPER"}, {0x0004, "MOVEABLE"}, {0x0010, "NULLCREDS"}, {0x0020, "MAJORSEEN"}, {0x0080, "DYNAMIC"}, {0x0100, "NO_ROUND_ROBIN"}, {0x0200, "SOFT"}, {0x0400, "SOFTCONN"}, {0x0800, "SENT"}, @@ -286,30 +311,32 @@ REGISTER_FTRACE_EVENT_FORMATTER( } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_task_complete) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(rpc_task_complete) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rpc_task_complete) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( rpc_task_run_action, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_task_run_action_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_task_run_action_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_task_run_action_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.action()) > 0) { functionStr = kernelSymbols[msg.action()]; } if (functionStr != "") { len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "rpc_task_run_action: task:%08x@%08x flags=%s runstate=%s " - "status=%d action=%s", - msg.task_id(), msg.client_id(), + "rpc_task_run_action: task:%08x@%08x flags=%s runstate=%s status=%d action=%s", msg.task_id(), + msg.client_id(), __print_flags(msg.flags(), "|", {0x0001, "ASYNC"}, {0x0002, "SWAPPER"}, {0x0004, "MOVEABLE"}, {0x0010, "NULLCREDS"}, {0x0020, "MAJORSEEN"}, {0x0080, "DYNAMIC"}, {0x0100, "NO_ROUND_ROBIN"}, {0x0200, "SOFT"}, {0x0400, "SOFTCONN"}, {0x0800, "SENT"}, @@ -321,9 +348,8 @@ REGISTER_FTRACE_EVENT_FORMATTER( } else { len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "rpc_task_run_action: task:%08x@%08x flags=%s runstate=%s " - "status=%d action=%p", - msg.task_id(), msg.client_id(), + "rpc_task_run_action: task:%08x@%08x flags=%s runstate=%s status=%d action=%p", msg.task_id(), + msg.client_id(), __print_flags(msg.flags(), "|", {0x0001, "ASYNC"}, {0x0002, "SWAPPER"}, {0x0004, "MOVEABLE"}, {0x0010, "NULLCREDS"}, {0x0020, "MAJORSEEN"}, {0x0080, "DYNAMIC"}, {0x0100, "NO_ROUND_ROBIN"}, {0x0200, "SOFT"}, {0x0400, "SOFTCONN"}, {0x0800, "SENT"}, @@ -335,22 +361,24 @@ REGISTER_FTRACE_EVENT_FORMATTER( } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_task_run_action) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(rpc_task_run_action) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rpc_task_run_action) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - rpc_task_sleep, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_task_sleep_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + rpc_task_sleep, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_task_sleep_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_task_sleep_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "rpc_task_sleep: task:%08x@%08x flags=%s runstate=%s status=%d " - "timeout=%" PRIu64 " queue=%s", - msg.task_id(), msg.client_id(), + "rpc_task_sleep: task:%08x@%08x flags=%s runstate=%s status=%d timeout=%" PRIu64 " queue=%s", msg.task_id(), + msg.client_id(), __print_flags(msg.flags(), "|", {0x0001, "ASYNC"}, {0x0002, "SWAPPER"}, {0x0004, "MOVEABLE"}, {0x0010, "NULLCREDS"}, {0x0020, "MAJORSEEN"}, {0x0080, "DYNAMIC"}, {0x0100, "NO_ROUND_ROBIN"}, {0x0200, "SOFT"}, {0x0400, "SOFTCONN"}, {0x0800, "SENT"}, {0x1000, "TIMEOUT"}, @@ -361,21 +389,23 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.status(), msg.timeout(), msg.q_name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_task_sleep) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(rpc_task_sleep) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rpc_task_sleep) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - rpc_task_wakeup, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_rpc_task_wakeup_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + rpc_task_wakeup, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_rpc_task_wakeup_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.rpc_task_wakeup_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "rpc_task_wakeup: task:%08x@%08x flags=%s runstate=%s status=%d " - "timeout=%" PRIu64 " queue=%s", + "rpc_task_wakeup: task:%08x@%08x flags=%s runstate=%s status=%d timeout=%" PRIu64 " queue=%s", msg.task_id(), msg.client_id(), __print_flags(msg.flags(), "|", {0x0001, "ASYNC"}, {0x0002, "SWAPPER"}, {0x0004, "MOVEABLE"}, {0x0010, "NULLCREDS"}, {0x0020, "MAJORSEEN"}, {0x0080, "DYNAMIC"}, {0x0100, "NO_ROUND_ROBIN"}, @@ -387,33 +417,39 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.status(), msg.timeout(), msg.q_name().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(rpc_task_wakeup) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(rpc_task_wakeup) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(rpc_task_wakeup) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - svc_process, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_svc_process_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + svc_process, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_svc_process_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.svc_process_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "svc_process: addr=%s xid=0x%08x service=%s vers=%u proc=%s", msg.addr().c_str(), msg.xid(), msg.service().c_str(), msg.vers(), msg.procedure().c_str()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(svc_process) msg " - "had be cut off in outfile"); + "maybe, the contents of print event(svc_process) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(svc_process) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - svc_send, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_svc_send_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + svc_send, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_svc_send_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.svc_send_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "svc_send: xid=0x%08x server=%pISpc client=%pISpc status=%d flags=%s", msg.xid(), __get_sockaddr(server), __get_sockaddr(client), msg.status(), @@ -422,37 +458,41 @@ REGISTER_FTRACE_EVENT_FORMATTER( {((((1UL))) << (4)), "SPLICE_OK"}, {((((1UL))) << (5)), "VICTIM"}, {((((1UL))) << (6)), "BUSY"}, {((((1UL))) << (7)), "DATA"})); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(svc_send) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(svc_send) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(svc_send) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - svc_wake_up, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_svc_wake_up_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + svc_wake_up, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_svc_wake_up_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.svc_wake_up_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "svc_wake_up: pid=%d", msg.pid()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(svc_wake_up) msg " - "had be cut off in outfile"); + "maybe, the contents of print event(svc_wake_up) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(svc_wake_up) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - svc_xprt_dequeue, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_svc_xprt_dequeue_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + svc_xprt_dequeue, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_svc_xprt_dequeue_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.svc_xprt_dequeue_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "svc_xprt_dequeue: server=%pISpc client=%pISpc flags=%s " - "wakeup-us=%" PRIu64 "", - __get_sockaddr(server), __get_sockaddr(client), + "svc_xprt_dequeue: server=%pISpc client=%pISpc flags=%s wakeup-us=%" PRIu64 "", __get_sockaddr(server), + __get_sockaddr(client), __print_flags(msg.flags(), "|", {((((1UL))) << (0)), "BUSY"}, {((((1UL))) << (1)), "CONN"}, {((((1UL))) << (2)), "CLOSE"}, {((((1UL))) << (3)), "DATA"}, {((((1UL))) << (4)), "TEMP"}, {((((1UL))) << (5)), "DEAD"}, {((((1UL))) << (6)), "CHNGBUF"}, @@ -464,39 +504,48 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.wakeup()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(svc_xprt_dequeue) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(svc_xprt_dequeue) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(svc_xprt_dequeue) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - xprt_lookup_rqst, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_xprt_lookup_rqst_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + xprt_lookup_rqst, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_xprt_lookup_rqst_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.xprt_lookup_rqst_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "xprt_lookup_rqst: peer=[%s]:%s xid=0x%08x status=%d", msg.addr().c_str(), msg.port().c_str(), msg.xid(), msg.status()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(xprt_lookup_rqst) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(xprt_lookup_rqst) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(xprt_lookup_rqst) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - xprt_transmit, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_xprt_transmit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + xprt_transmit, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_xprt_transmit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.xprt_transmit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "xprt_transmit: xid=0x%08x status=%d", msg.xid(), msg.status()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(xprt_transmit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(xprt_transmit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(xprt_transmit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_task_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_task_event_formatter.cpp index 10135ca5981e32b7c613a14e70d7b4d5327cdb25..d1e09a6f7a48a5a7c301d52a78e2208ab45770be 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_task_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_task_event_formatter.cpp @@ -23,33 +23,39 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - task_newtask, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_task_newtask_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + task_newtask, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_task_newtask_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.task_newtask_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "task_newtask: pid=%d comm=%s clone_flags=%" PRIx64 " oom_score_adj=%d", msg.pid(), msg.comm().c_str(), msg.clone_flags(), msg.oom_score_adj()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(task_newtask) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(task_newtask) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(task_newtask) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - task_rename, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_task_rename_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + task_rename, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_task_rename_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.task_rename_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "task_rename: pid=%d oldcomm=%s newcomm=%s oom_score_adj=%d", msg.pid(), msg.oldcomm().c_str(), msg.newcomm().c_str(), msg.oom_score_adj()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(task_rename) msg " - "had be cut off in outfile"); + "maybe, the contents of print event(task_rename) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(task_rename) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_timer_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_timer_event_formatter.cpp index cb389fa6f65cdf678a6f4a5a93cff08c2f3b18aa..4ac52b62edcf43b4184bbee2b3c33874ff94bb41 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_timer_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_timer_event_formatter.cpp @@ -24,28 +24,31 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - hrtimer_cancel, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_hrtimer_cancel_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + hrtimer_cancel, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_hrtimer_cancel_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.hrtimer_cancel_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "hrtimer_cancel: hrtimer=%p", msg.hrtimer()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(hrtimer_cancel) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(hrtimer_cancel) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(hrtimer_cancel) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( hrtimer_expire_entry, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_hrtimer_expire_entry_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_hrtimer_expire_entry_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.hrtimer_expire_entry_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.function()) > 0) { functionStr = kernelSymbols[msg.function()]; } @@ -60,32 +63,38 @@ REGISTER_FTRACE_EVENT_FORMATTER( } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(hrtimer_expire_entry) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(hrtimer_expire_entry) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(hrtimer_expire_entry) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( hrtimer_expire_exit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_hrtimer_expire_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_hrtimer_expire_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.hrtimer_expire_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "hrtimer_expire_exit: hrtimer=%p", msg.hrtimer()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(hrtimer_expire_exit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(hrtimer_expire_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(hrtimer_expire_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - hrtimer_init, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_hrtimer_init_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + hrtimer_init, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_hrtimer_init_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.hrtimer_init_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "hrtimer_init: hrtimer=%p clockid=%s mode=%s", msg.hrtimer(), __print_symbolic(msg.clockid(), {0, "CLOCK_REALTIME"}, {1, "CLOCK_MONOTONIC"}, {7, "CLOCK_BOOTTIME"}, @@ -99,20 +108,23 @@ REGISTER_FTRACE_EVENT_FORMATTER( {HRTIMER_MODE_REL_PINNED_HARD, "REL|PINNED|HARD"})); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(hrtimer_init) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(hrtimer_init) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(hrtimer_init) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - hrtimer_start, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_hrtimer_start_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + hrtimer_start, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_hrtimer_start_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.hrtimer_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.function()) > 0) { functionStr = kernelSymbols[msg.function()]; } @@ -143,66 +155,78 @@ REGISTER_FTRACE_EVENT_FORMATTER( } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(hrtimer_start) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(hrtimer_start) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(hrtimer_start) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - itimer_expire, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_itimer_expire_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + itimer_expire, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_itimer_expire_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.itimer_expire_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "itimer_expire: which=%d pid=%d now=%" PRIu64 "", msg.which(), (int)msg.pid(), msg.now()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(itimer_expire) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(itimer_expire) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(itimer_expire) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - itimer_state, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_itimer_state_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + itimer_state, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_itimer_state_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.itimer_state_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "itimer_state: which=%d expires=%" PRIu64 " it_value=%" PRIu64 "it_interval=%" PRIu64 "", msg.which(), msg.expires(), msg.value_sec(), msg.interval_sec()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(itimer_state) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(itimer_state) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(itimer_state) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - timer_cancel, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_timer_cancel_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + timer_cancel, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_timer_cancel_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.timer_cancel_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "timer_cancel: timer=%p", msg.timer()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(timer_cancel) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(timer_cancel) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(timer_cancel) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( timer_expire_entry, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_timer_expire_entry_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_timer_expire_entry_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.timer_expire_entry_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.function()) > 0) { functionStr = kernelSymbols[msg.function()]; } @@ -217,56 +241,64 @@ REGISTER_FTRACE_EVENT_FORMATTER( } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(timer_expire_entry) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(timer_expire_entry) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(timer_expire_entry) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( timer_expire_exit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_timer_expire_exit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_timer_expire_exit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.timer_expire_exit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "timer_expire_exit: timer=%p", msg.timer()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(timer_expire_exit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(timer_expire_exit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(timer_expire_exit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - timer_init, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_timer_init_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + timer_init, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_timer_init_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.timer_init_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "timer_init: timer=%p", msg.timer()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(timer_init) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(timer_init) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(timer_init) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - timer_start, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_timer_start_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + timer_start, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_timer_start_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.timer_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.function()) > 0) { functionStr = kernelSymbols[msg.function()]; } if (functionStr != "") { len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "timer_start: timer=%p function=%s expires=%" PRIu64 " [timeout=%" PRIu64 - "] cpu=%u idx=%u flags=%s", + "] cpu=%u idx=%u flags=%s", msg.timer(), functionStr.c_str(), msg.expires(), msg.expires() - msg.now(), msg.flags() & 0x0003FFFF, msg.flags() >> 22, __print_flags(msg.flags() & (0x00040000 | 0x00080000 | 0x00100000 | 0x00200000), "|", @@ -274,7 +306,7 @@ REGISTER_FTRACE_EVENT_FORMATTER( } else { len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "timer_start: timer=%p function=%p expires=%" PRIu64 " [timeout=%" PRIu64 - "] cpu=%u idx=%u flags=%s", + "] cpu=%u idx=%u flags=%s", msg.timer(), msg.function(), msg.expires(), msg.expires() - msg.now(), msg.flags() & 0x0003FFFF, msg.flags() >> 22, __print_flags(msg.flags() & (0x00040000 | 0x00080000 | 0x00100000 | 0x00200000), "|", @@ -282,8 +314,11 @@ REGISTER_FTRACE_EVENT_FORMATTER( } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(timer_start) msg " - "had be cut off in outfile"); + "maybe, the contents of print event(timer_start) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(timer_start) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_v4l2_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_v4l2_event_formatter.cpp index 82d250a3308767d702a7354435c55f478813b8d9..f7c118376bbe4940ef93402fa630740d62432e6d 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_v4l2_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_v4l2_event_formatter.cpp @@ -23,17 +23,16 @@ namespace { const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( - v4l2_dqbuf, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_v4l2_dqbuf_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + v4l2_dqbuf, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_v4l2_dqbuf_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.v4l2_dqbuf_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "v4l2_dqbuf: minor = %d, index = %u, type = %s, bytesused = %u, " - "flags = %s, field = %s, timestamp = %" PRIu64 - ", timecode = { type = %s, flags = %s, frames = %u, seconds = %u, " - "minutes = %u, hours = %u, userbits = { %u %u %u %u } }, sequence = " - "%u", + "v4l2_dqbuf: minor = %d, index = %u, type = %s, bytesused = %u, flags = %s, field = %s, timestamp = " + "%" PRIu64 + ", timecode = { type = %s, flags = %s, frames = %u, seconds = %u, minutes = %u, hours = %u, userbits = { " + "%u %u %u %u } }, sequence = %u", msg.minor(), msg.index(), __print_symbolic(msg.type(), {1, "VIDEO_CAPTURE"}, {2, "VIDEO_OUTPUT"}, {3, "VIDEO_OVERLAY"}, {4, "VBI_CAPTURE"}, {5, "VBI_OUTPUT"}, {6, "SLICED_VBI_CAPTURE"}, {7, "SLICED_VBI_OUTPUT"}, @@ -57,25 +56,25 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.timecode_userbits0(), msg.timecode_userbits1(), msg.timecode_userbits2(), msg.timecode_userbits3(), msg.sequence()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(v4l2_dqbuf) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(v4l2_dqbuf) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(v4l2_dqbuf) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - v4l2_qbuf, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_v4l2_qbuf_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + v4l2_qbuf, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_v4l2_qbuf_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.v4l2_qbuf_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "v4l2_qbuf: minor = %d, index = %u, type = %s, bytesused = %u, flags " - "= %s, field = %s, timestamp = %" PRIu64 - ", timecode = { type = %s, flags = %s, frames = %u, seconds = %u, " - "minutes = %u, hours = %u, userbits = { %u %u %u %u } }, sequence = " - "%u", + "v4l2_qbuf: minor = %d, index = %u, type = %s, bytesused = %u, flags = %s, field = %s, timestamp = %" PRIu64 + ", timecode = { type = %s, flags = %s, frames = %u, seconds = %u, minutes = %u, hours = %u, userbits = { " + "%u %u %u %u } }, sequence = %u", msg.minor(), msg.index(), __print_symbolic(msg.type(), {1, "VIDEO_CAPTURE"}, {2, "VIDEO_OUTPUT"}, {3, "VIDEO_OVERLAY"}, {4, "VBI_CAPTURE"}, {5, "VBI_OUTPUT"}, {6, "SLICED_VBI_CAPTURE"}, {7, "SLICED_VBI_OUTPUT"}, @@ -99,26 +98,26 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.timecode_userbits0(), msg.timecode_userbits1(), msg.timecode_userbits2(), msg.timecode_userbits3(), msg.sequence()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(v4l2_qbuf) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN(LOG_CORE, "maybe, the contents of print event(v4l2_qbuf) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(v4l2_qbuf) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( vb2_v4l2_buf_done, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_vb2_v4l2_buf_done_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_vb2_v4l2_buf_done_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.vb2_v4l2_buf_done_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "vb2_v4l2_buf_done: minor=%d flags = %s, field = %s, timestamp = " - "%" PRIu64 - ", timecode = { type = %s, flags = %s, frames = %u, " - "seconds = %u, minutes = %u, hours = %u, userbits = { %u " - "%u %u %u } }, sequence = %u", + "vb2_v4l2_buf_done: minor=%d flags = %s, field = %s, timestamp = %" PRIu64 + ", timecode = { type = %s, flags = %s, frames = %u, seconds = %u, minutes = %u, hours = %u, userbits = { " + "%u %u %u %u } }, sequence = %u", msg.minor(), __print_flags(msg.flags(), "|", {0x00000001, "MAPPED"}, {0x00000002, "QUEUED"}, {0x00000004, "DONE"}, {0x00000008, "KEYFRAME"}, {0x00000010, "PFRAME"}, {0x00000020, "BFRAME"}, @@ -138,25 +137,26 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.sequence()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(vb2_v4l2_buf_done) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(vb2_v4l2_buf_done) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(vb2_v4l2_buf_done) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( vb2_v4l2_buf_queue, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_vb2_v4l2_buf_queue_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_vb2_v4l2_buf_queue_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.vb2_v4l2_buf_queue_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "vb2_v4l2_buf_queue: minor=%d flags = %s, field = %s, timestamp = " - "%" PRIu64 - ", timecode = { type = %s, flags = %s, frames = %u, " - "seconds = %u, minutes = %u, hours = %u, userbits = { %u " - "%u %u %u } }, sequence = %u", + "vb2_v4l2_buf_queue: minor=%d flags = %s, field = %s, timestamp = %" PRIu64 + ", timecode = { type = %s, flags = %s, frames = %u, seconds = %u, minutes = %u, hours = %u, userbits = { " + "%u %u %u %u } }, sequence = %u", msg.minor(), __print_flags(msg.flags(), "|", {0x00000001, "MAPPED"}, {0x00000002, "QUEUED"}, {0x00000004, "DONE"}, {0x00000008, "KEYFRAME"}, {0x00000010, "PFRAME"}, {0x00000020, "BFRAME"}, @@ -176,24 +176,25 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.sequence()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(vb2_v4l2_buf_queue) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(vb2_v4l2_buf_queue) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(vb2_v4l2_buf_queue) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - vb2_v4l2_dqbuf, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_vb2_v4l2_dqbuf_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + vb2_v4l2_dqbuf, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_vb2_v4l2_dqbuf_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.vb2_v4l2_dqbuf_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "vb2_v4l2_dqbuf: minor=%d flags = %s, field = %s, timestamp = " - "%" PRIu64 - ", timecode = { type = %s, flags = %s, frames = %u, " - "seconds = %u, minutes = %u, hours = %u, userbits = { %u " - "%u %u %u } }, sequence = %u", + "vb2_v4l2_dqbuf: minor=%d flags = %s, field = %s, timestamp = %" PRIu64 + ", timecode = { type = %s, flags = %s, frames = %u, seconds = %u, minutes = %u, hours = %u, userbits = { " + "%u %u %u %u } }, sequence = %u", msg.minor(), __print_flags(msg.flags(), "|", {0x00000001, "MAPPED"}, {0x00000002, "QUEUED"}, {0x00000004, "DONE"}, {0x00000008, "KEYFRAME"}, {0x00000010, "PFRAME"}, {0x00000020, "BFRAME"}, @@ -213,23 +214,25 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.sequence()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(vb2_v4l2_dqbuf) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(vb2_v4l2_dqbuf) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(vb2_v4l2_dqbuf) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - vb2_v4l2_qbuf, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_vb2_v4l2_qbuf_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + vb2_v4l2_qbuf, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_vb2_v4l2_qbuf_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.vb2_v4l2_qbuf_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "vb2_v4l2_qbuf: minor=%d flags = %s, field = %s, timestamp = %" PRIu64 - ", timecode = { type = %s, flags = %s, frames = %u, seconds = %u, " - "minutes = %u, hours = %u, userbits = { %u %u %u %u } }, sequence = " - "%u", + ", timecode = { type = %s, flags = %s, frames = %u, seconds = %u, minutes = %u, hours = %u, userbits = { " + "%u %u %u %u } }, sequence = %u", msg.minor(), __print_flags(msg.flags(), "|", {0x00000001, "MAPPED"}, {0x00000002, "QUEUED"}, {0x00000004, "DONE"}, {0x00000008, "KEYFRAME"}, {0x00000010, "PFRAME"}, {0x00000020, "BFRAME"}, @@ -249,8 +252,11 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.sequence()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(vb2_v4l2_qbuf) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(vb2_v4l2_qbuf) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(vb2_v4l2_qbuf) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_vmscan_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_vmscan_event_formatter.cpp index f36c5687245d994e20757b813633a5884f434e0c..8f16f6b4d7f825c262c0efbfa8af54bf698bd011 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_vmscan_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_vmscan_event_formatter.cpp @@ -25,10 +25,10 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( mm_shrink_slab_end, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_shrink_slab_end_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_shrink_slab_end_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_shrink_slab_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_shrink_slab_end: %p %p: nid: %d unused scan count %" PRIu64 " new scan count %" PRIu64 " total_scan %" PRIu64 " last shrinker return val %d", @@ -36,18 +36,21 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.retval()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_shrink_slab_end) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(mm_shrink_slab_end) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_shrink_slab_end) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_shrink_slab_start, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_shrink_slab_start_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_shrink_slab_start_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_shrink_slab_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_shrink_slab_start: %p %p: nid: %d objects to shrink %" PRIu64 " gfp_flags %s cache items %" PRIu64 @@ -114,18 +117,21 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.cache_items(), msg.delta(), msg.total_scan(), msg.priority()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_shrink_slab_start) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(mm_shrink_slab_start) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_shrink_slab_start) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_vmscan_direct_reclaim_begin, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_vmscan_direct_reclaim_begin_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_vmscan_direct_reclaim_begin_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_vmscan_direct_reclaim_begin_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_vmscan_direct_reclaim_begin: order=%d gfp_flags=%s", msg.order(), (msg.gfp_flags()) @@ -187,89 +193,106 @@ REGISTER_FTRACE_EVENT_FORMATTER( {(unsigned long)((gfp_t)0x800000u), "__GFP_ZEROTAGS"}) : "none"); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(mm_vmscan_direct_reclaim_begin) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print " - "event(mm_vmscan_direct_reclaim_begin) msg " - "had be cut off in outfile"); + "the contents of event(mm_vmscan_direct_reclaim_begin) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_vmscan_direct_reclaim_end, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_vmscan_direct_reclaim_end_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_vmscan_direct_reclaim_end_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_vmscan_direct_reclaim_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_vmscan_direct_reclaim_end: nr_reclaimed=%" PRIu64 "", msg.nr_reclaimed()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(mm_vmscan_direct_reclaim_end) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_vmscan_direct_reclaim_end) " - "msg had be cut off in outfile"); + "the contents of event(mm_vmscan_direct_reclaim_end) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_vmscan_kswapd_sleep, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_vmscan_kswapd_sleep_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_vmscan_kswapd_sleep_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_vmscan_kswapd_sleep_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_vmscan_kswapd_sleep: nid=%d", msg.nid()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_vmscan_kswapd_sleep) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(mm_vmscan_kswapd_sleep) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_vmscan_kswapd_sleep) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_vmscan_kswapd_wake, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_vmscan_kswapd_wake_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_vmscan_kswapd_wake_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_vmscan_kswapd_wake_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_vmscan_kswapd_wake: nid=%d order=%d", msg.nid(), msg.order()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_vmscan_kswapd_wake) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(mm_vmscan_kswapd_wake) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_vmscan_kswapd_wake) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_vmscan_lru_isolate, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_vmscan_lru_isolate_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_vmscan_lru_isolate_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_vmscan_lru_isolate_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "mm_vmscan_lru_isolate: isolate_mode=%d classzone=%d " - "order=%d nr_requested=%" PRIu64 " nr_scanned=%" PRIu64 " nr_skipped=%" PRIu64 - " nr_taken=%" PRIu64 " lru=%s", + "mm_vmscan_lru_isolate: isolate_mode=%d classzone=%d order=%d nr_requested=%" PRIu64 + " nr_scanned=%" PRIu64 " nr_skipped=%" PRIu64 " nr_taken=%" PRIu64 " lru=%s", msg.isolate_mode(), msg.classzone_idx(), msg.order(), msg.nr_requested(), msg.nr_scanned(), msg.nr_skipped(), msg.nr_taken(), __print_symbolic(msg.lru(), {0, "inactive_anon"}, {1, "active_anon"}, {2, "inactive_file"}, {3, "active_file"}, {6, "unevictable"})); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_vmscan_lru_isolate) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(mm_vmscan_lru_isolate) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_vmscan_lru_isolate) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_vmscan_lru_shrink_inactive, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_vmscan_lru_shrink_inactive_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_vmscan_lru_shrink_inactive_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_vmscan_lru_shrink_inactive_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_vmscan_lru_shrink_inactive: nid=%d nr_scanned=%" PRIu64 " nr_reclaimed=%" PRIu64 " nr_dirty=%" PRIu64 @@ -282,19 +305,24 @@ REGISTER_FTRACE_EVENT_FORMATTER( {0x0004u, "RECLAIM_WB_SYNC"}, {0x0008u, "RECLAIM_WB_ASYNC"}) : "RECLAIM_WB_NONE"); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(mm_vmscan_lru_shrink_inactive) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_vmscan_lru_shrink_inactive) " - "msg had be cut off in outfile"); + "the contents of event(mm_vmscan_lru_shrink_inactive) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( mm_vmscan_wakeup_kswapd, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_mm_vmscan_wakeup_kswapd_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_mm_vmscan_wakeup_kswapd_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.mm_vmscan_wakeup_kswapd_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "mm_vmscan_wakeup_kswapd: nid=%d order=%d gfp_flags=%s", msg.nid(), msg.order(), @@ -357,9 +385,12 @@ REGISTER_FTRACE_EVENT_FORMATTER( {(unsigned long)((gfp_t)0x800000u), "__GFP_ZEROTAGS"}) : "none"); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(mm_vmscan_wakeup_kswapd) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(mm_vmscan_wakeup_kswapd) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(mm_vmscan_wakeup_kswapd) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_workqueue_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_workqueue_event_formatter.cpp index b2ce49923153e28e72b1598a8dc9fe95692ee5c4..5dd0500c16f746f63f5ce7b59f2c405b43420873 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_workqueue_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_workqueue_event_formatter.cpp @@ -24,44 +24,50 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( workqueue_activate_work, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_workqueue_activate_work_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_workqueue_activate_work_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.workqueue_activate_work_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "workqueue_activate_work: work struct %p", msg.work()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(workqueue_activate_work) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(workqueue_activate_work) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(workqueue_activate_work) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( workqueue_execute_end, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_workqueue_execute_end_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_workqueue_execute_end_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.workqueue_execute_end_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "workqueue_execute_end: work struct %p", msg.work()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(workqueue_execute_end) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(workqueue_execute_end) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(workqueue_execute_end) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( workqueue_execute_start, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_workqueue_execute_start_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_workqueue_execute_start_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.workqueue_execute_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.function()) > 0) { functionStr = kernelSymbols[msg.function()]; } @@ -73,40 +79,44 @@ REGISTER_FTRACE_EVENT_FORMATTER( "workqueue_execute_start: work struct %p: function %p", msg.work(), msg.function()); } if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(workqueue_execute_start) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(workqueue_execute_start) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(workqueue_execute_start) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( workqueue_queue_work, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_workqueue_queue_work_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_workqueue_queue_work_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.workqueue_queue_work_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = 0; std::string functionStr = ""; - auto &kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; + auto& kernelSymbols = EventFormatter::GetInstance().kernelSymbols_; if (kernelSymbols.count(msg.function()) > 0) { functionStr = kernelSymbols[msg.function()]; } if (functionStr != "") { len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "workqueue_queue_work: work struct=%p function=%s " - "workqueue=%s req_cpu=%d cpu=%d", + "workqueue_queue_work: work struct=%p function=%s workqueue=%s req_cpu=%d cpu=%d", msg.work(), functionStr.c_str(), msg.workqueue().c_str(), msg.req_cpu(), msg.cpu()); } else { len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, - "workqueue_queue_work: work struct=%p function=%p " - "workqueue=%s req_cpu=%d cpu=%d", + "workqueue_queue_work: work struct=%p function=%p workqueue=%s req_cpu=%d cpu=%d", msg.work(), msg.function(), msg.workqueue().c_str(), msg.req_cpu(), msg.cpu()); } if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(workqueue_queue_work) msg had " - "be cut off in outfile"); + "maybe, the contents of print event(workqueue_queue_work) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(workqueue_queue_work) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_writeback_event_formatter.cpp b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_writeback_event_formatter.cpp index dc9df494c3c35f44a110c4b8d4e4477435474add..2fa07f4f77bda88af2f7445e7fa68dcc19f09af2 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_writeback_event_formatter.cpp +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/event_formatters/ftrace_writeback_event_formatter.cpp @@ -25,109 +25,124 @@ const int BUFFER_SIZE = 512; REGISTER_FTRACE_EVENT_FORMATTER( balance_dirty_pages, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_balance_dirty_pages_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_balance_dirty_pages_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.balance_dirty_pages_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "balance_dirty_pages: bdi %s: limit=%" PRIu64 " setpoint=%" PRIu64 " dirty=%" PRIu64 - " bdi_setpoint=%" PRIu64 " bdi_dirty=%" PRIu64 " dirty_ratelimit=%" PRIu64 - " task_ratelimit=%" PRIu64 " dirtied=%u dirtied_pause=%u paused=%" PRIu64 " pause=%" PRIu64 - " period=%" PRIu64 " think=%" PRIu64 " cgroup_ino=%" PRId32 "", + " bdi_setpoint=%" PRIu64 " bdi_dirty=%" PRIu64 " dirty_ratelimit=%" PRIu64 + " task_ratelimit=%" PRIu64 " dirtied=%u dirtied_pause=%u paused=%" PRIu64 " pause=%" PRIu64 + " period=%" PRIu64 " think=%" PRIu64 " cgroup_ino=%" PRId32 "", msg.bdi().c_str(), msg.limit(), msg.setpoint(), msg.dirty(), msg.bdi_setpoint(), msg.bdi_dirty(), msg.dirty_ratelimit(), msg.task_ratelimit(), msg.dirtied(), msg.dirtied_pause(), msg.paused(), msg.pause(), msg.period(), msg.think(), msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(balance_dirty_pages) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(balance_dirty_pages) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(balance_dirty_pages) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( bdi_dirty_ratelimit, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_bdi_dirty_ratelimit_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_bdi_dirty_ratelimit_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.bdi_dirty_ratelimit_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "bdi_dirty_ratelimit: bdi %s: write_bw=%" PRIu64 " awrite_bw=%" PRIu64 " dirty_rate=%" PRIu64 - " dirty_ratelimit=%" PRIu64 " task_ratelimit=%" PRIu64 " balanced_dirty_ratelimit=%" PRIu64 - " cgroup_ino=%" PRId32 "", + " dirty_ratelimit=%" PRIu64 " task_ratelimit=%" PRIu64 " balanced_dirty_ratelimit=%" PRIu64 + " cgroup_ino=%" PRId32 "", msg.bdi().c_str(), msg.write_bw(), msg.avg_write_bw(), msg.dirty_rate(), msg.dirty_ratelimit(), msg.task_ratelimit(), msg.balanced_dirty_ratelimit(), msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(bdi_dirty_ratelimit) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(bdi_dirty_ratelimit) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(bdi_dirty_ratelimit) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( global_dirty_state, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_global_dirty_state_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_global_dirty_state_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.global_dirty_state_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "global_dirty_state: dirty=%" PRIu64 " writeback=%" PRIu64 " bg_thresh=%" PRIu64 - " thresh=%" PRIu64 " limit=%" PRIu64 " dirtied=%" PRIu64 " written=%" PRIu64 "", + " thresh=%" PRIu64 " limit=%" PRIu64 " dirtied=%" PRIu64 " written=%" PRIu64 "", msg.nr_dirty(), msg.nr_writeback(), msg.background_thresh(), msg.dirty_thresh(), msg.dirty_limit(), msg.nr_dirtied(), msg.nr_written()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(global_dirty_state) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(global_dirty_state) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(global_dirty_state) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - wbc_writepage, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_wbc_writepage_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + wbc_writepage, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_wbc_writepage_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.wbc_writepage_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "wbc_writepage: bdi %s: towrt=%" PRIu64 " skip=%" PRIu64 - " mode=%d kupd=%d bgrd=%d reclm=%d cyclic=%d start=0x%" PRIx64 " end=0x%" PRIx64 - " cgroup_ino=%" PRId32 "", + " mode=%d kupd=%d bgrd=%d reclm=%d cyclic=%d start=0x%" PRIx64 " end=0x%" PRIx64 + " cgroup_ino=%" PRId32 "", msg.name().c_str(), msg.nr_to_write(), msg.pages_skipped(), msg.sync_mode(), msg.for_kupdate(), msg.for_background(), msg.for_reclaim(), msg.range_cyclic(), msg.range_start(), msg.range_end(), msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(wbc_writepage) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(wbc_writepage) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(wbc_writepage) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_bdi_register, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_bdi_register_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_bdi_register_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_bdi_register_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_bdi_register: bdi %s", msg.name().c_str()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_bdi_register) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(writeback_bdi_register) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_bdi_register) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_dirty_inode, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_dirty_inode_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_dirty_inode_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_dirty_inode_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_dirty_inode: bdi %s: ino=%" PRIu64 " state=%s flags=%s", msg.name().c_str(), msg.ino(), @@ -140,19 +155,22 @@ REGISTER_FTRACE_EVENT_FORMATTER( {(1 << 5), "I_FREEING"}, {(1 << 6), "I_CLEAR"}, {(1 << 7), "I_SYNC"}, {(1 << 11), "I_DIRTY_TIME"}, {(1 << 8), "I_REFERENCED"})); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_dirty_inode) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(writeback_dirty_inode) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_dirty_inode) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_dirty_inode_enqueue, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_dirty_inode_enqueue_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_dirty_inode_enqueue_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_dirty_inode_enqueue_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_dirty_inode_enqueue: dev %d,%d ino %" PRIu64 " dirtied %" PRIu64 " state %s mode 0%o", @@ -164,19 +182,24 @@ REGISTER_FTRACE_EVENT_FORMATTER( {(1 << 11), "I_DIRTY_TIME"}, {(1 << 8), "I_REFERENCED"}), msg.mode()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(writeback_dirty_inode_enqueue) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_dirty_inode_enqueue) " - "msg had be cut off in outfile"); + "the contents of event(writeback_dirty_inode_enqueue) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_dirty_inode_start, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_dirty_inode_start_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_dirty_inode_start_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_dirty_inode_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_dirty_inode_start: bdi %s: ino=%" PRIu64 " state=%s flags=%s", msg.name().c_str(), msg.ino(), @@ -189,23 +212,27 @@ REGISTER_FTRACE_EVENT_FORMATTER( {(1 << 5), "I_FREEING"}, {(1 << 6), "I_CLEAR"}, {(1 << 7), "I_SYNC"}, {(1 << 11), "I_DIRTY_TIME"}, {(1 << 8), "I_REFERENCED"})); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(writeback_dirty_inode_start) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_dirty_inode_start) " - "msg had be cut off in outfile"); + "the contents of event(writeback_dirty_inode_start) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - writeback_exec, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_exec_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + writeback_exec, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_exec_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_exec_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_exec: bdi %s: sb_dev %d:%d nr_pages=%" PRIu64 - " sync_mode=%d kupdate=%d range_cyclic=%d background=%d reason=%s " - "cgroup_ino=%" PRId32 "", + " sync_mode=%d kupdate=%d range_cyclic=%d background=%d reason=%s cgroup_ino=%" PRId32 "", msg.name().c_str(), ((unsigned int)((msg.sb_dev()) >> 20)), ((unsigned int)((msg.sb_dev()) & ((1U << 20) - 1))), msg.nr_pages(), msg.sync_mode(), msg.for_kupdate(), msg.range_cyclic(), msg.for_background(), @@ -214,18 +241,21 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_exec) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(writeback_exec) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_exec) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_lazytime, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_lazytime_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_lazytime_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_lazytime_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_lazytime: dev %d,%d ino %" PRIu64 " dirtied %" PRIu64 " state %s mode 0%o", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), @@ -237,18 +267,21 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.mode()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_lazytime) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(writeback_lazytime) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_lazytime) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_lazytime_iput, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_lazytime_iput_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_lazytime_iput_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_lazytime_iput_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_lazytime_iput: dev %d,%d ino %" PRIu64 " dirtied %" PRIu64 " state %s mode 0%o", ((unsigned int)((msg.dev()) >> 20)), ((unsigned int)((msg.dev()) & ((1U << 20) - 1))), @@ -259,19 +292,22 @@ REGISTER_FTRACE_EVENT_FORMATTER( {(1 << 11), "I_DIRTY_TIME"}, {(1 << 8), "I_REFERENCED"}), msg.mode()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_lazytime_iput) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(writeback_lazytime_iput) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_lazytime_iput) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_mark_inode_dirty, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_mark_inode_dirty_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_mark_inode_dirty_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_mark_inode_dirty_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_mark_inode_dirty: bdi %s: ino=%" PRIu64 " state=%s flags=%s", msg.name().c_str(), msg.ino(), @@ -284,38 +320,45 @@ REGISTER_FTRACE_EVENT_FORMATTER( {(1 << 5), "I_FREEING"}, {(1 << 6), "I_CLEAR"}, {(1 << 7), "I_SYNC"}, {(1 << 11), "I_DIRTY_TIME"}, {(1 << 8), "I_REFERENCED"})); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(writeback_mark_inode_dirty) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_mark_inode_dirty) " - "msg had be cut off in outfile"); + "the contents of event(writeback_mark_inode_dirty) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_pages_written, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_pages_written_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_pages_written_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_pages_written_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_pages_written: %" PRIu64 "", msg.pages()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_pages_written) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(writeback_pages_written) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_pages_written) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - writeback_queue, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_queue_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + writeback_queue, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_queue_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_queue_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_queue: bdi %s: sb_dev %d:%d nr_pages=%" PRIu64 - " sync_mode=%d kupdate=%d range_cyclic=%d background=%d reason=%s " - "cgroup_ino=%" PRId32 "", + " sync_mode=%d kupdate=%d range_cyclic=%d background=%d reason=%s cgroup_ino=%" PRId32 "", msg.name().c_str(), ((unsigned int)((msg.sb_dev()) >> 20)), ((unsigned int)((msg.sb_dev()) & ((1U << 20) - 1))), msg.nr_pages(), msg.sync_mode(), msg.for_kupdate(), msg.range_cyclic(), msg.for_background(), @@ -324,18 +367,21 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_queue) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(writeback_queue) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_queue) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_queue_io, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_queue_io_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_queue_io_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_queue_io_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_queue_io: bdi %s: older=%" PRIu64 " age=%" PRIu64 " enqueue=%d reason=%s cgroup_ino=%" PRId32 "", @@ -345,21 +391,24 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_queue_io) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(writeback_queue_io) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_queue_io) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_sb_inodes_requeue, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_sb_inodes_requeue_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_sb_inodes_requeue_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_sb_inodes_requeue_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_sb_inodes_requeue: bdi %s: ino=%" PRIu64 " state=%s dirtied_when=%" PRIu64 - " age=%" PRIu64 " cgroup_ino=%" PRId32 "", + " age=%" PRIu64 " cgroup_ino=%" PRId32 "", msg.name().c_str(), msg.ino(), __print_flags(msg.state(), "|", {(1 << 0), "I_DIRTY_SYNC"}, {(1 << 1), "I_DIRTY_DATASYNC"}, {(1 << 2), "I_DIRTY_PAGES"}, {(1 << 3), "I_NEW"}, {(1 << 4), "I_WILL_FREE"}, @@ -367,23 +416,28 @@ REGISTER_FTRACE_EVENT_FORMATTER( {(1 << 11), "I_DIRTY_TIME"}, {(1 << 8), "I_REFERENCED"}), msg.dirtied_when(), (jiffies - msg.dirtied_when()) / 300, msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(writeback_sb_inodes_requeue) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_sb_inodes_requeue) " - "msg had be cut off in outfile"); + "the contents of event(writeback_sb_inodes_requeue) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_single_inode, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_single_inode_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_single_inode_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_single_inode_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_single_inode: bdi %s: ino=%" PRIu64 " state=%s dirtied_when=%" PRIu64 " age=%" PRIu64 - " index=%" PRIu64 " to_write=%" PRIu64 " wrote=%" PRIu64 " cgroup_ino=%" PRId32 "", + " index=%" PRIu64 " to_write=%" PRIu64 " wrote=%" PRIu64 " cgroup_ino=%" PRId32 "", msg.name().c_str(), msg.ino(), __print_flags(msg.state(), "|", {(1 << 0), "I_DIRTY_SYNC"}, {(1 << 1), "I_DIRTY_DATASYNC"}, {(1 << 2), "I_DIRTY_PAGES"}, {(1 << 3), "I_NEW"}, {(1 << 4), "I_WILL_FREE"}, @@ -392,23 +446,26 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.dirtied_when(), (jiffies - msg.dirtied_when()) / 300, msg.writeback_index(), msg.nr_to_write(), msg.wrote(), msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_single_inode) msg " - "had be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(writeback_single_inode) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_single_inode) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_single_inode_start, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_single_inode_start_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_single_inode_start_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_single_inode_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_single_inode_start: bdi %s: ino=%" PRIu64 " state=%s dirtied_when=%" PRIu64 - " age=%" PRIu64 " index=%" PRIu64 " to_write=%" PRIu64 " wrote=%" PRIu64 - " cgroup_ino=%" PRId32 "", + " age=%" PRIu64 " index=%" PRIu64 " to_write=%" PRIu64 " wrote=%" PRIu64 + " cgroup_ino=%" PRId32 "", msg.name().c_str(), msg.ino(), __print_flags(msg.state(), "|", {(1 << 0), "I_DIRTY_SYNC"}, {(1 << 1), "I_DIRTY_DATASYNC"}, {(1 << 2), "I_DIRTY_PAGES"}, {(1 << 3), "I_NEW"}, {(1 << 4), "I_WILL_FREE"}, @@ -417,23 +474,27 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.dirtied_when(), (jiffies - msg.dirtied_when()) / 300, msg.writeback_index(), msg.nr_to_write(), msg.wrote(), msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(writeback_single_inode_start) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_single_inode_start) " - "msg had be cut off in outfile"); + "the contents of event(writeback_single_inode_start) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - writeback_start, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_start_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + writeback_start, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_start_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_start: bdi %s: sb_dev %d:%d nr_pages=%" PRIu64 - " sync_mode=%d kupdate=%d range_cyclic=%d background=%d reason=%s " - "cgroup_ino=%" PRId32 "", + " sync_mode=%d kupdate=%d range_cyclic=%d background=%d reason=%s cgroup_ino=%" PRId32 "", msg.name().c_str(), ((unsigned int)((msg.sb_dev()) >> 20)), ((unsigned int)((msg.sb_dev()) & ((1U << 20) - 1))), msg.nr_pages(), msg.sync_mode(), msg.for_kupdate(), msg.range_cyclic(), msg.for_background(), @@ -442,22 +503,24 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_start) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(writeback_start) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_start) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( - writeback_wait, [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_wait_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + writeback_wait, [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_wait_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_wait_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_wait: bdi %s: sb_dev %d:%d nr_pages=%" PRIu64 - " sync_mode=%d kupdate=%d range_cyclic=%d background=%d reason=%s " - "cgroup_ino=%" PRId32 "", + " sync_mode=%d kupdate=%d range_cyclic=%d background=%d reason=%s cgroup_ino=%" PRId32 "", msg.name().c_str(), ((unsigned int)((msg.sb_dev()) >> 20)), ((unsigned int)((msg.sb_dev()) & ((1U << 20) - 1))), msg.nr_pages(), msg.sync_mode(), msg.for_kupdate(), msg.range_cyclic(), msg.for_background(), @@ -466,74 +529,89 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_wait) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(writeback_wait) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_wait) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_wake_background, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_wake_background_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_wake_background_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_wake_background_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_wake_background: bdi %s: cgroup_ino=%" PRId32 "", msg.name().c_str(), msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(writeback_wake_background) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_wake_background) msg " - "had be cut off in outfile"); + "the contents of event(writeback_wake_background) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_write_inode, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_write_inode_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_write_inode_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_write_inode_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_write_inode: bdi %s: ino=%" PRIu64 " sync_mode=%d cgroup_ino=%" PRId32 "", msg.name().c_str(), msg.ino(), msg.sync_mode(), msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { - PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_write_inode) msg had " - "be cut off in outfile"); + PROFILER_LOG_WARN( + LOG_CORE, "maybe, the contents of print event(writeback_write_inode) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_write_inode) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_write_inode_start, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_write_inode_start_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_write_inode_start_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_write_inode_start_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s(buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_write_inode_start: bdi %s: ino=%" PRIu64 " sync_mode=%d cgroup_ino=%" PRId32 "", msg.name().c_str(), msg.ino(), msg.sync_mode(), msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { + PROFILER_LOG_WARN( + LOG_CORE, + "maybe, the contents of print event(writeback_write_inode_start) msg had be cut off in outfile"); + } + if (len < 0) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_write_inode_start) " - "msg had be cut off in outfile"); + "the contents of event(writeback_write_inode_start) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); REGISTER_FTRACE_EVENT_FORMATTER( writeback_written, - [](const ForStandard::FtraceEvent &event) -> bool { return event.has_writeback_written_format(); }, - [](const ForStandard::FtraceEvent &event) -> std::string { + [](const ForStandard::FtraceEvent& event) -> bool { return event.has_writeback_written_format(); }, + [](const ForStandard::FtraceEvent& event) -> std::string { auto msg = event.writeback_written_format(); - char buffer[BUFFER_SIZE]; + char buffer[BUFFER_SIZE] = {0}; int len = snprintf_s( buffer, BUFFER_SIZE, BUFFER_SIZE - 1, "writeback_written: bdi %s: sb_dev %d:%d nr_pages=%" PRIu64 - " sync_mode=%d kupdate=%d range_cyclic=%d background=%d reason=%s " - "cgroup_ino=%" PRId32 "", + " sync_mode=%d kupdate=%d range_cyclic=%d background=%d reason=%s cgroup_ino=%" PRId32 "", msg.name().c_str(), ((unsigned int)((msg.sb_dev()) >> 20)), ((unsigned int)((msg.sb_dev()) & ((1U << 20) - 1))), msg.nr_pages(), msg.sync_mode(), msg.for_kupdate(), msg.range_cyclic(), msg.for_background(), @@ -542,8 +620,11 @@ REGISTER_FTRACE_EVENT_FORMATTER( msg.cgroup_ino()); if (len >= BUFFER_SIZE - 1) { PROFILER_LOG_WARN(LOG_CORE, - "maybe, the contents of print event(writeback_written) " - "msg had be cut off in outfile"); + "maybe, the contents of print event(writeback_written) msg had be cut off in outfile"); + } + if (len < 0) { + PROFILER_LOG_WARN(LOG_CORE, "the contents of event(writeback_written) msg snprintf_s format error "); + return ""; } return std::string(buffer); }); diff --git a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/ftrace_cpp_generator.py b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/ftrace_cpp_generator.py index 95292b7fbf0cb623ffe0de09acd2b37761deabb7..dc0f5654751bdb91a549fd4c61ddb1549dd093d3 100644 --- a/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/ftrace_cpp_generator.py +++ b/device/plugins/ftrace_plugin/tools/device_kernel_version/6.6.30/ftrace_cpp_generator.py @@ -300,7 +300,7 @@ class EventFormatterCodeGenerator(FtraceEventCodeGenerator): f.write("},") # end of check function f.write("[] {} {{\n".format(Common.format_function_args)) f.write(" auto msg = event.{}_format();\n".format(str.lower(event.name))) - f.write(" char buffer[BUFFER_SIZE];\n") + f.write(" char buffer[BUFFER_SIZE] = {0};\n") event.print_fmt = '"{}: {}'.format(event.name, event.print_fmt[2:]) event.print_fmt = str.replace(event.print_fmt, "%zu", '%" PRIu64 "') event.print_fmt = str.replace(event.print_fmt, "%zd", '%" PRIu64 "') @@ -401,7 +401,7 @@ class EventFormatterCodeGenerator(FtraceEventCodeGenerator): "msg.src_cpu(), msg.src_nid(), msg.pid(), msg.tgid(), msg.ngid(), msg.dst_cpu(), msg.dst_nid()" ) elif event.name == "workqueue_execute_end": - event.print_fmt = '"workqueue_execute_end: work struct %p", msg.work()' + event.print_fmt = '"workqueue_execute_end: work struct 0x%" PRIx64 "", msg.work()' elif event.name == "workqueue_queue_work": event.print_fmt = str.replace( event.print_fmt, "REC->workqueue", "msg.workqueue()" @@ -592,7 +592,7 @@ class EventFormatterCodeGenerator(FtraceEventCodeGenerator): event.name == "mm_filemap_delete_from_page_cache" ): event.print_fmt = ( - '"{}: dev %" PRIu64 ":%" PRIu64 " ino %p page=%s pfn=%" PRIu64 " ' + '"{}: dev %" PRIu64 ":%" PRIu64 " ino 0x%" PRIx64 " page=%s pfn=%" PRIu64 " ' 'ofs=%" PRIu64 "", (((msg.s_dev()) >> 20)), (((msg.s_dev()) & ((1U << 20) - 1))), ' 'msg.i_ino(), "0000000000000000", msg.pfn(), msg.index() << 12'.format( event.name @@ -606,22 +606,22 @@ class EventFormatterCodeGenerator(FtraceEventCodeGenerator): event.print_fmt, "__get_bitmask(target_cpus)", "msg.target_cpus()" ) elif event.name == "mm_page_alloc": - print_fmt = (event.print_fmt[:78], event.print_fmt[3783:]) + print_fmt = (event.print_fmt[:80], event.print_fmt[630:]) event.print_fmt = page_str.join(print_fmt) elif event.name == "mm_page_alloc_extfrag": - print_fmt = (event.print_fmt[:181], event.print_fmt[3853:]) + print_fmt = (event.print_fmt[:183], event.print_fmt[700:]) event.print_fmt = page_str.join(print_fmt) elif event.name == "mm_page_alloc_zone_locked": - print_fmt = (event.print_fmt[:94], event.print_fmt[3799:]) + print_fmt = (event.print_fmt[:96], event.print_fmt[646:]) event.print_fmt = page_str.join(print_fmt) elif event.name == "mm_page_free": - print_fmt = (event.print_fmt[:49], event.print_fmt[3721:]) + print_fmt = (event.print_fmt[:51], event.print_fmt[568:]) event.print_fmt = page_str.join(print_fmt) elif event.name == "mm_page_free_batched": - print_fmt = (event.print_fmt[:56], event.print_fmt[3728:]) + print_fmt = (event.print_fmt[:58], event.print_fmt[575:]) event.print_fmt = page_str.join(print_fmt) elif event.name == "mm_page_pcpu_drain": - print_fmt = (event.print_fmt[:70], event.print_fmt[3742:]) + print_fmt = (event.print_fmt[:72], event.print_fmt[589:]) event.print_fmt = page_str.join(print_fmt) elif event.name == "xprt_transmit": event.print_fmt = ( @@ -731,6 +731,13 @@ class EventFormatterCodeGenerator(FtraceEventCodeGenerator): 'in outfile");\n'.format(event.name) ) f.write(" }\n") + f.write(" if (len < 0) {\n") + f.write( + ' PROFILER_LOG_WARN(LOG_CORE, "the contents of event({}) msg snprintf_s format error ' + '");\n'.format(event.name) + ) + f.write(" return \"\";\n") + f.write(" }\n") f.write(" return std::string(buffer);\n") f.write("});\n") # end of format function