L11 - CME/Energy 211 Margot Gerritsen Shela Aboud Emmet...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
CME/Energy 211 Margot Gerritsen Shela Aboud Emmet Caulfield
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Lecture Overview • Debugging • Stacks • Stack-frames/calling conventions • Debuggers
Background image of page 2
Bug Types Code doesn’t compile – avoid by writing smaller sections of code and compile as you go; practice/experience Wrong output behavior –Test! Test! Test! printf statements; debugger Segmentation fault – debugger (gdb) assert ( true/false expression); Can be turned off with DNDEBUG
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
General Debugging Tricks • Think about the problem before writing the code. • Turn on all compiler warnings. • There is no “best” approach – do what works for you! • Don’t be afraid of your code! Test everything. • Use a format friendly editor (emacs). • Always fix bugs in order of the error message and recompile after fixing (each one). • The bigger the error messages the more silly the bug. • Be pessimistic about your code – assume there are many bugs.
Background image of page 4
Code Won’t Compile • The first error is always true, subsequent
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/17/2010 for the course CME 211 taught by Professor Staff during the Winter '10 term at Stanford.

Page1 / 11

L11 - CME/Energy 211 Margot Gerritsen Shela Aboud Emmet...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online