In the following C code:
#include <stdio.h>
int main(void)
{
unsigned i = 1;
while (i)
{
i <<= 1;
}
return 0;
}
I first compile with debugging info as followed: gcc -g single-step.c
Then I do lldb a.out. I want to see what i is doing, so i do b main and run, after which i set my watchpoint for i: watchpoint set variable i. When I do that however, lldb seems to assign a value to variable i, which it shouldn't
Watchpoint created: Watchpoint 1: addr = 0x16fdff498 size = 4 state = enabled type = w declare @ '/Users/d1ff1cult/Documents/KUL 2021-2022/IW/oefenzitting-c/les8-debugging/examples/single-step.c:5' watchpoint spec = 'i' new value: 53472
It gives i a seemingly completely random value, so what am I doing wrong?
I use CLion to write my code, but this happens in the CLion terminal as well as my macOS proper terminal. I am also using an M1 Mac.
Thanks in advance!