DOC PREVIEW
UW CSE 303 - Lecture Notes

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

'&$%CSE 303:Concepts and Tools for Software DevelopmentDan GrossmanWinter 2006Lecture 15— Debuggers, e.g., gdbDan Grossman CSE303 Winter 2006, Lecture 15 1'&$%Where are We“Tools you may not know exist” – debuggers, profilers, library-make rs,recompilation managers, version-control systems.The concepts behind these tools are orthogonal to programminglanguage and level of abstraction.But tools may need to “understand” your PL of choice.And we’ll largely use C to give you more practice.Today: debuggers (a terribly misnamed tool).Dan Grossman CSE303 Winter 2006, Lecture 15 2'&$%An execution monitor?What would like to “see from” and “do to” a running program?Why might all that be helpful?What are reasonable ways to debug a program?A “debugger” is a tool that lets you stop running programs, inspect(sometimes set) values, etc.Dan Grossman CSE303 Winter 2006, Lecture 15 3'&$%Issues• Source information for compiled code. (Get compiler help.)• Stopping your program too late to find the problem. (Art.)• Trying to “debug” the wrong algorithm.• Trying to “run the debugger” instead of understanding theprogram.It’s an important tool. I use it sometimes.Debugging C vs. Java• Eliminating crashes does not make your C program correct.• Debugging Java is “easier” because crashes and memory errors donot exist.• But programming Java is “easier” for the same reason!Dan Grossman CSE303 Winter 2006, Lecture 15 4'&$%gdbgdb (Gnu debugger) is on attu and supports several languages,including C compiled by gcc.Modern IDEs have fancy GUI interfaces, which help, but concepts arethe same.Compiling with debugging information: gcc -g• Otherwise, gdb can tell you little more than the stack of functioncalls.Running gdb: gdb executable• Source files should be in same directory (or use the -d flag).At prompt: run argsNote: You can also inspect core files, which is why they get saved. (Inever do.)Dan Grossman CSE303 Winter 2006, Lecture 15 5'&$%Basic functionality• backtrace• frame, up, down• print expression, info args, info localsOften enough for “crash debugging”Also often enough for learning how “the compiler does things” (e.g.,stack direction, malloc policy, ...)Dan Grossman CSE303 Winter 2006, Lecture 15 6'&$%Breakpoints• break function (or line-number or ...)• conditional breakpoints1. to skip a bunch of iterations2. to do assertion checking• going forward: continue, next, step, finish– Some debuggers let you “go backwards” (typically an illusion)Often enough for “binary search debugging”Also useful for learning program structure (e.g., when is some functioncalled)Dan Grossman CSE303 Winter 2006, Lecture 15 7'&$%AdviceUnderstand what the tool provides you.Use it to accomplish a task, for example “I want to know thecall-stack when I get the NULL-pointer derefere nce”Optimize your time developing software.Use development environments that have debuggers?See also: jdb for Java (on attu)Dan Grossman CSE303 Winter 2006, Lecture 15


View Full Document

UW CSE 303 - Lecture Notes

Documents in this Course
Profiling

Profiling

11 pages

Profiling

Profiling

22 pages

Profiling

Profiling

11 pages

Testing

Testing

12 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?