Breakpoints pile up. This one in bonus will stop you six times before the loop is done.
Listing, disabling and deleting breakpoints
Level 9 of 13 · interactive GDB exercise · runs in your browser
List the breakpoints that exist, switch one off temporarily, and remove one for good.
info breakpoints lists them, each with a number. disable 1 switches number 1 off; enable 1 switches it back on; delete 1 removes it for good.
Get to line 14 without stopping in bonus again, then remove that breakpoint.
You work in a real GDB session on the program below. Breakpoints on bonus and on line 14 were set and the program was started; it is paused in the first call to bonus.
#include <stdio.h>
int scores[6] = {4, 8, 15, 16, 23, 42};
int bonus(int score) {
return score / 4;
}
int main(void) {
int total = 0;
for (int i = 0; i < 6; i++) {
total += scores[i] + bonus(scores[i]);
}
printf("total = %d\n", total);
return 0;
}
main.c, compiled with gcc -g -O0 -std=c11 -Wall -fno-omit-frame-pointer -fno-stack-protector -no-pie -fno-pie for 32-bit x86 Linux.
info breakpointsdisable [n]enable [n]delete [n]clear <where>tbreak <where>startcondition <n> <cond>ignore <n> <count>continuedisable or delete with no number. That affects every breakpoint, so continue runs to the end. Set them again (break bonus), or use Reset level.disable instead; enable brings it back with its condition and hit count intact.delete. delete takes breakpoint numbers. To remove by place, use clear <line> or clear <function>.