From 41a05f95a057bd1927a3bde1f04b250657487690 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Sun, 24 Apr 2022 10:16:51 +0000 Subject: [PATCH] Thread: define how to access PC on BSD aarch64 after 580bd2b25eba 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(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 (cherry picked from commit beccce7b45dc56aeecc106ed30b776ec20f263ee) --- Utilities/Thread.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 8690f6760610..507463d1707d 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1222,7 +1222,15 @@ usz get_x64_access_size(x64_context* context, x64_op_t op, x64_reg_t reg, usz d_ #elif defined(ARCH_ARM64) +#if 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 #endif /* ARCH_ */