How do I get GDB to break on a GLib assertion failure?

别来无恙 提交于 2019-12-03 06:47:50

问题


Somewhere in a mass of code that I did not write (but I am trying to debug), an assertion fails in the GLib library:

(process:31987): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed

However, GDB and the code keeps on going. I would like GDB to break where this assertion fails so that I can find out why it is failing. I am not given any more information about where this assertion is. Is there a way to get GDB to break on such a failure?


回答1:


Break on g_log(). This covers all cases like g_warning(), g_critical(), etc.




回答2:


You should add an environment variable like this:

G_DEBUG=fatal_warnings gdb ...


来源:https://stackoverflow.com/questions/5785902/how-do-i-get-gdb-to-break-on-a-glib-assertion-failure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!