aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
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/remote.c
parent5c831a3c7f3ca98d6aba1200353311e1a1f84c70 (diff)
downloadfsf-binutils-gdb-f34652de0b68c4ee3050828b43a2839b852b5821.zip
fsf-binutils-gdb-f34652de0b68c4ee3050828b43a2839b852b5821.tar.gz
fsf-binutils-gdb-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/remote.c')
-rw-r--r--gdb/remote.c65
1 files changed, 23 insertions, 42 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index 17c2d17..5118ecd 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1593,8 +1593,7 @@ show_interrupt_sequence (struct ui_file *file, int from_tty,
"the remote target to interrupt the execution "
"of Linux kernel.\n"));
else
- internal_error (__FILE__, __LINE__,
- _("Invalid value for interrupt_sequence_mode: %s."),
+ internal_error (_("Invalid value for interrupt_sequence_mode: %s."),
interrupt_sequence_mode);
}
@@ -2028,8 +2027,7 @@ packet_ok (const char *buf, struct packet_config *config)
if (config->detect != AUTO_BOOLEAN_TRUE
&& config->support == PACKET_DISABLE)
- internal_error (__FILE__, __LINE__,
- _("packet_ok: attempt to use a disabled packet"));
+ internal_error (_("packet_ok: attempt to use a disabled packet"));
result = packet_check_result (buf);
switch (result)
@@ -2286,7 +2284,7 @@ show_remote_protocol_packet_cmd (struct ui_file *file, int from_tty,
return;
}
}
- internal_error (__FILE__, __LINE__, _("Could not find config for %s"),
+ internal_error (_("Could not find config for %s"),
c->name);
}
@@ -4041,8 +4039,7 @@ remote_target::extra_thread_info (thread_info *tp)
struct gdb_ext_thread_info threadinfo;
if (rs->remote_desc == 0) /* paranoia */
- internal_error (__FILE__, __LINE__,
- _("remote_threads_extra_info"));
+ internal_error (_("remote_threads_extra_info"));
if (tp->ptid == magic_null_ptid
|| (tp->ptid.pid () != 0 && tp->ptid.lwp () == 0))
@@ -4401,8 +4398,7 @@ remote_target::send_interrupt_sequence ()
remote_serial_write ("g", 1);
}
else
- internal_error (__FILE__, __LINE__,
- _("Invalid value for interrupt_sequence_mode: %s."),
+ internal_error (_("Invalid value for interrupt_sequence_mode: %s."),
interrupt_sequence_mode);
}
@@ -8538,8 +8534,7 @@ remote_target::process_g_packet (struct regcache *regcache)
{
if (p[0] == 0 || p[1] == 0)
/* This shouldn't happen - we adjusted sizeof_g_packet above. */
- internal_error (__FILE__, __LINE__,
- _("unexpected end of 'g' packet reply"));
+ internal_error (_("unexpected end of 'g' packet reply"));
if (p[0] == 'x' && p[1] == 'x')
regs[i] = 0; /* 'x' */
@@ -8557,8 +8552,7 @@ remote_target::process_g_packet (struct regcache *regcache)
{
if ((r->offset + reg_size) * 2 > strlen (rs->buf.data ()))
/* This shouldn't happen - we adjusted in_g_packet above. */
- internal_error (__FILE__, __LINE__,
- _("unexpected end of 'g' packet reply"));
+ internal_error (_("unexpected end of 'g' packet reply"));
else if (rs->buf[r->offset * 2] == 'x')
{
gdb_assert (r->offset * 2 < strlen (rs->buf.data ()));
@@ -8713,7 +8707,7 @@ remote_target::store_register_using_P (const struct regcache *regcache,
case PACKET_UNKNOWN:
return 0;
default:
- internal_error (__FILE__, __LINE__, _("Bad result from packet_ok"));
+ internal_error (_("Bad result from packet_ok"));
}
}
@@ -8985,8 +8979,7 @@ remote_target::remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
int payload_length_bytes;
if (packet_format != 'X' && packet_format != 'M')
- internal_error (__FILE__, __LINE__,
- _("remote_write_bytes_aux: bad packet format"));
+ internal_error (_("remote_write_bytes_aux: bad packet format"));
if (len_units == 0)
return TARGET_XFER_EOF;
@@ -9035,8 +9028,7 @@ remote_target::remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
}
if (todo_units <= 0)
- internal_error (__FILE__, __LINE__,
- _("minimum packet size too small to write data"));
+ internal_error (_("minimum packet size too small to write data"));
/* If we already need another packet, then try to align the end
of this packet to a useful boundary. */
@@ -9151,10 +9143,9 @@ remote_target::remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr,
packet_format = "M";
break;
case PACKET_SUPPORT_UNKNOWN:
- internal_error (__FILE__, __LINE__,
- _("remote_write_bytes: bad internal state"));
+ internal_error (_("remote_write_bytes: bad internal state"));
default:
- internal_error (__FILE__, __LINE__, _("bad switch"));
+ internal_error (_("bad switch"));
}
return remote_write_bytes_aux (packet_format,
@@ -9352,7 +9343,7 @@ remote_target::remote_send_printf (const char *format, ...)
va_end (ap);
if (size >= max_size)
- internal_error (__FILE__, __LINE__, _("Too long remote packet."));
+ internal_error (_("Too long remote packet."));
if (putpkt (rs->buf) < 0)
error (_("Communication problem with target."));
@@ -10172,7 +10163,7 @@ remote_target::remote_vkill (int pid)
case PACKET_UNKNOWN:
return -1;
default:
- internal_error (__FILE__, __LINE__, _("Bad result from packet_ok"));
+ internal_error (_("Bad result from packet_ok"));
}
}
@@ -10666,8 +10657,7 @@ watchpoint_to_Z_packet (int type)
return Z_PACKET_ACCESS_WP;
break;
default:
- internal_error (__FILE__, __LINE__,
- _("hw_bp_to_z: bad watchpoint type %d"), type);
+ internal_error (_("hw_bp_to_z: bad watchpoint type %d"), type);
}
}
@@ -10706,8 +10696,7 @@ remote_target::insert_watchpoint (CORE_ADDR addr, int len,
case PACKET_OK:
return 0;
}
- internal_error (__FILE__, __LINE__,
- _("remote_insert_watchpoint: reached end of function"));
+ internal_error (_("remote_insert_watchpoint: reached end of function"));
}
bool
@@ -10753,8 +10742,7 @@ remote_target::remove_watchpoint (CORE_ADDR addr, int len,
case PACKET_OK:
return 0;
}
- internal_error (__FILE__, __LINE__,
- _("remote_remove_watchpoint: reached end of function"));
+ internal_error (_("remote_remove_watchpoint: reached end of function"));
}
@@ -10923,8 +10911,7 @@ remote_target::insert_hw_breakpoint (struct gdbarch *gdbarch,
case PACKET_OK:
return 0;
}
- internal_error (__FILE__, __LINE__,
- _("remote_insert_hw_breakpoint: reached end of function"));
+ internal_error (_("remote_insert_hw_breakpoint: reached end of function"));
}
@@ -10964,8 +10951,7 @@ remote_target::remove_hw_breakpoint (struct gdbarch *gdbarch,
case PACKET_OK:
return 0;
}
- internal_error (__FILE__, __LINE__,
- _("remote_remove_hw_breakpoint: reached end of function"));
+ internal_error (_("remote_remove_hw_breakpoint: reached end of function"));
}
/* Verify memory using the "qCRC:" request. */
@@ -12017,8 +12003,7 @@ register_remote_g_packet_guess (struct gdbarch *gdbarch, int bytes,
for (const remote_g_packet_guess &guess : data->guesses)
if (guess.bytes == bytes)
- internal_error (__FILE__, __LINE__,
- _("Duplicate g packet description added for size %d"),
+ internal_error (_("Duplicate g packet description added for size %d"),
bytes);
data->guesses.emplace_back (bytes, tdesc);
@@ -13181,9 +13166,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
else
/* If it passed validation at definition but fails now,
something is very wrong. */
- internal_error (__FILE__, __LINE__,
- _("Fast tracepoint not "
- "valid during download"));
+ internal_error (_("Fast tracepoint not valid during download"));
}
else
/* Fast tracepoints are functionally identical to regular
@@ -14265,8 +14248,7 @@ remote_target::read_btrace (struct btrace_data *btrace,
annex = "delta";
break;
default:
- internal_error (__FILE__, __LINE__,
- _("Bad branch tracing read type: %u."),
+ internal_error (_("Bad branch tracing read type: %u."),
(unsigned int) type);
}
@@ -14317,8 +14299,7 @@ remote_target::pid_to_exec_file (int pid)
inferior *inf = find_inferior_pid (this, pid);
if (inf == NULL)
- internal_error (__FILE__, __LINE__,
- _("not currently attached to process %d"), pid);
+ internal_error (_("not currently attached to process %d"), pid);
if (!inf->fake_pid_p)
{