Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What about optimizations?

Isn't it possible the compiler will re-order or combine statements differently than how they are written in source?



That's why step-debugging usually is done on unoptimized builds where there's a clear relationship between the original source code lines and variables and the generated machine code.

But there's a wide "grey area" depending on optimization level where the debug information is more or less off yet the mapping is still "good enough". Debugging on optimized builds can work surprisingly well if you know what to expect (e.g. the debugging cursor might jump to unexpected places in the source code because the line mapping is off, or you can't step into a function because it has been inlined).


Yes, it is. Do you have a specific question?


I think their question was this: how is it that I can step through and see the expected changes to my variables, given that the optimiser is permitted to re-order/elide/restructure my code?


You will not see the expected changes and stepping through will jump around erratically. Often you will be unable to print the value of a variable because it has been optimised out.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: