diff options
author | Tom Tromey <tromey@adacore.com> | 2024-11-01 10:08:34 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2024-11-11 07:42:01 -0700 |
commit | 218ee1660d139d945c8517775a4813107a174664 (patch) | |
tree | ef3b5038ace9df699e13aa7971aa37eb155e2808 | |
parent | 3a983e041b8b7130fc1e23d6e9e496850a968933 (diff) | |
download | gdb-218ee1660d139d945c8517775a4813107a174664.zip gdb-218ee1660d139d945c8517775a4813107a174664.tar.gz gdb-218ee1660d139d945c8517775a4813107a174664.tar.bz2 |
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>
-rw-r--r-- | gdb/NEWS | 5 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 13 | ||||
-rw-r--r-- | gdb/language.c | 15 | ||||
-rw-r--r-- | gdb/language.h | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/langs.exp | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/with.exp | 2 | ||||
-rw-r--r-- | gdb/top.c | 2 |
7 files changed, 41 insertions, 6 deletions
@@ -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 diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 844e660..53f41e6 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -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 diff --git a/gdb/language.c b/gdb/language.c index d697331..a8548a2 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -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 (); } diff --git a/gdb/language.h b/gdb/language.h index 985e622..26d7fb2 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -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) diff --git a/gdb/testsuite/gdb.base/langs.exp b/gdb/testsuite/gdb.base/langs.exp index 0acc1d6..862741b 100644 --- a/gdb/testsuite/gdb.base/langs.exp +++ b/gdb/testsuite/gdb.base/langs.exp @@ -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" diff --git a/gdb/testsuite/gdb.base/with.exp b/gdb/testsuite/gdb.base/with.exp index a646081..2e54825 100644 --- a/gdb/testsuite/gdb.base/with.exp +++ b/gdb/testsuite/gdb.base/with.exp @@ -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\\." @@ -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; |