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

Info iconThis preview shows pages 1–7. 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 • Memory Debuggers
Background image of page 2
Memory Debuggers • Many different flavors. • Common Tool: GNU Project Debugger (GDB) – Start your program, specifying anything that might affect its behavior. – Make your program stop on specified conditions. – Examine what has happened, when your program has stopped. – Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Memory Debuggers Where did the code stop and how did it get there? • GDB allows you to examine the stack and see the location of the function calls, the arguments of the function calls, and the corresponding local variables (all of which is saved on the stack). • When GDB is called it automatically selects the currently executing stack frame, but it is also possible to select different frames on the stack. • GDB assigns each existing stack frame a number, starting with zero for the innermost frame (the frame for the function that was most recently executed)
Background image of page 4
GDB stack numbering 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 DATA DATA DATA DATA Active Frame Stack Origin Stack Pointer main() m_rand() m_new() srandom() return link to m_new() return link to m_rand() return link to main() AVAILABLE STACK SPACE Inactive Frame Inactive Frame Inactive Frame 0 1 2 3 Frame number:
Background image of page 5

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

View Full DocumentRight Arrow Icon
GDB Command Options frame n or f n Select frame number n . Recall that frame zero is the innermost (currently executing) frame,
Background image of page 6
Image of page 7
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 / 10

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

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

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