diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-11-17 13:44:01 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-11-18 11:29:19 -0500 |
commit | 557b4d7650ffa3cd6dbfb8a56c830a1d45562d19 (patch) | |
tree | 0c08f5fc48886db33c57cb42bfaa1d0fc80640cc | |
parent | ab198279120fe7937c0970a8bb881922726678f9 (diff) | |
download | fsf-binutils-gdb-557b4d7650ffa3cd6dbfb8a56c830a1d45562d19.zip fsf-binutils-gdb-557b4d7650ffa3cd6dbfb8a56c830a1d45562d19.tar.gz fsf-binutils-gdb-557b4d7650ffa3cd6dbfb8a56c830a1d45562d19.tar.bz2 |
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
-rw-r--r-- | gdb/arch/arc.c | 4 | ||||
-rw-r--r-- | gdb/ax-gdb.c | 2 | ||||
-rw-r--r-- | gdb/cli/cli-option.c | 4 | ||||
-rw-r--r-- | gdb/compile/compile-c-support.c | 6 | ||||
-rw-r--r-- | gdb/compile/compile-c-symbols.c | 4 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 2 | ||||
-rw-r--r-- | gdb/findvar.c | 4 | ||||
-rw-r--r-- | gdb/infrun.c | 4 | ||||
-rw-r--r-- | gdb/printcmd.c | 2 | ||||
-rw-r--r-- | gdb/remote.c | 4 | ||||
-rw-r--r-- | gdb/riscv-tdep.c | 6 | ||||
-rw-r--r-- | gdb/thread-fsm.h | 2 | ||||
-rw-r--r-- | gdb/tid-parse.c | 4 | ||||
-rw-r--r-- | gdb/tracepoint.c | 2 | ||||
-rw-r--r-- | gdb/tui/tui-layout.c | 2 | ||||
-rw-r--r-- | gdb/ui-out.c | 12 | ||||
-rw-r--r-- | gdb/varobj.c | 3 | ||||
-rw-r--r-- | gdbsupport/filestuff.cc | 6 | ||||
-rw-r--r-- | gdbsupport/gdb_assert.h | 5 |
19 files changed, 39 insertions, 39 deletions
diff --git a/gdb/arch/arc.c b/gdb/arch/arc.c index 813f4ea..f5d81b6 100644 --- a/gdb/arch/arc.c +++ b/gdb/arch/arc.c @@ -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; diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 8e391a0..67d4db3 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -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 diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c index 846b819..4f5cb03 100644 --- a/gdb/cli/cli-option.c +++ b/gdb/cli/cli-option.c @@ -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"); } } diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c index 65f1867..e365cef 100644 --- a/gdb/compile/compile-c-support.c +++ b/gdb/compile/compile-c-support.c @@ -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."); } } }; diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 08ebe0f..fa1cb7a 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -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 diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index ed10123..4a963e4 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -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."); } } diff --git a/gdb/findvar.c b/gdb/findvar.c index d2b7713..f7e6328 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -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: { diff --git a/gdb/infrun.c b/gdb/infrun.c index 64e535a..89a98c2 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -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? */ diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 03abd75..e408b19 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -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 diff --git a/gdb/remote.c b/gdb/remote.c index c360197..61bde5a 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -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"); } } diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 522eaa7..94dad41 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -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) diff --git a/gdb/thread-fsm.h b/gdb/thread-fsm.h index 3c11c1d..98710ab 100644 --- a/gdb/thread-fsm.h +++ b/gdb/thread-fsm.h @@ -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"); } }; diff --git a/gdb/tid-parse.c b/gdb/tid-parse.c index 25c4669..6f902dc 100644 --- a/gdb/tid-parse.c +++ b/gdb/tid-parse.c @@ -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 diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 0c5107c..15506fd 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -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)) diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 89f84a2..b065769 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -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. */ diff --git a/gdb/ui-out.c b/gdb/ui-out.c index 982d157..fe0e18b 100644 --- a/gdb/ui-out.c +++ b/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]) diff --git a/gdb/varobj.c b/gdb/varobj.c index d0c857a..c448fc8 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -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 diff --git a/gdbsupport/filestuff.cc b/gdbsupport/filestuff.cc index 2975a0e..7063dd6 100644 --- a/gdbsupport/filestuff.cc +++ b/gdbsupport/filestuff.cc @@ -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 */ diff --git a/gdbsupport/gdb_assert.h b/gdbsupport/gdb_assert.h index bc8ad7b..6628c1d 100644 --- a/gdbsupport/gdb_assert.h +++ b/gdbsupport/gdb_assert.h @@ -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 */ |