diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/pdb/dbghelp.hpp | 31 | ||||
-rw-r--r-- | include/pdb/repo.hpp | 2 |
2 files changed, 26 insertions, 7 deletions
diff --git a/include/pdb/dbghelp.hpp b/include/pdb/dbghelp.hpp index af10789..328df2d 100644 --- a/include/pdb/dbghelp.hpp +++ b/include/pdb/dbghelp.hpp @@ -18,10 +18,14 @@ namespace pdb { class DbgHelp { public: - DbgHelp(bool invade_current_process = false); - ~DbgHelp(); + static DbgHelp current_process() { return DbgHelp{true}; } + static DbgHelp post_mortem() { return DbgHelp{false}; } - void close(); + void swap(DbgHelp& other) noexcept; + + DbgHelp(DbgHelp&& other) noexcept; + DbgHelp& operator=(DbgHelp) noexcept; + ~DbgHelp(); ModuleInfo load_pdb(const std::string& path) const; @@ -43,11 +47,26 @@ public: LineInfo resolve_line(Address) const; private: - const HANDLE id = GetCurrentProcess(); - bool closed = false; + explicit DbgHelp(bool invade_current_process); + + void close(); + + HANDLE id = GetCurrentProcess(); DbgHelp(const DbgHelp&) = delete; - DbgHelp& operator=(const DbgHelp&) = delete; }; +inline void swap(DbgHelp& a, DbgHelp& b) noexcept { + a.swap(b); +} + } // namespace pdb + +namespace std { + +template <> +inline void swap(pdb::DbgHelp& a, pdb::DbgHelp& b) noexcept { + a.swap(b); +} + +} // namespace std diff --git a/include/pdb/repo.hpp b/include/pdb/repo.hpp index 8bc5596..74a86a8 100644 --- a/include/pdb/repo.hpp +++ b/include/pdb/repo.hpp @@ -47,7 +47,7 @@ private: Address address_offline_to_online(Address) const; Address address_online_to_offline(Address) const; - const DbgHelp dbghelp; + const DbgHelp dbghelp{DbgHelp::post_mortem()}; std::unordered_set<file::ID> file_ids; std::map<Address, Module> online_bases; |