objective-c - 只有在我的一个项目中,我根本无法使用 Xcode 断点,lldb 崩溃并始终使用相同的日志。有没有办法调试这个问题?
问题描述
在调试还包含 Objective-C 部分的 Swift iOS 项目时,我不能使用断点,否则调试服务器会崩溃,并记录:
Message from debugger: The LLDB RPC server has crashed. The crash log is located in
~/Library/Logs/DiagnosticReports and has a prefix 'lldb-rpc-server'. Please file a bug and
attach the most recent crash log.
我使用的是最新的 Xcode (11.5),但这发生在多次更新之后。我怀疑这在安装最新的 Xcode 更新之一时开始发生,但我不确定 100%。
我知道这个问题可能是重复的,所以我会尽可能多地添加细节。日志在顶部包含:
Process: lldb-rpc-server [57486]
Path: /Applications/Xcode.app/Contents/SharedFrameworks/LLDBRPC.framework/Versions/A/Resources/lldb-rpc-server
Identifier: lldb-rpc-server
Version: 2
Code Type: X86-64 (Native)
Parent Process: Xcode [44264]
Responsible: Xcode [44264]
User ID: 501
Date/Time: 2020-06-27 20:11:09.502 +0200
OS Version: Mac OS X 10.15.5 (19F101)
Report Version: 12
Bridge OS Version: 4.5 (17P5300)
Anonymous UUID: AAD489A9-72D8-BF2A-EF2C-48E06D701EBA
Sleep/Wake UUID: 4DA8CC95-35BE-4383-A87D-E24E0A2C6A42
Time Awake Since Boot: 130000 seconds
Time Since Wake: 11000 seconds
System Integrity Protection: disabled
Crashed Thread: 9 RPC packet thread for client tid 002da567 (2991463)
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: EXC_I386_GPFLT
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [57486]
然后,我将附上崩溃线程日志:
Thread 9 Crashed:: RPC packet thread for client tid 002da567 (2991463)
0 com.apple.LLDB.framework 0x0000000109aff3f2 clang::ASTReader::ReadSLocEntry(int) + 226
1 com.apple.LLDB.framework 0x000000010a68e7ca clang::SourceManager::getFileIDLoaded(unsigned int) const + 618
2 com.apple.LLDB.framework 0x000000010a358a24 clang::SourceManager::getDecomposedLoc(clang::SourceLocation) const + 148
3 com.apple.LLDB.framework 0x0000000109b1f3ab clang::ASTReader::ReadPragmaDiagnosticMappings(clang::DiagnosticsEngine&) + 1131
4 com.apple.LLDB.framework 0x0000000109b1bf89 clang::ASTReader::InitializeContext() + 969
5 com.apple.LLDB.framework 0x0000000109b1b039 clang::ASTReader::ReadAST(llvm::StringRef, clang::serialization::ModuleKind, clang::SourceLocation, unsigned int, llvm::SmallVectorImpl<clang::ASTReader::ImportedSubmodule>*) + 3833
6 com.apple.LLDB.framework 0x00000001098ca8da clang::CompilerInstance::loadModule(clang::SourceLocation, llvm::ArrayRef<std::__1::pair<clang::IdentifierInfo*, clang::SourceLocation> >, clang::Module::NameVisibilityKind, bool) + 11034
7 com.apple.LLDB.framework 0x0000000107e00f47 swift::ClangImporter::Implementation::loadModuleClang(swift::SourceLoc, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >)::$_6::operator()(llvm::ArrayRef<std::__1::pair<clang::IdentifierInfo*, clang::SourceLocation> >, bool) const + 311
8 com.apple.LLDB.framework 0x0000000107e00cb5 swift::ClangImporter::Implementation::loadModuleClang(swift::SourceLoc, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 869
9 com.apple.LLDB.framework 0x0000000107e01320 swift::ClangImporter::loadModule(swift::SourceLoc, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 32
10 com.apple.LLDB.framework 0x0000000107d4c3f1 swift::ModuleFile::getModule(llvm::ArrayRef<swift::Identifier>, bool) + 881
11 com.apple.LLDB.framework 0x0000000107d7c1ab swift::ModuleFile::associateWithFileContext(swift::FileUnit*, swift::SourceLoc, bool) + 1627
12 com.apple.LLDB.framework 0x0000000107dd64a2 swift::SerializedModuleLoaderBase::loadAST(swift::ModuleDecl&, llvm::Optional<swift::SourceLoc>, llvm::StringRef, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, bool, bool) + 642
13 com.apple.LLDB.framework 0x0000000107dd83d4 swift::SerializedModuleLoaderBase::loadModule(swift::SourceLoc, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 452
14 com.apple.LLDB.framework 0x0000000107f09884 swift::ASTContext::getModule(llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 244
15 com.apple.LLDB.framework 0x0000000107d4c34c swift::ModuleFile::getModule(llvm::ArrayRef<swift::Identifier>, bool) + 716
16 com.apple.LLDB.framework 0x0000000107d7c1ab swift::ModuleFile::associateWithFileContext(swift::FileUnit*, swift::SourceLoc, bool) + 1627
17 com.apple.LLDB.framework 0x0000000107dd64a2 swift::SerializedModuleLoaderBase::loadAST(swift::ModuleDecl&, llvm::Optional<swift::SourceLoc>, llvm::StringRef, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, bool, bool) + 642
18 com.apple.LLDB.framework 0x0000000107dd85dd swift::MemoryBufferSerializedModuleLoader::loadModule(swift::SourceLoc, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 285
19 com.apple.LLDB.framework 0x0000000107f09bb5 swift::ASTContext::getModuleByName(llvm::StringRef) + 773
20 com.apple.LLDB.framework 0x0000000106edea5d lldb_private::SwiftASTContext::GetModule(lldb_private::SourceModule const&, lldb_private::Status&) + 749
21 com.apple.LLDB.framework 0x0000000106eed644 LoadOneModule(lldb_private::SourceModule const&, lldb_private::SwiftASTContext&, std::__1::weak_ptr<lldb_private::StackFrame>&, llvm::SmallVectorImpl<swift::SourceFile::ImportedModuleDesc>&, lldb_private::Status&) + 516
22 com.apple.LLDB.framework 0x0000000106eedf79 lldb_private::SwiftASTContext::PerformAutoImport(lldb_private::SwiftASTContext&, lldb_private::SymbolContext&, std::__1::weak_ptr<lldb_private::StackFrame>&, swift::SourceFile*, lldb_private::Status&) + 281
23 com.apple.LLDB.framework 0x0000000106f4f13b lldb_private::Target::GetScratchSwiftASTContext(lldb_private::Status&, lldb_private::ExecutionContextScope&, bool) + 1291
24 com.apple.LLDB.framework 0x0000000106dc233c lldb_private::ValueObject::GetScratchSwiftASTContext() + 108
25 com.apple.LLDB.framework 0x0000000106f88744 lldb_private::SwiftLanguageRuntime::GetDynamicTypeAndAddress(lldb_private::ValueObject&, lldb::DynamicValueType, lldb_private::TypeAndOrName&, lldb_private::Address&, lldb_private::Value::ValueType&) + 148
26 com.apple.LLDB.framework 0x000000010711b8ff lldb_private::SwiftLanguage::GetPossibleFormattersMatches(lldb_private::ValueObject&, lldb::DynamicValueType) + 303
27 com.apple.LLDB.framework 0x0000000106dd5654 lldb_private::FormatManager::GetPossibleMatches(lldb_private::ValueObject&, lldb_private::CompilerType, unsigned int, lldb::DynamicValueType, std::__1::vector<lldb_private::FormattersMatchCandidate, std::__1::allocator<lldb_private::FormattersMatchCandidate> >&, bool, bool, bool, bool) + 1492
28 com.apple.LLDB.framework 0x0000000106dd4a85 lldb_private::FormattersMatchData::GetMatchesVector() + 117
29 com.apple.LLDB.framework 0x0000000106de6a08 void lldb_private::TypeCategoryMap::Get<std::__1::shared_ptr<lldb_private::TypeSummaryImpl> >(lldb_private::FormattersMatchData&, std::__1::shared_ptr<lldb_private::TypeSummaryImpl>&) + 392
30 com.apple.LLDB.framework 0x0000000106dd9420 std::__1::shared_ptr<lldb_private::TypeSummaryImpl> lldb_private::FormatManager::GetCached<std::__1::shared_ptr<lldb_private::TypeSummaryImpl> >(lldb_private::FormattersMatchData&) + 448
31 com.apple.LLDB.framework 0x0000000106dd739c std::__1::shared_ptr<lldb_private::TypeSummaryImpl> lldb_private::FormatManager::Get<std::__1::shared_ptr<lldb_private::TypeSummaryImpl> >(lldb_private::ValueObject&, lldb::DynamicValueType) + 60
32 com.apple.LLDB.framework 0x0000000106dd734e lldb_private::FormatManager::GetSummaryFormat(lldb_private::ValueObject&, lldb::DynamicValueType) + 14
33 com.apple.LLDB.framework 0x0000000106dd18c3 lldb_private::DataVisualization::GetSummaryFormat(lldb_private::ValueObject&, lldb::DynamicValueType) + 51
34 com.apple.LLDB.framework 0x0000000106dbd827 lldb_private::ValueObject::UpdateFormatsIfNeeded() + 439
35 com.apple.LLDB.framework 0x0000000106dc358e lldb_private::ValueObject::CalculateSyntheticValue(bool) + 94
36 com.apple.LLDB.framework 0x0000000106dc3842 lldb_private::ValueObject::GetSyntheticValue(bool) + 34
37 com.apple.LLDB.framework 0x0000000106d2cd5d ValueImpl::GetSP(lldb_private::ProcessRunLock::ProcessRunLocker&, std::__1::unique_lock<std::__1::recursive_mutex>&, lldb_private::Status&) + 557
38 com.apple.LLDB.framework 0x0000000106d1b33b lldb::SBValue::GetSP(ValueLocker&) const + 139
39 com.apple.LLDB.framework 0x0000000106d1bf4b lldb::SBValue::GetValueType() + 187
40 lldb-rpc-server 0x00000001068a39e4 rpc_server::_ZN4lldb7SBValue12GetValueTypeEv::HandleRPCCall(rpc_common::Connection&, rpc_common::RPCStream&, rpc_common::RPCStream&) + 36
41 lldb-rpc-server 0x00000001068a6ce1 rpc_common::Connection::PrivateHandleRPCPacket(rpc_common::RPCPacket&, rpc_common::RPCPacket&, bool&) + 1553
42 lldb-rpc-server 0x00000001068aa36d Packets::ProcessPackets() + 1005
43 lldb-rpc-server 0x00000001068a9e96 Packets::ReadThread() + 214
44 lldb-rpc-server 0x00000001068a9db9 Packets::RunReadThread(void*) + 9
45 libsystem_pthread.dylib 0x00007fff72ea4109 _pthread_start + 148
46 libsystem_pthread.dylib 0x00007fff72e9fb8b thread_start + 15
只有在少数情况下,我可以通过从模拟器/设备中删除应用程序并在 Xcode 中清理项目来临时解决问题。
我尝试了以下方法:
我从项目中完全删除了所有与 Cocoapods 相关的东西,并用大部分 Carthage 替换了 Cocoapods 依赖项,并用它们的整个源代码添加了一些库。问题仍然存在。
在 Cocoapods 解体后,我尝试从构建设置中删除所有剩余的引用 Cocoapods 的条目。
问题仍然存在,它必须是特定于项目的,因为我在任何其他项目中都没有遇到过。我什至尝试将 hopper disassembler 附加到调试服务器以更好地跟踪崩溃,但目前我还没有找到问题的根本原因。任何帮助将不胜感激。
编辑:
经过无数个小时,我至少可以确定一个更重要的细节:崩溃仅在我将配置设置为 Debug 时发生,而在 Release 中从未发生。我现在正在一一更改不同的构建设置。这是一个非常漫长的过程,因为问题只有 80% 的时间是一致的,这意味着错误的配置可能会暂时起作用。唯一可以确定的是,它从未在发布模式下发生过。感谢您的关注和帮助。
解决方案
这不是直接断点的问题,它们只是导致 lldb 读取项目调试信息的第一件事。当 lldb 尝试重建将某些 ObjC 类绑定到 swift 模块信息所需的 clang 模块时,崩溃即将到来。从崩溃报告中收集的信息不多。但是 lldb “类型”日志将显示崩溃时 lldb 正在处理的内容。要生成该日志,请输入以下命令:
日志启用 -f /tmp/lldb-log.txt lldb 类型
在您的 ~/.lldbinit 中,并重做您的调试会话。当它崩溃时,在日志中提交错误并使用http://bugs.swift.org提交崩溃。
推荐阅读
- python - 使用破折号(Python 包)绘制图形
- javascript - 如何在jQuery中遍历DOM时选择和获取视频和音频元素的属性
- linq.js - 搜索文本如何使用 linq.js 包含单引号?
- java - 覆盖 Dlog4j.configuration Java 参数
- shopify - 如何在不使用任何应用程序的情况下在 shopify 中创建基于标签的集合过滤器
- nativescript - 如何使用modalStack在nativescript中的文本字段下方显示键盘?
- java - Flutter:NoSuchMethodError:在 null 上调用了 getter 'nom'。接收者; null 尝试调用:nom
- android - 在 transformation.map 之后运行挂起函数
- android - kotlin 协程流中的并发
- postgresql - 是否可以使用带有 npgsql 的 EF CORE 3.1 中的 UNACCENT 扩展为 postgresql 进行选择?