Qt Creator不使用GDB Pretty Printing

时间:2018-04-03 14:10:51

标签: gdb qt-creator pretty-print

我试图在Linux中使用Qt Creator开发虚幻引擎4。我遇到了调试器的问题:我无法让Qt Creator使用GDB的漂亮打印机。

Epic为自己的自定义容器编写了漂亮的打印机(比如它们的字符串类),这些打印机在GDB中运行良好。从Qt Creator的调试器日志中,我可以看到GDB正在注册这些打印机。事实上,我甚至可以输入" print"命令和输出格式很好。但是,在监视窗口中输入变量作为表达式,我看到的只是FString指向的内存地址。

具体来说,这是发出的调试器命令以及当我添加FString变量时产生的结果"文件名"到观察窗口:

命令:

140python theDumper.fetchVariables({"autoderef":1,"context":"","displaystringlimit":"100","dyntype":1,"expanded":["local","watch","inspect","local.Filename.Data","local.Filename","return"],"fancy":1,"formats":{},"nativemixed":0,"partialvar":"watch.0","passexceptions":0,"qobjectnames":0,"resultvarname":"","stringcutoff":"10000","token":140,"typeformats":{},"watchers":[{"exp":"46696c656e616d65","iname":"watch.0"}]})
<Rebuild Watchmodel 16 @ 09:05:19.576 [54836ms] >

输出:

dADJUSTING CHILD EXPECTATION FOR local.Filename
dADJUSTING CHILD EXPECTATION FOR local.Filename.Data


<140python theDumper.fetchVariables({"autoderef":1,"context":"","displaystringlimit":"100","dyntype":1,"expanded":["local","watch","inspect","local.Filename.Data","local.Filename","return"],"fancy":1,"formats":{},"nativemixed":0,"partialvar":"watch.0","passexceptions":0,"qobjectnames":0,"resultvarname":"","stringcutoff":"10000","token":140,"typeformats":{},"watchers":[{"exp":"46696c656e616d65","iname":"watch.0"}]})
>&"python theDumper.fetchVariables({\"autoderef\":1,\"context\":\"\",\"displaystringlimit\":\"100\",\"dyntype\":1,\"expanded\":[\"local\",\"watch\",\"inspect\",\"local.Filename.Data\",\"local.Filename\",\"return\"],\"fancy\":1,\"formats\":{},\"nativemixed\":0,\"partialvar\":\"watch.0\",\"passexceptions\":0,\"qobjectnames\":0,\"resultvarname\":\"\",\"stringcutoff\":\"10000\",\"token\":140,\"typeformats\":{},\"watchers\":[{\"exp\":\"46696c656e616d65\",\"iname\":\"watch.0\"}]})\n"

>~"data=[{iname=\"watch.0\",name=\"0\",numchild=\"0\",valueencoded=\"notaccessible\",value=\"\",},{iname=\"watch.0\",wname=\"46696c656e616d65\",numchild=\"1\",type=\"FString &\",value=\"\",address=\"0x7fffffff76b8\",},],typeinfo=[],partial=\"1\"\n"
>~"\"[{'d_d_ptr': 3, 'cannotBeQObject': 3}, [['locals', 117], ['watches', 837842], ['safePrint', 54]]]\"\n"
>140^done
 <Rebuild Watchmodel 16 @ 09:05:19.576 [54836ms] >
sFinished retrieving data

(不确定&#34;调整儿童期望&#34;行是否适用于上一个命令或此命令)

切换&#34;加载系统GDB漂亮的打印机&#34;选项似乎没有任何效果。

到目前为止,搜索网络并没有给我带来太多帮助。任何帮助将不胜感激!

编辑:哦,这很有趣。我做了一个输出的差异与漂亮的打印禁用vs启用。启用它后,我得到:

&lt; 23importPlainDumpers on sSthped在第1个断点1(1)。

<24-thread-info
>&"importPlainDumpers on\n"
>&"Python Exception <type 'exceptions.AttributeError'> 'function' object has no attribute 'subprinters': \n"
>&"Error occurred in Python command: 'function' object has no attribute 'subprinters'\n"
>23^error,msg="Error occurred in Python command: 'function' object has no attribute 'subprinters'"

编辑2:进一步研究,看来Qt Creator可能不支持涉及使用查找功能的漂亮打印机。是这种情况吗?

1 个答案:

答案 0 :(得分:0)

好。似乎Qt Creator希望漂亮的打印机符合PrettyPrinter和SubPrettyPrinter对象定义的结构,并由register_pretty_printer()函数强制执行,该函数在gdb的printing.py脚本中定义并记录在此处:https://sourceware.org/gdb/onlinedocs/gdb/gdb_002eprinting.html

虚幻的打印机不会这样做。

然而,即使他们这样做了,出现 Qt Creator的导入代码只会导入 sub 打印机,而不是父母漂亮的打印机(参考gdbbridge.py中的importPlainDumpers())。似乎解决这个问题的最好方法是更新Unreal的打印机,以便按照我可以找到的使用函数来构建'RegexpCollectionPrettyPrinter'的示例。