Programming Cleverness Roundtable (Friday)
Brian Sharp, bsharp -at- ionstorm.com, link to moderator notes will be posted on www.ionstorm.com.
Debugging
- Win32 has a WriteDump that can create a 50k "minidump" of a thread built with debug info from VC7. Can then inspect state with debugger. Used, eg. with a button in the assert dialog.
- Stack trace + custom memory manager + debug info can be used to automatically find memory leaks.
- B.net servers send email to programmers.
- Database to map function names to programmer: e-mail the right person with an assert.
- Watch dog thread that looks for keys pressed for > 4 seconds: used to dump a minidump, int 3, or exit game.
- If you turn off a particular optimization (didn't catch which one), you can do your own stack walk without dbghlp.
- Visual debugging gives a big payoff:
- Visualize cues that could start sounds
- bright pink for missing textures
- print out a text string for missing sound (contains more useful info than replacing with a sine wave)
- Use code to make conditional breakpoints, often faster than using debugger facilities
- Script function to trigger debugger breakpoint.
Big logs
- Problem: logging / warnings event queue fills up or gets too much data to be useful.
- Can send to screen to make sure it gets fixed...
- Disable/enable logging on a per class basis; use a string prefix to help filtering
- VC7's __FUNCTION__ preprocessor symbol very handy.
- Could prioritize asserts: eventually never trip any.
- Use a per-user profiles stored on HD to map type of error and severity to action (assert, log, ignore).
Custom Memory Management
- Memory poisoning in custom memory allocation very good: init memory to known values, guards at ends, change when deallocated. Try Paul Nettle's mmgr.
- Can measure the amount of wasted space: that which was never changed from init value.
- Can limit total memory.
- Can test a pointer to see if it points into allocated space.
Similar to ATL/MS debug libraries that have "is good {read,write} ptr"
Misc
- Daily build errors mailed to every programmer.
- Netscape used talkback system, or get minidumps from Microsoft.
- Output screenshots to make movies
- To get instant replays to work, add function traces so you can locate divergences
- Nice to be able to pause AI and physics but still render and toggle various debug visualizations.
- Keyboard lights may be used as debug output when you have nothing else.
- Silly: using perfect pitch for debug output and profiling
- Avoid catch(...)
- On linux: valgrind recommended
- Crash only in release mode: non-initialized memory, or asserts with side effects
- SoftIce on Win9X can do conditional breakpoints
- Look at Visual Assist for use with VC++, though bad with lots of templates or very large projects.
- Take advantage of scripting in editor to add a new class to the project with dummy test code.
- These and other VC++ tricks in "Debugging Applications" by Jon Robbins:
- Look at autoexp.dat: for viewing data in debugger.
- @err shows GetLastErr
- f() calls function f in watch window (but calls it twice! beware)
- @clk give time stamp
- ,su for unicode string
- ,hr for hresult
- There is some registry key for avoiding pause when using direct input.
- f12 breaks into debugger in VC++, can't be remapped
- debug SDK: can use MS's debug data server to debug breaks into GDI32, etc.
- "ReadDirectoryChangesW" fuction so artists can drop a bitmap (or whatever) into a directory and it immediately appears in the game
- PC-Lint good for giving warnings
- pragma 4389 handy for something or other.