objective-c 防止lldb上的“执行被中断,原因:内部ObjC异常断点(-3)”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21056370/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Prevent "Execution was interrupted, reason: internal ObjC exception breakpoint(-3)" on lldb
提问by steipete
I've written some code that dumps all ivars of a class into a dictionary in Objective C. This uses valueForKey:to get the data from the class. Sometimes, KVC throws an internal exception that is also captured properly - but this disrupts lldb's feature and all I get is:
我写了一些代码,将一个类的所有变量转储到 Objective C 中的字典中。这用于valueForKey:从类中获取数据。有时,KVC 会抛出一个也被正确捕获的内部异常 - 但这会破坏 lldb 的功能,我得到的只是:
error: Execution was interrupted, reason: internal ObjC exception breakpoint(-3).. The process has been returned to the state before expression evaluation.
错误:执行被中断,原因:内部ObjC异常断点(-3)。进程已经返回到表达式求值前的状态。
There are no breakpoints set. I even tried with -itrue -ufalseas expression options, but it doesn't make a difference. This totally defeats for what I want to use lldb for, and it seems like such a tiny issue. How can I bring clang to simply ignoreif there are internal, captured ObjC exceptions while calling a method?
没有设置断点。我什至尝试使用-itrue -ufalseas 表达式选项,但它没有任何区别。这完全违背了我想要使用 lldb 的目的,这似乎是一个很小的问题。如果在调用方法时存在内部捕获的 ObjC 异常,我如何让 clang 简单地忽略?
I tried this both from within Xcode, and directly via calling clang from the terminal and connecting to a remote debug server - no difference.
我在 Xcode 中尝试了这个,也直接通过从终端调用 clang 并连接到远程调试服务器 - 没有区别。
回答by haShalosh
I ran into the same issue. My solution was to wrap a try/catcharound it (I only use this code for debugging). See: DALIntrospection.mline #848
我遇到了同样的问题。我的解决方案是将try/catch它包裹起来(我只使用此代码进行调试)。请参阅:DALIntrospection.m第 848 行
NSDictionary *DALPropertyNamesAndValuesMemoryAddressesForObject(NSObject *instance)
Or, if you're running on iOS 7, the private instance method _ivarDescriptionwill print all the ivarsfor you (similar instance methods are _methodDescriptionand _shortMethodDescription).
或者,如果您在 上运行iOS 7,私有实例方法_ivarDescription将为您打印所有ivars内容(类似的实例方法是_methodDescription和_shortMethodDescription)。
回答by mollysmile.ye
I met the same problem.
我遇到了同样的问题。
My solution is simply alloc initthe property before assigning it to the value which caused the crash.
我的解决方案只是alloc init在将其分配给导致崩溃的值之前的属性。
回答by Dave Lee
Myself and coworkers ran into this today, and we eventually found a workaround using lldb's python API. The manual way is to run script, and enter:
我自己和同事今天遇到了这个问题,我们最终找到了使用 lldb 的 python API 的解决方法。手动方式是运行script,然后输入:
options = lldb.SBExpressionOptions()
options.SetTrapExceptions(False)
print lldb.frame.EvaluateExpression('ThisThrowsAndCatches()', options).value
This could be packaged into its own command via command script add.
这可以通过command script add.

