diff --git a/cmake/stackUsageAnalyzer.cmake b/cmake/stackUsageAnalyzer.cmake index 0b27429..cae7a29 100644 --- a/cmake/stackUsageAnalyzer.cmake +++ b/cmake/stackUsageAnalyzer.cmake @@ -3,7 +3,7 @@ include(FetchContent) FetchContent_Declare( stack_analyzer GIT_REPOSITORY https://github.com/CoreTrace/coretrace-stack-analyzer.git - GIT_TAG v0.17.0 + GIT_TAG v0.18.1 EXCLUDE_FROM_ALL ) diff --git a/include/Config/config.hpp b/include/Config/config.hpp index 5db7afb..631e0b6 100644 --- a/include/Config/config.hpp +++ b/include/Config/config.hpp @@ -128,7 +128,7 @@ namespace ctrace std::vector specificTools; ///< List of specific tools to invoke. - std::string entry_points = "main"; ///< Entry points for analysis. + std::string entry_points = ""; ///< Entry points for analysis. std::string report_file = "ctrace-report.txt"; ///< Path to the report file. std::string output_file = "ctrace.out"; ///< Path to the output file. std::string config_file; ///< Path to the JSON config file. diff --git a/include/Process/Ipc/HttpServer.hpp b/include/Process/Ipc/HttpServer.hpp index bada6da..367c300 100644 --- a/include/Process/Ipc/HttpServer.hpp +++ b/include/Process/Ipc/HttpServer.hpp @@ -564,6 +564,10 @@ class ApiHandler result["stack_analyzer_mode"] = config.global.stack_analyzer_mode; result["stack_analyzer_output_format"] = config.global.stack_analyzer_output_format; result["stack_analyzer_extra_args"] = config.global.stack_analyzer_extra_args; + const auto diagnosticsSummaryTotal = invoker.diagnosticsSummaryTotal(); + result["diagnostics_summary_total"] = {{"info", diagnosticsSummaryTotal.info}, + {"warning", diagnosticsSummaryTotal.warning}, + {"error", diagnosticsSummaryTotal.error}}; if (output_capture) { json outputs = json::object(); diff --git a/include/Process/Tools/ToolsInvoker.hpp b/include/Process/Tools/ToolsInvoker.hpp index 49f968e..6b05815 100644 --- a/include/Process/Tools/ToolsInvoker.hpp +++ b/include/Process/Tools/ToolsInvoker.hpp @@ -188,6 +188,21 @@ namespace ctrace runToolList(deduplicateToolNames(tool_names), files); } + [[nodiscard]] DiagnosticSummary diagnosticsSummaryTotal() const + { + std::lock_guard lock(m_diagnosticsSummaryMutex); + + DiagnosticSummary total{}; + for (const auto& [_, summary] : m_diagnosticsSummaryByTool) + { + total.info += summary.info; + total.warning += summary.warning; + total.error += summary.error; + } + + return total; + } + private: void registerTool(const std::string& name, std::unique_ptr tool) { @@ -212,12 +227,12 @@ namespace ctrace { std::lock_guard lock(*lock_it->second); tool_it->second->execute(file, m_config); - logDiagnosticsSummary(tool_name, *tool_it->second); + recordDiagnosticsSummary(tool_name, *tool_it->second); return; } tool_it->second->execute(file, m_config); - logDiagnosticsSummary(tool_name, *tool_it->second); + recordDiagnosticsSummary(tool_name, *tool_it->second); } void executeBatchTool(const std::string& tool_name, const std::vector& files) @@ -242,12 +257,12 @@ namespace ctrace { std::lock_guard lock(*lock_it->second); tool_it->second->executeBatch(files, m_config); - logDiagnosticsSummary(tool_name, *tool_it->second); + recordDiagnosticsSummary(tool_name, *tool_it->second); return; } tool_it->second->executeBatch(files, m_config); - logDiagnosticsSummary(tool_name, *tool_it->second); + recordDiagnosticsSummary(tool_name, *tool_it->second); } void runToolList(const std::vector& tool_names, const std::string& file) @@ -393,12 +408,18 @@ namespace ctrace return tool_name == "ctrace_stack_analyzer"; } - static void logDiagnosticsSummary(const std::string& tool_name, const IAnalysisTool& tool) + void recordDiagnosticsSummary(const std::string& tool_name, const IAnalysisTool& tool) { const auto summary = tool.lastDiagnosticsSummary(); coretrace::log(coretrace::Level::Info, coretrace::Module(tool_name), "Diagnostics summary: info={}, warning={}, error={}\n", summary.info, summary.warning, summary.error); + + std::lock_guard lock(m_diagnosticsSummaryMutex); + auto& total = m_diagnosticsSummaryByTool[tool_name]; + total.info += summary.info; + total.warning += summary.warning; + total.error += summary.error; } std::unordered_map> tools; @@ -411,6 +432,8 @@ namespace ctrace std::shared_ptr m_ipc; std::shared_ptr m_output_capture; std::unique_ptr m_threadPool; + mutable std::mutex m_diagnosticsSummaryMutex; + std::unordered_map m_diagnosticsSummaryByTool; }; } // namespace ctrace