Thread: define how to access PC on BSD aarch64 after 580bd2b25e

Utilities/Thread.cpp:1799:51: error: no member named 'pc' in '__mcontext'
        const bool is_executing = uptr(info->si_addr) == RIP(context);
                                                         ^~~~~~~~~~~~
Utilities/Thread.cpp:1800:62: error: no member named 'pc' in '__mcontext'
        const u32 insn = is_executing ? 0 : *reinterpret_cast<u32*>(RIP(context));
                                                                    ^~~~~~~~~~~~
Utilities/Thread.cpp:1836:90: error: no member named 'pc' in '__mcontext'
        std::string msg = fmt::format("Segfault %s location %p at %p.\n", cause, info->si_addr, RIP(context));
                                                                                                ^~~~~~~~~~~~
Utilities/Thread.cpp:1229:46: note: expanded from macro 'RIP'
 #define RIP(context) ((context)->uc_mcontext.pc)
                       ~~~~~~~~~~~~~~~~~~~~~~ ^

Based on https://github.com/mozilla/gecko-dev/commit/480b73c38c73
This commit is contained in:
Jan Beich 2022-04-24 10:16:51 +00:00 committed by Ivan
parent cd6aa0774f
commit f04655c814
1 changed files with 6 additions and 0 deletions

View File

@ -1225,6 +1225,12 @@ usz get_x64_access_size(x64_context* context, x64_op_t op, x64_reg_t reg, usz d_
#if defined(__APPLE__)
// https://github.com/bombela/backward-cpp/issues/200
#define RIP(context) ((context)->uc_mcontext->__ss.__pc)
#elif defined(__FreeBSD__)
#define RIP(context) ((context)->uc_mcontext.mc_gpregs.gp_elr)
#elif defined(__NetBSD__)
#define RIP(context) ((context)->uc_mcontext.__gregs[_REG_PC])
#elif defined(__OpenBSD__)
#define RIP(context) ((context)->sc_elr)
#else
#define RIP(context) ((context)->uc_mcontext.pc)
#endif