Skip to content

Commit

Permalink
Test program for testing breakpoint conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
epasveer committed Nov 23, 2023
1 parent 6a56e2b commit f3e4540
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/hellofibonacci/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hellofibonacci
core*
10 changes: 10 additions & 0 deletions tests/hellofibonacci/Makefile
Original file line number Diff line number Diff line change
@@ -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

11 changes: 11 additions & 0 deletions tests/hellofibonacci/README
Original file line number Diff line number Diff line change
@@ -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

3 changes: 3 additions & 0 deletions tests/hellofibonacci/breakpoints.seer
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions tests/hellofibonacci/hellofibonacci.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <iostream>
#include <stdlib.h>

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;
}

0 comments on commit f3e4540

Please sign in to comment.