一段时间以来,我一直在努力解决一个奇怪的问题.在最初关闭iOS模拟器的情况下运行我的应用程序时,它会正确启动.但是,如果我再次运行它而不关闭模拟器,它会崩溃并在错误日志中打印(lldb).如果我再次运行它(不关闭模拟器)它会正确启动.如果我再次这样做,它会崩溃.所以似乎每隔一段时间.它在使用iOS设备时有效,而且我有一个完全相同的项目的大学,在iOS模拟器中没有遇到这个问题.我尝试过的是清理,重置内容和设置,手动删除应用程序,重新启动计算机并重新安装Xcode.
我在 Rust 中包装了一个低级别的 ABI,利用了naked函数特性。这是我的代码和相关的反汇编
#![feature(asm)]
#![feature(naked_functions)]
struct MyStruct {
someVar: i64, // not important
// ...
}
impl MyStruct {
#[naked]
extern "C" fn wrap(&self) {
unsafe {
asm!("NOP" :::: "volatile");
// not sure if the volatile option is needed, but I
// figured it wouldn't hurt
}
}
}
Run Code Online (Sandbox Code Playgroud)
用LLDB反汇编:
ABIWrap`ABIWrap::{{impl}}::wrap:
* 0x100001310 <+0>: movq %rdi, -0x10(%rbp)
* 0x100001314 <+4>: movq %rsi, -0x8(%rbp)
* 0x100001318 <+8>: movq -0x10(%rbp), %rax
* 0x10000131c <+12>: movq -0x8(%rbp), %rcx
* 0x100001320 …Run Code Online (Sandbox Code Playgroud)