mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-17 16:18:37 +08:00
[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>
This commit is contained in:
@@ -281,7 +281,8 @@ source_cache::ensure (struct symtab *s)
|
|||||||
return false;
|
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
|
bool already_styled
|
||||||
= try_source_highlight (contents, s->language (), fullname);
|
= try_source_highlight (contents, s->language (), fullname);
|
||||||
@@ -291,7 +292,26 @@ source_cache::ensure (struct symtab *s)
|
|||||||
gdb::optional<std::string> ext_contents;
|
gdb::optional<std::string> ext_contents;
|
||||||
ext_contents = ext_lang_colorize (fullname, contents);
|
ext_contents = ext_lang_colorize (fullname, contents);
|
||||||
if (ext_contents.has_value ())
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ public:
|
|||||||
{
|
{
|
||||||
m_source_map.clear ();
|
m_source_map.clear ();
|
||||||
m_offset_cache.clear ();
|
m_offset_cache.clear ();
|
||||||
|
m_no_styling_files.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -95,6 +96,9 @@ private:
|
|||||||
/* The file offset cache. The key is the full name of the source
|
/* The file offset cache. The key is the full name of the source
|
||||||
file. */
|
file. */
|
||||||
std::unordered_map<std::string, std::vector<off_t>> m_offset_cache;
|
std::unordered_map<std::string, std::vector<off_t>> m_offset_cache;
|
||||||
|
|
||||||
|
/* The list of files where styling failed. */
|
||||||
|
std::unordered_set<std::string> m_no_styling_files;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The global source cache. */
|
/* The global source cache. */
|
||||||
|
|||||||
Reference in New Issue
Block a user