Whenever I set a breakpoint in my c program in gdb, it sets the breakpoint one line after the line I specify in the "break" command.
So I want to examine some simple c code just to get me started in debugging in c, I set a breakpoint at line 6 in the code, but it keeps setting the breakpoint on line 7 instead.
#include <stdio.h>
#include <string.h>
int main() {
char str_a[20];
strcpy(str_a, "Hello, world!\n");
printf(str_a);
}
I first list the lines of code using "list", then I use the command "break 6" to add a breakpoint at line 6, I would expect the output to be something like this: "Breakpoint 1 at 0x000d: file char_array.c, line 6." but the output for this command is actually "Breakpoint 1 at 0x113d: file char_array.c, line 7." This line is spit out whenever I try to add breakpoints at all the lines above line 7 as well. Could this be a bug?
You can only set a breakpoint where there's something that executes.
Line 6 is blank. It never gets executed. So you can't put a breakpoint there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.