From Steve Jacobson at stanford via Julie Zelenski, modified by Owen Astrachan to be more OO/C++ ish This was inspired by a fitful night of half-sleep before hw1b was due. I spent a very long evening writing the darray.c code, and then had a segmentation fault I was too tired to track down. I ended up debugging code all night in my sleep, dreaming about the most bizarre and inconsequential things that could be wrong (none of which were, of course). SteveJ { because it went So I ran it under gdb, but I've got to remember to ; } { My code ; My code ; The example search code ; The they gave us ; The provided ; My code ; My code ; } { ; ; } { tvector ; Map ; grammar.cpp ; iostream ; HashMap ; scanner.cpp ; string ; } { tvector.h ; map.h ; grammar.h ; string ; } { grammar.o ; rsg.o ; hashmap.cpp ; } { got a segfault ; had a bus error ; had an alignment error ; just hung ; went off in the weeds somewhere ; went out to lunch ; crashed in a spectacular ball of fire ; ate the big one and died ; went into a death spiral ; collapsed in a pile of smoldering wreckage ; asserted again ; spewed these really bizarre messages ; } { ; } { ; ; ; ; ; and finally dereferenced a NULL *. ; and ended up calling a NULL function. ; } { to a ; through a ; dereferencing a ; } { ; ; which was really a ; which should have been a ; } { GrammarElement * ; Map * ; HashMap * ; UVMap * ; Tree * ; } { I can't remember and ; I wish I knew and ; why won't it and ; I forget where I put that darn gdb handout. ; I wonder where I put my gdb book. ; } { the command to ; the syntax to ; how to ; the right way to ; the best way to ; any way to ; } { clear the breakpoints ; dump the local variables ; dump the parameters ; step out of the function ; show the stack trace ; stop before the crash ; } { add some more comments to and ; try and get some sleep, and ; try and use only one late day, and ; walk through the code and ; use a Scanner for cin, and ; clean up a bit and ; put those grotesque casts in a helper function, and ; pull that ugly hack out of and ; read the header files just one more time. ; }