Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e7d11d8
build(cmake): add FetchContent module for coretrace logger
SizzleUnrlsd Mar 19, 2026
9f5e145
build(cmake): link coretrace logger and tool config source
SizzleUnrlsd Mar 19, 2026
86214ff
feat(config): add tool config loader interface
SizzleUnrlsd Mar 19, 2026
37a2f93
feat(config): implement JSON tool config mapper
SizzleUnrlsd Mar 19, 2026
81f6c9e
feat(config): extend global options for stack analyzer controls
SizzleUnrlsd Mar 19, 2026
abb20c3
feat(cli): register config and analyzer command options
SizzleUnrlsd Mar 19, 2026
72c7b0c
feat(files): resolve compile_commands inputs with deduplication
SizzleUnrlsd Mar 19, 2026
45adc26
feat(ipc): support config-driven analysis parameters
SizzleUnrlsd Mar 19, 2026
6606074
feat(tools): add batch execution and diagnostic summary API
SizzleUnrlsd Mar 19, 2026
47970ab
feat(stack-analyzer): declare batch execution overrides
SizzleUnrlsd Mar 19, 2026
92a07ad
feat(stack-analyzer): bridge coretrace options to analyzer app
SizzleUnrlsd Mar 19, 2026
acfc90d
refactor(invoker): execute tools in batch with thread-safe scheduling
SizzleUnrlsd Mar 19, 2026
973c8c1
refactor(runner): run analyses through unified logger flow
SizzleUnrlsd Mar 19, 2026
48125fb
refactor(main): initialize coretrace logger before execution
SizzleUnrlsd Mar 19, 2026
f7d481a
style(thread): align namespace closing comment
SizzleUnrlsd Mar 19, 2026
1a92dc8
chore(config): add stack analyzer JSON config example
SizzleUnrlsd Mar 19, 2026
948a782
test(fixtures): include stdio in empty for statement sample
SizzleUnrlsd Mar 19, 2026
345fa70
test(fixtures): print baseline value in bound index sample
SizzleUnrlsd Mar 19, 2026
a017b9a
fix(build): add threadpool fallback when std::jthread is unavailable
SizzleUnrlsd Mar 19, 2026
eb2cac1
perf(scripts): scope format commands to first-party source files
SizzleUnrlsd Mar 19, 2026
43aebcd
chore(style): format code with clang-format
SizzleUnrlsd Mar 19, 2026
60fcf81
chore(CI): update version of clang-format: 17 -> 20
SizzleUnrlsd Mar 19, 2026
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
6 changes: 3 additions & 3 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install clang-format 17
- name: Install clang-format 20
run: |
sudo apt-get update
sudo apt-get install -y clang-format-17
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-17 100
sudo apt-get install -y clang-format-20
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-20 100

- name: Run format-check
run: ./scripts/format-check.sh
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set(COMMON_SOURCES
src/ArgumentParser/ArgumentManager.cpp
src/ArgumentParser/ArgumentParserFactory.cpp
src/App/Config.cpp
src/App/ToolConfig.cpp
src/App/Files.cpp
src/App/Runner.cpp
src/ctrace_tools/mangle.cpp
Expand Down Expand Up @@ -66,6 +67,9 @@ target_link_libraries(ctrace PRIVATE nlohmann_json::nlohmann_json)
include(${CMAKE_SOURCE_DIR}/cmake/stackUsageAnalyzer.cmake)
target_link_libraries(ctrace PRIVATE coretrace::stack_usage_analyzer_lib)

include(${CMAKE_SOURCE_DIR}/cmake/logger/coretraceLog.cmake)
target_link_libraries(ctrace PRIVATE coretrace::logger)

include(${CMAKE_SOURCE_DIR}/cmake/httpLib.cmake)
target_link_libraries(ctrace PRIVATE httplib::httplib)

Expand Down
10 changes: 10 additions & 0 deletions cmake/logger/coretraceLog.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(CORETRACE_LOGGER_BUILD_EXAMPLES OFF CACHE BOOL "Disable logger examples" FORCE)
set(CORETRACE_LOGGER_BUILD_TESTS OFF CACHE BOOL "Disable logger tests" FORCE)

include(FetchContent)

FetchContent_Declare(coretrace-logger
GIT_REPOSITORY https://github.com/CoreTrace/coretrace-log.git
GIT_TAG main
)
FetchContent_MakeAvailable(coretrace-logger)
24 changes: 24 additions & 0 deletions config/tool-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"invoke": [
"ctrace_stack_analyzer"
],
"stack_analyzer": {
"compile_commands": "",
"include_compdb_deps": false,
"analysis-profile": "full",
"timing": true,
"smt": "on",
"smt-backend": "z3",
"smt-secondary-backend": "single",
"smt-mode": "single",
"smt-timeout-ms": 80,
"smt-rules": ["recursion","integer-overflow","size-minus-k","stack-buffer","oob-read","type-confusion"],
"entry_points": [],
"demangle": true,
"quiet": false,
"stack_limit": 8388608,
"resource_model": "../../coretrace-stack-analyzer/models/resource-lifetime/generic.txt",
"escape_model": "../../coretrace-stack-analyzer/models/stack-escape/generic.txt",
"buffer_model": "../../coretrace-stack-analyzer/models/buffer-overflow/generic.txt"
}
}
15 changes: 15 additions & 0 deletions include/App/ToolConfig.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef APP_TOOL_CONFIG_HPP
#define APP_TOOL_CONFIG_HPP

