QtCreator调试遇到 #line 的问题

今天调试一段代码的时候,遇到一个问题

如下图所示,代码中有 #line的关键字,导致了QtCreator无法调试,主要是不能正常的单步执行,我的开发环境是(vc2015)

 

 

于是给Qt官方提交bug,https://bugreports.qt.io/browse/QTCREATORBUG-23082

经过将近一个月的等待,终于等来了官方的回复。

其实这个问题原因不是 #line的问题,而是 atoi.rl 的问题,这个文件是中间代码,依靠它生成的C++代码会参与真正的项目编译,生成的代码里面在有需要的位置会使用#line来指示调试器重定位到atoi.rl,调试的时候还需要用到此文件。

在QtCreator环境中启动调试,默认只把 %{buildDir} 目录环境给了 cdb ,cdb在调试的时候,跟据上面的#Line指示的文件,在 %{buildDir} 目录中是找不到这个文件的,也导致单步执行定位失败,只能在栈上看到数据,却定位不到源代码的line位置。

解决方法就是 附加一个 cp 命令,自动把 atoi.rl 文件copy到 %{buildDir}中去。

见官方原始回复:

It seems cdb is able to find the correct source location, because lsa with the address returned by

x demo_ragel!a_to_longlong but when listing stack frames via k it just returns a constructed path with %{buildDir} and atoi.rl

 

Not even setting the cdb source path to the demo_ragel source directory seems to improve the situation there, the only thing that helped for me  is to add an additional deploy step with a cp command and the {{%{sourceDir}\atoi.rl %{buildDir} }} as arguments.

 

So as this seems to be a CDB issue I declare this as out of scope, try reporting this issue to Microsoft.

当然了,官方工作人员认为这是CDB的问题,但我不认为这是CDB的问题

 

posted @ 2019-11-11 11:08  GUOBBS  阅读(342)  评论(0编辑  收藏  举报