造成GTK来上断言中止 [英] Causing Gtk to abort on assert

查看:192
本文介绍了造成GTK来上断言中止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要调试程序,它在很大程度上依赖于基于GTK。问题是,由于某种原因,很多运行时的警告已经开始与的GtkWindow 对象时出现。问题是,即使基于GTK关键错误的抱怨,它不会对这些错误中止。我没有为code碱基的改变历史,所以我唯一的选择似乎是韦德,尽管所有的GTK通话,这似乎嫌疑人,看到问题的所在。但是,如果我能以某种方式导致GTK来终止这个错误,我可以使用gdb运行它,并试图让回溯,找到错误的确切位置。任何想法,这可怎么办呢?

  GLib的-的GObject-WARNING **:无效uninstantiatable类型`<无效>'在投地'的GObject
GLib的-的GObject-CRITICAL **:g_object_get_data:断言`G_IS_OBJECT(对象)'失败
GLib的-的GObject-WARNING **:无效uninstantiatable类型`<无效>'在投地'的GObject
GLib的-的GObject-CRITICAL **:g_object_get_data:断言`G_IS_OBJECT(对象)'失败
GLib的-的GObject-WARNING **:无效uninstantiatable类型`<无效>'在投地'的GObject
GLib的-的GObject-CRITICAL **:g_object_get_data:断言`G_IS_OBJECT(对象)'失败


解决方案

我收集马特提到的方法和一个我发现这里提供完整的答案。我将它标记为所选择的答案和上投马特的答案。

三种方式来强制GTK来agort的错误:


  1. G_DEBUG = fatal_warnings ./myprog ...

  2. ./ MYPROG -prog-ARGS --g致命的警告

  3. 使用g_log_set_handler,和/或g_log_default_handler,并提供自己的设计,将中止基于传递给它的每个消息GLogLevelFlags的GLogFunc。

我还要提到 g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); 来使列表完整,即使总是致命的是不是我要找的。

I have to debug a program which is heavily dependent on Gtk. The issue is that for some reason a lot of runtime warnings have started appearing when working with GtkWindow objects. The problem is, even though Gtk complains of critical errors, it does not abort on these errors. I don't have the change history for the code base so my only option seems to be to wade though all gtk calls which seem suspect and see where the problem is. If however, I can somehow cause Gtk to abort on this error, I can run it with gdb and try to get the backtrace and locate the exact position of the error. Any idea how this can be done?

GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GObject'
GLib-GObject-CRITICAL **: g_object_get_data: assertion `G_IS_OBJECT (object)' failed
GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GObject'
GLib-GObject-CRITICAL **: g_object_get_data: assertion `G_IS_OBJECT (object)' failed
GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GObject'
GLib-GObject-CRITICAL **: g_object_get_data: assertion `G_IS_OBJECT (object)' failed

解决方案

I am collecting the methods Matt mentioned and the one I found out to provide the complete answer here. I will mark it as the chosen answer and up-vote Matt's answer.

Three ways to force gtk to agort on error:

  1. G_DEBUG=fatal_warnings ./myprog ...
  2. ./myprog -prog-args --g-fatal-warnings
  3. Use g_log_set_handler, and/or g_log_default_handler and provide a GLogFunc of your own design that aborts based on the GLogLevelFlags passed to it for each message.

I should also mention g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING); to make the list complete even though "always fatal" is not what I was looking for.

这篇关于造成GTK来上断言中止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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