Files
UoL/CM2010 Software Design and Development/Topic 4/12.2.3 Debug/debug.cpp
2021-09-02 00:23:24 -05:00

47 lines
566 B
C++

#include <iostream>
int x = 0;
void looper()
{
for(int i=0; i < 4; i++)
{
printf("i is %i \n", i);
if(i > 2) x++;
}
}
int main()
{
looper();
x++;
return 0;
}
/* command
g++ -g debug.cpp -o debugme
Outputs debugme.exe
Debug
gdb debugme
In gdb
run
break 1
break 9 // Add a breakpoint in the code
print variable
info locals
info stack
info args
next - next line of code
step - follow function calls
continue - resume the program until it hits the next breakpoint or end of the program
Conditional breakpoint
break 9 if i > 2
Watchpoint
*/