(gdb) b 11
Breakpoint 1 at 0x890: file example.c, line 11.
(gdb) cond 1 (i==5)
(gdb) r
Starting program: /home/bankde/Desktop/tmp/example.o
Put string to split: hello world
Breakpoint 1, split (input=0x7fffffffdf40 "hello world\n") at example.c:11
11 if (input[i] == ' ') {
(gdb) p i
$1 = 5
(gdb)
10 for (int i=0; i<strlen(input); i++) {
(gdb)
11 if (input[i] == ' ') {
(gdb) watch i
Hardware watchpoint 2: i
(gdb) c
Continuing.
Hardware watchpoint 2: i
Old value = 0
New value = 1
0x00005555555548e3 in split (input=0x7fffffffdf40 "hello world\n") at example.c:10
10 for (int i=0; i<strlen(input); i++) {
(gdb) c
Continuing.
Hardware watchpoint 2: i
Old value = 1
New value = 2
0x00005555555548e3 in split (input=0x7fffffffdf40 "hello world\n") at example.c:10
10 for (int i=0; i<strlen(input); i++) {
(gdb) c
Continuing.
Hardware watchpoint 2: i
Old value = 2
New value = 3
0x00005555555548e3 in split (input=0x7fffffffdf40 "hello world\n") at example.c:10
10 for (int i=0; i<strlen(input); i++) {
(gdb) b getInputAndRun
Breakpoint 1 at 0x90d: file example.c, line 20.
(gdb) r
Starting program: /home/bankde/Desktop/tmp/example.o
Breakpoint 1, getInputAndRun () at example.c:20
20 int getInputAndRun() {
(gdb) n
22 printf("Put string to split: ");
(gdb)
23 fgets(input, 100, stdin);
(gdb)
Put string to split: hello world
24 if (strcmp(input, "exit") == 0) return -1;
(gdb) x/s input
0x7fffffffdf40: "hello world\n"
(gdb) watch *0x7fffffffdf40 mask 0xffffffffff00
This target does not support masked watchpoints.
(gdb) watch *0x7fffffffdf40
Hardware watchpoint 2: *0x7fffffffdf40
(gdb) watch *0x7fffffffdf44
Hardware watchpoint 3: *0x7fffffffdf44
(gdb) watch *0x7fffffffdf48
Hardware watchpoint 4: *0x7fffffffdf48
(gdb) c
Continuing.
Hardware watchpoint 3: *0x7fffffffdf44
Old value = 1870078063
New value = 1870069871
split (input=0x7fffffffdf40 "hello") at example.c:13
13 result[j] = input+i+1;
(gdb) x/4xb 0x7fffffffdf44
0x7fffffffdf44: 0x6f 0x00 0x77 0x6f
(gdb) c
Continuing.
Hardware watchpoint 2: *0x7fffffffdf40
Old value = 1819043176
New value = 1819043144
getInputAndRun () at example.c:28
28 *result[1] = toupper(result[1][0]);
(gdb) c
Continuing.
Hardware watchpoint 3: *0x7fffffffdf44
Old value = 1870069871
New value = 1867972719
getInputAndRun () at example.c:29
29 printf("First str: %s\n", result[0]);
(gdb) c
Continuing.
First str: Hello
Second str: World