调试器的断点comend xcode中的跳转 [英] breakpoint with debugger Commend jump in xcode

查看:74
本文介绍了调试器的断点comend xcode中的跳转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Xcode中创建了一个断点,并通过跳转来强制传递某些条件,但是当它执行到第168行时,它会崩溃并显示消息

I made a breakpoint in Xcode with the jump commend to force passing some condition, but when it execute to line 168 it crash with message

"Thread 1: EXC_BAD_ACCESS (code=1, address=0x1)"

为什么会这样?

控制台登录:

警告:MoreMultitypeCollectionViewCell.swift:178在此函数中出现多次,选择第一个位置:

warning: MoreMultitypeCollectionViewCell.swift:178 appears multiple times in this function, selecting the first location:

MoreMultitypeCollectionViewCell.(updateButtonStateCkeck in _9A12557DCAB30EEB52DC7C2EA09487CD)() -> () + 1580 at MoreMultitypeCollectionViewCell.swift:178

MoreMultitypeCollectionViewCell.(updateButtonStateCkeck in _9A12557DCAB30EEB52DC7C2EA09487CD)() -> () + 1600 at MoreMultitypeCollectionViewCell.swift:178

我的问题是:

  1. 如何输入lldb以选择位置?
  2. 有没有更好的方法可以在不更改代码的情况下强制传递到If语句并重建项目?
  3. 有时当我在lldb中键入'po'或在变量视图中单击打印说明时,它会显示失败消息,那是怎么回事?

推荐答案

1)在lldb中,等效命令是thread jump,您可以在其中指定地址和行号.

1) In lldb, the equivalent command is thread jump and you can specify an address as well as a line number there.

2)thread jump或等效的Xcode是一种内在的危险操作.如果跳过某些变量的初始化,那么您现在将处理错误的数据,并且很可能会崩溃.有时您可能会发现这种事情-尽管Swift对初始化很懒,所以变量的实际初始化可能不会在您认为它在源代码中发生的地方发生.还有更多的细微问题.例如,如果跳过一些代码,该代码作为其操作的副产品保留或释放了一个对象,则该对象最终将在保留之下或之上.前者将导致崩溃,后者将导致内存泄漏.这些保留&这些版本是由编译器生成的,因此即使您查看要跳过的代码的反汇编,也无法在源代码中看到它们.

2) thread jump or the Xcode equivalent is an inherently dangerous operation. If you jump over the initialization of some variable, you will be dealing with bad data now and will likely crash. That sort of thing you can sometimes spot by eye - though Swift is lazy about initialization so the actual initialization of a variable may not happen where you think it does in the source. There are more subtle problems as well. For instance, if you jump over some code that as a byproduct of its operation retains or releases an object, the object will end up under or over retained. The former will cause crashes, the latter memory leaks. These retains & releases are generated by the compiler, so you can't see them in your source code, though you could if you look at the disassembly of the code you are jumping over.

如果不查看有问题的代码,我无法说出为什么这种特殊的跳转会导致崩溃.

Without looking at the code in question, I can't tell why this particular jump caused a crash.

但是您不能100%安全地跳过编译器选择发出的某些代码.查看反汇编,您可能可以发现(a)在跳转之前停下来的一个好地方-即停止经过会导致问题的保留或释放,或者跳转到行中间的地址,以便您仍然致电需要保留.您必须手动解决这个问题.

But you can't 100% safely skip some of the code the compiler choose to emit. Looking at the disassembly you might be able to spot either (a) a better place to stop before the jump - i.e. stop past some retain or release that is causing a problem or jump to an address in the middle of a line so you still call a retain that's needed. You'll have to figure this out by hand.

3)没有足够的信息来回答这个问题.

3) There's not enough info to answer this question.

顺便说一句,您的图片链接似乎无法解析.

BTW, your image links don't seem to resolve.

这篇关于调试器的断点comend xcode中的跳转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