Do the following steps.
Open command prompt window.
Compile program with -g flag to generate debug info
> g++ example.cpp -g
Debug program with gdb
> gdb a.exe
Put a breakpoint at main() function
(gdb) b main
Run program which will pause at breakpoint
(gdb) run
gdb information source
(gdb) info source
Output something like the following:
{
Current source file is example.cpp
Compilation directory is C:\Users\xxx\Desktop\cpp_directoryLocated in C:\Users\xxx\Desktop\cpp_directory\example.cpp
Contains 21 lines.
Source language is c++.
Producer is GNU C++14 8.1.0 -mtune=core2 -march=nocona -g.
Compiled with DWARF 2 debugging format.
Does not include preprocessor macro info.
}
(gdb) quit
>
No comments:
Post a Comment