aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2022-10-17 17:12:20 +0100
committerPedro Alves <pedro@palves.net>2022-10-19 15:32:36 +0100
commitf34652de0b68c4ee3050828b43a2839b852b5821 (patch)
tree851720f14f2ac022c3e82428254edf161d619e91 /gdb/dwarf2
parent5c831a3c7f3ca98d6aba1200353311e1a1f84c70 (diff)
downloadbinutils-f34652de0b68c4ee3050828b43a2839b852b5821.zip
binutils-f34652de0b68c4ee3050828b43a2839b852b5821.tar.gz
binutils-f34652de0b68c4ee3050828b43a2839b852b5821.tar.bz2
internal_error: remove need to pass __FILE__/__LINE__
Currently, every internal_error call must be passed __FILE__/__LINE__ explicitly, like: internal_error (__FILE__, __LINE__, "foo %d", var); The need to pass in explicit __FILE__/__LINE__ is there probably because the function predates widespread and portable variadic macros availability. We can use variadic macros nowadays, and in fact, we already use them in several places, including the related gdb_assert_not_reached. So this patch renames the internal_error function to something else, and then reimplements internal_error as a variadic macro that expands __FILE__/__LINE__ itself. The result is that we now should call internal_error like so: internal_error ("foo %d", var); Likewise for internal_warning. The patch adjusts all calls sites. 99% of the adjustments were done with a perl/sed script. The non-mechanical changes are in gdbsupport/errors.h, gdbsupport/gdb_assert.h, and gdb/gdbarch.py. Approved-By: Simon Marchi <simon.marchi@efficios.com> Change-Id: Ia6f372c11550ca876829e8fd85048f4502bdcf06
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/comp-unit-head.c12
-rw-r--r--gdb/dwarf2/expr.c10
-rw-r--r--gdb/dwarf2/frame.c20
-rw-r--r--gdb/dwarf2/leb.c3
-rw-r--r--gdb/dwarf2/loc.c4
5 files changed, 19 insertions, 30 deletions
diff --git a/gdb/dwarf2/comp-unit-head.c b/gdb/dwarf2/comp-unit-head.c
index 5f78ac8..edb2a8a 100644
--- a/gdb/dwarf2/comp-unit-head.c
+++ b/gdb/dwarf2/comp-unit-head.c
@@ -65,8 +65,7 @@ read_comp_unit_head (struct comp_unit_head *cu_header,
cu_header->unit_type = DW_UT_type;
break;
default:
- internal_error (__FILE__, __LINE__,
- _("read_comp_unit_head: invalid section_kind"));
+ internal_error (_("read_comp_unit_head: invalid section_kind"));
}
else
{
@@ -113,8 +112,7 @@ read_comp_unit_head (struct comp_unit_head *cu_header,
}
signed_addr = bfd_get_sign_extend_vma (abfd);
if (signed_addr < 0)
- internal_error (__FILE__, __LINE__,
- _("read_comp_unit_head: dwarf from non elf file"));
+ internal_error (_("read_comp_unit_head: dwarf from non elf file"));
cu_header->signed_addr_p = signed_addr;
bool header_has_signature = section_kind == rcuh_kind::TYPE
@@ -215,8 +213,7 @@ comp_unit_head::read_address (bfd *abfd, const gdb_byte *buf,
retval = bfd_get_signed_64 (abfd, buf);
break;
default:
- internal_error (__FILE__, __LINE__,
- _("read_address: bad switch, signed [in module %s]"),
+ internal_error (_("read_address: bad switch, signed [in module %s]"),
bfd_get_filename (abfd));
}
}
@@ -234,8 +231,7 @@ comp_unit_head::read_address (bfd *abfd, const gdb_byte *buf,
retval = bfd_get_64 (abfd, buf);
break;
default:
- internal_error (__FILE__, __LINE__,
- _("read_address: bad switch, "
+ internal_error (_("read_address: bad switch, "
"unsigned [in module %s]"),
bfd_get_filename (abfd));
}
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 2df0696..73dfd4b 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -162,8 +162,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized)
else
{
if (value_type (v) != value_enclosing_type (v))
- internal_error (__FILE__, __LINE__,
- _("Should not be able to create a lazy value with "
+ internal_error (_("Should not be able to create a lazy value with "
"an enclosing type"));
if (check_optimized)
v_contents = nullptr;
@@ -432,7 +431,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized)
break;
default:
- internal_error (__FILE__, __LINE__, _("invalid location type"));
+ internal_error (_("invalid location type"));
}
offset += this_size_bits;
@@ -1057,7 +1056,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
/* DWARF_VALUE_OPTIMIZED_OUT can't occur in this context --
it can only be encountered when making a piece. */
default:
- internal_error (__FILE__, __LINE__, _("invalid location type"));
+ internal_error (_("invalid location type"));
}
}
@@ -2103,8 +2102,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
result_val = value_from_ulongest (address_type, result);
break;
default:
- internal_error (__FILE__, __LINE__,
- _("Can't be reached."));
+ internal_error (_("Can't be reached."));
}
}
break;
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 83565ea..d4bc53e 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -500,8 +500,7 @@ bad CFI data; mismatched DW_CFA_restore_state at %s"),
insn);
}
else
- internal_error (__FILE__, __LINE__,
- _("Unknown CFI encountered."));
+ internal_error (_("Unknown CFI encountered."));
}
}
}
@@ -827,7 +826,7 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
return 0;
default:
- internal_error (__FILE__, __LINE__, _("Unknown CFA rule."));
+ internal_error (_("Unknown CFA rule."));
}
}
@@ -974,7 +973,7 @@ dwarf2_frame_cache (frame_info_ptr this_frame, void **this_cache)
break;
default:
- internal_error (__FILE__, __LINE__, _("Unknown CFA rule."));
+ internal_error (_("Unknown CFA rule."));
}
}
catch (const gdb_exception_error &ex)
@@ -1218,7 +1217,7 @@ dwarf2_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
return cache->reg[regnum].loc.fn (this_frame, this_cache, regnum);
default:
- internal_error (__FILE__, __LINE__, _("Unknown register rule."));
+ internal_error (_("Unknown register rule."));
}
}
@@ -1405,7 +1404,7 @@ encoding_for_size (unsigned int size)
case 8:
return DW_EH_PE_udata8;
default:
- internal_error (__FILE__, __LINE__, _("Unsupported address size"));
+ internal_error (_("Unsupported address size"));
}
}
@@ -1421,8 +1420,7 @@ read_encoded_value (struct comp_unit *unit, gdb_byte encoding,
/* GCC currently doesn't generate DW_EH_PE_indirect encodings for
FDE's. */
if (encoding & DW_EH_PE_indirect)
- internal_error (__FILE__, __LINE__,
- _("Unsupported encoding: DW_EH_PE_indirect"));
+ internal_error (_("Unsupported encoding: DW_EH_PE_indirect"));
*bytes_read_ptr = 0;
@@ -1454,8 +1452,7 @@ read_encoded_value (struct comp_unit *unit, gdb_byte encoding,
}
break;
default:
- internal_error (__FILE__, __LINE__,
- _("Invalid or unsupported encoding"));
+ internal_error (_("Invalid or unsupported encoding"));
}
if ((encoding & 0x07) == 0x00)
@@ -1502,8 +1499,7 @@ read_encoded_value (struct comp_unit *unit, gdb_byte encoding,
*bytes_read_ptr += 8;
return (base + bfd_get_signed_64 (unit->abfd, (bfd_byte *) buf));
default:
- internal_error (__FILE__, __LINE__,
- _("Invalid or unsupported encoding"));
+ internal_error (_("Invalid or unsupported encoding"));
}
}
diff --git a/gdb/dwarf2/leb.c b/gdb/dwarf2/leb.c
index 75af98c..199a5b9 100644
--- a/gdb/dwarf2/leb.c
+++ b/gdb/dwarf2/leb.c
@@ -127,8 +127,7 @@ read_offset (bfd *abfd, const gdb_byte *buf, unsigned int offset_size)
retval = bfd_get_64 (abfd, buf);
break;
default:
- internal_error (__FILE__, __LINE__,
- _("read_offset_1: bad switch [in module %s]"),
+ internal_error (_("read_offset_1: bad switch [in module %s]"),
bfd_get_filename (abfd));
}
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 791648d..c42359a 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -739,7 +739,7 @@ call_site_target::iterate_over_addresses
break;
default:
- internal_error (__FILE__, __LINE__, _("invalid call site target kind"));
+ internal_error (_("invalid call site target kind"));
}
}
@@ -3035,7 +3035,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
{
int targ = offsets[dw_labels[i]];
if (targ == -1)
- internal_error (__FILE__, __LINE__, _("invalid label"));
+ internal_error (_("invalid label"));
ax_label (expr, patches[i], targ);
}
}