]]>Dev Toolshttp://www.shnenglu.com/wangjs720/archive/2009/08/28/94707.html鎶槦鎴存湀鎶槦鎴存湀Fri, 28 Aug 2009 14:43:00 GMThttp://www.shnenglu.com/wangjs720/archive/2009/08/28/94707.htmlhttp://www.shnenglu.com/wangjs720/comments/94707.htmlhttp://www.shnenglu.com/wangjs720/archive/2009/08/28/94707.html#Feedback0http://www.shnenglu.com/wangjs720/comments/commentRss/94707.htmlhttp://www.shnenglu.com/wangjs720/services/trackbacks/94707.htmlastyle
Artistic Style is a reindenter and reformatter of C, C++, C# and Java source code.
autoconf Development version of the automatic configure script builder.
automake A tool for generating GNU-compliant Makefiles.
bashdb Debugger for bash scripts
cppcheck A tool for static C/C++ code analysis
doxygen A documentation system for C++, C, Java, Objective-C, IDL and to some extent PHP, C# and D.
]]>gflags - a debugging story http://www.shnenglu.com/wangjs720/archive/2009/07/14/90012.html鎶槦鎴存湀鎶槦鎴存湀Tue, 14 Jul 2009 04:47:00 GMThttp://www.shnenglu.com/wangjs720/archive/2009/07/14/90012.htmlhttp://www.shnenglu.com/wangjs720/comments/90012.htmlhttp://www.shnenglu.com/wangjs720/archive/2009/07/14/90012.html#Feedback0http://www.shnenglu.com/wangjs720/comments/commentRss/90012.htmlhttp://www.shnenglu.com/wangjs720/services/trackbacks/90012.htmlI hate crashes that disappear when run under the debugger and I had one when porting mupdf to Windows.
It helps to know that there鈥檚 at least one reason for a changed behavior under the debugger: it automatically triggers using debugging heap. While debugging heap usually helps find problems, sometimes it does the opposite by changing the details of memory allocation.
One helpful tool when debugging memory problems on Windows is gflags which can enable page heap instrumentation for a given program. It works by putting each allocation into a separate region of memory and putting a non-readable page right after that. Also, upon freeing it makes the memory unreadable. That way an overwrite of memory block while it鈥檚 still being used or accessing the memory after it was freed will cause immediate crash.
The downside is that using gflags uses much more memory. But in those days of cheap gigabytes it鈥檚 not a problem that can鈥檛 be solved with a couple hundred bucks.
Basic usage of gflags.exe is simple: gflags /p /full /enable foo.exe
From now on foo.exe will always be run with this instrumentation turned on. To disable, do gflags /p /disable foo.exe
To see which programs have page heap enabled, do gflags /p. gflags offers many other option and you can learn about them via gflags /?. If you run gflags without any options, you鈥檒l get a (very confusing) GUI.
It worked like a charm. I got a crash on accessing freed memory and all I had to do was to backtrack to where this memory was allocated to figure out the problem.