diff options
author | Pedro Alves <pedro@palves.net> | 2022-10-17 17:12:20 +0100 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2022-10-19 15:32:36 +0100 |
commit | f34652de0b68c4ee3050828b43a2839b852b5821 (patch) | |
tree | 851720f14f2ac022c3e82428254edf161d619e91 /gdb/nat | |
parent | 5c831a3c7f3ca98d6aba1200353311e1a1f84c70 (diff) | |
download | binutils-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/nat')
-rw-r--r-- | gdb/nat/linux-btrace.c | 4 | ||||
-rw-r--r-- | gdb/nat/linux-namespaces.c | 9 | ||||
-rw-r--r-- | gdb/nat/mips-linux-watch.c | 21 | ||||
-rw-r--r-- | gdb/nat/x86-dregs.c | 9 |
4 files changed, 16 insertions, 27 deletions
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c index c31fb5f..4911630 100644 --- a/gdb/nat/linux-btrace.c +++ b/gdb/nat/linux-btrace.c @@ -912,7 +912,7 @@ linux_read_pt (struct btrace_data_pt *btrace, return BTRACE_ERR_NONE; } - internal_error (__FILE__, __LINE__, _("Unknown btrace read type.")); + internal_error (_("Unknown btrace read type.")); } /* See linux-btrace.h. */ @@ -943,7 +943,7 @@ linux_read_btrace (struct btrace_data *btrace, return linux_read_pt (&btrace->variant.pt, tinfo, type); } - internal_error (__FILE__, __LINE__, _("Unkown branch trace format.")); + internal_error (_("Unkown branch trace format.")); } /* See linux-btrace.h. */ diff --git a/gdb/nat/linux-namespaces.c b/gdb/nat/linux-namespaces.c index 94b247c..0ac51cb 100644 --- a/gdb/nat/linux-namespaces.c +++ b/gdb/nat/linux-namespaces.c @@ -734,8 +734,7 @@ mnsh_maybe_mourn_peer (void) if (errno == ECHILD) warning (_("mount namespace helper vanished?")); else - internal_warning (__FILE__, __LINE__, - _("unhandled error %d"), errno); + internal_warning (_("unhandled error %d"), errno); } else if (pid == helper->pid) { @@ -746,12 +745,10 @@ mnsh_maybe_mourn_peer (void) warning (_("mount namespace helper killed by signal %d"), WTERMSIG (status)); else - internal_warning (__FILE__, __LINE__, - _("unhandled status %d"), status); + internal_warning (_("unhandled status %d"), status); } else - internal_warning (__FILE__, __LINE__, - _("unknown pid %d"), pid); + internal_warning (_("unknown pid %d"), pid); /* Something unrecoverable happened. */ helper->pid = -1; diff --git a/gdb/nat/mips-linux-watch.c b/gdb/nat/mips-linux-watch.c index 04fd0b0..deeeb00 100644 --- a/gdb/nat/mips-linux-watch.c +++ b/gdb/nat/mips-linux-watch.c @@ -32,8 +32,7 @@ mips_linux_watch_get_irw_mask (struct pt_watch_regs *regs, int n) case pt_watch_style_mips64: return regs->mips64.watch_masks[n] & IRW_MASK; default: - internal_error (__FILE__, __LINE__, - _("Unrecognized watch register style")); + internal_error (_("Unrecognized watch register style")); } } @@ -50,8 +49,7 @@ get_reg_mask (struct pt_watch_regs *regs, int n) case pt_watch_style_mips64: return regs->mips64.watch_masks[n] & ~IRW_MASK; default: - internal_error (__FILE__, __LINE__, - _("Unrecognized watch register style")); + internal_error (_("Unrecognized watch register style")); } } @@ -67,8 +65,7 @@ mips_linux_watch_get_num_valid (struct pt_watch_regs *regs) case pt_watch_style_mips64: return regs->mips64.num_valid; default: - internal_error (__FILE__, __LINE__, - _("Unrecognized watch register style")); + internal_error (_("Unrecognized watch register style")); } } @@ -85,8 +82,7 @@ mips_linux_watch_get_watchlo (struct pt_watch_regs *regs, int n) case pt_watch_style_mips64: return regs->mips64.watchlo[n]; default: - internal_error (__FILE__, __LINE__, - _("Unrecognized watch register style")); + internal_error (_("Unrecognized watch register style")); } } @@ -108,8 +104,7 @@ mips_linux_watch_set_watchlo (struct pt_watch_regs *regs, int n, regs->mips64.watchlo[n] = value; break; default: - internal_error (__FILE__, __LINE__, - _("Unrecognized watch register style")); + internal_error (_("Unrecognized watch register style")); } } @@ -126,8 +121,7 @@ mips_linux_watch_get_watchhi (struct pt_watch_regs *regs, int n) case pt_watch_style_mips64: return regs->mips64.watchhi[n]; default: - internal_error (__FILE__, __LINE__, - _("Unrecognized watch register style")); + internal_error (_("Unrecognized watch register style")); } } @@ -147,8 +141,7 @@ mips_linux_watch_set_watchhi (struct pt_watch_regs *regs, int n, regs->mips64.watchhi[n] = value; break; default: - internal_error (__FILE__, __LINE__, - _("Unrecognized watch register style")); + internal_error (_("Unrecognized watch register style")); } } diff --git a/gdb/nat/x86-dregs.c b/gdb/nat/x86-dregs.c index 94de026..f4e742f 100644 --- a/gdb/nat/x86-dregs.c +++ b/gdb/nat/x86-dregs.c @@ -261,8 +261,7 @@ x86_length_and_rw_bits (int len, enum target_hw_bp_type type) rw = DR_RW_WRITE; break; case hw_read: - internal_error (__FILE__, __LINE__, - _("The i386 doesn't support " + internal_error (_("The i386 doesn't support " "data-read watchpoints.\n")); case hw_access: rw = DR_RW_READ; @@ -274,7 +273,7 @@ x86_length_and_rw_bits (int len, enum target_hw_bp_type type) break; #endif default: - internal_error (__FILE__, __LINE__, _("\ + internal_error (_("\ Invalid hardware breakpoint type %d in x86_length_and_rw_bits.\n"), (int) type); } @@ -292,7 +291,7 @@ Invalid hardware breakpoint type %d in x86_length_and_rw_bits.\n"), return (DR_LEN_8 | rw); /* FALL THROUGH */ default: - internal_error (__FILE__, __LINE__, _("\ + internal_error (_("\ Invalid hardware breakpoint length %d in x86_length_and_rw_bits.\n"), len); } } @@ -462,7 +461,7 @@ x86_handle_nonaligned_watchpoint (struct x86_debug_reg_state *state, else if (what == WP_REMOVE) retval = x86_remove_aligned_watchpoint (state, addr, len_rw); else - internal_error (__FILE__, __LINE__, _("\ + internal_error (_("\ Invalid value %d of operation in x86_handle_nonaligned_watchpoint.\n"), (int) what); if (retval) |