DOC PREVIEW
IUPUI CSCI 23000 - Debugger

This preview shows page 1-2-3-4-5 out of 15 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 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 15 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 15 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 15 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 15 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

DebuggerGDBGDB cont….GDB CommandsRun commandBreak pointsBreak points Cont….Watch PointsDeleting Break and Watch pointsContinue and steppingStepping ContinuedMiscellaneousMiscellaneous (cont)Slide 14Slide 15Dale RobertsDebuggerDebuggerDale Roberts, LecturerComputer Science, IUPUIE-mail: [email protected] of Computer and Information Science,School of Science, IUPUIDale RobertsGDB GDB The purpose of a debugger such as GDB is to The purpose of a debugger such as GDB is to allow you to see what is going on inside the allow you to see what is going on inside the program while it executes.program while it executes.GDB – GNU debuggerGDB – GNU debuggerGDB can be used to debug programs written in GDB can be used to debug programs written in C, C++.C, C++.The C++ debugging facilities are jointly The C++ debugging facilities are jointly implemented by the C++ compiler and GDB.implemented by the C++ compiler and GDB.To debug your C++ code, you must compile your To debug your C++ code, you must compile your C++ programs with a supported C++ compiler, C++ programs with a supported C++ compiler, such as GNU such as GNU g++g++, or the HP ANSI C++ compiler , or the HP ANSI C++ compiler ((aCCaCC) with a –g option to include symbols. ) with a –g option to include symbols.Dale RobertsGDB cont….GDB cont….GDB can do four main kinds of things (plus other things in support of GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act: these) to help you catch bugs in the act: Start your program, specifying anything that might affect its behavior. Start your program, specifying anything that might affect its behavior. Make your program stop on specified conditions. Make your program stop on specified conditions. Examine what has happened, when your program has stopped. Examine what has happened, when your program has stopped. Change things in your program, so that you can experiment with correcting Change things in your program, so that you can experiment with correcting the effects of one bug and go on to learn about another.the effects of one bug and go on to learn about another.Dale RobertsGDB CommandsGDB CommandsGDB is invoked by running the program gdb. Once the GDB is invoked by running the program gdb. Once the debugger is started, GDB reads command until you tell debugger is started, GDB reads command until you tell it to exit. GDB can be started with variety of arguments it to exit. GDB can be started with variety of arguments and options.and options.The most usual way to start debugging isThe most usual way to start debugging isgdb gdb program – program – one argument, which is an executable file one argument, which is an executable file more than one arguments can be providedmore than one arguments can be providedgdb gdb program coreprogram core – two arguments, one executable and – two arguments, one executable and one core fileone core filegdb gdb program 1234 – program 1234 – specify process id as second specify process id as second argumentargumentDale RobertsRun commandRun commandWhen gdb starts, your program is not When gdb starts, your program is not actually running. It won't run until actually running. It won't run until you instruct gdb how to run it.you instruct gdb how to run it. run – will start your program as if you run – will start your program as if you had typed a.outhad typed a.out You can provide command line You can provide command line arguments if the program requires.arguments if the program requires.Dale RobertsBreak pointsBreak pointsA A break break point makes your program stop point makes your program stop whenever a certain point in the program is whenever a certain point in the program is reachedreachedWays to set a break pointWays to set a break pointbreak break functionfunction - Set a breakpoint at entry to - Set a breakpoint at entry to function function functionfunctionbreak break +offset+offset - -break -break -offsetoffset - Sets a breakpoint some number - Sets a breakpoint some number of lines forward or back from the position at which of lines forward or back from the position at which execution stopped.execution stopped.break break linenumlinenum - Sets a breakpoint at line - Sets a breakpoint at line linenumlinenum in the current source file in the current source fileDale RobertsBreak points Cont….Break points Cont….break break filenamefilename::functionfunction - Sets a - Sets a breakpoint at entry to function breakpoint at entry to function functionfunction found in file found in file filenamefilename. . Specifying a file name as well as a Specifying a file name as well as a function name is superfluous except function name is superfluous except when multiple files contain similarly when multiple files contain similarly named functions.named functions.info breakpoints info breakpoints info break - info break - Prints a table of all Prints a table of all breakpoints set and not deletedbreakpoints set and not deletedDale RobertsWatch PointsWatch PointsA A watch watch point is a special breakpoint point is a special breakpoint that stops your program when the that stops your program when the value of an expression changesvalue of an expression changesWays to set a watch pointWays to set a watch point watch watch exprexpr - Sets a watchpoint for - Sets a watchpoint for an expression. an expression. info watchpointsinfo watchpoints - Prints a table of - Prints a table of all watch points set and not deleted all watch points set and not deletedDale RobertsDeleting Break and Watch pointsDeleting Break and Watch pointsDeleting Break points and watch Deleting Break points and watch pointspointsclearclear clear clear functionfunction clear clear file namefile name::funct ionfunct ion clear clear linenumlinenum clear clear file namefile name::linenu mlinenu m delete n – deletes the break point. n is a delete n – deletes the break point. n is a break point number.break point number.Dale RobertsContinue and steppingContinue and steppingcontinue [continue [ignore-countignore-count]] - - ContinuingContinuing means means resuming program execution until your program resuming program execution until your program completes normally.completes normally.Resumes program execution, at the address where Resumes program execution, at the address where your program last stopped, any breakpoints set at your program last stopped, any


View Full Document

IUPUI CSCI 23000 - Debugger

Download Debugger
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 Debugger 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 Debugger 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?