Hacker News new | ask | show | jobs
by asrp 2919 days ago
Thanks. The choice of gcc was somewhat arbitrary so clang could work too. I actually fiddle a bit with lldb before this.

From your description, it sounds like I'd really ought to removing optimizations (with -O0 from what's suggested here).

For variables, local variables can be optimized out (something I recall seeing in gdb without -O0) but all global variables are still kept, right? (At least, the ELF has names and addresses.)

1 comments

Compilers are free to delete global variables, if nothing references them, just like local variables. That said, if you don't declare them static or some other form of private variable, then compilers generally need to assume that some unknown entity can refer to them, which generally prevents their removal.