From e61b76c6793de8085c2ea512d1e45e8c8016bd5c Mon Sep 17 00:00:00 2001 From: "qsr@chromium.org" Date: Fri, 3 May 2013 15:04:12 +0000 Subject: Fix minidump generation from exception. Review URL: https://breakpad.appspot.com/583002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1169 4c0a9323-5329-0410-9bdc-e9ce6186880e --- .../ios/handler/ios_exception_minidump_generator.h | 3 +++ .../ios/handler/ios_exception_minidump_generator.mm | 21 ++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'src/client') diff --git a/src/client/ios/handler/ios_exception_minidump_generator.h b/src/client/ios/handler/ios_exception_minidump_generator.h index 59f24819..fd2f0149 100644 --- a/src/client/ios/handler/ios_exception_minidump_generator.h +++ b/src/client/ios/handler/ios_exception_minidump_generator.h @@ -53,6 +53,9 @@ class IosExceptionMinidumpGenerator : public MinidumpGenerator { // Get the crashing program counter from the exception. uint32_t GetPCFromException(); + // Get the crashing link register from the exception. + uint32_t GetLRFromException(); + // Write a virtual thread context for the crashing site. bool WriteCrashingContext(MDLocationDescriptor *register_location); diff --git a/src/client/ios/handler/ios_exception_minidump_generator.mm b/src/client/ios/handler/ios_exception_minidump_generator.mm index 912c4312..764e893c 100644 --- a/src/client/ios/handler/ios_exception_minidump_generator.mm +++ b/src/client/ios/handler/ios_exception_minidump_generator.mm @@ -79,9 +79,8 @@ bool IosExceptionMinidumpGenerator::WriteCrashingContext( context_ptr->context_flags = MD_CONTEXT_ARM_FULL; context_ptr->iregs[7] = kExpectedFinalFp; // FP context_ptr->iregs[13] = kExpectedFinalSp; // SP - uint32_t pc = GetPCFromException(); - context_ptr->iregs[14] = pc; // LR - context_ptr->iregs[15] = pc; // PC + context_ptr->iregs[14] = GetLRFromException(); // LR + context_ptr->iregs[15] = GetPCFromException(); // PC return true; #else assert(false); @@ -93,6 +92,10 @@ uint32_t IosExceptionMinidumpGenerator::GetPCFromException() { return [[return_addresses_ objectAtIndex:0] unsignedIntegerValue]; } +uint32_t IosExceptionMinidumpGenerator::GetLRFromException() { + return [[return_addresses_ objectAtIndex:1] unsignedIntegerValue]; +} + bool IosExceptionMinidumpGenerator::WriteExceptionStream( MDRawDirectory *exception_stream) { #ifdef HAS_ARM_SUPPORT @@ -135,14 +138,14 @@ bool IosExceptionMinidumpGenerator::WriteThreadStream(mach_port_t thread_id, scoped_array stack_memory(new uint8_t[size]); uint32_t sp = size - 4; uint32_t fp = 0; - uint32_t lr = [[return_addresses_ lastObject] unsignedIntegerValue]; - for (int current_frame = frame_count - 2; - current_frame >= 0; + uint32_t lr = 0; + for (int current_frame = frame_count - 1; + current_frame > 0; --current_frame) { - AppendToMemory(stack_memory.get(), sp, fp); + AppendToMemory(stack_memory.get(), sp, lr); sp -= 4; + AppendToMemory(stack_memory.get(), sp, fp); fp = sp; - AppendToMemory(stack_memory.get(), sp, lr); sp -= 4; lr = [[return_addresses_ objectAtIndex:current_frame] unsignedIntegerValue]; } @@ -150,7 +153,7 @@ bool IosExceptionMinidumpGenerator::WriteThreadStream(mach_port_t thread_id, return false; assert(sp == kExpectedFinalSp); assert(fp == kExpectedFinalFp); - assert(lr == GetPCFromException()); + assert(lr == GetLRFromException()); thread->stack.start_of_memory_range = sp; thread->stack.memory = memory.location(); memory_blocks_.push_back(thread->stack); -- cgit v1.2.1