aboutsummaryrefslogtreecommitdiffhomepage
path: root/development/gcov
diff options
context:
space:
mode:
authorjohannst <johannst@users.noreply.github.com>2023-05-29 20:34:16 +0000
committerjohannst <johannst@users.noreply.github.com>2023-05-29 20:34:16 +0000
commiteaad036407c9546be0de27f61745fef4b6856e56 (patch)
treec270e3fbc87f3b7c9fc25ac60f4f8f611962de5e /development/gcov
parent87c538b89ea68cf0c133a9243097ffac646e6739 (diff)
downloadnotes-eaad036407c9546be0de27f61745fef4b6856e56.tar.gz
notes-eaad036407c9546be0de27f61745fef4b6856e56.zip
deploy: d2013ee5952bbcf88906a832748783e372f3a939
Diffstat (limited to 'development/gcov')
-rw-r--r--development/gcov/Makefile24
-rw-r--r--development/gcov/cov.cc17
2 files changed, 41 insertions, 0 deletions
diff --git a/development/gcov/Makefile b/development/gcov/Makefile
new file mode 100644
index 0000000..f27f8d8
--- /dev/null
+++ b/development/gcov/Makefile
@@ -0,0 +1,24 @@
+# Copyright (C) 2023 johannst
+
+CXXFLAGS = -fprofile-arcs -ftest-coverage
+# or the alias
+#CXXFLAGS = --coverage
+
+cov-gcc: clean
+ g++ $(CXXFLAGS) -c -o cov.o cov.cc
+ g++ $(CXXFLAGS) -o $@ cov.o
+ ./$@
+ gcov --demangled-names cov.cc
+ cat cov.cc.gcov
+.PHONY: cov-gcc
+
+cov-clang: clean
+ clang++ $(CXXFLAGS) -c -o cov.o cov.cc
+ clang++ $(CXXFLAGS) -o $@ cov.o
+ ./$@
+ llvm-cov gcov --demangled-names cov.cc
+ cat cov.cc.gcov
+.PHONY: cov-clang
+
+clean:
+ $(RM) *.gcov *.gcno *.gcda *.o cov-*
diff --git a/development/gcov/cov.cc b/development/gcov/cov.cc
new file mode 100644
index 0000000..3737d81
--- /dev/null
+++ b/development/gcov/cov.cc
@@ -0,0 +1,17 @@
+// Copyright (C) 2023 johannst
+
+#include <cstdio>
+
+void tell_me(int desc) {
+ if (desc & 1) {
+ std::puts("this");
+ } else {
+ std::puts("that");
+ }
+}
+
+int main(int argc, char *argv[]) {
+ tell_me(argc);
+ tell_me(argc);
+ return 0;
+}