gdbsupport: make gdb_assert_not_reached accept a format string
Change gdb_assert_not_reached to accept a format string plus corresponding arguments. This allows giving more precise messages. Because the format string passed by the caller is prepended with a "%s:" to add the function name, the callers can no longer pass a translated string (`_(...)`). Make the gdb_assert_not_reached include the _(), just like the gdb_assert_fail macro just above. Change-Id: Id0cfda5a57979df6cdaacaba0d55dd91ae9efee7
This commit is contained in:
parent
ab19827912
commit
557b4d7650
19 changed files with 39 additions and 39 deletions
|
@ -54,7 +54,7 @@ arc_create_target_description (const struct arc_arch_features &features)
|
|||
std::string msg = string_printf
|
||||
("Cannot determine architecture: ISA=%d; bitness=%d",
|
||||
features.isa, 8 * features.reg_size);
|
||||
gdb_assert_not_reached (msg.c_str ());
|
||||
gdb_assert_not_reached ("%s", msg.c_str ());
|
||||
}
|
||||
|
||||
set_tdesc_architecture (tdesc.get (), arch_name.c_str ());
|
||||
|
@ -75,7 +75,7 @@ arc_create_target_description (const struct arc_arch_features &features)
|
|||
default:
|
||||
std::string msg = string_printf
|
||||
("Cannot choose target description XML: %d", features.isa);
|
||||
gdb_assert_not_reached (msg.c_str ());
|
||||
gdb_assert_not_reached ("%s", msg.c_str ());
|
||||
}
|
||||
|
||||
return tdesc;
|
||||
|
|
|
@ -609,7 +609,7 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
|
|||
break;
|
||||
|
||||
case LOC_COMPUTED:
|
||||
gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method"));
|
||||
gdb_assert_not_reached ("LOC_COMPUTED variable missing a method");
|
||||
|
||||
case LOC_OPTIMIZED_OUT:
|
||||
/* Flag this, but don't say anything; leave it up to callers to
|
||||
|
|
|
@ -445,7 +445,7 @@ parse_option (gdb::array_view<const option_def_group> options_group,
|
|||
|
||||
default:
|
||||
/* Not yet. */
|
||||
gdb_assert_not_reached (_("option type not supported"));
|
||||
gdb_assert_not_reached ("option type not supported");
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -824,7 +824,7 @@ add_setshow_cmds_for_options (command_class cmd_class,
|
|||
set_list, show_list);
|
||||
}
|
||||
else
|
||||
gdb_assert_not_reached (_("option type not handled"));
|
||||
gdb_assert_not_reached ("option type not handled");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -352,7 +352,7 @@ struct c_add_code_header
|
|||
break;
|
||||
|
||||
default:
|
||||
gdb_assert_not_reached (_("Unknown compiler scope reached."));
|
||||
gdb_assert_not_reached ("Unknown compiler scope reached.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -376,7 +376,7 @@ struct c_add_code_footer
|
|||
break;
|
||||
|
||||
default:
|
||||
gdb_assert_not_reached (_("Unknown compiler scope reached."));
|
||||
gdb_assert_not_reached ("Unknown compiler scope reached.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -477,7 +477,7 @@ struct cplus_add_code_header
|
|||
break;
|
||||
|
||||
default:
|
||||
gdb_assert_not_reached (_("Unknown compiler scope reached."));
|
||||
gdb_assert_not_reached ("Unknown compiler scope reached.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -587,8 +587,8 @@ generate_c_for_for_one_variable (compile_instance *compiler,
|
|||
error (_("Local symbol unhandled when generating C code."));
|
||||
|
||||
case LOC_COMPUTED:
|
||||
gdb_assert_not_reached (_("LOC_COMPUTED variable "
|
||||
"missing a method."));
|
||||
gdb_assert_not_reached ("LOC_COMPUTED variable "
|
||||
"missing a method.");
|
||||
|
||||
default:
|
||||
/* Nothing to do for all other cases, as they don't represent
|
||||
|
|
|
@ -19979,7 +19979,7 @@ read_attribute_reprocess (const struct die_reader_specs *reader,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
gdb_assert_not_reached (_("Unexpected DWARF form."));
|
||||
gdb_assert_not_reached ("Unexpected DWARF form.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -364,7 +364,7 @@ symbol_read_needs (struct symbol *sym)
|
|||
/* All cases listed explicitly so that gcc -Wall will detect it if
|
||||
we failed to consider one. */
|
||||
case LOC_COMPUTED:
|
||||
gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method"));
|
||||
gdb_assert_not_reached ("LOC_COMPUTED variable missing a method");
|
||||
|
||||
case LOC_REGISTER:
|
||||
case LOC_ARG:
|
||||
|
@ -744,7 +744,7 @@ language_defn::read_var_value (struct symbol *var,
|
|||
break;
|
||||
|
||||
case LOC_COMPUTED:
|
||||
gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method"));
|
||||
gdb_assert_not_reached ("LOC_COMPUTED variable missing a method");
|
||||
|
||||
case LOC_UNRESOLVED:
|
||||
{
|
||||
|
|
|
@ -2401,8 +2401,8 @@ resume_1 (enum gdb_signal sig)
|
|||
step = gdbarch_displaced_step_hw_singlestep (gdbarch);
|
||||
}
|
||||
else
|
||||
gdb_assert_not_reached (_("Invalid displaced_step_prepare_status "
|
||||
"value."));
|
||||
gdb_assert_not_reached ("Invalid displaced_step_prepare_status "
|
||||
"value.");
|
||||
}
|
||||
|
||||
/* Do we need to do it the hard way, w/temp breakpoints? */
|
||||
|
|
|
@ -1724,7 +1724,7 @@ info_address_command (const char *exp, int from_tty)
|
|||
break;
|
||||
|
||||
case LOC_COMPUTED:
|
||||
gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method"));
|
||||
gdb_assert_not_reached ("LOC_COMPUTED variable missing a method");
|
||||
|
||||
case LOC_REGISTER:
|
||||
/* GDBARCH is the architecture associated with the objfile the symbol
|
||||
|
|
|
@ -2217,7 +2217,7 @@ packet_config_support (struct packet_config *config)
|
|||
case AUTO_BOOLEAN_AUTO:
|
||||
return config->support;
|
||||
default:
|
||||
gdb_assert_not_reached (_("bad switch"));
|
||||
gdb_assert_not_reached ("bad switch");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10316,7 +10316,7 @@ remote_target::extended_remote_run (const std::string &args)
|
|||
error (_("Running \"%s\" on the remote target failed"),
|
||||
remote_exec_file);
|
||||
default:
|
||||
gdb_assert_not_reached (_("bad switch"));
|
||||
gdb_assert_not_reached ("bad switch");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -864,7 +864,7 @@ riscv_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
|
|||
case 4:
|
||||
return ebreak;
|
||||
default:
|
||||
gdb_assert_not_reached (_("unhandled breakpoint kind"));
|
||||
gdb_assert_not_reached ("unhandled breakpoint kind");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2877,7 +2877,7 @@ riscv_print_arg_location (ui_file *stream, struct gdbarch *gdbarch,
|
|||
break;
|
||||
|
||||
default:
|
||||
gdb_assert_not_reached (_("unknown argument location type"));
|
||||
gdb_assert_not_reached ("unknown argument location type");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3039,7 +3039,7 @@ riscv_push_dummy_call (struct gdbarch *gdbarch,
|
|||
break;
|
||||
|
||||
default:
|
||||
gdb_assert_not_reached (_("unknown argument location type"));
|
||||
gdb_assert_not_reached ("unknown argument location type");
|
||||
}
|
||||
|
||||
if (second_arg_length > 0)
|
||||
|
|
|
@ -106,7 +106,7 @@ protected:
|
|||
FSM finishes successfully. */
|
||||
virtual enum async_reply_reason do_async_reply_reason ()
|
||||
{
|
||||
gdb_assert_not_reached (_("should not call async_reply_reason here"));
|
||||
gdb_assert_not_reached ("should not call async_reply_reason here");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ tid_range_parser::finished () const
|
|||
return m_range_parser.finished ();
|
||||
}
|
||||
|
||||
gdb_assert_not_reached (_("unhandled state"));
|
||||
gdb_assert_not_reached ("unhandled state");
|
||||
}
|
||||
|
||||
/* See tid-parse.h. */
|
||||
|
@ -168,7 +168,7 @@ tid_range_parser::cur_tok () const
|
|||
return m_range_parser.cur_tok ();
|
||||
}
|
||||
|
||||
gdb_assert_not_reached (_("unhandled state"));
|
||||
gdb_assert_not_reached ("unhandled state");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -2641,7 +2641,7 @@ info_scope_command (const char *args_in, int from_tty)
|
|||
printf_filtered ("optimized out.\n");
|
||||
continue;
|
||||
case LOC_COMPUTED:
|
||||
gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method"));
|
||||
gdb_assert_not_reached ("LOC_COMPUTED variable missing a method");
|
||||
}
|
||||
}
|
||||
if (SYMBOL_TYPE (sym))
|
||||
|
|
|
@ -163,7 +163,7 @@ find_layout (tui_layout_split *layout)
|
|||
if (layout == layouts[i].get ())
|
||||
return i;
|
||||
}
|
||||
gdb_assert_not_reached (_("layout not found!?"));
|
||||
gdb_assert_not_reached ("layout not found!?");
|
||||
}
|
||||
|
||||
/* Function to set the layout. */
|
||||
|
|
12
gdb/ui-out.c
12
gdb/ui-out.c
|
@ -638,10 +638,10 @@ ui_out::vmessage (const ui_file_style &in_style, const char *format,
|
|||
}
|
||||
break;
|
||||
case wide_string_arg:
|
||||
gdb_assert_not_reached (_("wide_string_arg not supported in vmessage"));
|
||||
gdb_assert_not_reached ("wide_string_arg not supported in vmessage");
|
||||
break;
|
||||
case wide_char_arg:
|
||||
gdb_assert_not_reached (_("wide_char_arg not supported in vmessage"));
|
||||
gdb_assert_not_reached ("wide_char_arg not supported in vmessage");
|
||||
break;
|
||||
case long_long_arg:
|
||||
call_do_message (style, current_substring, va_arg (args, long long));
|
||||
|
@ -704,16 +704,16 @@ ui_out::vmessage (const ui_file_style &in_style, const char *format,
|
|||
call_do_message (style, current_substring, va_arg (args, double));
|
||||
break;
|
||||
case long_double_arg:
|
||||
gdb_assert_not_reached (_("long_double_arg not supported in vmessage"));
|
||||
gdb_assert_not_reached ("long_double_arg not supported in vmessage");
|
||||
break;
|
||||
case dec32float_arg:
|
||||
gdb_assert_not_reached (_("dec32float_arg not supported in vmessage"));
|
||||
gdb_assert_not_reached ("dec32float_arg not supported in vmessage");
|
||||
break;
|
||||
case dec64float_arg:
|
||||
gdb_assert_not_reached (_("dec64float_arg not supported in vmessage"));
|
||||
gdb_assert_not_reached ("dec64float_arg not supported in vmessage");
|
||||
break;
|
||||
case dec128float_arg:
|
||||
gdb_assert_not_reached (_("dec128float_arg not supported in vmessage"));
|
||||
gdb_assert_not_reached ("dec128float_arg not supported in vmessage");
|
||||
break;
|
||||
case ptr_arg:
|
||||
switch (current_substring[2])
|
||||
|
|
|
@ -661,8 +661,7 @@ varobj_get_iterator (struct varobj *var)
|
|||
return py_varobj_get_iterator (var, var->dynamic->pretty_printer);
|
||||
#endif
|
||||
|
||||
gdb_assert_not_reached (_("\
|
||||
requested an iterator from a non-dynamic varobj"));
|
||||
gdb_assert_not_reached ("requested an iterator from a non-dynamic varobj");
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
@ -215,7 +215,7 @@ unmark_fd_no_cloexec (int fd)
|
|||
if (it != open_fds.end ())
|
||||
open_fds.erase (it);
|
||||
else
|
||||
gdb_assert_not_reached (_("fd not found in open_fds"));
|
||||
gdb_assert_not_reached ("fd not found in open_fds");
|
||||
}
|
||||
|
||||
/* Helper function for close_most_fds that closes the file descriptor
|
||||
|
@ -378,7 +378,7 @@ gdb_socketpair_cloexec (int domain, int style, int protocol,
|
|||
|
||||
return result;
|
||||
#else
|
||||
gdb_assert_not_reached (_("socketpair not available on this host"));
|
||||
gdb_assert_not_reached ("socketpair not available on this host");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ gdb_pipe_cloexec (int filedes[2])
|
|||
mark_cloexec (filedes[1]);
|
||||
}
|
||||
#else /* HAVE_PIPE */
|
||||
gdb_assert_not_reached (_("pipe not available on this host"));
|
||||
gdb_assert_not_reached ("pipe not available on this host");
|
||||
#endif /* HAVE_PIPE */
|
||||
#endif /* HAVE_PIPE2 */
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
/* The canonical form of gdb_assert (0).
|
||||
MESSAGE is a string to include in the error message. */
|
||||
|
||||
#define gdb_assert_not_reached(message) \
|
||||
internal_error (__FILE__, __LINE__, "%s: %s", __func__, _(message))
|
||||
#define gdb_assert_not_reached(message, ...) \
|
||||
internal_error (__FILE__, __LINE__, _("%s: " message), __func__, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
#endif /* COMMON_GDB_ASSERT_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue