At the start of the year I switched to using my mac for programming instead of windows. With it came some changes. One was using the SDL library instead of Win32 for the platform layer. The other big change was using Xcode as the debugger instead of Visual Studio. My goal was to use it in a similar way to how Casey’s uses Visual Studio. Stepping through the code, setting breakpoints etc. but not actually using it as the text editor. Once I got used to using it, the flow process was pretty similar to how I was programming on Windows. I had my text editor and then run the program in the debugger and if it crashed, you could easily see why.
One day the breakpoints stopped working on Xcode. I’m not sure if I changed a setting or it was just undefined behaviour, but it would only honour breakpoints set in the file with the entry point, and ignore all others. I tried fixing it, then just used how it was for a while, but eventually this was a catalyst to just stop using a debugger. I went back to using printf and running the program from the command line.
So I’m using sublime text for the editor and just have a terminal window to compile with clang and run the executable. I found with this workflow, I got better at fixing bugs, and weirdly felt like I was more productive. When I was using a debugger, it took mental energy to use it, like setting up variables setting breakpoints, keeping an eye on not skipping over the function I was debugging. And it narrowed my focus. I started seeing trees, instead of the forest. When I was using printf, I have to think more holistically, and so get more practice at solving the bugs. Also I find seeing how the information changes over time helps a lot, i.e. a list of the values that happened.
Debuggers are also useful for seeing where the program crashed. Although this is far superior then the printf case in which you just get a segmentation fault, I found the apple report afterwards gave enough information to solve the bug. It gives you the line number, file and the call stack of where the program crashed.
The other benefit I found running from the command line is that your more likely to run into things that stop the program from being portable. I.e getting resources using the executable path, loading libraries etc.
So overall it was a blessing in disguise that Xcode stopped working. Although sometimes I think, Im not going to be able to solve this without a debugger, I find some way to solve it using printf.