Clang Python在解析linux的某些文件时死亡

我正在使用Clang Python绑定自动解析源代码,但是当它解析某些linux文件时,进程死机,没有CPU消耗,没有错误异常,没有响应,甚至我无法使用Ctrl + C杀死终端。我的代码如下:

index = Index.create()
tu = index.parse(file_path)
next_func(tu)

它与许多源存储库(例如Libpng,OpenCV等)配合良好。解析目录linux-master\drivers\gpu\drm\nouveau\nvkm\subdev\i2c下的文件(例如https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/anx9805.c)时它如何死。我逐步运行代码,发现运行tu = index.parse(file_path)时发生了错误。

环境:Windows 10,libclang.dll(6.0)python2.7。

我尝试了命令clang -cc1 -fsyntax-only -ast-dump anx9805.c 它报告说找不到一些头文件,并按如下方式构造其ast:

In file included from \linux\linux-master\drivers\gpu\drm\nouveau\nvkm\subdev\i2c\anx9805.c:28:
In file included from \linux\linux-master\drivers\gpu\drm\nouveau\nvkm\subdev\i2c/bus.h:4: \linux\linux-master\drivers\gpu\drm\nouveau\nvkm\subdev\i2c/pad.h:4:10: fatal error: 'subdev/i2c.h' file not found
#include <subdev/i2c.h>
         ^~~~~~~~~~~~~~
TranslationUnitDecl 0x13de7f82728 <<invalid sloc>> <invalid sloc>
|-TypedefDecl 0x13de7f82ca0 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
| `-BuiltinType 0x13de7f829c0 '__int128'
|-TypedefDecl 0x13de7f82d10 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
| `-BuiltinType 0x13de7f829e0 'unsigned __int128'
...
...

但是,该过程能够结束,我不知道python中是否发生错误,为什么终端中的进程没有响应,我的代码中的try...except...无法捕获错误,甚至我也无法杀死进程。允许忽略这些错误文件。最重要的是,我不希望代码运行中断。

fangshijie66 回答:Clang Python在解析linux的某些文件时死亡

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3023489.html

大家都在问