aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/call_stack.cpp
blob: 1f6ce377d1211162323893db1e80dfb460118b6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "pdb/all.hpp"

#include <exception>
#include <iostream>

namespace test {

void call_stack() {
    const auto dbghelp = pdb::DbgHelp::current_process();
    const auto call_stack = pdb::CallStack::capture();
    call_stack.dump(std::cout, dbghelp);
}

void __declspec(noinline) baz() {
    std::cout << "baz\n";
    call_stack();
}

void __declspec(noinline) bar() {
    std::cout << "bar\n";
    baz();
}

void __declspec(noinline) foo() {
    std::cout << "foo\n";
    bar();
}

} // namespace test

int main() {
    try {
        test::foo();
    } catch (const std::exception& e) {
        std::cerr << e.what() << '\n';
        return 1;
    }
    return 0;
}