26
Chapter 1
2. Compile your program with debug support:
$
g++-8 main.cpp -o stepfun -g
3. Debug your program using
gdb
; you should see the following interactive
console session:
$
gdb stepfun
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from stepfun...done.
(gdb)
4. To insert a breakpoint, use the command
break
, which takes a single
argument corresponding to the name of the source file and the line
where you want to break, separated by a colon (
:
). For example, sup-
pose you want to break on the first line of
main.cpp. In Listing 1-8, that
is on line 5 (although you might need to adjust placement depending
on how you’ve written the source). You can create a breakpoint using
the following command at the (
gdb
) prompt:
(gdb)
Dostları ilə paylaş: