全部博文(1293)
分类: C/C++
2011-04-09 23:44:00
We never debug our code, because we don't put bugs破坏正常运转能力的问题或者缺陷 in. Okay, you want some real stuff. Sam still uses printf() to find out where it crashes崩溃. For real programmers, here is a summary of what you can do if you have problems. Where does it crash ?
The best way to know that is to use gdb. You can start using it with good chances by configuring with --enable-debug . It will add -g to the compiler CFLAGS, and activate some additional safety checks. Just run gdb vlc, type run myfile.vob, and wait until it crashes. You can view where it stopped with bt, and print variables with print
If you run into troubles, you may want to turn the optimizations off. Optimizations (especially inline functions) may confuse混淆 the debugger(调试器). Use --disable-optimizations in that case.
Other problemsIt may be more complicated than that, for instance unpredictable behaviour, random bug or performance issue. You have several options to deal with this. If you experience unpredictable behaviour, I hope you don't have a heap or stack corruption (eg. writing in an unallocated space), because they are hard to find. If you are really desperate, have a look at something like ElectricFence障碍 or dmalloc. Under GNU/Linux, an easy check is to type export MALLOC_CHECK_=2 before launching vlc (see malloc(3) for more information).
VLC offers a "trace-mode". It can create a log file with very accurate dates and messages of what it does, so it is useful to detect performance issues or lock-ups. Compile with --enable-trace and tune the TRACE_* flags in include/config.h to enable certain某些 types of messages (log file writing can take up(占用) a lot of time, and will have side effects).
Appendix A. Ports
Appendix C. Project history