gdb - Getting started with gdb Running gdb You need to...

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

View Full Document Right Arrow Icon
Getting started with gdb Running gdb You need to compile your file with the "-g" flag: g++ -g -o myprog myprog.cpp This command runs gdb on your program: gdb myprog Once gdb starts, you'll need to use the "run" command to run it. Basic commands r run/restart the program from the beginning r arg arg arg run with command-line arguments c continue running after breakpoint s single step l 9 list line 9 l myprog.cpp:9 list line 9 of file myprog.c b 9 set breakpoint at line 9 b main set breakpoint at main display x, y display x and y after every step or breakpoint p x print x (once)
Background image of page 1

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

View Full DocumentRight Arrow Icon
where show the stack backtrace help learn more about gdb Hints If the program is crashing with a segmentation fault, start it in gdb and just run it without setting a breakpoint. When it crashes, gdb will tell you where the crash happened. You can print variables to figure out what happened, or set a breakpoint there or at some earlier and run the program again. If the program isn't crashing but has a difficult bug to find, use breakpoints, single-stepping, and the print and
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/01/2011 for the course CSSE 250 taught by Professor Dr.yingwuzhu during the Spring '11 term at UH Clear Lake.

Page1 / 2

gdb - Getting started with gdb Running gdb You need to...

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

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