From 599eda0403501596242a99c0aed1df7ed9d68096 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Fri, 25 Sep 2015 16:26:29 -0400 Subject: [PATCH] Use references instead of pointers for CPU context in SimulateCrash The Windows equivalent uses references, which are better than pointers for these const non-null objects. R=scottmg@chromium.org Review URL: https://codereview.chromium.org/1368023004 . --- client/simulate_crash_mac.cc | 22 +++++++++++----------- client/simulate_crash_mac.h | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/client/simulate_crash_mac.cc b/client/simulate_crash_mac.cc index 763cb87e..1884262f 100644 --- a/client/simulate_crash_mac.cc +++ b/client/simulate_crash_mac.cc @@ -59,7 +59,7 @@ bool DeliverException(thread_t thread, exception_type_t exception, const mach_exception_data_t code, mach_msg_type_number_t code_count, - const NativeCPUContext* cpu_context, + const NativeCPUContext& cpu_context, const ExceptionPorts::ExceptionHandler& handler, bool set_state) { kern_return_t kr; @@ -81,18 +81,18 @@ bool DeliverException(thread_t thread, switch (flavor) { #if defined(ARCH_CPU_X86_FAMILY) case x86_THREAD_STATE: - state = reinterpret_cast(cpu_context); + state = reinterpret_cast(&cpu_context); state_count = x86_THREAD_STATE_COUNT; break; #if defined(ARCH_CPU_X86) case x86_THREAD_STATE32: - state = reinterpret_cast(&cpu_context->uts.ts32); - state_count = cpu_context->tsh.count; + state = reinterpret_cast(&cpu_context.uts.ts32); + state_count = cpu_context.tsh.count; break; #elif defined(ARCH_CPU_X86_64) case x86_THREAD_STATE64: - state = reinterpret_cast(&cpu_context->uts.ts64); - state_count = cpu_context->tsh.count; + state = reinterpret_cast(&cpu_context.uts.ts64); + state_count = cpu_context.tsh.count; break; #endif #else @@ -176,16 +176,16 @@ bool DeliverException(thread_t thread, } // namespace -void SimulateCrash(const NativeCPUContext* cpu_context) { +void SimulateCrash(const NativeCPUContext& cpu_context) { #if defined(ARCH_CPU_X86) - DCHECK_EQ(cpu_context->tsh.flavor, + DCHECK_EQ(cpu_context.tsh.flavor, implicit_cast(x86_THREAD_STATE32)); - DCHECK_EQ(implicit_cast(cpu_context->tsh.count), + DCHECK_EQ(implicit_cast(cpu_context.tsh.count), x86_THREAD_STATE32_COUNT); #elif defined(ARCH_CPU_X86_64) - DCHECK_EQ(cpu_context->tsh.flavor, + DCHECK_EQ(cpu_context.tsh.flavor, implicit_cast(x86_THREAD_STATE64)); - DCHECK_EQ(implicit_cast(cpu_context->tsh.count), + DCHECK_EQ(implicit_cast(cpu_context.tsh.count), x86_THREAD_STATE64_COUNT); #endif diff --git a/client/simulate_crash_mac.h b/client/simulate_crash_mac.h index 7c11cd21..e14db3c9 100644 --- a/client/simulate_crash_mac.h +++ b/client/simulate_crash_mac.h @@ -45,7 +45,7 @@ namespace crashpad { //! state flavor that the exception handler accepts. If it is not //! compatible, the correct thread state for the handler will be obtained by //! calling `thread_get_state()`. -void SimulateCrash(const NativeCPUContext* cpu_context); +void SimulateCrash(const NativeCPUContext& cpu_context); } // namespace crashpad @@ -54,7 +54,7 @@ void SimulateCrash(const NativeCPUContext* cpu_context); do { \ crashpad::NativeCPUContext cpu_context; \ crashpad::CaptureContext(&cpu_context); \ - crashpad::SimulateCrash(&cpu_context); \ + crashpad::SimulateCrash(cpu_context); \ } while (false) #endif // CRASHPAD_CLIENT_SIMULATE_CRASH_MAC_H_