使用gdb加载ctypes的调试库 [英] debug library loaded with ctypes using gdb

查看:173
本文介绍了使用gdb加载ctypes的调试库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  GDBFLAGS = -gdwarf- 2 -g3 -O0 -ggdb 

我用python调用它的一些非静态函数,使用ctypes。

我希望调试C库X.so.有时,X.so的一些函数会崩溃,而不是所有的时间,我希望使用gdb来监视执行。



我使用linux-gnu。我怎样才能调试ctypes?

解决方案

使用gdb python并照常运行程序。然后当它崩溃,调试正常。



顺便说一句,我建议只使用-g3。不要使用-gdwarf-2,现在这样做是错误的 - DWARF 2实际上已经很老了,现在默认更新。


I loaded in python a C library X.so, that I compiled with these flags.

GDBFLAGS = -gdwarf-2 -g3 -O0 -ggdb

and I call some of its non-static functions from python , using ctypes.

I wish debugging the C library X.so. Some function from X.so crashes sometimes, not all the time, and I wish monitoring the execution using gdb.

I use linux-gnu. How can I debug ctypes ?

解决方案

Use "gdb python" and run your program as usual. Then when it crashes, debug as normal.

BTW I recommend using just "-g3". Don't use "-gdwarf-2", this does the wrong thing nowadays -- DWARF 2 is quite old actually and the default is newer now.

这篇关于使用gdb加载ctypes的调试库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