Chapter 28 . Programming (Best web design) Tools and Utilities 749

Chapter 28 . Programming Tools and Utilities 749 The expression $1 is an alias that refers to an entry in GDB s value history. GDB creates value history entries for each command you type that produces computed results. The alias numbers increment sequentially each time you execute a command that produces some sort of computed output. As a result, you can access these computed values using aliases rather than retyping the command. For example, the command $1-5 produces: (gdb) print $1-5 $2 = 719 Notice that the alias incremented to $2. If you later need to use the value 719, you can use the alias $2. The value history is reset each time you start GDB, and the values are not accessible outside GDB. You are not limited to using discrete values because gdb can display the addresses of data stored in an arbitrary region of memory. For example, to print the first 10 memory locations associated with ary, use the following command: (gdb) print ary@10 $3 = {0xbffffc90, 0×40015580, 0×400115800, 0×0, 0×1, 0×2, 0c3, 0×4, 0×5} The notation @10 means to print the 10 values that begin at ary. Say, on the other hand, that you want to print the five values stored in ary beginning with the first element. The command for this would be the following: (gdb) print ary[1]@5 $4 = {1, 2, 3, 4, 5} Why go to the trouble of printing variable or array values? Although it isn t necessary in this particular example because you know where the trouble occurs, it is often necessary to see the value of a variable at a particular point in a program s execution so you monitor what is happening to variables. In the case of arrays, a command that prints the values in an array, such as print ary[1]@5 in the preceding example, enables you to confirm at a glance the values are what you expect them to be. If the values don t match up with your expectations, though, that is a clue that some code is altering the array in a way you didn t intend. As a result, you can focus your bug hunting on a specific section of code. GDB also can tell you the types of variables using the whatis command. GDB s whatis command is comparable to the man -f command, which searches the whatis database of system commands for short descriptions of those system commands (the manual page whatis database is totally separate from the whatis command used by GDB).While man s whatis database works on system commands, GDB s whatis command describes the types of variables and other data structures used in a program.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Leave a Reply