internal_error: remove need to pass __FILE__/__LINE__
authorPedro Alves <pedro@palves.net>
Mon, 17 Oct 2022 16:12:20 +0000 (17:12 +0100)
committerPedro Alves <pedro@palves.net>
Wed, 19 Oct 2022 14:32:36 +0000 (15:32 +0100)
commitf34652de0b68c4ee3050828b43a2839b852b5821
tree851720f14f2ac022c3e82428254edf161d619e91
parent5c831a3c7f3ca98d6aba1200353311e1a1f84c70
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
152 files changed:
gdb/aarch64-tdep.c
gdb/ada-exp.y
gdb/ada-lang.c
gdb/addrmap.c
gdb/alpha-tdep.c
gdb/amd64-tdep.c
gdb/arc-tdep.c
gdb/arch-utils.c
gdb/arch/arm.c
gdb/arm-linux-tdep.c
gdb/arm-netbsd-tdep.c
gdb/arm-tdep.c
gdb/avr-tdep.c
gdb/ax-gdb.c
gdb/ax-general.c
gdb/bfin-tdep.c
gdb/blockframe.c
gdb/breakpoint.c
gdb/btrace.c
gdb/c-exp.y
gdb/c-lang.c
gdb/cli/cli-script.c
gdb/coffread.c
gdb/compile/compile-c-support.c
gdb/compile/compile-c-symbols.c
gdb/compile/compile-cplus-symbols.c
gdb/compile/compile-cplus-types.c
gdb/compile/compile-object-load.c
gdb/corefile.c
gdb/cp-abi.c
gdb/cp-namespace.c
gdb/cris-tdep.c
gdb/dbxread.c
gdb/dictionary.c
gdb/dtrace-probe.c
gdb/dwarf2/comp-unit-head.c
gdb/dwarf2/expr.c
gdb/dwarf2/frame.c
gdb/dwarf2/leb.c
gdb/dwarf2/loc.c
gdb/elfread.c
gdb/event-top.c
gdb/exceptions.c
gdb/exec.c
gdb/fbsd-nat.c
gdb/fbsd-tdep.c
gdb/findvar.c
gdb/frame-unwind.c
gdb/frame.c
gdb/frv-linux-tdep.c
gdb/frv-tdep.c
gdb/gdbarch.c
gdb/gdbarch.py
gdb/gdbtypes.c
gdb/go32-nat.c
gdb/h8300-tdep.c
gdb/hppa-tdep.c
gdb/i386-linux-nat.c
gdb/i386-tdep.c
gdb/i387-tdep.c
gdb/ia64-tdep.c
gdb/infcall.c
gdb/infcmd.c
gdb/infrun.c
gdb/interps.c
gdb/language.c
gdb/linux-nat.c
gdb/loongarch-tdep.c
gdb/m32c-tdep.c
gdb/m32r-linux-nat.c
gdb/m68k-linux-nat.c
gdb/m68k-tdep.c
gdb/macroexp.c
gdb/maint.c
gdb/mi/mi-cmd-stack.c
gdb/mi/mi-getopt.c
gdb/mi/mi-out.c
gdb/microblaze-tdep.c
gdb/minsyms.c
gdb/mips-tdep.c
gdb/mn10300-tdep.c
gdb/msp430-tdep.c
gdb/nat/linux-btrace.c
gdb/nat/linux-namespaces.c
gdb/nat/mips-linux-watch.c
gdb/nat/x86-dregs.c
gdb/nds32-tdep.c
gdb/netbsd-tdep.c
gdb/objfiles.h
gdb/osabi.c
gdb/ppc-linux-nat.c
gdb/ppc-linux-tdep.c
gdb/ppc-sysv-tdep.c
gdb/printcmd.c
gdb/process-stratum-target.c
gdb/psymtab.c
gdb/record-btrace.c
gdb/regcache.c
gdb/reggroups.c
gdb/remote-sim.c
gdb/remote.c
gdb/riscv-tdep.c
gdb/rl78-tdep.c
gdb/rs6000-aix-nat.c
gdb/rs6000-tdep.c
gdb/s390-tdep.c
gdb/sentinel-frame.c
gdb/ser-event.c
gdb/ser-mingw.c
gdb/ser-unix.c
gdb/serial.c
gdb/source.c
gdb/sparc-tdep.c
gdb/sparc64-tdep.c
gdb/stack.c
gdb/stap-probe.c
gdb/symtab.c
gdb/target-descriptions.c
gdb/target.c
gdb/tic6x-tdep.c
gdb/tracectf.c
gdb/tracefile-tfile.c
gdb/tracepoint.c
gdb/tui/tui-interp.c
gdb/ui-out.c
gdb/utils.c
gdb/valops.c
gdb/valprint.c
gdb/value.c
gdb/windows-nat.c
gdb/xml-support.c
gdb/xml-syscall.c
gdb/xtensa-tdep.c
gdbserver/ax.cc
gdbserver/linux-amd64-ipa.cc
gdbserver/linux-arm-low.cc
gdbserver/linux-i386-ipa.cc
gdbserver/linux-low.cc
gdbserver/linux-ppc-ipa.cc
gdbserver/linux-s390-ipa.cc
gdbserver/mem-break.cc
gdbserver/regcache.cc
gdbserver/remote-utils.cc
gdbserver/tracepoint.cc
gdbsupport/btrace-common.cc
gdbsupport/common-exceptions.cc
gdbsupport/common-utils.cc
gdbsupport/errors.cc
gdbsupport/errors.h
gdbsupport/event-loop.cc
gdbsupport/gdb_assert.h
gdbsupport/print-utils.cc