What are the best techniques to debug a program?
I wrote a program in Swift using Metal in Xcode. Since Metal needs MTLBuffers in order to work I need to deal with pointers.
And now I get unexpected and totally unlogical behavior (sometimes it crashes and sometimes not with the same starting conditions; numbers seem to be zero and in the next moment they are not initialized; short: it’s a mess :)
How do you debug such behavior (it’s hard to do that with breakpoints and debugger because the program crashes only sometimes)? Are there some tricks? Or some general steps to debug it?
Thanks for your answers!