aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/test_lib.cpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-09-13 13:47:30 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-09-14 00:18:49 +0300
commit418e850b2b1f76b204af87a5d930f5129055e09a (patch)
tree470f40f91b500ca1de712689d171433d9dd4d0d5 /test/test_lib.cpp
parentcall_stack: try to fix __declspec(noinline) #3 (diff)
downloadwinapi-debug-418e850b2b1f76b204af87a5d930f5129055e09a.tar.gz
winapi-debug-418e850b2b1f76b204af87a5d930f5129055e09a.zip
call_stack: can't noinline w/ MSVC, let's try a DLL
Diffstat (limited to 'test/test_lib.cpp')
-rw-r--r--test/test_lib.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/test_lib.cpp b/test/test_lib.cpp
new file mode 100644
index 0000000..19c0d32
--- /dev/null
+++ b/test/test_lib.cpp
@@ -0,0 +1,44 @@
+#include "test_lib.hpp"
+
+#include <pdb/all.hpp>
+
+#include <boost/nowide/iostream.hpp>
+
+// Prevent frame pointer omission (FPO) and/or inlining.
+#ifdef _MSC_VER
+#pragma optimize("", off)
+#endif
+
+namespace test {
+namespace {
+
+void do_print_call_stack() {
+ const auto dbghelp = pdb::DbgHelp::current_process();
+ const auto call_stack = pdb::CallStack::capture();
+ call_stack.dump(boost::nowide::cout, dbghelp);
+}
+
+} // namespace
+
+volatile int var = 42;
+
+void baz(F f) {
+ boost::nowide::cout << "baz\n";
+ f();
+}
+
+void bar(F f) {
+ boost::nowide::cout << "bar\n";
+ baz(f);
+}
+
+void foo(F f) {
+ boost::nowide::cout << "foo\n";
+ bar(f);
+}
+
+void print_call_stack() {
+ foo(&do_print_call_stack);
+}
+
+} // namespace test