summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--.clang-format9
-rw-r--r--.github/workflows/ci.yml7
-rw-r--r--include/winapi/debug/call_stack.hpp23
-rw-r--r--include/winapi/debug/dbghelp.hpp9
-rw-r--r--include/winapi/debug/module.hpp17
-rw-r--r--include/winapi/debug/symbol.hpp52
-rw-r--r--test/unit_tests/fixtures.hpp20
-rw-r--r--utils/command_line.hpp8
-rw-r--r--utils/enum_symbols.cpp12
9 files changed, 123 insertions, 34 deletions
diff --git a/.clang-format b/.clang-format
index e2ecaef..d75ff99 100644
--- a/.clang-format
+++ b/.clang-format
@@ -2,12 +2,19 @@
Language: Cpp
BasedOnStyle: Chromium
+IndentWidth: 4
+
AccessModifierOffset: -4
+AlignConsecutiveMacros: AcrossComments
+AllowShortFunctionsOnASingleLine: Empty
BinPackArguments: false
+BreakConstructorInitializers: BeforeComma
+BreakInheritanceList: BeforeComma
+BreakStringLiterals: false
ColumnLimit: 100
IncludeBlocks: Regroup
-IndentWidth: 4
SpacesBeforeTrailingComments: 1
+WrapNamespaceBodyWithEmptyLines: Always
IncludeCategories:
- Regex: '^".+'
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 60f07a4..c129778 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -14,8 +14,15 @@ jobs:
uses: actions/checkout@v6
with:
submodules: recursive
+ - name: Set up clang-format
+ uses: egor-tensin/setup-clang@v2
+ with:
+ # To use the latest clang-format features:
+ version: 22
- name: Run clang-format
uses: egor-tensin/clang-format@v1
+ with:
+ version: 22
build:
strategy:
diff --git a/include/winapi/debug/call_stack.hpp b/include/winapi/debug/call_stack.hpp
index a9a9d43..caa9226 100644
--- a/include/winapi/debug/call_stack.hpp
+++ b/include/winapi/debug/call_stack.hpp
@@ -38,12 +38,25 @@ public:
void dump(std::ostream& os, const DbgHelp&) const;
- std::size_t length() const { return _length; }
+ std::size_t length() const {
+ return _length;
+ }
- const Address* begin() const { return frames.data(); }
- const Address* cbegin() const { return begin(); }
- const Address* end() const { return begin() + _length; }
- const Address* cend() const { return end(); }
+ const Address* begin() const {
+ return frames.data();
+ }
+
+ const Address* cbegin() const {
+ return begin();
+ }
+
+ const Address* end() const {
+ return begin() + _length;
+ }
+
+ const Address* cend() const {
+ return end();
+ }
private:
CallStack() = default;
diff --git a/include/winapi/debug/dbghelp.hpp b/include/winapi/debug/dbghelp.hpp
index 8fc2cda..907c705 100644
--- a/include/winapi/debug/dbghelp.hpp
+++ b/include/winapi/debug/dbghelp.hpp
@@ -18,8 +18,13 @@ namespace winapi {
class DbgHelp {
public:
- static DbgHelp current_process() { return DbgHelp{true}; }
- static DbgHelp post_mortem() { return DbgHelp{false}; }
+ static DbgHelp current_process() {
+ return DbgHelp{true};
+ }
+
+ static DbgHelp post_mortem() {
+ return DbgHelp{false};
+ }
void swap(DbgHelp& other) noexcept;
diff --git a/include/winapi/debug/module.hpp b/include/winapi/debug/module.hpp
index 0437ddb..591bcb5 100644
--- a/include/winapi/debug/module.hpp
+++ b/include/winapi/debug/module.hpp
@@ -21,10 +21,17 @@ public:
ModuleInfo();
explicit ModuleInfo(const Impl& impl);
- explicit operator Impl&() { return impl; }
- explicit operator const Impl&() const { return impl; }
+ explicit operator Impl&() {
+ return impl;
+ }
- Address get_offline_base() const { return impl.BaseOfImage; }
+ explicit operator const Impl&() const {
+ return impl;
+ }
+
+ Address get_offline_base() const {
+ return impl.BaseOfImage;
+ }
std::string get_name() const;
@@ -39,7 +46,9 @@ public:
Module(Address online_base, const ModuleInfo& info)
: ModuleInfo{info}, online_base{online_base} {}
- Address get_online_base() const { return online_base; }
+ Address get_online_base() const {
+ return online_base;
+ }
Address translate_offline_address(Address offline) const;
Address translate_online_address(Address online) const;
diff --git a/include/winapi/debug/symbol.hpp b/include/winapi/debug/symbol.hpp
index 828a040..cefb6c2 100644
--- a/include/winapi/debug/symbol.hpp
+++ b/include/winapi/debug/symbol.hpp
@@ -39,27 +39,48 @@ public:
SymbolInfo();
explicit SymbolInfo(const Impl& impl);
- explicit operator Impl&() { return get_impl(); }
- explicit operator const Impl&() const { return get_impl(); }
+ explicit operator Impl&() {
+ return get_impl();
+ }
- Address get_displacement() const { return displacement; }
- void set_displacement(Address new_value) { displacement = new_value; }
+ explicit operator const Impl&() const {
+ return get_impl();
+ }
+
+ Address get_displacement() const {
+ return displacement;
+ }
+
+ void set_displacement(Address new_value) {
+ displacement = new_value;
+ }
std::string get_name() const;
- Address get_offline_base() const { return get_impl().ModBase; }
- Address get_offline_address() const { return get_impl().Address; }
+ Address get_offline_base() const {
+ return get_impl().ModBase;
+ }
- symbol::Tag get_tag() const { return get_impl().Tag; }
+ Address get_offline_address() const {
+ return get_impl().Address;
+ }
+
+ symbol::Tag get_tag() const {
+ return get_impl().Tag;
+ }
enum class Type : symbol::Tag {
Function = symbol::SYM_TAG_FUNCTION,
RESERVED = ULONG_MAX,
};
- Type get_type() const { return static_cast<Type>(get_tag()); }
+ Type get_type() const {
+ return static_cast<Type>(get_tag());
+ }
- bool is_function() const { return get_type() == Type::Function; }
+ bool is_function() const {
+ return get_type() == Type::Function;
+ }
private:
static constexpr std::size_t char_size = sizeof(std::remove_extent<decltype(Impl::Name)>::type);
@@ -69,8 +90,13 @@ private:
std::array<unsigned char, max_buffer_size> buffer;
Address displacement = 0;
- const Impl& get_impl() const { return *reinterpret_cast<const Impl*>(buffer.data()); }
- Impl& get_impl() { return *reinterpret_cast<Impl*>(buffer.data()); }
+ const Impl& get_impl() const {
+ return *reinterpret_cast<const Impl*>(buffer.data());
+ }
+
+ Impl& get_impl() {
+ return *reinterpret_cast<Impl*>(buffer.data());
+ }
};
class Symbol : public SymbolInfo {
@@ -78,7 +104,9 @@ public:
Symbol(Address online_address, const SymbolInfo& info)
: SymbolInfo{info}, online_address{online_address} {}
- Address get_online_address() const { return online_address; }
+ Address get_online_address() const {
+ return online_address;
+ }
private:
const Address online_address;
diff --git a/test/unit_tests/fixtures.hpp b/test/unit_tests/fixtures.hpp
index 8fe7e91..8233f95 100644
--- a/test/unit_tests/fixtures.hpp
+++ b/test/unit_tests/fixtures.hpp
@@ -31,7 +31,9 @@ class DbgHelp {
public:
DbgHelp(winapi::DbgHelp&& dbghelp) : dbghelp{std::move(dbghelp)} {}
- ~DbgHelp() { BOOST_TEST_MESSAGE("Cleaning up DbgHelp"); }
+ ~DbgHelp() {
+ BOOST_TEST_MESSAGE("Cleaning up DbgHelp");
+ }
const winapi::DbgHelp dbghelp;
@@ -54,11 +56,17 @@ public:
reinterpret_cast<void*>(&test_ns::baz)});
}
- static SymbolList expected_functions() { return make_qualified({"foo", "bar", "baz"}); }
+ static SymbolList expected_functions() {
+ return make_qualified({"foo", "bar", "baz"});
+ }
- static SymbolList expected_functions_full() { return add_module(expected_functions()); }
+ static SymbolList expected_functions_full() {
+ return add_module(expected_functions());
+ }
- static SymbolList expected_variables() { return make_qualified({"var"}); }
+ static SymbolList expected_variables() {
+ return make_qualified({"var"});
+ }
static SymbolList expected_symbols() {
return join(expected_functions(), expected_variables());
@@ -105,7 +113,9 @@ private:
class PostMortem : public DbgHelp {
public:
- PostMortem() : DbgHelp{init_dbghelp(false)} { load_module_pdb(); }
+ PostMortem() : DbgHelp{init_dbghelp(false)} {
+ load_module_pdb();
+ }
private:
void load_module_pdb() {
diff --git a/utils/command_line.hpp b/utils/command_line.hpp
index ebed79e..d3178f1 100644
--- a/utils/command_line.hpp
+++ b/utils/command_line.hpp
@@ -22,7 +22,9 @@ public:
virtual ~SettingsParser() = default;
- virtual const char* get_short_description() const { return "[--option VALUE]..."; }
+ virtual const char* get_short_description() const {
+ return "[--option VALUE]...";
+ }
virtual void parse(int argc, char* argv[]) {
boost::program_options::options_description all;
@@ -41,7 +43,9 @@ public:
bool exit_with_usage = false;
- void usage() const { std::cout << *this; }
+ void usage() const {
+ std::cout << *this;
+ }
void usage_error(const std::exception& e) const {
std::cerr << std::format("usage error: {}\n", e.what());
diff --git a/utils/enum_symbols.cpp b/utils/enum_symbols.cpp
index 574f0d0..645bc13 100644
--- a/utils/enum_symbols.cpp
+++ b/utils/enum_symbols.cpp
@@ -38,11 +38,17 @@ public:
std::vector<std::string> pdbs;
- bool type_specified() const { return tag != reserved_tag; }
+ bool type_specified() const {
+ return tag != reserved_tag;
+ }
- winapi::Symbol::Type get_type() const { return static_cast<winapi::Symbol::Type>(tag); }
+ winapi::Symbol::Type get_type() const {
+ return static_cast<winapi::Symbol::Type>(tag);
+ }
- std::string get_mask() const { return symbol_mask; }
+ std::string get_mask() const {
+ return symbol_mask;
+ }
private:
static constexpr auto reserved_tag =