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 why it happens?
切换到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:
我的localhost设置:
2 个解决方案
#1
37
Make sure you have localhost
mapped to 127.0.0.1
in your /etc/hosts
file:
确保在/ etc / hosts文件中将localhost映射到127.0.0.1:
$ grep localhost /etc/hosts
If grep
doesn't show 127.0.0.1
then 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的命令提示符;不要输入它,否则你会发表声明,不会发生任何事情
NOTE Use >>
and not >
! (better is to edit it using vi
or mate
or whatever).
注意使用>>而不是>! (更好的是使用vi或mate或其他方式编辑它)。
My /etc/hosts
file shows (ignoring comments):
我的/ etc / hosts文件显示(忽略注释):
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
#2
2
Apple likes to move forward. So setting gdb as the debugger for all new projects is not an option.
Apple喜欢向前发展。因此,不能选择将gdb设置为所有新项目的调试器。
Sometimes, you have to reset the iOS Simulator to clean up the debugger.
有时,您必须重置iOS模拟器以清理调试器。
#1
37
Make sure you have localhost
mapped to 127.0.0.1
in your /etc/hosts
file:
确保在/ etc / hosts文件中将localhost映射到127.0.0.1:
$ grep localhost /etc/hosts
If grep
doesn't show 127.0.0.1
then 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的命令提示符;不要输入它,否则你会发表声明,不会发生任何事情
NOTE Use >>
and not >
! (better is to edit it using vi
or mate
or whatever).
注意使用>>而不是>! (更好的是使用vi或mate或其他方式编辑它)。
My /etc/hosts
file shows (ignoring comments):
我的/ etc / hosts文件显示(忽略注释):
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
#2
2
Apple likes to move forward. So setting gdb as the debugger for all new projects is not an option.
Apple喜欢向前发展。因此,不能选择将gdb设置为所有新项目的调试器。
Sometimes, you have to reset the iOS Simulator to clean up the debugger.
有时,您必须重置iOS模拟器以清理调试器。