#include <string>
#include <string_view>

#include "Config/config.hpp"

namespace ctrace
{
bool applyToolConfigFile(ProgramConfig& config, std::string_view configPath,
std::string& errorMessage);
}

#endif // APP_TOOL_CONFIG_HPP
128 changes: 123 additions & 5 deletions include/Config/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define CONFIG_HPP

#include <cstdlib>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>
Expand All @@ -13,6 +14,8 @@
#include "ctrace_tools/strings.hpp"
#include "ctrace_defs/types.hpp"

#include <coretrace/logger.hpp>

static void printHelp(void)
{
std::cout << R"(ctrace - Static & Dynamic C/C++ Code Analysis Tool
Expand All @@ -27,6 +30,21 @@ static void printHelp(void)
--report-file <path> Specifies the path to the report file (default: ctrace-report.txt).
--output-file <path> Specifies the output file for the analysed binary (default: ctrace.out).
--entry-points <names> Sets the entry points for analysis (default: main). Accepts a comma-separated list.
--config <path> Loads settings from a JSON config file.
--compile-commands <path> Path to compile_commands.json for tools that support it.
--include-compdb-deps Includes dependency entries (e.g. _deps) when auto-loading files from compile_commands.json.
--analysis-profile <p> Stack analyzer profile: fast|full.
--smt <on|off> Enables/disables SMT refinement in stack analyzer.
--smt-backend <name> Primary SMT backend (e.g. z3, interval).
--smt-secondary-backend <name> Secondary backend for multi-solver modes.
--smt-mode <mode> SMT mode: single|portfolio|cross-check|dual-consensus.
--smt-timeout-ms <n> SMT timeout in milliseconds.
--smt-budget-nodes <n> SMT node budget per query.
--smt-rules <list> Comma-separated SMT-enabled rules.
--resource-model <path> Path to the resource lifetime model for stack analyzer.
--escape-model <path> Path to the stack escape model for stack analyzer.
--buffer-model <path> Path to the buffer overflow model for stack analyzer.
--demangle Displays demangled function names in supported tools.
--static Enables static analysis.
--dyn Enables dynamic analysis.
--invoke <tools> Invokes specific tools (comma-separated).
Expand Down Expand Up @@ -66,15 +84,23 @@ namespace ctrace
explicit FileConfig(const std::string& str) : src_file(str) {}
};

struct SpecificConfig
{
std::string tool_name; ///< Name of the specific tool.
bool timing = false; ///< Indicates if timing information should be displayed.
};

/**
* @brief Represents the global configuration for the program.
*
* The `GlobalConfig` struct stores various global settings, such as verbosity,
* analysis options, and file paths for reports and outputs.
*/
struct GlobalConfig
struct GlobalConfig : public SpecificConfig
{
bool verbose = false; ///< Enables verbose output.
bool verbose = false; ///< Enables verbose output.
bool quiet = false; ///< Suppresses non-essential output.
bool demangle = false; ///< Enables demangled function names in supported tools.
std::launch hasAsync = std::launch::deferred; ///< Enables asynchronous execution.
bool hasSarifFormat = false; ///< Indicates if SARIF format is enabled.
bool hasStaticAnalysis = false; ///< Indicates if static analysis is enabled.
Expand All @@ -90,9 +116,25 @@ 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.
std::string compile_commands; ///< Path to compile_commands.json.
bool include_compdb_deps =
false; ///< Includes dependency entries from compile_commands.json auto-discovery.
std::string analysis_profile; ///< Stack analyzer analysis profile (fast|full).
std::string smt; ///< SMT enable switch (on|off).
std::string smt_backend; ///< SMT primary backend.
std::string smt_secondary_backend; ///< SMT secondary backend.
std::string smt_mode; ///< SMT mode.
uint32_t smt_timeout_ms = 0; ///< SMT timeout in milliseconds (0 = analyzer default).
uint64_t smt_budget_nodes = 0; ///< SMT node budget (0 = analyzer default).
std::vector<std::string> smt_rules; ///< SMT-enabled rule ids.
std::string resource_model; ///< Path to stack analyzer resource model.
std::string escape_model; ///< Path to stack analyzer escape model.
std::string buffer_model; ///< Path to stack analyzer buffer model.
uint64_t stack_limit = 8 * 1024 * 1024; ///< Stack limit in bytes.
};

