aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--include/winapi/debug/address.hpp4
-rw-r--r--include/winapi/debug/call_stack.hpp4
-rw-r--r--include/winapi/debug/dbghelp.hpp6
-rw-r--r--include/winapi/debug/module.hpp4
-rw-r--r--include/winapi/debug/repo.hpp4
-rw-r--r--include/winapi/debug/symbol.hpp4
-rw-r--r--src/call_stack.cpp4
-rw-r--r--src/dbghelp.cpp8
-rw-r--r--src/module.cpp4
-rw-r--r--src/repo.cpp4
-rw-r--r--src/symbol.cpp4
-rw-r--r--test/test_lib.cpp12
-rw-r--r--test/unit_tests/call_stack.cpp17
-rw-r--r--test/unit_tests/dbghelp.cpp2
-rw-r--r--test/unit_tests/fixtures.hpp14
-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
19 files changed, 81 insertions, 77 deletions
diff --git a/include/winapi/debug/address.hpp b/include/winapi/debug/address.hpp
index 3d7acd6..1370ed4 100644
--- a/include/winapi/debug/address.hpp
+++ b/include/winapi/debug/address.hpp
@@ -10,7 +10,7 @@
#include <sstream>
#include <string>
-namespace pdb {
+namespace winapi {
typedef DWORD64 Address;
@@ -31,4 +31,4 @@ inline bool parse_address(Address& dest, const std::string& src) {
return iss >> dest && !iss.get(c);
}
-} // namespace pdb
+} // namespace winapi
diff --git a/include/winapi/debug/call_stack.hpp b/include/winapi/debug/call_stack.hpp
index 30f642c..e5b8c41 100644
--- a/include/winapi/debug/call_stack.hpp
+++ b/include/winapi/debug/call_stack.hpp
@@ -16,7 +16,7 @@
#include <ostream>
#include <string>
-namespace pdb {
+namespace winapi {
class CallStack {
public:
@@ -50,4 +50,4 @@ private:
CallStack() = default;
};
-} // namespace pdb
+} // namespace winapi
diff --git a/include/winapi/debug/dbghelp.hpp b/include/winapi/debug/dbghelp.hpp
index 6965823..fb179f3 100644
--- a/include/winapi/debug/dbghelp.hpp
+++ b/include/winapi/debug/dbghelp.hpp
@@ -14,7 +14,7 @@
#include <functional>
#include <string>
-namespace pdb {
+namespace winapi {
class DbgHelp {
public:
@@ -60,12 +60,12 @@ inline void swap(DbgHelp& a, DbgHelp& b) noexcept {
a.swap(b);
}
-} // namespace pdb
+} // namespace winapi
namespace std {
template <>
-inline void swap(pdb::DbgHelp& a, pdb::DbgHelp& b) noexcept {
+inline void swap(winapi::DbgHelp& a, winapi::DbgHelp& b) noexcept {
a.swap(b);
}
diff --git a/include/winapi/debug/module.hpp b/include/winapi/debug/module.hpp
index 5cfa69d..767aab9 100644
--- a/include/winapi/debug/module.hpp
+++ b/include/winapi/debug/module.hpp
@@ -12,7 +12,7 @@
#include <string>
-namespace pdb {
+namespace winapi {
class ModuleInfo {
public:
@@ -51,4 +51,4 @@ private:
const Address online_base;
};
-} // namespace pdb
+} // namespace winapi
diff --git a/include/winapi/debug/repo.hpp b/include/winapi/debug/repo.hpp
index 3b194ff..8ee7fde 100644
--- a/include/winapi/debug/repo.hpp
+++ b/include/winapi/debug/repo.hpp
@@ -17,7 +17,7 @@
#include <string>
#include <unordered_set>
-namespace pdb {
+namespace winapi {
class Repo {
public:
@@ -55,4 +55,4 @@ private:
std::map<Address, const Module&> offline_bases;
};
-} // namespace pdb
+} // namespace winapi
diff --git a/include/winapi/debug/symbol.hpp b/include/winapi/debug/symbol.hpp
index 47e4fb1..a46e9bb 100644
--- a/include/winapi/debug/symbol.hpp
+++ b/include/winapi/debug/symbol.hpp
@@ -17,7 +17,7 @@
#include <string>
#include <type_traits>
-namespace pdb {
+namespace winapi {
namespace symbol {
// MinGW-w64 (as of version 7.0) doesn't have SymTagEnum
@@ -94,4 +94,4 @@ public:
const unsigned long line_number;
};
-} // namespace pdb
+} // namespace winapi
diff --git a/src/call_stack.cpp b/src/call_stack.cpp
index f6ac0f9..30abaad 100644
--- a/src/call_stack.cpp
+++ b/src/call_stack.cpp
@@ -16,7 +16,7 @@
#include <string>
#include <system_error>
-namespace pdb {
+namespace winapi {
namespace {
template <typename T>
@@ -112,4 +112,4 @@ void CallStack::dump(std::ostream& os, const DbgHelp& dbghelp) const {
});
}
-} // namespace pdb
+} // namespace winapi
diff --git a/src/dbghelp.cpp b/src/dbghelp.cpp
index f645eb4..46905c5 100644
--- a/src/dbghelp.cpp
+++ b/src/dbghelp.cpp
@@ -18,7 +18,7 @@
#include <string>
#include <vector>
-namespace pdb {
+namespace winapi {
namespace {
void set_dbghelp_options() {
@@ -162,7 +162,7 @@ ModuleInfo DbgHelp::resolve_module(Address offline) const {
void DbgHelp::enum_symbols(const ModuleInfo& module,
const std::string& mask,
const OnSymbol& callback) const {
- pdb::enum_symbols(id, module.get_offline_base(), mask, callback);
+ winapi::enum_symbols(id, module.get_offline_base(), mask, callback);
}
void DbgHelp::enum_symbols(const ModuleInfo& module, const OnSymbol& callback) const {
@@ -170,7 +170,7 @@ void DbgHelp::enum_symbols(const ModuleInfo& module, const OnSymbol& callback) c
}
void DbgHelp::enum_symbols(const std::string& mask, const OnSymbol& callback) const {
- pdb::enum_symbols(id, 0, mask, callback);
+ winapi::enum_symbols(id, 0, mask, callback);
}
void DbgHelp::enum_symbols(const OnSymbol& callback) const {
@@ -210,4 +210,4 @@ LineInfo DbgHelp::resolve_line(Address offline) const {
return LineInfo{impl};
}
-} // namespace pdb
+} // namespace winapi
diff --git a/src/module.cpp b/src/module.cpp
index bb5a7a5..d676151 100644
--- a/src/module.cpp
+++ b/src/module.cpp
@@ -12,7 +12,7 @@
#include <stdexcept>
#include <string>
-namespace pdb {
+namespace winapi {
ModuleInfo::ModuleInfo() : ModuleInfo{create_impl()} {}
@@ -72,4 +72,4 @@ std::string Module::invalid_online_address(Address online) const {
return oss.str();
}
-} // namespace pdb
+} // namespace winapi
diff --git a/src/repo.cpp b/src/repo.cpp
index b186178..24d9e59 100644
--- a/src/repo.cpp
+++ b/src/repo.cpp
@@ -12,7 +12,7 @@
#include <string>
#include <utility>
-namespace pdb {
+namespace winapi {
namespace {
std::string pdb_already_loaded(Address online_base, const std::string& path) {
@@ -168,4 +168,4 @@ const Module& Repo::module_from_offline_address(Address offline) const {
return guess_module(offline_bases, offline);
}
-} // namespace pdb
+} // namespace winapi
diff --git a/src/symbol.cpp b/src/symbol.cpp
index 27e93b5..2f7638d 100644
--- a/src/symbol.cpp
+++ b/src/symbol.cpp
@@ -16,7 +16,7 @@
#include <string>
#include <type_traits>
-namespace pdb {
+namespace winapi {
namespace {
std::size_t calc_size(const SymbolInfo::Impl& impl) {
@@ -59,4 +59,4 @@ std::string SymbolInfo::get_name() const {
LineInfo::LineInfo(const Impl& impl)
: file_path{winapi::narrow(impl.FileName)}, line_number{cast_line_number(impl.LineNumber)} {}
-} // namespace pdb
+} // namespace winapi
diff --git a/test/test_lib.cpp b/test/test_lib.cpp
index e361ea4..bdb7bbf 100644
--- a/test/test_lib.cpp
+++ b/test/test_lib.cpp
@@ -18,13 +18,13 @@ namespace test_ns {
namespace {
void do_print_call_stack() {
- const auto dbghelp = pdb::DbgHelp::current_process();
- const auto call_stack = pdb::CallStack::capture();
+ const auto dbghelp = winapi::DbgHelp::current_process();
+ const auto call_stack = winapi::CallStack::capture();
call_stack.dump(std::cout, dbghelp);
}
void do_throw_call_stack() {
- throw pdb::CallStack::capture();
+ throw winapi::CallStack::capture();
}
} // namespace
@@ -32,17 +32,17 @@ void do_throw_call_stack() {
volatile int var = 42;
void baz(F f) {
- std::cout << "baz " << pdb::format_address(reinterpret_cast<void*>(&baz)) << '\n';
+ std::cout << "baz " << winapi::format_address(reinterpret_cast<void*>(&baz)) << '\n';
f();
}
void bar(F f) {
- std::cout << "bar " << pdb::format_address(reinterpret_cast<void*>(&bar)) << '\n';
+ std::cout << "bar " << winapi::format_address(reinterpret_cast<void*>(&bar)) << '\n';
baz(f);
}
void foo(F f) {
- std::cout << "foo " << pdb::format_address(reinterpret_cast<void*>(&foo)) << '\n';
+ std::cout << "foo " << winapi::format_address(reinterpret_cast<void*>(&foo)) << '\n';
bar(f);
}
diff --git a/test/unit_tests/call_stack.cpp b/test/unit_tests/call_stack.cpp
index 968555a..2f022c6 100644
--- a/test/unit_tests/call_stack.cpp
+++ b/test/unit_tests/call_stack.cpp
@@ -21,7 +21,7 @@ BOOST_FIXTURE_TEST_SUITE(call_stack_tests, CurrentProcess)
BOOST_AUTO_TEST_CASE(call_stack) {
try {
test_ns::throw_call_stack();
- } catch (const pdb::CallStack& call_stack) {
+ } catch (const winapi::CallStack& call_stack) {
// First, check that the call stack has been caught.
BOOST_TEST(true, "Caught the call stack");
@@ -32,23 +32,23 @@ BOOST_AUTO_TEST_CASE(call_stack) {
BOOST_TEST_MESSAGE("Call stack:");
for (const auto& addr : call_stack) {
pretty.emplace_back(call_stack.pretty_print_address(dbghelp, addr));
- BOOST_TEST_MESSAGE('\t' << pdb::format_address(addr) << ' ' << pretty.back());
+ BOOST_TEST_MESSAGE('\t' << winapi::format_address(addr) << ' ' << pretty.back());
}
// Second, resolve the symbols:
- std::vector<boost::optional<pdb::SymbolInfo>> symbols;
+ std::vector<boost::optional<winapi::SymbolInfo>> symbols;
symbols.reserve(call_stack.length);
BOOST_TEST_MESSAGE("Resolved symbols:");
for (const auto& addr : call_stack) {
try {
auto symbol = dbghelp.resolve_symbol(addr);
- BOOST_TEST_MESSAGE('\t' << pdb::format_address(symbol.get_offline_address()) << ' '
- << symbol.get_name());
+ BOOST_TEST_MESSAGE('\t' << winapi::format_address(symbol.get_offline_address())
+ << ' ' << symbol.get_name());
symbols.emplace_back(std::move(symbol));
} catch (const std::system_error& e) {
symbols.emplace_back(boost::none);
- BOOST_TEST_MESSAGE('\t' << pdb::format_address(addr)
+ BOOST_TEST_MESSAGE('\t' << winapi::format_address(addr)
<< " Couldn't resolve symbol: " << e.what());
}
}
@@ -57,14 +57,15 @@ BOOST_AUTO_TEST_CASE(call_stack) {
// Third, check that the expected function addresses are in the call stack.
const auto expected = expected_function_addresses();
- const auto check = [&](pdb::Address addr) {
+ const auto check = [&](winapi::Address addr) {
for (const auto& symbol : symbols)
if (symbol && symbol->get_offline_address() == addr)
return true;
return false;
};
for (const auto& addr : expected) {
- BOOST_TEST(check(addr), "Function frame captured: " << pdb::format_address(addr));
+ BOOST_TEST(check(addr),
+ "Function frame captured: " << winapi::format_address(addr));
}
}
diff --git a/test/unit_tests/dbghelp.cpp b/test/unit_tests/dbghelp.cpp
index 293c8b1..24beda1 100644
--- a/test/unit_tests/dbghelp.cpp
+++ b/test/unit_tests/dbghelp.cpp
@@ -21,7 +21,7 @@ BOOST_AUTO_TEST_CASE(enum_symbols) {
// First, enumerate all the symbols:
std::vector<std::string> all_symbols;
{
- const auto callback = [&all_symbols](const pdb::SymbolInfo& symbol) {
+ const auto callback = [&all_symbols](const winapi::SymbolInfo& symbol) {
all_symbols.emplace_back(symbol.get_name());
};
dbghelp.enum_symbols(callback);
diff --git a/test/unit_tests/fixtures.hpp b/test/unit_tests/fixtures.hpp
index 3da2b3b..f9f9872 100644
--- a/test/unit_tests/fixtures.hpp
+++ b/test/unit_tests/fixtures.hpp
@@ -30,11 +30,11 @@ Set<T> join(Set<T>&& xs, Set<T>&& ys) {
class DbgHelp {
public:
- DbgHelp(pdb::DbgHelp&& dbghelp) : dbghelp{std::move(dbghelp)} {}
+ DbgHelp(winapi::DbgHelp&& dbghelp) : dbghelp{std::move(dbghelp)} {}
~DbgHelp() { BOOST_TEST_MESSAGE("Cleaning up DbgHelp"); }
- const pdb::DbgHelp dbghelp;
+ const winapi::DbgHelp dbghelp;
static const std::string& get_module_name() {
static const std::string name{"test_lib"};
@@ -47,7 +47,7 @@ public:
}
typedef Set<std::string> SymbolList;
- typedef Set<pdb::Address> AddressList;
+ typedef Set<winapi::Address> AddressList;
static AddressList expected_function_addresses() {
return cast({reinterpret_cast<void*>(&test_ns::foo),
@@ -66,12 +66,12 @@ public:
}
protected:
- static pdb::DbgHelp init_dbghelp(bool current_process) {
+ static winapi::DbgHelp init_dbghelp(bool current_process) {
BOOST_TEST_MESSAGE("Initializing DbgHelp");
if (current_process) {
- return pdb::DbgHelp::current_process();
+ return winapi::DbgHelp::current_process();
} else {
- return pdb::DbgHelp::post_mortem();
+ return winapi::DbgHelp::post_mortem();
}
}
@@ -79,7 +79,7 @@ private:
static AddressList cast(Set<void*>&& fs) {
AddressList addresses;
for (auto&& f : fs) {
- addresses.emplace(reinterpret_cast<pdb::Address>(f));
+ addresses.emplace(reinterpret_cast<winapi::Address>(f));
}
return addresses;
}
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);