是否可以在块内设置符号断点?

时间:2013-10-10 15:42:10

标签: objective-c xcode

这是我的堆栈跟踪:

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的类)正在某处解除分配,但是我很难复制它。如果有任何见解可以获得,我会在这里添加。

1 个答案:

答案 0 :(得分: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

正如您可以看到堆栈跟踪,目标块是连接的直接调用方:didReceiveData:通过单击堆栈跟踪的该步骤,您可以在那里实际设置断点。我在断点“寄存器读取”中添加了一个操作,这是我在调试器中得到的:

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指向被调用的委托方法,所以我现在有关于从这个块调用的内容的一致信息。