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.
This commit is contained in:
parent
0b45135ec1
commit
7ff38b1c89
5 changed files with 71 additions and 44 deletions
63
gdb/stack.c
63
gdb/stack.c
|
@ -2560,46 +2560,43 @@ func_command (char *arg, int from_tty)
|
|||
select_and_print_frame (frame);
|
||||
}
|
||||
|
||||
/* Gets the language of the current frame. */
|
||||
/* Gets the language of FRAME. */
|
||||
|
||||
enum language
|
||||
get_frame_language (void)
|
||||
get_frame_language (struct frame_info *frame)
|
||||
{
|
||||
struct frame_info *frame = deprecated_safe_get_selected_frame ();
|
||||
CORE_ADDR pc = 0;
|
||||
int pc_p = 0;
|
||||
|
||||
if (frame)
|
||||
gdb_assert (frame!= NULL);
|
||||
|
||||
/* We determine the current frame language by looking up its
|
||||
associated symtab. To retrieve this symtab, we use the frame
|
||||
PC. However we cannot use the frame PC as is, because it
|
||||
usually points to the instruction following the "call", which
|
||||
is sometimes the first instruction of another function. So
|
||||
we rely on get_frame_address_in_block(), it provides us with
|
||||
a PC that is guaranteed to be inside the frame's code
|
||||
block. */
|
||||
|
||||
TRY
|
||||
{
|
||||
CORE_ADDR pc = 0;
|
||||
int pc_p = 0;
|
||||
pc = get_frame_address_in_block (frame);
|
||||
pc_p = 1;
|
||||
}
|
||||
CATCH (ex, RETURN_MASK_ERROR)
|
||||
{
|
||||
if (ex.error != NOT_AVAILABLE_ERROR)
|
||||
throw_exception (ex);
|
||||
}
|
||||
END_CATCH
|
||||
|
||||
/* We determine the current frame language by looking up its
|
||||
associated symtab. To retrieve this symtab, we use the frame
|
||||
PC. However we cannot use the frame PC as is, because it
|
||||
usually points to the instruction following the "call", which
|
||||
is sometimes the first instruction of another function. So
|
||||
we rely on get_frame_address_in_block(), it provides us with
|
||||
a PC that is guaranteed to be inside the frame's code
|
||||
block. */
|
||||
if (pc_p)
|
||||
{
|
||||
struct compunit_symtab *cust = find_pc_compunit_symtab (pc);
|
||||
|
||||
TRY
|
||||
{
|
||||
pc = get_frame_address_in_block (frame);
|
||||
pc_p = 1;
|
||||
}
|
||||
CATCH (ex, RETURN_MASK_ERROR)
|
||||
{
|
||||
if (ex.error != NOT_AVAILABLE_ERROR)
|
||||
throw_exception (ex);
|
||||
}
|
||||
END_CATCH
|
||||
|
||||
if (pc_p)
|
||||
{
|
||||
struct compunit_symtab *cust = find_pc_compunit_symtab (pc);
|
||||
|
||||
if (cust != NULL)
|
||||
return compunit_language (cust);
|
||||
}
|
||||
if (cust != NULL)
|
||||
return compunit_language (cust);
|
||||
}
|
||||
|
||||
return language_unknown;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue