Files
lightgui_rust/crates/lightgui-debug/tests/targets/console.cpp
T
cnmcdee 3d53281388 Add lightgui-debug and lightgui-support: GDB MI debugger + theme/preferences/codeview/cmake ports
lightgui-debug: GdbSession over gdb -q -i=mi2 pipes with hand-written MI
parser (mi.rs), settings/breakpoint/variable types, and the 44-check
C++ harness ported as Rust tests (37 console + 7 GTK, gdb 17.1).
lightgui-support: CodeTheme + C tokenizer/highlighter, FontSettings,
CodeView fold/gutter/inspection widget, CMake project builder.
Tests: debug 59/59, support 23/23 (incl. theme/font/cmake suites).
cargo test clean, zero rustc warnings, clippy clean, cargo fmt clean.
2026-11-29 06:10:11 +00:00

33 lines
1.0 KiB
C++

// Debugger test target: console C++ program.
// Markers (// MARK:xxx) are found by the harness to get line numbers, so
// edits here do not break the tests. Compile with: g++ -g -O0 -o console console.cpp
#include <cstdio>
#include <vector>
int helper(int v) {
int r = v * 2 + 1; // MARK:HELPER
return r;
}
int compute(int a, int b) {
int s = a + b; // MARK:COMPUTE
int d = helper(s); // MARK:COMPUTE_CALL
return d;
}
int main(int argc, char** argv) {
if (argc > 1) std::printf("ARG=%s\n", argv[1]); // MARK:ARG
int sum = 0;
std::vector<int> vals = {1, 2, 3};
for (int i = 0; i < 3; i++) {
int x = helper(i); // MARK:LOOP
sum += x; // MARK:LOOP_NEXT
std::printf("i=%d x=%d sum=%d\n", i, x, sum);
std::fflush(stdout); // line-buffered for the debugger's live view
}
int total = compute(10, 20); // MARK:CALL
std::printf("TOTAL total=%d sum=%d\n", total, sum); // MARK:AFTER_CALL
std::printf("DONE sum=%d\n", sum);
return 0;
}