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 /gdbserver | |
parent | 5c831a3c7f3ca98d6aba1200353311e1a1f84c70 (diff) | |
download | gdb-f34652de0b68c4ee3050828b43a2839b852b5821.zip gdb-f34652de0b68c4ee3050828b43a2839b852b5821.tar.gz 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 'gdbserver')
-rw-r--r-- | gdbserver/ax.cc | 3 | ||||
-rw-r--r-- | gdbserver/linux-amd64-ipa.cc | 9 | ||||
-rw-r--r-- | gdbserver/linux-arm-low.cc | 4 | ||||
-rw-r--r-- | gdbserver/linux-i386-ipa.cc | 5 | ||||
-rw-r--r-- | gdbserver/linux-low.cc | 20 | ||||
-rw-r--r-- | gdbserver/linux-ppc-ipa.cc | 3 | ||||
-rw-r--r-- | gdbserver/linux-s390-ipa.cc | 3 | ||||
-rw-r--r-- | gdbserver/mem-break.cc | 3 | ||||
-rw-r--r-- | gdbserver/regcache.cc | 2 | ||||
-rw-r--r-- | gdbserver/remote-utils.cc | 3 | ||||
-rw-r--r-- | gdbserver/tracepoint.cc | 50 |
11 files changed, 37 insertions, 68 deletions
diff --git a/gdbserver/ax.cc b/gdbserver/ax.cc index 365bd21..e5b4542 100644 --- a/gdbserver/ax.cc +++ b/gdbserver/ax.cc @@ -1207,8 +1207,7 @@ gdb_eval_agent_expr (struct eval_agent_expr_context *ctx, top = cnv.u8.val; break; default: - internal_error (__FILE__, __LINE__, - "unhandled register size"); + internal_error ("unhandled register size"); } } break; diff --git a/gdbserver/linux-amd64-ipa.cc b/gdbserver/linux-amd64-ipa.cc index bb89ba5..46c2578 100644 --- a/gdbserver/linux-amd64-ipa.cc +++ b/gdbserver/linux-amd64-ipa.cc @@ -159,8 +159,7 @@ supply_static_tracepoint_registers (struct regcache *regcache, } break; default: - internal_error (__FILE__, __LINE__, - "unhandled register size: %d", + internal_error ("unhandled register size: %d", x86_64_st_collect_regmap[i].size); break; } @@ -190,8 +189,7 @@ get_ipa_tdesc (int idx) { if (idx >= X86_TDESC_LAST) { - internal_error (__FILE__, __LINE__, - "unknown ipa tdesc index: %d", idx); + internal_error ("unknown ipa tdesc index: %d", idx); } #if defined __ILP32__ @@ -210,8 +208,7 @@ get_ipa_tdesc (int idx) return amd64_linux_read_description (idx2mask[idx], false); #endif - internal_error (__FILE__, __LINE__, - "unknown ipa tdesc index: %d", idx); + internal_error ("unknown ipa tdesc index: %d", idx); } /* Allocate buffer for the jump pads. The branch instruction has a diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc index ab6209a..a458b0f 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -413,9 +413,9 @@ arm_linux_init_hwbp_cap (int pid) arm_linux_hwbp_cap.bp_count = (unsigned char)(val & 0xff); if (arm_linux_hwbp_cap.wp_count > MAX_WPTS) - internal_error (__FILE__, __LINE__, "Unsupported number of watchpoints"); + internal_error ("Unsupported number of watchpoints"); if (arm_linux_hwbp_cap.bp_count > MAX_BPTS) - internal_error (__FILE__, __LINE__, "Unsupported number of breakpoints"); + internal_error ("Unsupported number of breakpoints"); } /* How many hardware breakpoints are available? */ diff --git a/gdbserver/linux-i386-ipa.cc b/gdbserver/linux-i386-ipa.cc index 88383a8..33909d5 100644 --- a/gdbserver/linux-i386-ipa.cc +++ b/gdbserver/linux-i386-ipa.cc @@ -179,7 +179,7 @@ supply_static_tracepoint_registers (struct regcache *regcache, } break; default: - internal_error (__FILE__, __LINE__, "unhandled register size: %d", + internal_error ("unhandled register size: %d", i386_st_collect_regmap[i].size); } } @@ -264,8 +264,7 @@ get_ipa_tdesc (int idx) { if (idx >= X86_TDESC_LAST) { - internal_error (__FILE__, __LINE__, - "unknown ipa tdesc index: %d", idx); + internal_error ("unknown ipa tdesc index: %d", idx); } return i386_linux_read_description (idx2mask[idx]); } diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 4754366..1676328 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -741,7 +741,7 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp, return 0; } - internal_error (__FILE__, __LINE__, _("unknown ptrace event %d"), event); + internal_error (_("unknown ptrace event %d"), event); } CORE_ADDR @@ -1892,8 +1892,7 @@ lwp_suspended_decr (struct lwp_info *lwp) { struct thread_info *thread = get_lwp_thread (lwp); - internal_error (__FILE__, __LINE__, - "unsuspend LWP %ld, suspended=%d\n", lwpid_of (thread), + internal_error ("unsuspend LWP %ld, suspended=%d\n", lwpid_of (thread), lwp->suspended); } } @@ -2524,8 +2523,7 @@ linux_process_target::wait_for_event_filtered (ptid_t wait_ptid, if (requested_child->suspended && requested_child->status_pending_p) { - internal_error (__FILE__, __LINE__, - "requesting an event out of a" + internal_error ("requesting an event out of a" " suspended child?"); } @@ -3793,8 +3791,7 @@ linux_process_target::stuck_in_jump_pad (thread_info *thread) if (lwp->suspended != 0) { - internal_error (__FILE__, __LINE__, - "LWP %ld is suspended, suspended=%d\n", + internal_error ("LWP %ld is suspended, suspended=%d\n", lwpid_of (thread), lwp->suspended); } gdb_assert (lwp->stopped); @@ -3817,8 +3814,7 @@ linux_process_target::move_out_of_jump_pad (thread_info *thread) if (lwp->suspended != 0) { - internal_error (__FILE__, __LINE__, - "LWP %ld is suspended, suspended=%d\n", + internal_error ("LWP %ld is suspended, suspended=%d\n", lwpid_of (thread), lwp->suspended); } gdb_assert (lwp->stopped); @@ -4067,8 +4063,7 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step, step = 1; else { - internal_error (__FILE__, __LINE__, - "moving out of jump pad single-stepping" + internal_error ("moving out of jump pad single-stepping" " not implemented on this target"); } } @@ -4469,8 +4464,7 @@ linux_process_target::start_step_over (lwp_info *lwp) if (lwp->suspended != 0) { - internal_error (__FILE__, __LINE__, - "LWP %ld suspended=%d\n", lwpid_of (thread), + internal_error ("LWP %ld suspended=%d\n", lwpid_of (thread), lwp->suspended); } diff --git a/gdbserver/linux-ppc-ipa.cc b/gdbserver/linux-ppc-ipa.cc index 8925838..362ae0e 100644 --- a/gdbserver/linux-ppc-ipa.cc +++ b/gdbserver/linux-ppc-ipa.cc @@ -218,8 +218,7 @@ get_ipa_tdesc (int idx) return tdesc_powerpc_e500l; #endif default: - internal_error (__FILE__, __LINE__, - "unknown ipa tdesc index: %d", idx); + internal_error ("unknown ipa tdesc index: %d", idx); #ifdef __powerpc64__ return tdesc_powerpc_64l; #else diff --git a/gdbserver/linux-s390-ipa.cc b/gdbserver/linux-s390-ipa.cc index 500e57b..3305eea 100644 --- a/gdbserver/linux-s390-ipa.cc +++ b/gdbserver/linux-s390-ipa.cc @@ -372,8 +372,7 @@ get_ipa_tdesc (int idx) return tdesc_s390_gs_linux64; #endif default: - internal_error (__FILE__, __LINE__, - "unknown ipa tdesc index: %d", idx); + internal_error ("unknown ipa tdesc index: %d", idx); #ifdef __s390x__ return tdesc_s390x_linux64; #else diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc index 72ce8c8..47dace4 100644 --- a/gdbserver/mem-break.cc +++ b/gdbserver/mem-break.cc @@ -253,8 +253,7 @@ raw_bkpt_type_to_target_hw_bp_type (enum raw_bkpt_type raw_type) case raw_bkpt_type_access_wp: return hw_access; default: - internal_error (__FILE__, __LINE__, - "bad raw breakpoint type %d", (int) raw_type); + internal_error ("bad raw breakpoint type %d", (int) raw_type); } } diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 27491ef..5cbcea9 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -252,7 +252,7 @@ find_regno (const struct target_desc *tdesc, const char *name) if (strcmp (name, find_register_by_number (tdesc, i).name) == 0) return i; } - internal_error (__FILE__, __LINE__, "Unknown register %s requested", + internal_error ("Unknown register %s requested", name); } diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc index db9b2a6..2ddb275 100644 --- a/gdbserver/remote-utils.cc +++ b/gdbserver/remote-utils.cc @@ -296,8 +296,7 @@ remote_prepare (const char *name) ((struct sockaddr_in6 *) iter->ai_addr)->sin6_addr = in6addr_any; break; default: - internal_error (__FILE__, __LINE__, - _("Invalid 'ai_family' %d\n"), iter->ai_family); + internal_error (_("Invalid 'ai_family' %d\n"), iter->ai_family); } if (bind (listen_desc, iter->ai_addr, iter->ai_addrlen) != 0) diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc index 18b2b0b..d82b8e2 100644 --- a/gdbserver/tracepoint.cc +++ b/gdbserver/tracepoint.cc @@ -2921,8 +2921,7 @@ get_jump_space_head (void) if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer, &gdb_jump_pad_head)) { - internal_error (__FILE__, __LINE__, - "error extracting jump_pad_buffer"); + internal_error ("error extracting jump_pad_buffer"); } } @@ -2954,15 +2953,13 @@ claim_trampoline_space (ULONGEST used, CORE_ADDR *trampoline) if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer, &trampoline_buffer_tail)) { - internal_error (__FILE__, __LINE__, - "error extracting trampoline_buffer"); + internal_error ("error extracting trampoline_buffer"); } if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end, &trampoline_buffer_head)) { - internal_error (__FILE__, __LINE__, - "error extracting trampoline_buffer_end"); + internal_error ("error extracting trampoline_buffer_end"); } } @@ -2997,8 +2994,7 @@ have_fast_tracepoint_trampoline_buffer (char *buf) if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end, &trampoline_end)) { - internal_error (__FILE__, __LINE__, - "error extracting trampoline_buffer_end"); + internal_error ("error extracting trampoline_buffer_end"); } if (buf) @@ -3008,8 +3004,7 @@ have_fast_tracepoint_trampoline_buffer (char *buf) if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_error, &errbuf)) { - internal_error (__FILE__, __LINE__, - "error extracting errbuf"); + internal_error ("error extracting errbuf"); } read_inferior_memory (errbuf, (unsigned char *) buf, 100); @@ -3173,7 +3168,7 @@ install_tracepoint (struct tracepoint *tpoint, char *own_buf) } else - internal_error (__FILE__, __LINE__, "Unknown tracepoint type"); + internal_error ("Unknown tracepoint type"); if (tpoint->handle == NULL) { @@ -3362,22 +3357,19 @@ cmd_qtstart (char *packet) { if (write_inferior_integer (ipa_sym_addrs.addr_tracing, 1)) { - internal_error (__FILE__, __LINE__, - "Error setting tracing variable in lib"); + internal_error ("Error setting tracing variable in lib"); } if (write_inferior_data_pointer (ipa_sym_addrs.addr_stopping_tracepoint, 0)) { - internal_error (__FILE__, __LINE__, - "Error clearing stopping_tracepoint variable" + internal_error ("Error clearing stopping_tracepoint variable" " in lib"); } if (write_inferior_integer (ipa_sym_addrs.addr_trace_buffer_is_full, 0)) { - internal_error (__FILE__, __LINE__, - "Error clearing trace_buffer_is_full variable" + internal_error ("Error clearing trace_buffer_is_full variable" " in lib"); } @@ -3429,8 +3421,7 @@ stop_tracing (void) { if (write_inferior_integer (ipa_sym_addrs.addr_tracing, 0)) { - internal_error (__FILE__, __LINE__, - "Error clearing tracing variable in lib"); + internal_error ("Error clearing tracing variable in lib"); } } @@ -5599,27 +5590,23 @@ fast_tracepoint_collecting (CORE_ADDR thread_area, if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer, &ipa_gdb_jump_pad_buffer)) { - internal_error (__FILE__, __LINE__, - "error extracting `gdb_jump_pad_buffer'"); + internal_error ("error extracting `gdb_jump_pad_buffer'"); } if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer_end, &ipa_gdb_jump_pad_buffer_end)) { - internal_error (__FILE__, __LINE__, - "error extracting `gdb_jump_pad_buffer_end'"); + internal_error ("error extracting `gdb_jump_pad_buffer_end'"); } if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer, &ipa_gdb_trampoline_buffer)) { - internal_error (__FILE__, __LINE__, - "error extracting `gdb_trampoline_buffer'"); + internal_error ("error extracting `gdb_trampoline_buffer'"); } if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end, &ipa_gdb_trampoline_buffer_end)) { - internal_error (__FILE__, __LINE__, - "error extracting `gdb_trampoline_buffer_end'"); + internal_error ("error extracting `gdb_trampoline_buffer_end'"); } if (ipa_gdb_jump_pad_buffer <= stop_pc @@ -5978,8 +5965,7 @@ target_malloc (ULONGEST size) if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_tp_heap_buffer, &target_tp_heap)) { - internal_error (__FILE__, __LINE__, - "couldn't get target heap head pointer"); + internal_error ("couldn't get target heap head pointer"); } } @@ -6205,8 +6191,7 @@ download_tracepoint (struct tracepoint *tpoint) + offsetof (struct tracepoint, next), &tp_prev_target_next_addr)) { - internal_error (__FILE__, __LINE__, - "error reading `tp_prev->next'"); + internal_error ("error reading `tp_prev->next'"); } /* tpoint->next = tp_prev->next */ @@ -6458,8 +6443,7 @@ upload_fast_traceframes (void) if (ipa_tframe.tpnum == 0) { - internal_error (__FILE__, __LINE__, - "Uploading: No (more) fast traceframes, but" + internal_error ("Uploading: No (more) fast traceframes, but" " ipa_traceframe_count == %u??\n", ipa_traceframe_write_count - ipa_traceframe_read_count); |