Bug 8684 - GDB should cache the source files for the executable being debugged
Summary: GDB should cache the source files for the executable being debugged
Status: ASSIGNED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 5.2
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 9651 (view as bug list)
Depends on:
Blocks: 9651
  Show dependency treegraph
 
Reported: 2004-03-01 20:48 UTC by agraph03
Modified: 2024-03-28 05:09 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description agraph03 2004-03-01 20:48:01 UTC
[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.
Comment 1 agraph03 2004-03-01 20:48:01 UTC
Fix:
Load the source file into memory before starting debugging. Modern machines got plenty of ram.
Comment 2 Pedro Alves 2010-04-18 01:09:38 UTC
*** Bug 9651 has been marked as a duplicate of this bug. ***
Comment 3 Hannes Domani 2020-02-01 21:07:45 UTC
Wasn't this basically implemented with source-cache.c?
Comment 4 Tom Tromey 2020-04-01 18:08:05 UTC
(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.
Comment 5 Tom Tromey 2022-04-08 00:18:57 UTC
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.