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 multi-file 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).
TIP
807
Programming Tools and Utilities 29
To specify one or more additional directories containing source code, start GDB using one or more
-d dirname options, as this example illustrates:
$ gdb -d /source/project1 -d /oldsource/project1 -d /home/
bubba/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.
Pages:
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458