From c8821b824e727d22f331d50365bdaf3635262e50 Mon Sep 17 00:00:00 2001 From: Kenny Date: Sat, 13 Dec 2025 19:40:50 -0800 Subject: [PATCH 1/2] Merged what left of branch --- include/validator.hpp | 3 +++ src/main.cpp | 7 ++++++- src/validator.cpp | 28 ++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/include/validator.hpp b/include/validator.hpp index 3f037df..fd6fbb9 100644 --- a/include/validator.hpp +++ b/include/validator.hpp @@ -55,6 +55,9 @@ class Validator std::optional demangle(const char* mangled); std::optional get_symbol(std::string_view name); + bool thrown_functions(std::string_view func_name); + std::vector find_thrown_functions(); + enum class CorrelateError { NoTypeinfoForFunction, // Validator has no typeinfo for this function diff --git a/src/main.cpp b/src/main.cpp index b45daec..e578515 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,7 +42,7 @@ enum class main_error : uint8_t */ struct arg_value_s { - std::string_view file_name; + std::string file_name; std::optional flag; }; @@ -128,6 +128,11 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } + for (const auto& f : val.find_thrown_functions()) { + std::println("throws: {}", + val.demangle(f.name.c_str()).value_or(f.name)); + } + // we print it but we canremove this for (const auto& m : res.value()) { auto dn = val.demangle(m.thrown.name.c_str()).value_or(m.thrown.name); diff --git a/src/validator.cpp b/src/validator.cpp index 5fbe381..0b6940c 100644 --- a/src/validator.cpp +++ b/src/validator.cpp @@ -198,4 +198,32 @@ Validator::Result Validator::analyze_exceptions(std::string_view func_name) cons return result; } +bool Validator::thrown_functions(std::string_view func_name) +{ + auto thrown_opt = find_typeinfo(func_name); + return thrown_opt.has_value() && !thrown_opt->empty(); +} + +std::vector Validator::find_thrown_functions() +{ + std::vector out; + + for (const auto& s : m_sym) { + // Only consider real functions + if (GELF_ST_TYPE(s.info) != STT_FUNC) { + continue; + } + // skip undefined / external stubs if you want + if (s.shndx == SHN_UNDEF) { + continue; + } + + if (thrown_functions(s.name)) { + out.push_back(s); + } + } + + return out; +} + } // namespace safe From ee5f0a3d73d98e0b654766350634758a8d793148 Mon Sep 17 00:00:00 2001 From: Kenny Date: Sat, 13 Dec 2025 20:30:22 -0800 Subject: [PATCH 2/2] nit tweak --- include/validator.hpp | 2 +- src/validator.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/validator.hpp b/include/validator.hpp index fd6fbb9..9099772 100644 --- a/include/validator.hpp +++ b/include/validator.hpp @@ -55,7 +55,7 @@ class Validator std::optional demangle(const char* mangled); std::optional get_symbol(std::string_view name); - bool thrown_functions(std::string_view func_name); + bool check_thrown_functions(std::string_view func_name); std::vector find_thrown_functions(); enum class CorrelateError diff --git a/src/validator.cpp b/src/validator.cpp index 0b6940c..590d6d2 100644 --- a/src/validator.cpp +++ b/src/validator.cpp @@ -198,7 +198,7 @@ Validator::Result Validator::analyze_exceptions(std::string_view func_name) cons return result; } -bool Validator::thrown_functions(std::string_view func_name) +bool Validator::check_thrown_functions(std::string_view func_name) { auto thrown_opt = find_typeinfo(func_name); return thrown_opt.has_value() && !thrown_opt->empty(); @@ -218,7 +218,7 @@ std::vector Validator::find_thrown_functions() continue; } - if (thrown_functions(s.name)) { + if (check_thrown_functions(s.name)) { out.push_back(s); } }