2

这是我的堆栈跟踪:

Thread: Unknown Name (Crashed)
0     libobjc.A.dylib                       0x39bdcb36 objc_msgSend + 22
1     Foundation                            0x301423a3 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 55
2     Foundation                            0x301467cf -[NSBlockOperation main] + 131
3     Foundation                            0x3013697b -[__NSOperationInternal _start:] + 771
4     Foundation                            0x301dab35 __NSOQSchedule_f + 61
5     libdispatch.dylib                     0x3a0ca6df _dispatch_async_redirect_invoke$VARIANT$mp + 111
6     libdispatch.dylib                     0x3a0cbda5 _dispatch_root_queue_drain + 221
7     libdispatch.dylib                     0x3a0cbf8d _dispatch_worker_thread2 + 57
8     libsystem_pthread.dylib               0x3a206dbf _pthread_wqthread + 299

我想做的是在

__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke

并检查寄存器以查看它应该访问的内容。环境

__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke

因为断点不会触发任何东西。在

-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]

有效,但我仍然不知道该块内发生了什么。我很感激任何建议。

更新 我能够想出一个我已经添加为答案的解决方法。崩溃的原因很可能是我的 NSURLConnectionDelegate(在这种情况下是一个名为 WebOperation 的类)在某处被释放,但是我很难复制它。如果有任何见解,我会在这里添加。

4

1 回答 1

0

我无法使用“添加异常断点...”直接设置断点但是我能做的是在

- (void)connection:(NSURLConnection *)con didReceiveData:(NSData *)data

当我到达断点时,它看起来像这样:

#0  0x00063e2c in -[WebOperation connection:didReceiveData:] at /Users/.../WebOperation.mm:638
#1  0x31c9b3a2 in __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke ()
#2  0x31c9b2e6 in -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] ()
#3  0x31c9b200 in -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] ()
#4  0x31c9b550 in _NSURLConnectionDidReceiveData ()
#5  0x30fce274 in ___ZN27URLConnectionClient_Classic29_delegate_didReceiveDataArrayEv_block_invoke ()
#6  0x30fcdae2 in ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 ()
#7  0x30fff31e in ___ZNK17CoreSchedulingSet13_performAsyncEPKcU13block_pointerFvvE_block_invoke ()
#8  0x31295718 in CFArrayApplyFunction ()
#9  0x30f65c3c in RunloopBlockContext::perform() ()
#10 0x30f65b0c in MultiplexerSource::perform() ()
#11 0x30f659a0 in MultiplexerSource::_perform(void*) ()
#12 0x3132d18a in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#13 0x3132c65a in __CFRunLoopDoSources0 ()
#14 0x3132ae4e in __CFRunLoopRun ()
#15 0x31295ce6 in CFRunLoopRunSpecific ()
#16 0x31295aca in CFRunLoopRunInMode ()
#17 0x35f7f282 in GSEventRunModal ()
#18 0x33b37a40 in UIApplicationMain ()
#19 0x00020c6e in main at /Users/.../main.mm:16

可以看到stacktrace,target block是connection的直接调用者:didReceiveData:通过点击stack trace的那一步,实际上可以在那里设置断点。我在断点“寄存器读取”中添加了一个动作,这就是我在调试器中得到的:

General Purpose Registers:
        r0 = 0x27d96afc
        r1 = 0x3da33230  libsystem_pthread.dylib`_MergedGlobals11 + 224
        r2 = 0x00004000
        r3 = 0x27d967e0
        r4 = 0x27d96994
        r5 = 0x27d96998
        r6 = 0x188d2a00
        r7 = 0x27d96970
        r8 = 0x17596310
        r9 = 0x1775eb78
       r10 = 0x27d969d4
       r11 = 0x00000000
       r12 = 0x00870b28  (void *)0x3bc3dc19: _Unwind_SjLj_Unregister + 1
        sp = 0x27d96968
        lr = 0x000b51d9  SomeProject`-[WebOperation connection:didFailWithError:] + 733 at WebOperation.mm:652
        pc = 0x31c9b3a2  Foundation`__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 54
      cpsr = 0x60000030

寄存器 lr 指向被调用的委托方法,所以我现在有关于从这个块调用的内容的一致信息。

于 2013-10-11T14:21:22.210 回答