Free web design - Chapter 28 . Programming Tools and Utilities 751
Chapter 28 . Programming Tools and Utilities 751 (gdb) break linenum if expr (gdb) break funcname if expr expr can be any expression that evaluates to true (nonzero). For example, the following break command stops execution at line 24 of debugme when the variable i equals 15: (gdb) break 24 if i == 15 Breakpoint 1 at 0×80483cb: file debugme.c, line 24. (gdb) run Starting program: /home/kwall/code/debugme Breakpoint 1, index_to_the_moon (ary=0xbffff4b0) at debugme.c:24 24 ary[i] = i; Stopping when i equals 15 is an arbitrary choice to demonstrate conditional breaks. As you can see, gdb stopped on line 24. A quick print command confirms that it stopped when the value of i reached the requested value: (gdb) print i $1 = 15 To resume executing after hitting a breakpoint, type continue. If you have set many breakpoints and have lost track of what has been set and which ones have been triggered, you can use the info breakpoints command to refresh your memory. Working with Source Code Locating a specific variable or function in a multifile project is a breeze with GDB, provided you use the -d switch to tell it where to find additional source code files. This is a particularly helpful option when not all of your source code is located in your current working directory or in the program s compilation directory (which GCC recorded in its symbol table). To specify one or more additional directories, start GDB using one or more -d dirname options, as this example illustrates: $ gdb -d /source/project1 -d /oldsource/project1 -d /home/b ubba/src killerapp To locate the next occurrence of a particular string in the current file, use the search string command. Use reverse-search string to find the previous occurrence of string. If you want to find the previous occurrence of the word return in debugme.c (see Listing 28-5), for example, use the command reverse-search return. GDB obliges and displays the text: (gdb) reverse-search return 17 return ret;
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.