aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/complaints.h11
-rw-r--r--gdb/dwarf2/read.c31
2 files changed, 27 insertions, 15 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)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 8e42c0f..78f4cc1 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -12043,20 +12043,23 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
if (dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, nullptr, nullptr)
<= PC_BOUNDS_INVALID)
{
- attr = dwarf2_attr (die, DW_AT_external, cu);
- bool external_p = attr != nullptr && attr->as_boolean ();
- attr = dwarf2_attr (die, DW_AT_inline, cu);
- bool inlined_p
- = (attr != nullptr
- && attr->is_nonnegative ()
- && (attr->as_nonnegative () == DW_INL_inlined
- || attr->as_nonnegative () == DW_INL_declared_inlined));
- attr = dwarf2_attr (die, DW_AT_declaration, cu);
- bool decl_p = attr != nullptr && attr->as_boolean ();
- if (!external_p && !inlined_p && !decl_p)
- complaint (_("cannot get low and high bounds "
- "for subprogram DIE at %s"),
- sect_offset_str (die->sect_off));
+ if (have_complaint ())
+ {
+ attr = dwarf2_attr (die, DW_AT_external, cu);
+ bool external_p = attr != nullptr && attr->as_boolean ();
+ attr = dwarf2_attr (die, DW_AT_inline, cu);
+ bool inlined_p
+ = (attr != nullptr
+ && attr->is_nonnegative ()
+ && (attr->as_nonnegative () == DW_INL_inlined
+ || attr->as_nonnegative () == DW_INL_declared_inlined));
+ attr = dwarf2_attr (die, DW_AT_declaration, cu);
+ bool decl_p = attr != nullptr && attr->as_boolean ();
+ if (!external_p && !inlined_p && !decl_p)
+ complaint (_("cannot get low and high bounds "
+ "for subprogram DIE at %s"),
+ sect_offset_str (die->sect_off));
+ }
return;
}