Red Hat ENTERPRISE LINUX 3 - DEVELOPER TOOLS GUIDE Manuel d'utilisateur Page 18

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 24
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 17
14 Chapter 3. Developing with Red Hat Enterprise Linux Developer Tools
3.3. Run the Executable
To run the program, use the following example:
./hello
The program generates
hello world!
3 + 4 = 7
and returns when the program exits.
3.4. Debug the Executable
To start GDB, use the following commands:
gdb hello
After the initial copyright and configuration information, GDB returns its own prompt, (gdb). The
following is a sample debugging session:
1. To set a breakpoint, type:
break main
The following output displays:
Breakpoint 1 at 0x132: file hello.c, line 15.
Note the exact address and line number may vary, depending upon the target architecture being
debugged and the exact layout of the C code in the hello.c file.
2. To run the program, type:
run
The following output displays (when the program stops at a breakpoint):
Starting program: hello
Breakpoint 1, main () at hello.c:15
15 a = 3;
Again note that the exact line number and instruction displayed is dependent upon the source
code layout.
3. To print the value of variable, a, type:
print a
The following output displays:
$1 = 0
4. To execute the next command, type next:
next
The following output displays:
16 b = 4;
5. To display the value of a again, type:
print a
The following output displays:
$2 = 3
6. To display the program being debugged, type:
list
Vue de la page 17
1 2 ... 13 14 15 16 17 18 19 20 21 22 23 24

Commentaires sur ces manuels

Pas de commentaire