diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-01-15 19:20:50 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-01-16 01:21:32 +0300 |
commit | 3dc0b9a3ae90dcac2f1150e6b2dfb0a5a310355b (patch) | |
tree | fca7da94fdc0f4693a8b49b765738b9e842a1407 /include/pdb/call_stack.hpp | |
parent | lab_rat -> foobar (diff) | |
download | winapi-debug-3dc0b9a3ae90dcac2f1150e6b2dfb0a5a310355b.tar.gz winapi-debug-3dc0b9a3ae90dcac2f1150e6b2dfb0a5a310355b.zip |
add call stack collection support
Diffstat (limited to 'include/pdb/call_stack.hpp')
-rw-r--r-- | include/pdb/call_stack.hpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/include/pdb/call_stack.hpp b/include/pdb/call_stack.hpp new file mode 100644 index 0000000..7f0c8b0 --- /dev/null +++ b/include/pdb/call_stack.hpp @@ -0,0 +1,46 @@ +// Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com> +// This file is part of the "PDB repository" project. +// For details, see https://github.com/egor-tensin/pdb-repo. +// Distributed under the MIT License. + +#pragma once + +#include "address.hpp" +#include "dbghelp.hpp" + +#include <SafeInt.hpp> + +#include <Windows.h> + +#include <array> +#include <cstddef> +#include <string> + +namespace pdb { + +class CallStack { +public: + static constexpr std::size_t frames_to_skip = 0; + static constexpr std::size_t frames_to_capture = 62; + + // Imposed by CaptureStackBackTrace: + static constexpr std::size_t max_length = 62; + + static_assert(frames_to_skip + frames_to_capture <= max_length, + "Call stack length is too large"); + + static CallStack capture(); + + const std::array<Address, max_length> frames; + const std::size_t length; + +private: + CallStack() = default; +}; + +namespace call_stack { + +std::string pretty_print_address(const DbgHelp& dbghelp, Address addr); + +} // namespace call_stack +} // namespace pdb |