aboutsummaryrefslogtreecommitdiff
path: root/gdb/source-cache.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2023-10-17 11:38:06 +0200
committerTom de Vries <tdevries@suse.de>2023-10-17 11:38:06 +0200
commitdcbdb080edf53aa1bed4c84e99fe50e0573d239a (patch)
tree937bfbf76c3ae9fb1517dd0d9856ba2ce6a5238f /gdb/source-cache.c
parent62dfd02e30e33be7b6acab5e2e50677d60b8ff8c (diff)
downloadgdb-dcbdb080edf53aa1bed4c84e99fe50e0573d239a.zip
gdb-dcbdb080edf53aa1bed4c84e99fe50e0573d239a.tar.gz
gdb-dcbdb080edf53aa1bed4c84e99fe50e0573d239a.tar.bz2
[gdb/cli] Keep track of styling failures in source_cache
In source_cache::ensure, keep track of which files failed to be styled, and don't attempt to style them again in case the file dropped out of the cache. Tested on x86_64-linux. Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Diffstat (limited to 'gdb/source-cache.c')
-rw-r--r--gdb/source-cache.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/gdb/source-cache.c b/gdb/source-cache.c
index a6b035b..99be333 100644
--- a/gdb/source-cache.c
+++ b/gdb/source-cache.c
@@ -281,7 +281,8 @@ source_cache::ensure (struct symtab *s)
return false;
}
- if (source_styling && gdb_stdout->can_emit_style_escape ())
+ if (source_styling && gdb_stdout->can_emit_style_escape ()
+ && m_no_styling_files.count (fullname) == 0)
{
bool already_styled
= try_source_highlight (contents, s->language (), fullname);
@@ -291,7 +292,26 @@ source_cache::ensure (struct symtab *s)
gdb::optional<std::string> ext_contents;
ext_contents = ext_lang_colorize (fullname, contents);
if (ext_contents.has_value ())
- contents = std::move (*ext_contents);
+ {
+ contents = std::move (*ext_contents);
+ already_styled = true;
+ }
+ }
+
+ if (!already_styled)
+ {
+ /* Styling failed. Styling can fail for instance for these
+ reasons:
+ - the language is not supported.
+ - the language cannot not be auto-detected from the file name.
+ - no stylers available.
+
+ Since styling failed, don't try styling the file again after it
+ drops from the cache.
+
+ Note that clearing the source cache also clears
+ m_no_styling_files. */
+ m_no_styling_files.insert (fullname);
}
}