File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,6 +55,9 @@ class Validator
5555 std::optional<std::string> demangle (const char * mangled);
5656 std::optional<symbol_s> get_symbol (std::string_view name);
5757
58+ bool thrown_functions (std::string_view func_name);
59+ std::vector<symbol_s> find_thrown_functions ();
60+
5861 enum class CorrelateError
5962 {
6063 NoTypeinfoForFunction, // Validator has no typeinfo for this function
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ enum class main_error : uint8_t
4242 */
4343struct arg_value_s
4444{
45- std::string_view file_name;
45+ std::string file_name;
4646 std::optional<std::string_view> flag;
4747};
4848
@@ -128,6 +128,11 @@ int main(int argc, char* argv[])
128128 return EXIT_FAILURE;
129129 }
130130
131+ for (const auto & f : val.find_thrown_functions ()) {
132+ std::println (" throws: {}" ,
133+ val.demangle (f.name .c_str ()).value_or (f.name ));
134+ }
135+
131136 // we print it but we canremove this
132137 for (const auto & m : res.value ()) {
133138 auto dn = val.demangle (m.thrown .name .c_str ()).value_or (m.thrown .name );
Original file line number Diff line number Diff line change @@ -198,4 +198,32 @@ Validator::Result Validator::analyze_exceptions(std::string_view func_name) cons
198198 return result;
199199}
200200
201+ bool Validator::thrown_functions (std::string_view func_name)
202+ {
203+ auto thrown_opt = find_typeinfo (func_name);
204+ return thrown_opt.has_value () && !thrown_opt->empty ();
205+ }
206+
207+ std::vector<symbol_s> Validator::find_thrown_functions ()
208+ {
209+ std::vector<symbol_s> out;
210+
211+ for (const auto & s : m_sym) {
212+ // Only consider real functions
213+ if (GELF_ST_TYPE (s.info ) != STT_FUNC) {
214+ continue ;
215+ }
216+ // skip undefined / external stubs if you want
217+ if (s.shndx == SHN_UNDEF) {
218+ continue ;
219+ }
220+
221+ if (thrown_functions (s.name )) {
222+ out.push_back (s);
223+ }
224+ }
225+
226+ return out;
227+ }
228+
201229} // namespace safe
You can’t perform that action at this time.
0 commit comments