Files
Language-Server/experiments/frontend/gcc-worker/Main.cpp
T
faumaray da8003f6d4 Implement the VLS roadmap on the native VBS build
Native VBS and CMake builds of the server and every registered suite:
protocol and document sync, VBS/compdb providers, stock GCC diagnostics
(including in-process default profile preparation), the stock occurrence
observer and hover/definition, the bounded Scheduler, C++ module graph,
scan and artifact cache with real CMI production, the context-aware
symbol index with schema-2 snapshot migration, navigation and guarded
rename, reflection provenance with splice-origin extraction, index-backed
completion and signature help, live GCC worker control with a registered
DAP suite, and the Neovim and VS Code clients.

VoidLibrary follows main. The private GCC 16.2.0 frontend is reproduced
from the versioned patches and verified stepping reflection/template code
with projected values 17/34 and 41/82.
2026-12-05 14:06:50 +03:00

68 lines
2.3 KiB
C++

#include "Leaf.hpp"
#include "Supervisor.hpp"
#include "Trace.hpp"
#include <charconv>
#include <csignal>
#include <iostream>
namespace {
constexpr std::string_view usage =
"vls_gcc_probe run COMPILER SHA256 SOURCE NEW_TRACE [--step]\n"
"vls_gcc_probe replay TRACE [EVENT_SEQUENCE]\n"
"At a stop, send NONCE STOP inspect|step|continue|cancel and a newline.\n"
"During a stepped run, NONCE cancel cancels the running frontend.\n";
}
int main(int argc, char **argv) try {
using namespace vls::gcc;
const std::string_view mode = argc >= 2 ? argv[1] : "";
if (mode == "--leaf" && argc == 6) {
const std::string_view action{argv[5]};
if (action != "step" && action != "observe")
return 126;
return run_leaf(argv[2], argv[3], argv[4], action == "step");
}
if (mode == "--help" && argc == 2) {
std::cout << usage;
return 0;
}
std::signal(SIGPIPE, SIG_IGN);
if (mode == "run" && (argc == 6 || (argc == 7 && std::string_view(argv[6]) == "--step"))) {
RunOptions options{std::filesystem::absolute(argv[2]), argv[3],
std::filesystem::absolute(argv[4]), std::filesystem::absolute(argv[5]),
argc == 7};
auto result = run_session(options);
if (!result) {
std::cerr << "vls_gcc_probe: " << result.error() << '\n';
return 1;
}
return *result;
}
if (mode == "replay" && (argc == 3 || argc == 4)) {
std::optional<std::uint32_t> sequence;
if (argc == 4) {
const std::string_view text{argv[3]};
const auto end = text.data() + text.size();
auto [last, error] = std::from_chars(text.data(), end, sequence.emplace());
if (error != std::errc{} || last != end)
return 2;
}
auto snapshot = replay(std::filesystem::absolute(argv[2]), sequence);
if (!snapshot) {
std::cerr << "vls_gcc_probe: " << snapshot.error() << '\n';
return 1;
}
auto json = Protocol::serialize_json(*snapshot);
if (!json)
return 1;
std::cout << *json << '\n';
return std::cout ? 0 : 1;
}
std::cerr << usage;
return 2;
} catch (const std::exception &error) {
std::cerr << "vls_gcc_probe: " << error.what() << '\n';
return 1;
}