If you approach debugging in a very minimalist way, you should never use a debugger because it only serves to complicate things using the I/O subsystem to debug your program is a far more efficient way to debug. If you do things this way, you orthogonalize the optimization side of your compiler from the mess created by trying to assist the debugging process via the rather complex and intrusive (from the compiler's pe…
GCC gOlogy: studying the impact of optimizations on debugging
11–20 of 32 posts
Re: GCC gOlogy: studying the impact of optimizations on debugging
#12If you approach debugging in a very minimalist way, you should never use a debugger because it only serves to complicate things using the I/O subsystem to debug your program is a far more efficient way to debug. If you do things this way, you orthogonalize the optimization side of your compiler from the mess created by trying to assist the debugging process via the rather complex and intrusive (from the compiler's pe…
Re: GCC gOlogy: studying the impact of optimizations on debugging
#13More times than I'd like, I've encountered GDB refusing to show the value of a variable, claiming it's "optimized away". No, it's sitting right there in a register, and I know that because I just stepped through, instruction-by-instruction, the code that computed its value. Fortunately it does not claim the register has been "optimized away" too, but the experience of debugging optimised code could definitely use a l…
Given the invariant of "debug info does not affect optimization", you end up with plenty of cases where your only possible choices are "give the user a possibly wrong value for the variable" or "say the value does not exist anymore".
Most of the time, the latter is done instead of the former.
You also unfortunately cannot just mark them so the debugger tells you "this may be wrong, it may be right, good luck".
Historically, compilers tried doing the former, users complained enough that they switched to doing the latter.
Re: GCC gOlogy: studying the impact of optimizations on debugging
#14More times than I'd like, I've encountered GDB refusing to show the value of a variable, claiming it's "optimized away". No, it's sitting right there in a register, and I know that because I just stepped through, instruction-by-instruction, the code that computed its value. Fortunately it does not claim the register has been "optimized away" too, but the experience of debugging optimised code could definitely use a l…
Re: GCC gOlogy: studying the impact of optimizations on debugging
#15More times than I'd like, I've encountered GDB refusing to show the value of a variable, claiming it's "optimized away". No, it's sitting right there in a register, and I know that because I just stepped through, instruction-by-instruction, the code that computed its value. Fortunately it does not claim the register has been "optimized away" too, but the experience of debugging optimised code could definitely use a l…
(I wrote a bunch of gcc's initial support for optimized code debugging, as well as the initial associated gdb support for evaluating location lists and expressions, which is what makes this all work under the covers) Given the invariant of "debug info does not affect optimization", you end up with plenty of cases where your only possible choices are "give the user a possibly wrong value for the variable" or "say the…
Re: GCC gOlogy: studying the impact of optimizations on debugging
#16What I'd appreciate is if GDB, when stopped during execution, could show _all_ of the source statements that are currently 'in progress' (for the common case under optimisation where the execution of several source statements are interleaved). I don't know how feasible that is, though.
[1] https://docs.microsoft.com/en-us/visualstudio/debugger/using...
Re: GCC gOlogy: studying the impact of optimizations on debugging
#17More times than I'd like, I've encountered GDB refusing to show the value of a variable, claiming it's "optimized away". No, it's sitting right there in a register, and I know that because I just stepped through, instruction-by-instruction, the code that computed its value. Fortunately it does not claim the register has been "optimized away" too, but the experience of debugging optimised code could definitely use a l…
Regarding MSVC, just if you don't know already, you might want to try /Zo (formerly /d2Zi+). [1] [1] https://msdn.microsoft.com/en-us/library/dn785163.aspx
Re: GCC gOlogy: studying the impact of optimizations on debugging
#18Earlier quoted context omitted.
(I wrote a bunch of gcc's initial support for optimized code debugging, as well as the initial associated gdb support for evaluating location lists and expressions, which is what makes this all work under the covers) Given the invariant of "debug info does not affect optimization", you end up with plenty of cases where your only possible choices are "give the user a possibly wrong value for the variable" or "say the…
I wonder if the error message could just be better. Instead of using the excuse that the variable has been "optimized away", maybe gdb should just say it "cannot determine variable value due to optimization".
Re: GCC gOlogy: studying the impact of optimizations on debugging
#19What I'd appreciate is if GDB, when stopped during execution, could show _all_ of the source statements that are currently 'in progress' (for the common case under optimisation where the execution of several source statements are interleaved). I don't know how feasible that is, though.
Re: GCC gOlogy: studying the impact of optimizations on debugging
#20If you approach debugging in a very minimalist way, you should never use a debugger because it only serves to complicate things using the I/O subsystem to debug your program is a far more efficient way to debug. If you do things this way, you orthogonalize the optimization side of your compiler from the mess created by trying to assist the debugging process via the rather complex and intrusive (from the compiler's pe…