From f3e454003d2e404e2574e3d77719e125c84db074 Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Thu, 23 Nov 2023 15:04:25 -0600 Subject: [PATCH] Test program for testing breakpoint conditions. --- tests/hellofibonacci/.gitignore | 2 ++ tests/hellofibonacci/Makefile | 10 +++++++ tests/hellofibonacci/README | 11 +++++++ tests/hellofibonacci/breakpoints.seer | 3 ++ tests/hellofibonacci/hellofibonacci.cpp | 40 +++++++++++++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 tests/hellofibonacci/.gitignore create mode 100644 tests/hellofibonacci/Makefile create mode 100644 tests/hellofibonacci/README create mode 100644 tests/hellofibonacci/breakpoints.seer create mode 100644 tests/hellofibonacci/hellofibonacci.cpp diff --git a/tests/hellofibonacci/.gitignore b/tests/hellofibonacci/.gitignore new file mode 100644 index 00000000..cba6a606 --- /dev/null +++ b/tests/hellofibonacci/.gitignore @@ -0,0 +1,2 @@ +hellofibonacci +core* diff --git a/tests/hellofibonacci/Makefile b/tests/hellofibonacci/Makefile new file mode 100644 index 00000000..84ff04ad --- /dev/null +++ b/tests/hellofibonacci/Makefile @@ -0,0 +1,10 @@ +.PHONY: all +all: hellofibonacci + +hellofibonacci: hellofibonacci.cpp + g++ -g -o hellofibonacci hellofibonacci.cpp + +.PHONY: clean +clean: + rm -f hellofibonacci hellofibonacci.o + diff --git a/tests/hellofibonacci/README b/tests/hellofibonacci/README new file mode 100644 index 00000000..d1325865 --- /dev/null +++ b/tests/hellofibonacci/README @@ -0,0 +1,11 @@ + +A good program to test the "break if condition is met". + +See problem report: + + https://github.com/epasveer/seer/issues/184 + +Use this breakpoint file when running Seer: + + $ seergdb -s --break-load breakpoints.seer hellofibonacci 255 + diff --git a/tests/hellofibonacci/breakpoints.seer b/tests/hellofibonacci/breakpoints.seer new file mode 100644 index 00000000..b9fcb86d --- /dev/null +++ b/tests/hellofibonacci/breakpoints.seer @@ -0,0 +1,3 @@ +break -source /nas/erniep/Development/seer/tests/hellofibonacci/hellofibonacci.cpp -line 23 +break -source /nas/erniep/Development/seer/tests/hellofibonacci/hellofibonacci.cpp -line 29 + condition $bpnum nextTerm > 10 diff --git a/tests/hellofibonacci/hellofibonacci.cpp b/tests/hellofibonacci/hellofibonacci.cpp new file mode 100644 index 00000000..152c486f --- /dev/null +++ b/tests/hellofibonacci/hellofibonacci.cpp @@ -0,0 +1,40 @@ +#include +#include + +int main (int argc, char* argv[]) { + + if (argc != 2) { + std::cout << "usage: " << argv[0] << " N" << std::endl; + return 1; + } + + int t1 = 0; + int t2 = 1; + int nextTerm = 0; + int n = atoi(argv[1]); + + // Check N + if (n < 0) { + std::cout << "Bad value of 'N': " << argv[1] << std::endl; + return 1; + } + + // Displays the first two terms which is always 0 and 1 + std::cout << "Fibonacci Series: " << t1 << ", " << t2 << ", "; + + // Display next terms. + nextTerm = t1 + t2; + + while (nextTerm <= n) { + std::cout << nextTerm << ", "; + t1 = t2; + t2 = nextTerm; + nextTerm = t1 + t2; + } + + // Final EOL + std::cout << std::endl; + + return 0; +} +