aboutsummaryrefslogtreecommitdiff
path: root/gdb/complaints.h
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2022-10-06 14:53:07 +0200
committerTom de Vries <tdevries@suse.de>2022-10-06 14:53:07 +0200
commitca10a126c67f03e4e56dbbb6966c1682014912d8 (patch)
treed4a5db921379fc31cb7aa9e12262fa7b3caf88c7 /gdb/complaints.h
parent80e0c6dc91f52fad32c3ff3cf20da889d77013ac (diff)
downloadgdb-ca10a126c67f03e4e56dbbb6966c1682014912d8.zip
gdb-ca10a126c67f03e4e56dbbb6966c1682014912d8.tar.gz
gdb-ca10a126c67f03e4e56dbbb6966c1682014912d8.tar.bz2
[gdb/symtab] Factor out have_complaint
After committing 8ba677d3560 ("[gdb/symtab] Don't complain about function decls") I noticed that quite a bit of code in read_func_scope is used to decide whether to issue the "cannot get low and high bounds for subprogram DIE at $hex" complaint, which executes unnecessarily if we have the default "set complaints 0". Fix this by (NFC): - factoring out new static function have_complaint from macro complaint, and - using it to wrap the relevant code in read_func_scope. Tested on x86_64-linux.
Diffstat (limited to 'gdb/complaints.h')
-rw-r--r--gdb/complaints.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/gdb/complaints.h b/gdb/complaints.h
index 68c79bd..02c8c2c 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -31,6 +31,15 @@ extern void complaint_internal (const char *fmt, ...)
extern int stop_whining;
+/* Return true if complaints are enabled. This can be used to guard code
+ that is used only to decide whether to issue a complaint. */
+
+static inline bool
+have_complaint ()
+{
+ return stop_whining > 0;
+}
+
/* Register a complaint. This is a macro around complaint_internal to
avoid computing complaint's arguments when complaints are disabled.
Running FMT via gettext [i.e., _(FMT)] can be quite expensive, for
@@ -38,7 +47,7 @@ extern int stop_whining;
#define complaint(FMT, ...) \
do \
{ \
- if (stop_whining > 0) \
+ if (have_complaint ()) \
complaint_internal (FMT, ##__VA_ARGS__); \
} \
while (0)