Bug 1784210 - Incorrect printing of source lines (colorized source lines not updated when source reloaded?)
Summary: Incorrect printing of source lines (colorized source lines not updated when s...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: gdb
Version: 31
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Sergio Durigan Junior
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-12-16 23:52 UTC by Dave Malcolm
Modified: 2020-02-20 05:03 UTC (History)
6 users (show)

Fixed In Version: gdb-8.3.50.20190824-30.fc31
Clone Of:
: 1798695 (view as bug list)
Environment:
Last Closed: 2020-02-20 05:03:43 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Dave Malcolm 2019-12-16 23:52:24 UTC
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

Comment 1 Dave Malcolm 2019-12-17 00:13:08 UTC
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	    }

Comment 2 Dave Malcolm 2019-12-17 15:06:24 UTC
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);

Comment 3 Dave Malcolm 2019-12-17 19:57:44 UTC
Upstream bug:
  https://sourceware.org/bugzilla/show_bug.cgi?id=25126

Comment 4 Sergio Durigan Junior 2020-02-04 21:36:43 UTC
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?

Comment 5 Dave Malcolm 2020-02-04 21:41:18 UTC
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.

Comment 8 Fedora Update System 2020-02-11 20:46:49 UTC
FEDORA-2020-d606156d7a has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2020-d606156d7a

Comment 9 Fedora Update System 2020-02-12 01:57:40 UTC
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

Comment 10 Fedora Update System 2020-02-20 05:03:43 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.