750 Part VI . Programming in Linux (gdb) (Sri lanka web server)
750 Part VI . Programming in Linux (gdb) whatis i type = int (gdb) whatis ary type = int * (gdb) whatis index_to_the_moon type = void (int *) This feature may seem rather useless because, of course, you know the types of all the variables in your program (yeah, right!). But, you will change your mind the first time you have to debug someone else s code or have to fix a multifile project for which you haven t seen the source files for a couple of months. The whatis command can also help you track down bugs that result from assigning an inappropriate value to a variable. Setting Breakpoints As you debug problematic code, it is often useful to halt execution at some point. Perhaps you want to stop execution before the code enters a section that is known to have problems. In other cases, you can set breakpoint so you can look at the values of certain variables at a given point in the execution flow. In still other situations, you might find it useful to stop execution so you can step through the code one instruction at a time. GDB enables you to set breakpoints on several different kinds of code constructs, including line numbers and function names, and also enables you to set conditional breakpoints, where the code stops only if a certain condition is met. To set a breakpoint on a line number, use the following syntax: (gdb) break linenum To stop execution when the code enters a function, use: (gdb) break funcname In either case, GDB halts execution before executing the specified line number or entering the specified function. You can then use print to display variable values, for example, or use list to review the code that is about to be executed. If you have a multifile project and want to halt execution on a line of code or in a function that is not in the current source file, use the following forms: (gdb) break filename:linenum (gdb) break filename:funcname Conditional breakpoints are usually more useful. They enable you to temporarily halt program execution if or when a particular condition is met. The correct syntax for setting conditional breakpoints is:
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.