xcode 为什么 LLDB Debugger 总是无法附加?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15174282/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:53:20  来源:igfitidea点击:

Why does the LLDB Debugger constantly fail to attach?

iosxcodedebuggingios-simulatorlldb

提问by Lithu T.V

I have seen a lot of answers for this question:

这个问题我看过很多答案:

error: failed to attach to process ID

错误:无法附加到进程 ID

as switch to GDB. But no one addresses the reason of whyit happens?

作为switch to GDB。但是没有人解释为什么会发生这种情况?

Attaching works fine with the GDB debugger but the default and recommended project setting is LLDB.

附加适用于 GDB 调试器,但默认和推荐的项目设置是 LLDB。

Can anybody explain why LLDB fails? Is it a common bug or am I doing something wrong?

谁能解释为什么 LLDB 失败?这是一个常见的错误还是我做错了什么?

Alternatively, how can I set GDB as my default debugger without changing it manually when creating the new projects?

或者,如何在创建新项目时将 GDB 设置为我的默认调试器而无需手动更改它?

System Info:

系统信息:

OS: Lion
RAM: 5GB
XCode: Version 4.6 (4H127)
Device: Mac mini

My localhost setting: enter image description here

我的本地主机设置: 在此处输入图片说明

回答by trojanfoe

Make sure you have localhostmapped to 127.0.0.1in your /etc/hostsfile:

确保您已在文件中localhost映射到:127.0.0.1/etc/hosts

$ grep localhost /etc/hosts

If grepdoesn't show 127.0.0.1then add it:

如果grep没有显示,127.0.0.1则添加它:

$ sudo -i
# echo "127.0.0.1 localhost" >> /etc/hosts

^ That '#' is root's command prompt; don't type it otherwise you will comment-out the statement and nothing will happen

^ '#' 是 root 的命令提示符;不要输入它,否则你会注释掉语句,什么都不会发生

NOTEUse >>and not >! (better is to edit it using vior mateor whatever).

注意使用>>而不是>!(更好的是使用vimate或其他方式编辑它)。

My /etc/hostsfile shows (ignoring comments):

我的/etc/hosts文件显示(忽略评论):

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

回答by Black Frog

Apple likes to move forward. So setting gdb as the debugger for all new projects is not an option.

苹果喜欢前进。因此,不能将 gdb 设置为所有新项目的调试器。

Sometimes, you have to reset the iOS Simulatorto clean up the debugger.

有时,您必须重置iOS 模拟器以清理调试器。