27 #include <sys/types.h> 48 callback(
struct dl_phdr_info *info,
size_t size,
void *
data)
52 static auto once =
false;
57 for (
int i = 0; i < info->dlpi_phnum; i++)
59 if (info->dlpi_phdr[i].p_type == PT_LOAD)
77 g_eh_frame_list[0].
addr =
reinterpret_cast<void *
>(
g_offs);
92 dl_iterate_phdr(callback,
nullptr);
94 std::stringstream eh_frame_offs_ss;
95 std::stringstream eh_frame_size_ss;
97 eh_frame_offs_ss <<
"readelf -SW /proc/" <<
getpid() <<
"/exe | grep \".eh_frame\" | grep -v \".eh_frame_hdr\" | awk '{print $4}' > offs.txt";
98 eh_frame_size_ss <<
"readelf -SW /proc/" <<
getpid() <<
"/exe | grep \".eh_frame\" | grep -v \".eh_frame_hdr\" | awk '{print $6}' > size.txt";
100 system(eh_frame_offs_ss.str().c_str());
101 system(eh_frame_size_ss.str().c_str());
103 auto &&offs_file = std::ifstream(
"offs.txt");
104 auto &&size_file = std::ifstream(
"size.txt");
106 auto &&offs_str =
std::string((std::istreambuf_iterator<char>(offs_file)), std::istreambuf_iterator<char>());
107 auto &&size_str =
std::string((std::istreambuf_iterator<char>(size_file)), std::istreambuf_iterator<char>());
109 std::remove(
"offs.txt");
110 std::remove(
"size.txt");
112 std::cout <<
view_as_pointer(std::stoull(offs_str,
nullptr, 16)) <<
'\n';
113 std::cout <<
view_as_pointer(std::stoull(size_str,
nullptr, 16)) <<
'\n';
115 g_offs += std::stoull(offs_str,
nullptr, 16);
116 g_size += std::stoull(size_str,
nullptr, 16);
131 this->test_catch_all();
132 this->test_catch_bool();
133 this->test_catch_int();
134 this->test_catch_cstr();
135 this->test_catch_string();
136 this->test_catch_exception();
137 this->test_catch_custom_exception();
138 this->test_catch_multiple_catches_per_function();
139 this->test_catch_raii();
140 this->test_catch_throw_from_stream();
141 this->test_catch_nested_throw_in_catch();
142 this->test_catch_nested_throw_outside_catch();
143 this->test_catch_nested_throw_uncaught();
144 this->test_catch_nested_throw_rethrow();
145 this->test_catch_throw_with_lots_of_register_mods();
int main(int argc, char *argv[])
int64_t unsigned long void * data
struct eh_frame_t * get_eh_frame_list() noexcept
constexpr const auto size
void uint64_t uint64_t uint64_t *rdx noexcept
#define RUN_ALL_TESTS(ut)
constexpr const auto string
eh_frame_t g_eh_frame_list[MAX_NUM_MODULES]
const void * view_as_pointer(const T val)