aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-05-29 01:24:29 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-05-29 01:27:53 +0300
commite162f2a21632e3f7b1c7ab9dd7b530beb1f2d4a8 (patch)
tree65199bce3779ff1800821c6b1c6bc0bc4592e66c
parentnamespace pdb -> namespace winapi (diff)
downloadwinapi-debug-e162f2a21632e3f7b1c7ab9dd7b530beb1f2d4a8.tar.gz
winapi-debug-e162f2a21632e3f7b1c7ab9dd7b530beb1f2d4a8.zip
rename class Repo to PostMortem
Diffstat (limited to '')
-rw-r--r--include/winapi/debug.hpp2
-rw-r--r--include/winapi/debug/post_mortem.hpp (renamed from include/winapi/debug/repo.hpp)4
-rw-r--r--src/post_mortem.cpp (renamed from src/repo.cpp)30
-rw-r--r--utils/addr2name.cpp16
-rw-r--r--utils/name2addr.cpp10
5 files changed, 32 insertions, 30 deletions
diff --git a/include/winapi/debug.hpp b/include/winapi/debug.hpp
index dc42557..93b952f 100644
--- a/include/winapi/debug.hpp
+++ b/include/winapi/debug.hpp
@@ -9,5 +9,5 @@
#include "debug/call_stack.hpp"
#include "debug/dbghelp.hpp"
#include "debug/module.hpp"
-#include "debug/repo.hpp"
+#include "debug/post_mortem.hpp"
#include "debug/symbol.hpp"
diff --git a/include/winapi/debug/repo.hpp b/include/winapi/debug/post_mortem.hpp
index 8ee7fde..bf4ad83 100644
--- a/include/winapi/debug/repo.hpp
+++ b/include/winapi/debug/post_mortem.hpp
@@ -19,9 +19,9 @@
namespace winapi {
-class Repo {
+class PostMortem {
public:
- Repo() = default;
+ PostMortem() = default;
Address add_pdb(Address online_base, const std::string& path);
diff --git a/src/repo.cpp b/src/post_mortem.cpp
index 24d9e59..d365b02 100644
--- a/src/repo.cpp
+++ b/src/post_mortem.cpp
@@ -86,7 +86,7 @@ const Module& guess_module(const std::map<Address, Value>& modules, Address pivo
} // namespace
-Address Repo::add_pdb(Address online_base, const std::string& path) {
+Address PostMortem::add_pdb(Address online_base, const std::string& path) {
if (online_bases.find(online_base) != online_bases.cend())
throw std::runtime_error{pdb_already_loaded(online_base, path)};
@@ -107,64 +107,64 @@ Address Repo::add_pdb(Address online_base, const std::string& path) {
return offline_base;
}
-void Repo::enum_symbols(const OnSymbol& callback) const {
+void PostMortem::enum_symbols(const OnSymbol& callback) const {
for (const auto& it : offline_bases)
enum_symbols(it.second, callback);
}
-void Repo::enum_symbols(Address offline_base, const OnSymbol& callback) const {
+void PostMortem::enum_symbols(Address offline_base, const OnSymbol& callback) const {
const auto it = offline_bases.find(offline_base);
if (it == offline_bases.cend())
throw std::runtime_error{"unknown module"};
enum_symbols(it->second, callback);
}
-void Repo::enum_symbols(const Module& module, const OnSymbol& callback) const {
+void PostMortem::enum_symbols(const Module& module, const OnSymbol& callback) const {
dbghelp.enum_symbols(
module, [&](const SymbolInfo& impl) { callback(symbol_from_buffer(module, impl)); });
}
-Symbol Repo::resolve_symbol(Address online) const {
+Symbol PostMortem::resolve_symbol(Address online) const {
return symbol_from_buffer(dbghelp.resolve_symbol(address_online_to_offline(online)));
}
-Symbol Repo::resolve_symbol(const std::string& name) const {
+Symbol PostMortem::resolve_symbol(const std::string& name) const {
return symbol_from_buffer(dbghelp.resolve_symbol(name));
}
-LineInfo Repo::resolve_line(Address online) const {
+LineInfo PostMortem::resolve_line(Address online) const {
return dbghelp.resolve_line(address_online_to_offline(online));
}
-const Module& Repo::module_with_online_base(Address base) const {
+const Module& PostMortem::module_with_online_base(Address base) const {
return lookup_module(online_bases, base);
}
-const Module& Repo::module_with_offline_base(Address base) const {
+const Module& PostMortem::module_with_offline_base(Address base) const {
return lookup_module(offline_bases, base);
}
-Symbol Repo::symbol_from_buffer(const SymbolInfo& impl) const {
+Symbol PostMortem::symbol_from_buffer(const SymbolInfo& impl) const {
return symbol_from_buffer(module_with_offline_base(impl.get_offline_base()), impl);
}
-Symbol Repo::symbol_from_buffer(const Module& module, const SymbolInfo& impl) {
+Symbol PostMortem::symbol_from_buffer(const Module& module, const SymbolInfo& impl) {
return {module.translate_offline_address(impl.get_offline_address()), impl};
}
-Address Repo::address_online_to_offline(Address online) const {
+Address PostMortem::address_online_to_offline(Address online) const {
return module_from_online_address(online).translate_online_address(online);
}
-Address Repo::address_offline_to_online(Address offline) const {
+Address PostMortem::address_offline_to_online(Address offline) const {
return module_from_offline_address(offline).translate_offline_address(offline);
}
-const Module& Repo::module_from_online_address(Address online) const {
+const Module& PostMortem::module_from_online_address(Address online) const {
return guess_module(online_bases, online);
}
-const Module& Repo::module_from_offline_address(Address offline) const {
+const Module& PostMortem::module_from_offline_address(Address offline) const {
return guess_module(offline_bases, offline);
}
diff --git a/utils/addr2name.cpp b/utils/addr2name.cpp
index 611e02b..5a8cbc3 100644
--- a/utils/addr2name.cpp
+++ b/utils/addr2name.cpp
@@ -62,17 +62,19 @@ void dump_error(const std::exception& e) {
std::cerr << "error: " << e.what() << '\n';
}
-void resolve_symbol(const winapi::Repo& repo, winapi::Address address, bool lines = false) {
+void resolve_symbol(const winapi::PostMortem& analysis,
+ winapi::Address address,
+ bool lines = false) {
try {
- const auto symbol = repo.resolve_symbol(address);
- const auto& module = repo.module_with_offline_base(symbol.get_offline_base());
+ const auto symbol = analysis.resolve_symbol(address);
+ const auto& module = analysis.module_with_offline_base(symbol.get_offline_base());
std::ostringstream msg;
msg << format_symbol(module, symbol);
if (lines) {
try {
- const auto line_info = repo.resolve_line(address);
+ const auto line_info = analysis.resolve_line(address);
msg << ' ' << format_line_info(line_info);
} catch (const std::exception& e) {
dump_error(e);
@@ -104,13 +106,13 @@ int main(int argc, char* argv[]) {
return 0;
}
- winapi::Repo repo;
+ winapi::PostMortem analysis;
for (const auto& pdb : settings.pdbs)
- repo.add_pdb(pdb.online_base, pdb.path);
+ analysis.add_pdb(pdb.online_base, pdb.path);
for (const auto& address : settings.addresses)
- resolve_symbol(repo, address, settings.lines);
+ resolve_symbol(analysis, address, settings.lines);
} catch (const std::exception& e) {
dump_error(e);
return 1;
diff --git a/utils/name2addr.cpp b/utils/name2addr.cpp
index db07c3a..c113a9a 100644
--- a/utils/name2addr.cpp
+++ b/utils/name2addr.cpp
@@ -42,9 +42,9 @@ void dump_error(const std::exception& e) {
std::cerr << "error: " << e.what() << '\n';
}
-void resolve_symbol(const winapi::Repo& repo, const std::string& name) {
+void resolve_symbol(const winapi::PostMortem& analysis, const std::string& name) {
try {
- const auto address = repo.resolve_symbol(name).get_online_address();
+ const auto address = analysis.resolve_symbol(name).get_online_address();
std::cout << winapi::format_address(address) << '\n';
} catch (const std::exception& e) {
dump_error(e);
@@ -70,13 +70,13 @@ int main(int argc, char* argv[]) {
return 0;
}
- winapi::Repo repo;
+ winapi::PostMortem analysis;
for (const auto& pdb : settings.pdbs)
- repo.add_pdb(pdb.online_base, pdb.path);
+ analysis.add_pdb(pdb.online_base, pdb.path);
for (const auto& name : settings.names)
- resolve_symbol(repo, name);
+ resolve_symbol(analysis, name);
} catch (const std::exception& e) {
dump_error(e);
return 1;