From f04655c81480ae9fa0cec27f040236393bff0d5a 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 --- Utilities/Thread.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index a731e34a86..68ac417d4e 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -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