最近在ubuntu上安装了unrealEngine之后发现kdevelop的调试功能用不了了!!
按“Debug”按钮之后发现弹出窗口:
gdb error:you need gdb 7.0.0 or higher
you are using:Registered pretty printers for UE4 classes
在网上搜了很久,有人建议用lldb取代gdb,我试了一下还是报错(但网上有人成功了,不知道是为什么)。
于是下定决心找出为什么gdb不能用!!
首先是查看系统里的gdb版本是否正确:
lxl@omnisky:~$ gdb -v
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
可以看到版本是大于7.0的,说明gdb本身没有问题,那为什么用不了呢?思来想去还是在kdevelop中寻找问题。。
仔细观察可以看到,kdevelop在debug时第一条执行的命令是:
gdb --interpreter=mi2 -quiet
然后我按照这个指令在外面终端中输了一下,发现出现:
=thread-group-added,id="i1"
~"Registered pretty printers for UE4 classes\n"
(gdb)
第二条不就是我刚刚得到的错误信息么,找到根源了!!一定是UE4虚幻引擎安装的时候对gdb做了些什么,而且经过试验,发现重装gdb并没有发生什么变化,那结论一定是修改了什么配置文件,而且配置文件是独立存在的,重新安装的时候不会将其覆盖。。
明白了这一点到网上一查就知道了,gdb会检测一个叫.gdbinit的配置文件,默认是在用户根目录下。
我找到这个文件打开一看,果然里面添加了如下命令:
python
import syssys.path.append('/home/lxl/.config/Epic/GDBPrinters/')
from UE4Printers import register_ue4_printers
register_ue4_printers(None)
print("Registered pretty printers for UE4 classes")end
是你,是你,就是你!害我忙了半天的罪魁祸首!!
接着就很简单了:
mv .gdbinit .gdbinit_back
完美解决,如果以后还要用到虚幻引擎,mv回来就行了。。