aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-12-10 14:16:06 -0700
committerTom Tromey <tom@tromey.com>2024-01-08 18:40:21 -0700
commit8e279fda0f725500c8f84a8b2ed56b0ee8d00ce0 (patch)
tree266a39de85287280db4ad3a9cc77f3eaf3c5b384 /gdb/utils.h
parent54b815ddb428944a70694e3767a0fadbdd9ca9ea (diff)
downloadgdb-8e279fda0f725500c8f84a8b2ed56b0ee8d00ce0.zip
gdb-8e279fda0f725500c8f84a8b2ed56b0ee8d00ce0.tar.gz
gdb-8e279fda0f725500c8f84a8b2ed56b0ee8d00ce0.tar.bz2
Add deferred_warnings parameter to read_addrmap_from_aranges
When DWARF reading is done in the background, read_addrmap_from_aranges will be called from a worker thread. Because warnings can't be emitted from these threads, this patch adds a new deferred_warnings parameter to the function, letting the caller control exactly how the warnings are emitted.
Diffstat (limited to 'gdb/utils.h')
-rw-r--r--gdb/utils.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/gdb/utils.h b/gdb/utils.h
index f646b30..0acf11c 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -395,13 +395,16 @@ assign_return_if_changed (T &lval, const T &val)
struct deferred_warnings
{
+ deferred_warnings ()
+ : m_can_style (gdb_stderr->can_emit_style_escape ())
+ {
+ }
+
/* Add a warning to the list of deferred warnings. */
void warn (const char *format, ...) ATTRIBUTE_PRINTF(2,3)
{
- /* Generate the warning text into a string_file. We allow the text to
- be styled only if gdb_stderr allows styling -- warnings are sent to
- gdb_stderr. */
- string_file msg (gdb_stderr->can_emit_style_escape ());
+ /* Generate the warning text into a string_file. */
+ string_file msg (m_can_style);
va_list args;
va_start (args, format);
@@ -421,6 +424,11 @@ struct deferred_warnings
private:
+ /* True if gdb_stderr supports styling at the moment this object is
+ constructed. This is done just once so that objects of this type
+ can be used off the main thread. */
+ bool m_can_style;
+
/* The list of all deferred warnings. */
std::vector<string_file> m_warnings;
};