CMSC212: Intro to Low-Level Programming Concepts - PowerPoint PPT Presentation

cmsc212 intro to low level programming concepts n.
Skip this Video
Loading SlideShow in 5 Seconds..
CMSC212: Intro to Low-Level Programming Concepts PowerPoint Presentation
Download Presentation
CMSC212: Intro to Low-Level Programming Concepts

play fullscreen
1 / 9
CMSC212: Intro to Low-Level Programming Concepts
Download Presentation
Download Presentation

CMSC212: Intro to Low-Level Programming Concepts

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. CMSC212: Intro to Low-Level Programming Concepts Section 0101: 9:00am – 9:50am Section 0102: 10:00am-10:50am Monday & Wednesdays Room 3118

  2. Announcements/Reminders • Quiz #2: This Wednesday (12mins) • Reminder: Must submit versions of every project that work on at least half the public tests to pass the course (Still can submit Project #1 up until 10:00 tonight) • Today: First, the GNU Project Debugger (GDB) and its innards. Later, a worksheet (based on quiz questions from earlier semesters)

  3. GNU Project Debugger (GDB) • The main idea • Lets your step through your code “line-by-line” during execution • Lets you look/modify variables and their values during run-time • Breakpoints! • Want your program to temporary halt execution on a particular line of code, set a breakpoint •

  4. GNU Project Debugger (GDB) • Programs must be compiled with the option –g to be debugged with gdb • Some common commands with console gdb • r: run: runs the program from the beginning • c: cont: continues execution after breakpoint • n: next: executes next statement, steps over function calls • s: step: executes next statement, steeping into function calls • finish: completes the execution (returns from current function)

  5. GNU Project Debugger (GDB) • Breakpoints • b: break: sets a breakpoint on current line or any line • tb: tbreak: sets a temporary breakpoint on indicated line • d: delete: deletes one or all breakpoints • i b: info breakpoints: lists all currently set breakpoints

  6. GNU Project Debugger (GDB) • Looking at data • p: print: prints a variable’s current value., print/x prints in hex • info locals: prints values of current function’s local variables • display: followed by a variable name which is visible at the current position, prints the value of that variable each time the program execution stops. • undisplay: Cancels the display of variables set in prior display commands

  7. GNU Project Debugger (GDB) • Execution history • where: shows list of active functions, in order from most recent-called back to main function • up: moves up the function which called the current one (to be able to examine its data) • down: move back after calling up • If program crashes during execution (e.g. segfault, use ‘where’ to find out where it happened

  8. GDB with emacs • Hit escape-x • Type ‘gdb’ • The following may appear, just hit enter to launch: gdb –annotate=3 program.x • Begin debugging, hit r • Should see a split window of console and code • set breakpoints using cursor in the code window

  9. Other features: Look at menu ‘GuD’, “GDB-UI”, and “Display other Windows” • Gdb interaction (console) window • display of local variables in the main program • Source code • Runtime stack and current function call chain • List o breakpoints set