From 9991c3526cd0d4a773e17064327fd41fd091129d Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 13 Jun 2026 19:26:04 +0200 Subject: finally, perfect .clang-format settings? --- src/dbghelp.cpp | 33 ++++++++++++++++++++------------- src/module.cpp | 20 ++++++++++++-------- src/post_mortem.cpp | 27 +++++++++++++++++---------- src/utils/addr2name.cpp | 17 +++++++++++------ src/utils/command_line.hpp | 12 +++++++----- src/utils/enum_symbols.cpp | 12 +++++++----- src/utils/name2addr.cpp | 11 +++++++---- src/utils/pdb_descr.hpp | 20 ++++++++++++-------- 8 files changed, 93 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/dbghelp.cpp b/src/dbghelp.cpp index 20f23c3..77509af 100644 --- a/src/dbghelp.cpp +++ b/src/dbghelp.cpp @@ -45,7 +45,8 @@ Address gen_next_offline_base(std::size_t pdb_size) { const auto max_addr = std::numeric_limits::max(); if (max_addr - next_offline_base < pdb_size) throw std::runtime_error{ - "no more PDB files can be added, the internal address space is exhausted"}; + "no more PDB files can be added, the internal address space is exhausted" + }; next_offline_base += pdb_size; return base; @@ -79,15 +80,19 @@ BOOL CALLBACK enum_symbols_callback(SYMBOL_INFOW* info, ULONG, VOID* raw_callbac return TRUE; } -void enum_symbols(HANDLE id, - Address module_base, - std::string_view mask, - const DbgHelp::OnSymbol& callback) { - if (!SymEnumSymbolsW(id, - module_base, - winapi::widen(mask).c_str(), - &enum_symbols_callback, - const_cast(&callback))) +void enum_symbols( + HANDLE id, + Address module_base, + std::string_view mask, + const DbgHelp::OnSymbol& callback +) { + if (!SymEnumSymbolsW( + id, + module_base, + winapi::widen(mask).c_str(), + &enum_symbols_callback, + const_cast(&callback) + )) throw winapi::error::windows(GetLastError(), "SymEnumSymbolsW"); } @@ -159,9 +164,11 @@ ModuleInfo DbgHelp::resolve_module(Address offline) const { return get_module_info(id, offline); } -void DbgHelp::enum_symbols(const ModuleInfo& module, - std::string_view mask, - const OnSymbol& callback) const { +void DbgHelp::enum_symbols( + const ModuleInfo& module, + std::string_view mask, + const OnSymbol& callback +) const { winapi::enum_symbols(id, module.get_offline_base(), mask, callback); } diff --git a/src/module.cpp b/src/module.cpp index ae4a95f..ca76cf5 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -59,17 +59,21 @@ Address Module::translate_online_address(Address online) const { } std::string Module::invalid_offline_address(Address offline) const { - return std::format("offline address {} doesn't belong to module {} (base offline address {})", - address::format(offline), - get_name(), - address::format(get_offline_base())); + return std::format( + "offline address {} doesn't belong to module {} (base offline address {})", + address::format(offline), + get_name(), + address::format(get_offline_base()) + ); } std::string Module::invalid_online_address(Address online) const { - return std::format("online address {} doesn't belong to module {} (base online address {})", - address::format(online), - get_name(), - address::format(get_online_base())); + return std::format( + "online address {} doesn't belong to module {} (base online address {})", + address::format(online), + get_name(), + address::format(get_online_base()) + ); } } // namespace winapi diff --git a/src/post_mortem.cpp b/src/post_mortem.cpp index 84da809..e7a1e8e 100644 --- a/src/post_mortem.cpp +++ b/src/post_mortem.cpp @@ -16,9 +16,11 @@ namespace winapi { namespace { std::string pdb_already_loaded(Address online_base, std::string_view path) { - return std::format("module with online base address {} has already been loaded: {}", - address::format(online_base), - path); + return std::format( + "module with online base address {} has already been loaded: {}", + address::format(online_base), + path + ); } std::string pdb_already_loaded(std::string_view path) { @@ -28,7 +30,8 @@ std::string pdb_already_loaded(std::string_view path) { std::string offline_base_already_used(Address base) { return std::format( "module with offline base address {} has already been loaded (shouldn't happen)", - address::format(base)); + address::format(base) + ); } std::string module_not_found(Address base) { @@ -36,13 +39,16 @@ std::string module_not_found(Address base) { } std::string guess_module_no_modules(Address pivot) { - return std::format("couldn't select a module for address {}: no modules have been loaded yet", - address::format(pivot)); + return std::format( + "couldn't select a module for address {}: no modules have been loaded yet", + address::format(pivot) + ); } std::string guess_module_address_too_low(Address pivot) { - return std::format("couldn't select a module for address {}: it's too low", - address::format(pivot)); + return std::format( + "couldn't select a module for address {}: it's too low", address::format(pivot) + ); } template @@ -111,8 +117,9 @@ void PostMortem::enum_symbols(Address offline_base, const OnSymbol& callback) co } void PostMortem::enum_symbols(const Module& module, const OnSymbol& callback) const { - dbghelp.enum_symbols( - module, [&](const SymbolInfo& impl) { callback(symbol_from_buffer(module, impl)); }); + dbghelp.enum_symbols(module, [&](const SymbolInfo& impl) { + callback(symbol_from_buffer(module, impl)); + }); } Symbol PostMortem::resolve_symbol(Address online) const { diff --git a/src/utils/addr2name.cpp b/src/utils/addr2name.cpp index 98b53b9..28cc464 100644 --- a/src/utils/addr2name.cpp +++ b/src/utils/addr2name.cpp @@ -25,13 +25,16 @@ public: namespace po = boost::program_options; visible.add_options()( - "pdb", po::value>(&pdbs)->value_name("ADDR,PATH"), "load a PDB file"); + "pdb", po::value>(&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"); + "lines,l", po::bool_switch(&lines), "try to resolve source files & line numbers" + ); hidden.add_options()( "address", po::value>(&addresses)->value_name("ADDR"), - "add an address to resolve"); + "add an address to resolve" + ); positional.add("address", -1); } @@ -60,9 +63,11 @@ void dump_error(const std::exception& e) { std::cerr << std::format("error: {}\n", e.what()); } -void resolve_symbol(const winapi::PostMortem& analysis, - winapi::Address address, - bool lines = false) { +void resolve_symbol( + const winapi::PostMortem& analysis, + winapi::Address address, + bool lines = false +) { try { const auto symbol = analysis.resolve_symbol(address); const auto& module = analysis.module_with_offline_base(symbol.get_offline_base()); diff --git a/src/utils/command_line.hpp b/src/utils/command_line.hpp index d3178f1..434e6e8 100644 --- a/src/utils/command_line.hpp +++ b/src/utils/command_line.hpp @@ -30,11 +30,13 @@ public: boost::program_options::options_description all; all.add(hidden).add(visible); boost::program_options::variables_map vm; - boost::program_options::store(boost::program_options::command_line_parser{argc, argv} - .options(all) - .positional(positional) - .run(), - vm); + boost::program_options::store( + boost::program_options::command_line_parser{argc, argv} + .options(all) + .positional(positional) + .run(), + vm + ); if (vm.count("help")) exit_with_usage = true; else diff --git a/src/utils/enum_symbols.cpp b/src/utils/enum_symbols.cpp index 645bc13..9ce11e6 100644 --- a/src/utils/enum_symbols.cpp +++ b/src/utils/enum_symbols.cpp @@ -21,15 +21,17 @@ public: explicit EnumSymbols(int argc, char** argv) : SettingsParser{argc, argv} { namespace po = boost::program_options; - visible.add_options()("pdb", - po::value>(&pdbs)->value_name("PATH"), - "load a PDB file"); + visible.add_options()( + "pdb", po::value>(&pdbs)->value_name("PATH"), "load a PDB file" + ); visible.add_options()( "functions", po::value(&tag)->implicit_value(function_tag)->zero_tokens(), - "only list functions"); + "only list functions" + ); visible.add_options()( - "mask", po::value(&symbol_mask)->value_name("MASK"), "symbol mask"); + "mask", po::value(&symbol_mask)->value_name("MASK"), "symbol mask" + ); } const char* get_short_description() const override { diff --git a/src/utils/name2addr.cpp b/src/utils/name2addr.cpp index d253aa9..2988c26 100644 --- a/src/utils/name2addr.cpp +++ b/src/utils/name2addr.cpp @@ -24,10 +24,13 @@ public: namespace po = boost::program_options; visible.add_options()( - "pdb", po::value>(&pdbs)->value_name("ADDR,PATH"), "load a PDB file"); - hidden.add_options()("name", - po::value>(&names)->value_name("NAME"), - "add a name to resolve"); + "pdb", po::value>(&pdbs)->value_name("ADDR,PATH"), "load a PDB file" + ); + hidden.add_options()( + "name", + po::value>(&names)->value_name("NAME"), + "add a name to resolve" + ); positional.add("name", -1); } diff --git a/src/utils/pdb_descr.hpp b/src/utils/pdb_descr.hpp index c2e720a..586f73a 100644 --- a/src/utils/pdb_descr.hpp +++ b/src/utils/pdb_descr.hpp @@ -39,10 +39,12 @@ struct PDB { }; template -void validate(boost::any& dest, - const std::vector>& src_tokens, - PDB*, - int) { +void validate( + boost::any& dest, + const std::vector>& src_tokens, + PDB*, + int +) { namespace po = boost::program_options; po::validators::check_first_occurrence(dest); const auto& src_token = po::validators::get_single_string(src_tokens); @@ -50,10 +52,12 @@ void validate(boost::any& dest, } template -void validate(boost::any& dest, - const std::vector>& src_tokens, - winapi::Address*, - int) { +void validate( + boost::any& dest, + const std::vector>& src_tokens, + winapi::Address*, + int +) { namespace po = boost::program_options; po::validators::check_first_occurrence(dest); const auto& src_token = po::validators::get_single_string(src_tokens); -- cgit v1.3