http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55608
Bug #: 55608 Summary: [4.6/4.7/4.8 Regression] Debug info quality regressions with file scope vars Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug AssignedTo: ja...@gcc.gnu.org ReportedBy: ja...@gcc.gnu.org static const char *a = "opq"; static const char b[8] = "rstuv"; int main () { const char *p = "abcd"; const char *q = "efgh"; const char r[] = "ijk\0lmn"; const char *s = r; return 0; } at -g -O2, gdb ./test; b main; p a; p b shows (gdb) p a $1 = 0x400560 "opq" (gdb) p b $2 = "rstuv\000\000" in e.g. GCC 3.2 or 3.3, but later on it is <optimized out>. This is related to PR55395, without reverting or adjusting part of that all the info is gone. I have a patch which so far makes p b work (if a non-DECL_EXTERNAL variable is optimized away and had an initializer, it means nothing is actually changing it and so we can add DW_AT_const_value attribute), plans how to do some other vars in this testcase.