I started with --- #include <stdio.h> void foo (void) { printf ("hello\n"); } int main () { foo (); return 0; } ~ --- I compiled it with -g and set break point at line 6. I got (gdb) r Starting program: /export/build/gnu/tools-build/gdb/build-x86_64-linux/gdb/a.out Missing separate debuginfos, use: dnf debuginfo-install glibc-2.29-23.0.fc30.x86_64 Breakpoint 1, foo () at /tmp/foo.c:6 6 printf ("hello\n"); (gdb) Then I added a line: --- #include <stdio.h> void foo (void) { printf ("foo\n"); printf ("hello\n"); } int main () { foo (); return 0; } --- I recompiled and restarted gdb. I got (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y `/export/build/gnu/tools-build/gdb/build-x86_64-linux/gdb/a.out' has changed; re-reading symbols. Starting program: /export/build/gnu/tools-build/gdb/build-x86_64-linux/gdb/a.out Missing separate debuginfos, use: dnf debuginfo-install glibc-2.29-23.0.fc30.x86_64 Breakpoint 1, foo () at /tmp/foo.c:6 6 printf ("hello\n"); (gdb) list 1 #include <stdio.h> 2 3 void 4 foo (void) 5 { 6 printf ("hello\n"); 7 } 8 9 int 10 main () (gdb) Somehow gdb displayed the staled source.
This is caused by commit 872dceaaff9b54764b8f510b549497b9d904b136 Author: Tom Tromey <tromey@adacore.com> Date: Mon Jul 22 12:41:23 2019 -0600 Save plain text in the source cache Currently the source cache will only store highlighted text. However, there's no reason it could not also store plain text, when styling is turned off. This patch makes this change. This also simplifies the source cache code somewhat. The staled plain text in the source cache is used for source display.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7b71fc971bd31b27cce8b883007ad467a7567499 commit 7b71fc971bd31b27cce8b883007ad467a7567499 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Oct 24 15:43:21 2019 -0700 Call forget_cached_source_info to clear the stale source cache Clear the stale source cache when re-reading symbols. PR gdb/25126 * symfile.c (reread_symbols): Call forget_cached_source_info to clear the stale source cache.
Fixed. Nathan, I've CC'd you on this bug since this is the one you mentioned to me at the airport ... now fixed thanks to H.J.
The master branch has been updated by Sergio Durigan Junior <sergiodj@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f6be87130b5b327075a09c05e78532816f186995 commit f6be87130b5b327075a09c05e78532816f186995 Author: Sergio Durigan Junior <sergiodj@redhat.com> Date: Thu Feb 6 17:52:54 2020 -0500 New testcase for PR tui/25126 (staled source cache) I'm dealing with a Fedora GDB bug that is related to PR tui/25126, and I thought I'd write a specific testcase for it because I couldn't find one. The idea is to get the simple reproducer from the bug and tweak the testcase around it. This one was a bit hard because, since we need to modify the source file and recompile it, it involved a bit of TCL-foo to do things. Also for this reason, I'm only enabling the test for native boards. I tested this with an upstream GDB and made sure everything is passing. I also tested with a faulty GDB and made sure the test failed. gdb/testsuite/ChangeLog: 2020-02-11 Sergio Durigan Junior <sergiodj@redhat.com> PR tui/25126 https://bugzilla.redhat.com/show_bug.cgi?id=1784210 * gdb.base/cached-source-file.c: New file. * gdb.base/cached-source-file.exp: New file. Change-Id: Ib1b074342ebe8613c6d1dfde631691ebdf6d81c6