mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
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 .
This commit is contained in:
parent
0758dbde9a
commit
599eda0403
@ -59,7 +59,7 @@ bool DeliverException(thread_t thread,
|
|||||||
exception_type_t exception,
|
exception_type_t exception,
|
||||||
const mach_exception_data_t code,
|
const mach_exception_data_t code,
|
||||||
mach_msg_type_number_t code_count,
|
mach_msg_type_number_t code_count,
|
||||||
const NativeCPUContext* cpu_context,
|
const NativeCPUContext& cpu_context,
|
||||||
const ExceptionPorts::ExceptionHandler& handler,
|
const ExceptionPorts::ExceptionHandler& handler,
|
||||||
bool set_state) {
|
bool set_state) {
|
||||||
kern_return_t kr;
|
kern_return_t kr;
|
||||||
@ -81,18 +81,18 @@ bool DeliverException(thread_t thread,
|
|||||||
switch (flavor) {
|
switch (flavor) {
|
||||||
#if defined(ARCH_CPU_X86_FAMILY)
|
#if defined(ARCH_CPU_X86_FAMILY)
|
||||||
case x86_THREAD_STATE:
|
case x86_THREAD_STATE:
|
||||||
state = reinterpret_cast<ConstThreadState>(cpu_context);
|
state = reinterpret_cast<ConstThreadState>(&cpu_context);
|
||||||
state_count = x86_THREAD_STATE_COUNT;
|
state_count = x86_THREAD_STATE_COUNT;
|
||||||
break;
|
break;
|
||||||
#if defined(ARCH_CPU_X86)
|
#if defined(ARCH_CPU_X86)
|
||||||
case x86_THREAD_STATE32:
|
case x86_THREAD_STATE32:
|
||||||
state = reinterpret_cast<ConstThreadState>(&cpu_context->uts.ts32);
|
state = reinterpret_cast<ConstThreadState>(&cpu_context.uts.ts32);
|
||||||
state_count = cpu_context->tsh.count;
|
state_count = cpu_context.tsh.count;
|
||||||
break;
|
break;
|
||||||
#elif defined(ARCH_CPU_X86_64)
|
#elif defined(ARCH_CPU_X86_64)
|
||||||
case x86_THREAD_STATE64:
|
case x86_THREAD_STATE64:
|
||||||
state = reinterpret_cast<ConstThreadState>(&cpu_context->uts.ts64);
|
state = reinterpret_cast<ConstThreadState>(&cpu_context.uts.ts64);
|
||||||
state_count = cpu_context->tsh.count;
|
state_count = cpu_context.tsh.count;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
@ -176,16 +176,16 @@ bool DeliverException(thread_t thread,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void SimulateCrash(const NativeCPUContext* cpu_context) {
|
void SimulateCrash(const NativeCPUContext& cpu_context) {
|
||||||
#if defined(ARCH_CPU_X86)
|
#if defined(ARCH_CPU_X86)
|
||||||
DCHECK_EQ(cpu_context->tsh.flavor,
|
DCHECK_EQ(cpu_context.tsh.flavor,
|
||||||
implicit_cast<thread_state_flavor_t>(x86_THREAD_STATE32));
|
implicit_cast<thread_state_flavor_t>(x86_THREAD_STATE32));
|
||||||
DCHECK_EQ(implicit_cast<mach_msg_type_number_t>(cpu_context->tsh.count),
|
DCHECK_EQ(implicit_cast<mach_msg_type_number_t>(cpu_context.tsh.count),
|
||||||
x86_THREAD_STATE32_COUNT);
|
x86_THREAD_STATE32_COUNT);
|
||||||
#elif defined(ARCH_CPU_X86_64)
|
#elif defined(ARCH_CPU_X86_64)
|
||||||
DCHECK_EQ(cpu_context->tsh.flavor,
|
DCHECK_EQ(cpu_context.tsh.flavor,
|
||||||
implicit_cast<thread_state_flavor_t>(x86_THREAD_STATE64));
|
implicit_cast<thread_state_flavor_t>(x86_THREAD_STATE64));
|
||||||
DCHECK_EQ(implicit_cast<mach_msg_type_number_t>(cpu_context->tsh.count),
|
DCHECK_EQ(implicit_cast<mach_msg_type_number_t>(cpu_context.tsh.count),
|
||||||
x86_THREAD_STATE64_COUNT);
|
x86_THREAD_STATE64_COUNT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace crashpad {
|
|||||||
//! state flavor that the exception handler accepts. If it is not
|
//! state flavor that the exception handler accepts. If it is not
|
||||||
//! compatible, the correct thread state for the handler will be obtained by
|
//! compatible, the correct thread state for the handler will be obtained by
|
||||||
//! calling `thread_get_state()`.
|
//! calling `thread_get_state()`.
|
||||||
void SimulateCrash(const NativeCPUContext* cpu_context);
|
void SimulateCrash(const NativeCPUContext& cpu_context);
|
||||||
|
|
||||||
} // namespace crashpad
|
} // namespace crashpad
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ void SimulateCrash(const NativeCPUContext* cpu_context);
|
|||||||
do { \
|
do { \
|
||||||
crashpad::NativeCPUContext cpu_context; \
|
crashpad::NativeCPUContext cpu_context; \
|
||||||
crashpad::CaptureContext(&cpu_context); \
|
crashpad::CaptureContext(&cpu_context); \
|
||||||
crashpad::SimulateCrash(&cpu_context); \
|
crashpad::SimulateCrash(cpu_context); \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
#endif // CRASHPAD_CLIENT_SIMULATE_CRASH_MAC_H_
|
#endif // CRASHPAD_CLIENT_SIMULATE_CRASH_MAC_H_
|
||||||
|
Loading…
x
Reference in New Issue
Block a user