aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-05-29 01:11:44 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-05-29 01:11:44 +0300
commite2961032fd1896899f688cdcdf41f23ed71e3e82 (patch)
tree0ce11fa3137f027866e91bdc7cc71ff36fe3f6f8 /utils
parentinclude/pdb/ -> include/winapi/debug/ (diff)
downloadwinapi-debug-e2961032fd1896899f688cdcdf41f23ed71e3e82.tar.gz
winapi-debug-e2961032fd1896899f688cdcdf41f23ed71e3e82.zip
namespace pdb -> namespace winapi
Diffstat (limited to 'utils')
-rw-r--r--utils/addr2name.cpp21
-rw-r--r--utils/enum_symbols.cpp22
-rw-r--r--utils/name2addr.cpp6
-rw-r--r--utils/pdb_descr.hpp14
4 files changed, 33 insertions, 30 deletions
diff --git a/utils/addr2name.cpp b/utils/addr2name.cpp
index cffc756..611e02b 100644
--- a/utils/addr2name.cpp
+++ b/utils/addr2name.cpp
@@ -27,9 +27,10 @@ public:
"pdb", po::value<std::vector<PDB>>(&pdbs)->value_name("ADDR,PATH"), "load a PDB file");
visible.add_options()(
"lines,l", po::bool_switch(&lines), "try to resolve source files & line numbers");
- hidden.add_options()("address",
- po::value<std::vector<pdb::Address>>(&addresses)->value_name("ADDR"),
- "add an address to resolve");
+ hidden.add_options()(
+ "address",
+ po::value<std::vector<winapi::Address>>(&addresses)->value_name("ADDR"),
+ "add an address to resolve");
positional.add("address", -1);
}
@@ -38,20 +39,20 @@ public:
}
std::vector<PDB> pdbs;
- std::vector<pdb::Address> addresses;
+ std::vector<winapi::Address> addresses;
bool lines = false;
};
-std::string format_symbol(const pdb::Module& module, const pdb::Symbol& symbol) {
+std::string format_symbol(const winapi::Module& module, const winapi::Symbol& symbol) {
std::ostringstream oss;
oss << module.get_name() << '!' << symbol.get_name();
const auto displacement = symbol.get_displacement();
if (displacement)
- oss << '+' << pdb::format_address(displacement);
+ oss << '+' << winapi::format_address(displacement);
return oss.str();
}
-std::string format_line_info(const pdb::LineInfo& line_info) {
+std::string format_line_info(const winapi::LineInfo& line_info) {
std::ostringstream oss;
oss << '[' << line_info.file_path << " @ " << line_info.line_number << ']';
return oss.str();
@@ -61,7 +62,7 @@ void dump_error(const std::exception& e) {
std::cerr << "error: " << e.what() << '\n';
}
-void resolve_symbol(const pdb::Repo& repo, pdb::Address address, bool lines = false) {
+void resolve_symbol(const winapi::Repo& repo, 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());
@@ -81,7 +82,7 @@ void resolve_symbol(const pdb::Repo& repo, pdb::Address address, bool lines = fa
std::cout << msg.str() << '\n';
} catch (const std::exception& e) {
dump_error(e);
- std::cout << pdb::format_address(address) << '\n';
+ std::cout << winapi::format_address(address) << '\n';
}
}
@@ -103,7 +104,7 @@ int main(int argc, char* argv[]) {
return 0;
}
- pdb::Repo repo;
+ winapi::Repo repo;
for (const auto& pdb : settings.pdbs)
repo.add_pdb(pdb.online_base, pdb.path);
diff --git a/utils/enum_symbols.cpp b/utils/enum_symbols.cpp
index 0eea104..4950a82 100644
--- a/utils/enum_symbols.cpp
+++ b/utils/enum_symbols.cpp
@@ -26,7 +26,7 @@ public:
"load a PDB file");
visible.add_options()(
"functions",
- po::value<pdb::symbol::Tag>(&tag)->implicit_value(function_tag)->zero_tokens(),
+ po::value<winapi::symbol::Tag>(&tag)->implicit_value(function_tag)->zero_tokens(),
"only list functions");
visible.add_options()(
"mask", po::value<std::string>(&symbol_mask)->value_name("MASK"), "symbol mask");
@@ -40,20 +40,22 @@ public:
bool type_specified() const { return tag != reserved_tag; }
- pdb::Symbol::Type get_type() const { return static_cast<pdb::Symbol::Type>(tag); }
+ winapi::Symbol::Type get_type() const { return static_cast<winapi::Symbol::Type>(tag); }
std::string get_mask() const { return symbol_mask; }
private:
- static constexpr auto reserved_tag = static_cast<pdb::symbol::Tag>(pdb::Symbol::Type::RESERVED);
- static constexpr auto function_tag = static_cast<pdb::symbol::Tag>(pdb::Symbol::Type::Function);
+ static constexpr auto reserved_tag =
+ static_cast<winapi::symbol::Tag>(winapi::Symbol::Type::RESERVED);
+ static constexpr auto function_tag =
+ static_cast<winapi::symbol::Tag>(winapi::Symbol::Type::Function);
- pdb::symbol::Tag tag = reserved_tag;
- std::string symbol_mask{pdb::DbgHelp::all_symbols};
+ winapi::symbol::Tag tag = reserved_tag;
+ std::string symbol_mask{winapi::DbgHelp::all_symbols};
};
-constexpr pdb::symbol::Tag EnumSymbols::reserved_tag;
-constexpr pdb::symbol::Tag EnumSymbols::function_tag;
+constexpr winapi::symbol::Tag EnumSymbols::reserved_tag;
+constexpr winapi::symbol::Tag EnumSymbols::function_tag;
} // namespace
@@ -73,12 +75,12 @@ int main(int argc, char* argv[]) {
return 0;
}
- const auto dbghelp = pdb::DbgHelp::post_mortem();
+ const auto dbghelp = winapi::DbgHelp::post_mortem();
for (const auto& pdb : settings.pdbs) {
const auto id = dbghelp.load_pdb(pdb);
- dbghelp.enum_symbols(id, settings.get_mask(), [&](const pdb::SymbolInfo& symbol) {
+ dbghelp.enum_symbols(id, settings.get_mask(), [&](const winapi::SymbolInfo& symbol) {
if (!settings.type_specified() || settings.get_type() == symbol.get_type())
std::cout << symbol.get_name() << '\n';
});
diff --git a/utils/name2addr.cpp b/utils/name2addr.cpp
index e90aacb..db07c3a 100644
--- a/utils/name2addr.cpp
+++ b/utils/name2addr.cpp
@@ -42,10 +42,10 @@ void dump_error(const std::exception& e) {
std::cerr << "error: " << e.what() << '\n';
}
-void resolve_symbol(const pdb::Repo& repo, const std::string& name) {
+void resolve_symbol(const winapi::Repo& repo, const std::string& name) {
try {
const auto address = repo.resolve_symbol(name).get_online_address();
- std::cout << pdb::format_address(address) << '\n';
+ std::cout << winapi::format_address(address) << '\n';
} catch (const std::exception& e) {
dump_error(e);
std::cout << name << '\n';
@@ -70,7 +70,7 @@ int main(int argc, char* argv[]) {
return 0;
}
- pdb::Repo repo;
+ winapi::Repo repo;
for (const auto& pdb : settings.pdbs)
repo.add_pdb(pdb.online_base, pdb.path);
diff --git a/utils/pdb_descr.hpp b/utils/pdb_descr.hpp
index 8619fdc..5925b93 100644
--- a/utils/pdb_descr.hpp
+++ b/utils/pdb_descr.hpp
@@ -14,7 +14,7 @@
#include <vector>
struct PDB {
- pdb::Address online_base;
+ winapi::Address online_base;
std::string path;
static PDB parse(std::string src) {
@@ -24,16 +24,16 @@ struct PDB {
if (sep_pos == std::string::npos)
boost::throw_exception(boost::program_options::invalid_option_value{src});
- pdb::Address online_base;
- if (!pdb::parse_address(online_base, src.substr(0, sep_pos)))
+ winapi::Address online_base;
+ if (!winapi::parse_address(online_base, src.substr(0, sep_pos)))
boost::throw_exception(boost::program_options::invalid_option_value{src});
return {online_base, src.substr(sep_pos + 1)};
}
- static pdb::Address parse_address(const std::string& src) {
- pdb::Address dest;
- if (!pdb::parse_address(dest, src))
+ static winapi::Address parse_address(const std::string& src) {
+ winapi::Address dest;
+ if (!winapi::parse_address(dest, src))
boost::throw_exception(boost::program_options::invalid_option_value{src});
return dest;
}
@@ -53,7 +53,7 @@ void validate(boost::any& dest,
template <typename charT>
void validate(boost::any& dest,
const std::vector<std::basic_string<charT>>& src_tokens,
- pdb::Address*,
+ winapi::Address*,
int) {
namespace po = boost::program_options;
po::validators::check_first_occurrence(dest);