Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/stackUsageAnalyzer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion include/Config/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace ctrace

std::vector<std::string> 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.
Expand Down
4 changes: 4 additions & 0 deletions include/Process/Ipc/HttpServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
33 changes: 28 additions & 5 deletions include/Process/Tools/ToolsInvoker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,21 @@ namespace ctrace
runToolList(deduplicateToolNames(tool_names), files);
}

[[nodiscard]] DiagnosticSummary diagnosticsSummaryTotal() const
{
std::lock_guard<std::mutex> 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<IAnalysisTool> tool)
{
Expand All @@ -212,12 +227,12 @@ namespace ctrace
{
std::lock_guard<std::mutex> 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<std::string>& files)
Expand All @@ -242,12 +257,12 @@ namespace ctrace
{
std::lock_guard<std::mutex> 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<std::string>& tool_names, const std::string& file)
Expand Down Expand Up @@ -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<std::mutex> lock(m_diagnosticsSummaryMutex);
auto& total = m_diagnosticsSummaryByTool[tool_name];
total.info += summary.info;
total.warning += summary.warning;
total.error += summary.error;
}

std::unordered_map<std::string, std::unique_ptr<IAnalysisTool>> tools;
Expand All @@ -411,6 +432,8 @@ namespace ctrace
std::shared_ptr<IpcStrategy> m_ipc;
std::shared_ptr<ctrace::Thread::Output::CaptureBuffer> m_output_capture;
std::unique_ptr<ThreadPool> m_threadPool;
mutable std::mutex m_diagnosticsSummaryMutex;
std::unordered_map<std::string, DiagnosticSummary> m_diagnosticsSummaryByTool;
};
} // namespace ctrace

Expand Down
Loading