[Converted from Gnats 1579] Whenever debugging anything gdb IMNSHO should cache the source files being debugged so that if you edit the source while debugging an executable that does not result in a gibberish (text at the wrong offset in the source file) being displayed. Debuggers for windoze adapted to user editing the source being debugged for ages. And so should gdb. 339 REQUIRE2(abuff,1); (gdb) n 340 REQUIRE2(abuff,1); (gdb) n 341 char c = *abuff(); Here the source was edited. Then you start to get this. (gdb) 342 uff(); (gdb) 344 fputc(c, debug); (gdb) 349 ; Release: 5.2.1 Environment: Linux (non OS specific really) How-To-Repeat: Add some code to the source file being shown during debug session, save the file and resume going thru the code.
Fix: Load the source file into memory before starting debugging. Modern machines got plenty of ram.
*** Bug 9651 has been marked as a duplicate of this bug. ***
Wasn't this basically implemented with source-cache.c?
(In reply to Hannes Domani from comment #3) > Wasn't this basically implemented with source-cache.c? Partly but the cache is not very large -- just 5 files. So if you go past that, gdb will re-read from the filesystem. I guess we could make this configurable.
One thought is that this will never really work properly. gdb isn't going to pre-read all the possible source files. So you'll always have a risk of seeing one out-of-date.