mirror of
https://github.com/chromium/crashpad.git
synced 2025-01-14 09:17:57 +08:00
[fuchsia] support general registers for arm64
Bug: fuchsia:DX-639 Change-Id: Iaf44fffc6adc11025a37f3a62676cdebff435002 Tested: CQ; `crasher` on Fuchsia device (report id 27fac91e5550ea06) Reviewed-on: https://chromium-review.googlesource.com/c/1309159 Commit-Queue: Francois Rousseau <frousseau@google.com> Reviewed-by: Joshua Peraza <jperaza@chromium.org> Reviewed-by: Scott Graham <scottmg@chromium.org>
This commit is contained in:
parent
95e97a32eb
commit
8c0d3d2c1e
@ -21,7 +21,7 @@ namespace internal {
|
||||
|
||||
#if defined(ARCH_CPU_X86_64)
|
||||
|
||||
void InitializeCPUContextX86_64(
|
||||
void InitializeCPUContextX86_64_NoFloatingPoint(
|
||||
const zx_thread_state_general_regs_t& thread_context,
|
||||
CPUContextX86_64* context) {
|
||||
memset(context, 0, sizeof(*context));
|
||||
@ -45,6 +45,36 @@ void InitializeCPUContextX86_64(
|
||||
context->rflags = thread_context.rflags;
|
||||
}
|
||||
|
||||
#elif defined(ARCH_CPU_ARM64)
|
||||
|
||||
void InitializeCPUContextARM64_NoFloatingPoint(
|
||||
const zx_thread_state_general_regs_t& thread_context,
|
||||
CPUContextARM64* context) {
|
||||
memset(context, 0, sizeof(*context));
|
||||
|
||||
// Fuchsia stores the link register (x30) on its own while Crashpad stores it
|
||||
// with the other general purpose x0-x28 and x29 frame pointer registers. So
|
||||
// we expect the size and number of elements to be off by one unit.
|
||||
static_assert(sizeof(context->regs) - sizeof(context->regs[30]) ==
|
||||
sizeof(thread_context.r),
|
||||
"registers size mismatch");
|
||||
static_assert((sizeof(context->regs) - sizeof(context->regs[30])) /
|
||||
sizeof(context->regs[0]) ==
|
||||
sizeof(thread_context.r) / sizeof(thread_context.r[0]),
|
||||
"registers number of elements mismatch");
|
||||
memcpy(&context->regs, &thread_context.r, sizeof(thread_context.r));
|
||||
context->regs[30] = thread_context.lr;
|
||||
context->sp = thread_context.sp;
|
||||
context->pc = thread_context.pc;
|
||||
|
||||
// Only the NZCV flags (bits 31 to 28 respectively) of the cpsr register are
|
||||
// readable and writable by userland on ARM64.
|
||||
constexpr uint64_t kNZCV = 0xf0000000;
|
||||
// Fuchsia uses the "cspr" terminology while Crashpad uses the "pstate"
|
||||
// terminology. For the NZCV flags, the bit layout should be the same.
|
||||
context->pstate = thread_context.cpsr & kNZCV;
|
||||
}
|
||||
|
||||
#endif // ARCH_CPU_X86_64
|
||||
|
||||
} // namespace internal
|
||||
|
@ -34,12 +34,27 @@ namespace internal {
|
||||
//!
|
||||
//! \param[in] thread_context The native thread context.
|
||||
//! \param[out] context The CPUContextX86_64 structure to initialize.
|
||||
void InitializeCPUContextX86_64(
|
||||
void InitializeCPUContextX86_64_NoFloatingPoint(
|
||||
const zx_thread_state_general_regs_t& thread_context,
|
||||
CPUContextX86_64* context);
|
||||
|
||||
#endif // ARCH_CPU_X86_64 || DOXYGEN
|
||||
|
||||
#if defined(ARCH_CPU_ARM64) || DOXYGEN
|
||||
|
||||
//! \brief Initializes a CPUContextARM64 structure from native context
|
||||
//! structures on Fuchsia.
|
||||
//!
|
||||
//! Floating point registers are currently initialized to zero.
|
||||
//!
|
||||
//! \param[in] thread_context The native thread context.
|
||||
//! \param[out] context The CPUContextARM64 structure to initialize.
|
||||
void InitializeCPUContextARM64_NoFloatingPoint(
|
||||
const zx_thread_state_general_regs_t& thread_context,
|
||||
CPUContextARM64* context);
|
||||
|
||||
#endif // ARCH_CPU_ARM64 || DOXYGEN
|
||||
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
||||
|
@ -59,13 +59,15 @@ void ExceptionSnapshotFuchsia::Initialize(
|
||||
#if defined(ARCH_CPU_X86_64)
|
||||
context_.architecture = kCPUArchitectureX86_64;
|
||||
context_.x86_64 = &context_arch_;
|
||||
// TODO(scottmg): Float context, once Fuchsia has a debug API to capture
|
||||
// floating point registers. ZX-1750 upstream.
|
||||
InitializeCPUContextX86_64(t.general_registers, context_.x86_64);
|
||||
// TODO(fuchsia/DX-642): Add float context once saved in |t|.
|
||||
InitializeCPUContextX86_64_NoFloatingPoint(t.general_registers,
|
||||
context_.x86_64);
|
||||
#elif defined(ARCH_CPU_ARM64)
|
||||
context_.architecture = kCPUArchitectureARM64;
|
||||
context_.arm64 = &context_arch_;
|
||||
// TODO(scottmg): Implement context capture for arm64.
|
||||
// TODO(fuchsia/DX-642): Add float context once saved in |t|.
|
||||
InitializeCPUContextARM64_NoFloatingPoint(t.general_registers,
|
||||
context_.arm64);
|
||||
#else
|
||||
#error Port.
|
||||
#endif
|
||||
@ -85,7 +87,6 @@ void ExceptionSnapshotFuchsia::Initialize(
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
INITIALIZATION_STATE_SET_VALID(initialized_);
|
||||
}
|
||||
|
||||
|
@ -39,13 +39,15 @@ bool ThreadSnapshotFuchsia::Initialize(
|
||||
#if defined(ARCH_CPU_X86_64)
|
||||
context_.architecture = kCPUArchitectureX86_64;
|
||||
context_.x86_64 = &context_arch_;
|
||||
// TODO(scottmg): Float context, once Fuchsia has a debug API to capture
|
||||
// floating point registers. ZX-1750 upstream.
|
||||
InitializeCPUContextX86_64(thread.general_registers, context_.x86_64);
|
||||
// TODO(fuchsia/DX-642): Add float context once saved in |thread|.
|
||||
InitializeCPUContextX86_64_NoFloatingPoint(thread.general_registers,
|
||||
context_.x86_64);
|
||||
#elif defined(ARCH_CPU_ARM64)
|
||||
context_.architecture = kCPUArchitectureARM64;
|
||||
context_.arm64 = &context_arch_;
|
||||
// TODO(scottmg): Implement context capture for arm64.
|
||||
// TODO(fuchsia/DX-642): Add float context once saved in |thread|.
|
||||
InitializeCPUContextARM64_NoFloatingPoint(thread.general_registers,
|
||||
context_.arm64);
|
||||
#else
|
||||
#error Port.
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user