aboutsummaryrefslogtreecommitdiff
path: root/test/profile/Inputs
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-01-07 19:55:37 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-01-07 19:55:37 +0000
commitca9211ecdede9bdedb812b2243a4abdb8dacd1b9 (patch)
tree9b19e801150082c33e9152275829a6ce90614b55 /test/profile/Inputs
parent8ef50bf3d1c287b5013c3168de77a462dfce3495 (diff)
downloadsrc-ca9211ecdede9bdedb812b2243a4abdb8dacd1b9.tar.gz
src-ca9211ecdede9bdedb812b2243a4abdb8dacd1b9.zip
Notes
Diffstat (limited to 'test/profile/Inputs')
-rw-r--r--test/profile/Inputs/instrprof-dlopen-func.c1
-rw-r--r--test/profile/Inputs/instrprof-dlopen-func2.c1
-rw-r--r--test/profile/Inputs/instrprof-dlopen-main.c47
-rw-r--r--test/profile/Inputs/instrprof-dynamic-a.cpp7
-rw-r--r--test/profile/Inputs/instrprof-dynamic-b.cpp7
-rw-r--r--test/profile/Inputs/instrprof-dynamic-header.h5
-rw-r--r--test/profile/Inputs/instrprof-dynamic-main.cpp9
7 files changed, 77 insertions, 0 deletions
diff --git a/test/profile/Inputs/instrprof-dlopen-func.c b/test/profile/Inputs/instrprof-dlopen-func.c
new file mode 100644
index 000000000000..f2de3883535a
--- /dev/null
+++ b/test/profile/Inputs/instrprof-dlopen-func.c
@@ -0,0 +1 @@
+void func(int K) { if (K) {} }
diff --git a/test/profile/Inputs/instrprof-dlopen-func2.c b/test/profile/Inputs/instrprof-dlopen-func2.c
new file mode 100644
index 000000000000..d4d93dc0b256
--- /dev/null
+++ b/test/profile/Inputs/instrprof-dlopen-func2.c
@@ -0,0 +1 @@
+void func2(int K) { if (K) {} }
diff --git a/test/profile/Inputs/instrprof-dlopen-main.c b/test/profile/Inputs/instrprof-dlopen-main.c
new file mode 100644
index 000000000000..ec357fe05bd5
--- /dev/null
+++ b/test/profile/Inputs/instrprof-dlopen-main.c
@@ -0,0 +1,47 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef DLOPEN_FUNC_DIR
+#include <dlfcn.h>
+#else
+void func(int K);
+void func2(int K);
+#endif
+
+int main(int argc, char *argv[]) {
+#ifdef DLOPEN_FUNC_DIR
+ dlerror();
+ void *f1_handle = dlopen(DLOPEN_FUNC_DIR"/func.shared", DLOPEN_FLAGS);
+ if (f1_handle == NULL) {
+ fprintf(stderr, "unable to open '" DLOPEN_FUNC_DIR "/func.shared': %s\n",
+ dlerror());
+ return EXIT_FAILURE;
+ }
+
+ void (*func)(int) = (void (*)(int))dlsym(f1_handle, "func");
+ if (func == NULL) {
+ fprintf(stderr, "unable to lookup symbol 'func': %s\n", dlerror());
+ return EXIT_FAILURE;
+ }
+
+ void *f2_handle = dlopen(DLOPEN_FUNC_DIR"/func2.shared", DLOPEN_FLAGS);
+ if (f2_handle == NULL) {
+ fprintf(stderr, "unable to open '" DLOPEN_FUNC_DIR "/func2.shared': %s\n",
+ dlerror());
+ return EXIT_FAILURE;
+ }
+
+ void (*func2)(int) = (void (*)(int))dlsym(f2_handle, "func2");
+ if (func2 == NULL) {
+ fprintf(stderr, "unable to lookup symbol 'func2': %s\n", dlerror());
+ return EXIT_FAILURE;
+ }
+#endif
+
+ func(1);
+ func2(0);
+
+ return EXIT_SUCCESS;
+}
+
diff --git a/test/profile/Inputs/instrprof-dynamic-a.cpp b/test/profile/Inputs/instrprof-dynamic-a.cpp
new file mode 100644
index 000000000000..67de263c4d88
--- /dev/null
+++ b/test/profile/Inputs/instrprof-dynamic-a.cpp
@@ -0,0 +1,7 @@
+#include "instrprof-dynamic-header.h"
+void a() {
+ if (true) {
+ bar<void>();
+ bar<char>();
+ }
+}
diff --git a/test/profile/Inputs/instrprof-dynamic-b.cpp b/test/profile/Inputs/instrprof-dynamic-b.cpp
new file mode 100644
index 000000000000..c8fb75ef52ed
--- /dev/null
+++ b/test/profile/Inputs/instrprof-dynamic-b.cpp
@@ -0,0 +1,7 @@
+#include "instrprof-dynamic-header.h"
+void b() {
+ if (true) {
+ bar<void>();
+ bar<int>();
+ }
+}
diff --git a/test/profile/Inputs/instrprof-dynamic-header.h b/test/profile/Inputs/instrprof-dynamic-header.h
new file mode 100644
index 000000000000..1dc2e37ef82c
--- /dev/null
+++ b/test/profile/Inputs/instrprof-dynamic-header.h
@@ -0,0 +1,5 @@
+template <class T> void bar() {
+ if (true) {}
+}
+void a();
+void b();
diff --git a/test/profile/Inputs/instrprof-dynamic-main.cpp b/test/profile/Inputs/instrprof-dynamic-main.cpp
new file mode 100644
index 000000000000..0dd60213926e
--- /dev/null
+++ b/test/profile/Inputs/instrprof-dynamic-main.cpp
@@ -0,0 +1,9 @@
+#include "instrprof-dynamic-header.h"
+void foo(int K) { if (K) {} }
+int main(int argc, char *argv[]) {
+ foo(5);
+ bar<void>();
+ a();
+ b();
+ return 0;
+}