简体   繁体   English

在 c 中调试?

[英]debugging in c?

i found some error on my app and show some regarded information:我在我的应用程序上发现了一些错误并显示了一些重要信息:

(trunk:29564): Gtk-CRITICAL **: IA__gtk_tree_store_clear: assertion `GTK_IS_TREE_STORE (tree_store)' failed

my question is:我的问题是:

  • what is 29564?, is that offset of stack in code segment in the application, or in stack of memory?什么是 29564?,是应用程序代码段中堆栈的偏移量,还是 memory 堆栈中的偏移量? or where is it exactly?或者它到底在哪里?
  • how could i debug it?我该如何调试它? on which language it(debugging) would be ( C or asm )?它(调试)将使用哪种语言( C 或 asm )?

Use gdb.使用 gdb。

This errors in gtk+ application. gtk+ 应用程序中的此错误。

You must pass function parameters not foo(tree_store, ... ) you must as foo(GTK_IS_TREE_STORE(tree_store), ...)您必须传递 function 参数而不是foo(tree_store, ... )您必须作为foo(GTK_IS_TREE_STORE(tree_store), ...)

As Ancide said we need more information.正如 Ancide 所说,我们需要更多信息。 The completely blind, but sometimes effective, approach is to try grep -r on your source tree for various strings in the error message.完全盲目但有时有效的方法是在源代码树上尝试 grep -r 以获取错误消息中的各种字符串。 Probably you are looking for a function called IA__gtk_tree_store_clear, but then you need to find out who is calling it with something that's not a tree store...可能您正在寻找一个名为 IA__gtk_tree_store_clear 的 function,但随后您需要找出谁在使用不是树店的东西来调用它...

If you actually want to debug the exectuable, figure out how to enable debug info in the build (get a -g flag passed to gcc for example) and then run use gdb progname arguments to launch the program.如果您确实想调试可执行文件,请弄清楚如何在构建中启用调试信息(例如,将 -g 标志传递给 gcc)然后运行使用 gdb progname ZDBC11CAA5BDA99F77E6FB4DABD82 程序启动程序。 When it fails, use things like the back trace command (ct) to look at the call stack and figure out the chain of events that lead up to the failure.当它失败时,使用诸如回溯命令 (ct) 之类的东西来查看调用堆栈并找出导致失败的事件链。

EDIT: looks like you'll need to put a breakpoint in to keep the program from actually aborting, otherwise you won't have a call stack to examine.编辑:看起来您需要设置一个断点以防止程序实际中止,否则您将没有要检查的调用堆栈。 So you'll need to find the line of code on which the assert is checked.因此,您需要找到检查断言的代码行。 You can use a conditional expression in the breakpoint to make gdb only stop the program when the assertion would fail.您可以在断点中使用条件表达式使 gdb 仅在断言失败时停止程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM