Description of problem: When gdb reloads its symbols, it seems to incorrectly print source lines that were previously stepped through. It looks like the colorized source is cached, and it's not flushing the cache. For example, from a recent session debugging GCC's cc1 (edited for clarity): `/home/david/more-coding/gcc-git-analysis-output/build/gcc/cc1' has changed; re-reading symbols. (gdb) run Breakpoint 1, fancy_abort (file=0x276f700 "../../src/gcc/analyzer/region-model.cc", line=4215, function=0x276ffff "add") at ../../src/gcc/diagnostic.c:1775 1775 internal_error ("in %s, at %s:%d", function, trim_filename (file), line); Missing separate debuginfos, use: dnf debuginfo-install gmp-6.1.2-10.fc30.x86_64 libmpc-1.1.0-3.fc30.x86_64 libzstd-1.4.2-1.fc30.x86_64 mpfr-3.1.6-4.fc30.x86_64 [go up twice] (gdb) up #1 0x0000000001958548 in reachable_regions::add (this=0x7fffffffb530, rid=...) at ../../src/gcc/analyzer/region-model.cc:4215 4215 gcc_assert (m_model->get_num_regions () == m_rids.overall_num_regions ()); (gdb) #2 0x0000000001945fc7 in region_model::handle_unrecognized_call (this=0x3ea7750, call=0x7fffea72bb48, ctxt=0x7fffffffb6f0) at ../../src/gcc/analyzer/region-model.cc:4291 4291 } Note how line 4291 is supposedly just a brace, rather than a call to the fn at frame #1. (gdb) show style sources Source code styling is enabled. (gdb) set style sources off [go up, then down] (gdb) up #3 0x0000000001945e50 in region_model::on_call_pre (this=0x3ea7750, call=0x7fffea72bb48, ctxt=0x7fffffffb6f0) at ../../src/gcc/analyzer/region-model.cc:4199 4199 handle_unrecognized_call (call, ctxt); (gdb) down #2 0x0000000001945fc7 in region_model::handle_unrecognized_call (this=0x3ea7750, call=0x7fffea72bb48, ctxt=0x7fffffffb6f0) at ../../src/gcc/analyzer/region-model.cc:4291 4291 reachable_regions.add (pointee_rid); and line 4291 is now displayed correctly Version-Release number of selected component (if applicable): gdb-8.3-7.fc30.x86_64
Here's another example, after a rebuild of cc1, where the output for "list 4302" is only correct after "set style sources off" (and continues to be correct when "set style sources on"): (gdb) list 4302 4297 potentially looking at descendents. */ 4298 4299 /* Once we've found all reachable regions, purge all the values in 4300 them and their descendents (setting to new unknown values), without 4301 treating it as a leak. 4302 4303 TODO: make a distinction between reachable vs to-be-set-to-unknown 4304 so that we can purge state in descendents, and only set top-level 4305 regions to "unknown"? */ (gdb) set style sources off (gdb) list 4302 4297 svalue *parm_sval = get_svalue (parm_sid); 4298 if (parm_sval) 4299 if (region_svalue *parm_ptr = parm_sval->dyn_cast_region_svalue ()) 4300 { 4301 region_id pointee_rid = parm_ptr->get_pointee (); 4302 reachable_regions.add (pointee_rid); 4303 } 4304 // FIXME: what about compound parms that contain ptrs? 4305 } 4306 (gdb) set style sources on (gdb) list 4302 4297 svalue *parm_sval = get_svalue (parm_sid); 4298 if (parm_sval) 4299 if (region_svalue *parm_ptr = parm_sval->dyn_cast_region_svalue ()) 4300 { 4301 region_id pointee_rid = parm_ptr->get_pointee (); 4302 reachable_regions.add (pointee_rid); 4303 } 4304 // FIXME: what about compound parms that contain ptrs? 4305 }
FWIW "set style sources on" seems to be enough to purge the cache: (gdb) list 968,968 968 else (gdb) set style sources on (gdb) list 968,968 968 state->m_region_model->on_call_pre (call, &ctxt);
Upstream bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25126
Thanks for the report, David, and sorry for the long time it took me to process it. Do you still want the fix backported to F30 GDB, or do you mind if I just backport it to F31 GDB?
I've worked around it locally on my development box by adding set style enabled off to my ~/.gdbinit so I personally don't need it backported.
FEDORA-2020-d606156d7a has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2020-d606156d7a
gdb-8.3.50.20190824-30.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-d606156d7a
gdb-8.3.50.20190824-30.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report.