/**
Expand Down Expand Up @@ -148,6 +190,8 @@ namespace ctrace
std::exit(0);
};
commands["--verbose"] = [this](const std::string&) { config.global.verbose = true; };
commands["--quiet"] = [this](const std::string&) { config.global.quiet = true; };
commands["--demangle"] = [this](const std::string&) { config.global.demangle = true; };
commands["--sarif-format"] = [this](const std::string&)
{ config.global.hasSarifFormat = true; };
commands["--report-file"] = [this](const std::string& value)
Expand Down Expand Up @@ -199,6 +243,78 @@ namespace ctrace
{ config.global.hasDynamicAnalysis = true; };
commands["--entry-points"] = [this](const std::string& value)
{ config.global.entry_points = value; };
commands["--config"] = [this](const std::string& value)
{ config.global.config_file = value; };
commands["--compile-commands"] = [this](const std::string& value)
{ config.global.compile_commands = value; };
commands["--include-compdb-deps"] = [this](const std::string&)
{ config.global.include_compdb_deps = true; };
commands["--analysis-profile"] = [this](const std::string& value)
{ config.global.analysis_profile = value; };
commands["--smt"] = [this](const std::string& value) { config.global.smt = value; };
commands["--smt-backend"] = [this](const std::string& value)
{ config.global.smt_backend = value; };
commands["--smt-secondary-backend"] = [this](const std::string& value)
{ config.global.smt_secondary_backend = value; };
commands["--smt-mode"] = [this](const std::string& value)
{ config.global.smt_mode = value; };
commands["--smt-timeout-ms"] = [this](const std::string& value)
{
try
{
config.global.smt_timeout_ms = static_cast<uint32_t>(std::stoul(value));
}
catch (const std::exception& e)
{
coretrace::log(coretrace::Level::Error,
"Invalid smt timeout value: '{}'. Error: {}\n", value, e.what());
std::exit(EXIT_FAILURE);
}
};
commands["--smt-budget-nodes"] = [this](const std::string& value)
{
try
{
config.global.smt_budget_nodes = std::stoull(value);
}
catch (const std::exception& e)
{
coretrace::log(coretrace::Level::Error,
"Invalid smt budget value: '{}'. Error: {}\n", value, e.what());
std::exit(EXIT_FAILURE);
}
};
commands["--smt-rules"] = [this](const std::string& value)
{
config.global.smt_rules.clear();
for (const auto rule : ctrace_tools::strings::splitByComma(value))
{
config.global.smt_rules.emplace_back(rule);
}
};
commands["--resource-model"] = [this](const std::string& value)
{ config.global.resource_model = value; };
commands["--escape-model"] = [this](const std::string& value)
{ config.global.escape_model = value; };
commands["--buffer-model"] = [this](const std::string& value)
{ config.global.buffer_model = value; };
commands["--stack-limit"] = [this](const std::string& value)
{
try
{
config.global.stack_limit = std::stoul(value);
coretrace::log(coretrace::Level::Info, "Stack limit set to {} bytes",
config.global.stack_limit);
}
catch (const std::exception& e)
{
coretrace::log(coretrace::Level::Error,
"Invalid stack limit value: '{}'. Error: {}\n", value, e.what());
coretrace::log(coretrace::Level::Error,
"Please provide a valid unsigned integer.\n");
std::exit(EXIT_FAILURE);
}
};
commands["--ipc"] = [this](const std::string& value)
{
auto ipc_list = ctrace_defs::IPC_TYPES;
Expand All @@ -223,12 +339,14 @@ namespace ctrace
commands["--serve-host"] = [this](const std::string& value)
{
config.global.serverHost = value;
std::cout << "[DEBUG] Server host set to " << config.global.serverHost << std::endl;
coretrace::log(coretrace::Level::Debug, "Server host set to {}",
config.global.serverHost);
};
commands["--serve-port"] = [this](const std::string& value)
{
config.global.serverPort = std::stoi(value);
std::cout << "[DEBUG] Server port set to " << config.global.serverPort << std::endl;
coretrace::log(coretrace::Level::Debug, "Server port set to {}",
config.global.serverPort);
};
commands["--shutdown-token"] = [this](const std::string& value)
{ config.global.shutdownToken = value; };
Expand Down
Loading
Loading