aboutsummaryrefslogtreecommitdiff
path: root/gdb/language.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2015-07-14 15:07:35 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2015-08-07 11:54:59 +0200
commit7ff38b1c898be5db053193f26d6a3a1d8a6074e8 (patch)
tree3bfa2bd46803f98fc89c6cd60d777ff5c27e197e /gdb/language.c
parent0b45135ec1364f9d0c850a52ce05cf4ffb038021 (diff)
downloadgdb-7ff38b1c898be5db053193f26d6a3a1d8a6074e8.zip
gdb-7ff38b1c898be5db053193f26d6a3a1d8a6074e8.tar.gz
gdb-7ff38b1c898be5db053193f26d6a3a1d8a6074e8.tar.bz2
gdb: get_frame_language now takes a frame parameter.
As part of a drive to remove deprecated_safe_get_selected_frame, make the get_frame_language function take a frame parameter. Given the name of the function this actually seems to make a lot of sense. The task of fetching a suitable frame is then passed to the calling functions. For get_frame_language there are not many callers, these are updated to get the selected frame in a suitable way. gdb/ChangeLog: * language.c (show_language_command): Find selected frame before asking for the language of that frame. (set_language_command): Likewise. * language.h (get_frame_language): Add frame parameter. * stack.c (get_frame_language): Add frame parameter, assert parameter is not NULL, update comment and reindent. * top.c (check_frame_language_change): Pass the selected frame into get_frame_language.
Diffstat (limited to 'gdb/language.c')
-rw-r--r--gdb/language.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/gdb/language.c b/gdb/language.c
index a8b432e..ab767c3 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -118,7 +118,7 @@ static void
show_language_command (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- enum language flang; /* The language of the current frame. */
+ enum language flang; /* The language of the frame. */
if (language_mode == language_mode_auto)
fprintf_filtered (gdb_stdout,
@@ -130,11 +130,17 @@ show_language_command (struct ui_file *file, int from_tty,
_("The current source language is \"%s\".\n"),
current_language->la_name);
- flang = get_frame_language ();
- if (flang != language_unknown &&
- language_mode == language_mode_manual &&
- current_language->la_language != flang)
- printf_filtered ("%s\n", lang_frame_mismatch_warn);
+ if (has_stack_frames ())
+ {
+ struct frame_info *frame;
+
+ frame = get_selected_frame (NULL);
+ flang = get_frame_language (frame);
+ if (flang != language_unknown
+ && language_mode == language_mode_manual
+ && current_language->la_language != flang)
+ printf_filtered ("%s\n", lang_frame_mismatch_warn);
+ }
}
/* Set command. Change the current working language. */
@@ -142,7 +148,7 @@ static void
set_language_command (char *ignore, int from_tty, struct cmd_list_element *c)
{
int i;
- enum language flang;
+ enum language flang = language_unknown;
/* Search the list of languages for a match. */
for (i = 0; i < languages_size; i++)
@@ -155,7 +161,19 @@ set_language_command (char *ignore, int from_tty, struct cmd_list_element *c)
/* Enter auto mode. Set to the current frame's language, if
known, or fallback to the initial language. */
language_mode = language_mode_auto;
- flang = get_frame_language ();
+ TRY
+ {
+ struct frame_info *frame;
+
+ frame = get_selected_frame (NULL);
+ flang = get_frame_language (frame);
+ }
+ CATCH (ex, RETURN_MASK_ERROR)
+ {
+ flang = language_unknown;
+ }
+ END_CATCH
+
if (flang != language_unknown)
set_language (flang);
else