我可以在 iOS 中的代码中创建一个断点,比如 VC++ 上的 `__asm{int 3}`,然后在它被命中后继续执行吗? [英] Can I create a breakpoint in code in iOS, like `__asm{int 3}` on VC++, and continue execution after it's been hit?

查看:29
本文介绍了我可以在 iOS 中的代码中创建一个断点,比如 VC++ 上的 `__asm{int 3}`,然后在它被命中后继续执行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将等效的 asm{int 3} (或类似的)放入我的 iPhone 程序中.我的目标是让 Xcode 准确地停在有问题的行上,而不必摆弄调用堆栈(所以 _Debugger 听起来不像它会做的那样,并不是说我无论如何都能找到它所在的框架...),让我能够继续执行(这就是我对 assert 不满意的原因).

I'm trying to put the equivalent of asm{int 3} (or similar) into my iPhone program. My goal is to have Xcode stop exactly on the offending line, without having to fiddle with the call stack (so _Debugger doesn't sound like it would do, not that I could find which framework it's in anyway...), and leave me able to resume execution (which is why I'm not happy with assert).

(我在其他系统上已经习惯了这两种行为,我想在 iOS 上重现它们.)

(I'm used to both these behaviours on other systems, and I'd like to reproduce them on iOS.)

到目前为止我最好的尝试是这样的:

My best attempt so far has been this:

asm volatile("bkpt 1");

这会在有问题的行上停止 Xcode,但是当我尝试继续使用 Cmd+Alt+P 时,Xcode 似乎再次运行 BKPT.如果我使用 Shift+Cmd+O,我会得到这个:

This stops Xcode on the line in question, but when I try to continue with Cmd+Alt+P, Xcode appears to run the BKPT again. And if I use Shift+Cmd+O, I just get this:

Watchdog has expired.  Remote device was disconnected?  Debugging session terminated.

(不用说,远程设备仍然连接.)

(Needless to say, the remote device IS still connected.)

我在 iOS、Mac、ARM、gdb 或 gcc 的 asm 方面没有大量经验.所以我已经难住了.有什么方法可以让 iOS 和 Xcode 做我想做的事吗?

I don't have a huge amount of experience with iOS, Mac, ARM, gdb, or gcc's asm stuff. So I'm stumped already. Is there some way of getting iOS and Xcode to do what I want?

(我不知道这是否有区别,但从指令大小来看,我的程序是 ARM 代码.)

(I don't know if it makes a difference but judging by the instruction size my program is ARM code.)

推荐答案

raise(SIGTRAP) 是一种相对可移植的方式来设置in code"断点.

raise(SIGTRAP) is a relatively portable way to have an "in code" breakpoint.

这篇关于我可以在 iOS 中的代码中创建一个断点,比如 VC++ 上的 `__asm{int 3}`,然后在它被命中后继续执行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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