aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-03-16 17:19:24 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-03-16 17:19:24 +0300
commitc151774911b4ea658410cc6593dd40390862a168 (patch)
tree2d364e74bfb9923236fdc53d8cc7b64df3dcc883 /include
parentTravis: ignore everything in .dockerignore (diff)
downloadwinapi-debug-c151774911b4ea658410cc6593dd40390862a168.tar.gz
winapi-debug-c151774911b4ea658410cc6593dd40390862a168.zip
DbgHelp: start fixing the API
Diffstat (limited to 'include')
-rw-r--r--include/pdb/dbghelp.hpp31
-rw-r--r--include/pdb/repo.hpp2
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;