Add setting to control frame language mismatch warning

A customer noted that there is no way to prevent the "current language
does not match this frame" warning.  This patch adds a new setting to
allow this warning to be suppressed.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
Tom Tromey 2024-11-01 10:08:34 -06:00
parent 3a983e041b
commit 218ee1660d
7 changed files with 41 additions and 6 deletions

View File

@ -85,6 +85,11 @@ set style line-number background COLOR
set style line-number intensity VALUE
Control the styling of line numbers printed by GDB.
set warn-language-frame-mismatch [on|off]
show warn-language-frame-mismatch
Control the warning that is emitted when specifying a language that
does not match the current frame's language.
maintenance info inline-frames [ADDRESS]
New command which displays GDB's inline-frame information for the
current address, or for ADDRESS if specified. The output identifies

View File

@ -16795,6 +16795,19 @@ written in one source language can be used by a main program written in
a different source language. Using @samp{set language auto} in this
case frees you from having to set the working language manually.
The warning is enabled by default, but it can be controlled via a
setting:
@table @code
@item set warn-language-frame-mismatch [on|off]
@kindex warn-language-frame-mismatch
Enable or disable the warning that is issued when the current language
is set to a value that does not match the current frame.
@item show warn-language-frame-mismatch
Show whether the frame-mismatch warning will be issued.
@end table
@node Show
@section Displaying the Language

View File

@ -82,6 +82,9 @@ static const struct language_defn *global_current_language;
static lazily_set_language_ftype *lazy_language_setter;
enum language_mode language_mode = language_mode_auto;
/* Whether to warn on language changes. */
bool warn_frame_lang_mismatch = true;
/* See language.h. */
const struct language_defn *
@ -168,7 +171,7 @@ show_language_command (struct ui_file *file, int from_tty,
_("The current source language is \"%s\".\n"),
current_language->name ());
if (has_stack_frames ())
if (warn_frame_lang_mismatch && has_stack_frames ())
{
frame_info_ptr frame;
@ -1144,5 +1147,15 @@ For Fortran the default is off; for other languages the default is on."),
show_case_command,
&setlist, &showlist);
add_setshow_boolean_cmd ("warn-language-frame-mismatch", class_obscure,
&warn_frame_lang_mismatch, _("\
Enable or disable the frame language-mismatch warning."),
_("\
Show the current setting of the frame language-mismatch warning."),
_("\
The frame-language-mismatch warning is issued when the current language\n\
does not match the selected frame's language."), nullptr, nullptr,
&setlist, &showlist);
add_set_language_command ();
}

View File

@ -731,6 +731,10 @@ extern const struct language_defn *expected_language;
extern const char lang_frame_mismatch_warn[];
/* Controls whether to warn on a frame language mismatch. */
extern bool warn_frame_lang_mismatch;
/* language_mode ==
language_mode_auto: current_language automatically set upon selection
of scope (e.g. stack frame)

View File

@ -98,9 +98,9 @@ clean_restart $binfile
# Try exercising the "minimal" language a bit...
if {[runto csub]} {
gdb_test "set lang minimal" \
"Warning: the current language does not match this frame." \
"set lang to minimal"
# Also test warn-language-frame-mismatch.
gdb_test_no_output "set warn-language-frame-mismatch off"
gdb_test_no_output "set lang minimal" "set lang to minimal"
gdb_test "print x" " = 5000" "print parameter value"

View File

@ -238,7 +238,7 @@ with_test_prefix "errors" {
# Try ambiguous settings.
gdb_test "with w" \
"Ambiguous set command \"w\": watchdog, width, write\\."
"Ambiguous set command \"w\": warn-language-frame-mismatch, watchdog, width, write\\."
gdb_test "with print m" \
"Ambiguous set print command \"m\": max-depth, max-symbolic-offset, memory-tag-violations\\."

View File

@ -388,7 +388,7 @@ check_frame_language_change (void)
/* FIXME: This should be cacheing the frame and only running when
the frame changes. */
if (has_stack_frames ())
if (warn_frame_lang_mismatch && has_stack_frames ())
{
enum language flang;