(selected_frame): ...this. Make static.
(get_selected_frame, select_frame): Update.
* frame.h (deprected_select_frame): Delete.
(deprecated_safe_get_selected_frame): Update comments.
* breakpoint.c, cli/cli-cmds.c, f-valprint.c, infcmd.c, inflow.c,
infrun.c, stack.c, tui/tui-disasm.c, tui/tui-source.c,
tui/tui-winsource.c, valops.c, varobj.c, findvar.c, macroscope.c,
parse.c, regcache.h, sh64-tdep.c, tui/tui-hooks.c, tui/tui-win.c,
tui/tui.c: Replace references to deprecated_selected_frame.
+2007-02-27 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * frame.c (deprecated_selected_frame): Rename to...
+ (selected_frame): ...this. Make static.
+ (get_selected_frame, select_frame): Update.
+ * frame.h (deprected_select_frame): Delete.
+ (deprecated_safe_get_selected_frame): Update comments.
+
+ * breakpoint.c, cli/cli-cmds.c, f-valprint.c, infcmd.c, inflow.c,
+ infrun.c, stack.c, tui/tui-disasm.c, tui/tui-source.c,
+ tui/tui-winsource.c, valops.c, varobj.c, findvar.c, macroscope.c,
+ parse.c, regcache.h, sh64-tdep.c, tui/tui-hooks.c, tui/tui-win.c,
+ tui/tui.c: Replace references to deprecated_selected_frame.
+
2007-02-27 Fred Fish <fnf@specifix.com>
* rs6000-tdep.c (skip_prologue): Recognize addi instructions that
/* FIXME drow/2003-09-09: It would be nice if evaluate_expression
took a frame parameter, so that we didn't have to change the
selected frame. */
- saved_frame_id = get_frame_id (deprecated_selected_frame);
+ saved_frame_id = get_frame_id (get_selected_frame (NULL));
/* Determine if the watchpoint is within scope. */
if (bpt->owner->exp_valid_block == NULL)
{
struct symtabs_and_lines sals;
struct symtab_and_line sal;
- struct frame_info *prev_frame = get_prev_frame (deprecated_selected_frame);
+ struct frame_info *frame = get_selected_frame (NULL);
+ struct frame_info *prev_frame = get_prev_frame (frame);
struct breakpoint *breakpoint;
struct cleanup *old_chain;
struct continuation_arg *arg1;
else
/* Otherwise, specify the current frame, because we want to stop only
at the very same frame. */
- breakpoint = set_momentary_breakpoint (sal,
- get_frame_id (deprecated_selected_frame),
+ breakpoint = set_momentary_breakpoint (sal, get_frame_id (frame),
bp_until);
if (!target_can_async_p ())
name = NULL;
if (!arg)
{
- if (!deprecated_selected_frame)
- error (_("No frame selected."));
-
- pc = get_frame_pc (deprecated_selected_frame);
+ pc = get_frame_pc (get_selected_frame (_("No frame selected.")));
if (find_pc_partial_function (pc, &name, &low, &high) == 0)
error (_("No function contains program counter for selected frame."));
#if defined(TUI)
int
f77_get_dynamic_lowerbound (struct type *type, int *lower_bound)
{
+ struct frame_info *frame;
CORE_ADDR current_frame_addr;
CORE_ADDR ptr_to_lower_bound;
switch (TYPE_ARRAY_LOWER_BOUND_TYPE (type))
{
case BOUND_BY_VALUE_ON_STACK:
- current_frame_addr = get_frame_base (deprecated_selected_frame);
+ frame = deprecated_safe_get_selected_frame ();
+ current_frame_addr = get_frame_base (frame);
if (current_frame_addr > 0)
{
*lower_bound =
break;
case BOUND_BY_REF_ON_STACK:
- current_frame_addr = get_frame_base (deprecated_selected_frame);
+ frame = deprecated_safe_get_selected_frame ();
+ current_frame_addr = get_frame_base (frame);
if (current_frame_addr > 0)
{
ptr_to_lower_bound =
int
f77_get_dynamic_upperbound (struct type *type, int *upper_bound)
{
+ struct frame_info *frame;
CORE_ADDR current_frame_addr = 0;
CORE_ADDR ptr_to_upper_bound;
switch (TYPE_ARRAY_UPPER_BOUND_TYPE (type))
{
case BOUND_BY_VALUE_ON_STACK:
- current_frame_addr = get_frame_base (deprecated_selected_frame);
+ frame = deprecated_safe_get_selected_frame ();
+ current_frame_addr = get_frame_base (frame);
if (current_frame_addr > 0)
{
*upper_bound =
break;
case BOUND_BY_REF_ON_STACK:
- current_frame_addr = get_frame_base (deprecated_selected_frame);
+ frame = deprecated_safe_get_selected_frame ();
+ current_frame_addr = get_frame_base (frame);
if (current_frame_addr > 0)
{
ptr_to_upper_bound =
first make sure that it is visible and if so, let
us display its contents */
- fi = deprecated_selected_frame;
-
- if (fi == NULL)
- error (_("No frame selected"));
+ fi = get_selected_frame (_("No frame selected"));
/* The following is generally ripped off from stack.c's routine
print_frame_info() */
if (comname == NULL)
error (_("Cannot deal with NULL common name!"));
- fi = deprecated_selected_frame;
-
- if (fi == NULL)
- error (_("No frame selected"));
+ fi = get_selected_frame (_("No frame selected"));
/* The following is generally ripped off from stack.c's routine
print_frame_info() */
and a stack frame id, read the value of the variable
and return a (pointer to a) struct value containing the value.
If the variable cannot be found, return a zero pointer.
- If FRAME is NULL, use the deprecated_selected_frame. */
+ If FRAME is NULL, use the selected frame. */
struct value *
read_var_value (struct symbol *var, struct frame_info *frame)
/* The "selected" stack frame is used by default for local and arg
access. May be zero, for no selected frame. */
-struct frame_info *deprecated_selected_frame;
+static struct frame_info *selected_frame;
/* Return the selected frame. Always non-NULL (unless there isn't an
inferior sufficient for creating a frame) in which case an error is
struct frame_info *
get_selected_frame (const char *message)
{
- if (deprecated_selected_frame == NULL)
+ if (selected_frame == NULL)
{
if (message != NULL && (!target_has_registers
|| !target_has_stack
select_frame (get_current_frame ());
}
/* There is always a frame. */
- gdb_assert (deprecated_selected_frame != NULL);
- return deprecated_selected_frame;
+ gdb_assert (selected_frame != NULL);
+ return selected_frame;
}
/* This is a variant of get_selected_frame() which can be called when
{
struct symtab *s;
- deprecated_selected_frame = fi;
+ selected_frame = fi;
/* NOTE: cagney/2002-05-04: FI can be NULL. This occurs when the
frame is being invalidated. */
if (deprecated_selected_frame_level_changed_hook)
extern void return_command (char *, int);
-/* NOTE: cagney/2002-11-27:
+/* Notes (cagney/2002-11-27, drow/2003-09-06):
- You might think that the below global can simply be replaced by a
- call to either get_selected_frame() or select_frame().
+ You might think that calls to this function can simply be replaced by a
+ call to get_selected_frame().
Unfortunately, it isn't that easy.
The only real exceptions occur at the edge (in the CLI code) where
user commands need to pick up the selected frame before proceeding.
+ There are also some functions called with a NULL frame meaning either "the
+ program is not running" or "use the selected frame".
+
This is important. GDB is trying to stamp out the hack:
- saved_frame = deprecated_selected_frame;
- deprecated_selected_frame = ...;
+ saved_frame = deprecated_safe_get_selected_frame ();
+ select_frame (...);
hack_using_global_selected_frame ();
- deprecated_selected_frame = saved_frame;
-
- Take care! */
-
-extern struct frame_info *deprecated_selected_frame;
-
-/* NOTE: drow/2003-09-06:
+ select_frame (saved_frame);
- This function is "a step sideways" for uses of deprecated_selected_frame.
- They should be fixed as above, but meanwhile, we needed a solution for
- cases where functions are called with a NULL frame meaning either "the
- program is not running" or "use the selected frame". Lazy building of
- deprecated_selected_frame confuses the situation, because now
- deprecated_selected_frame can be NULL even when the inferior is running.
+ Take care!
This function calls get_selected_frame if the inferior should have a
frame, or returns NULL otherwise. */
error (_("The \"finish\" command does not take any arguments."));
if (!target_has_execution)
error (_("The program is not running."));
- if (deprecated_selected_frame == NULL)
- error (_("No selected frame."));
- frame = get_prev_frame (deprecated_selected_frame);
+ frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
if (frame == 0)
error (_("\"finish\" not meaningful in the outermost frame."));
/* Find the function we will return from. */
- function = find_pc_function (get_frame_pc (deprecated_selected_frame));
+ function = find_pc_function (get_frame_pc (get_selected_frame (NULL)));
/* Print info on the selected frame, including level number but not
source. */
void
registers_info (char *addr_exp, int fpregs)
{
+ struct frame_info *frame;
int regnum, numregs;
char *end;
if (!target_has_registers)
error (_("The program has no registers now."));
- if (deprecated_selected_frame == NULL)
- error (_("No selected frame."));
+ frame = get_selected_frame (NULL);
if (!addr_exp)
{
gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
- deprecated_selected_frame, -1, fpregs);
+ frame, -1, fpregs);
return;
}
/* A register name? */
{
- int regnum = frame_map_name_to_regnum (deprecated_selected_frame,
+ int regnum = frame_map_name_to_regnum (frame,
start, end - start);
if (regnum >= 0)
{
gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
- deprecated_selected_frame, regnum, fpregs);
+ frame, regnum, fpregs);
continue;
}
}
&& regnum < NUM_REGS + NUM_PSEUDO_REGS)
{
gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
- deprecated_selected_frame, regnum, fpregs);
+ frame, regnum, fpregs);
continue;
}
}
if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
group))
gdbarch_print_registers_info (current_gdbarch,
- gdb_stdout, deprecated_selected_frame,
+ gdb_stdout, frame,
regnum, fpregs);
}
continue;
print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
struct frame_info *frame, const char *args)
{
- if (!target_has_registers)
- error (_("The program has no registers now."));
- if (deprecated_selected_frame == NULL)
- error (_("No selected frame."));
-
if (gdbarch_print_vector_info_p (gdbarch))
gdbarch_print_vector_info (gdbarch, file, frame, args);
else
static void
vector_info (char *args, int from_tty)
{
- print_vector_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);
+ if (!target_has_registers)
+ error (_("The program has no registers now."));
+
+ print_vector_info (current_gdbarch, gdb_stdout,
+ get_selected_frame (NULL), args);
}
\f
print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
struct frame_info *frame, const char *args)
{
- if (!target_has_registers)
- error (_("The program has no registers now."));
- if (deprecated_selected_frame == NULL)
- error (_("No selected frame."));
-
if (gdbarch_print_float_info_p (gdbarch))
gdbarch_print_float_info (gdbarch, file, frame, args);
else
static void
float_info (char *args, int from_tty)
{
+ if (!target_has_registers)
+ error (_("The program has no registers now."));
+
print_float_info (current_gdbarch, gdb_stdout,
- deprecated_selected_frame, args);
+ get_selected_frame (NULL), args);
}
\f
static void
if (target_has_stack)
{
printf_filtered (_("In %s,\n"), target_longname);
- if (deprecated_selected_frame == NULL)
- fputs_filtered ("No selected stack frame.\n", gdb_stdout);
- else
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
}
bfd_cache_close_all ();
}
bpstat_print() contains the logic deciding in detail
what to print, based on the event(s) that just occurred. */
- if (stop_print_frame && deprecated_selected_frame)
+ if (stop_print_frame)
{
int bpstat_ret;
int source_flag;
inf_status->registers = regcache_dup (current_regcache);
- inf_status->selected_frame_id = get_frame_id (deprecated_selected_frame);
+ inf_status->selected_frame_id = get_frame_id (get_selected_frame (NULL));
return inf_status;
}
{
struct symtab_and_line sal;
struct macro_scope *ms;
+ struct frame_info *frame;
- /* If there's a selected frame, use its PC. */
- if (deprecated_selected_frame)
- sal = find_pc_line (get_frame_pc (deprecated_selected_frame), 0);
+ /* If there's a selected frame, use its PC. */
+ frame = deprecated_safe_get_selected_frame ();
+ if (frame)
+ sal = find_pc_line (get_frame_pc (frame), 0);
- /* If the target has any registers at all, then use its PC. Why we
- would have registers but no stack, I'm not sure. */
- else if (target_has_registers)
- sal = find_pc_line (read_pc (), 0);
-
- /* If all else fails, fall back to the current listing position. */
+ /* Fall back to the current listing position. */
else
{
/* Don't call select_source_symtab here. That can raise an
/* Handle tokens that refer to machine registers:
$ followed by a register name. */
- i = frame_map_name_to_regnum (deprecated_selected_frame,
+ i = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (),
str.ptr + 1, str.length - 1);
if (i >= 0)
goto handle_register;
simple substitution is required when updating the code. The
change, as far as practical, should avoid adding references to
global variables (e.g., current_regcache, current_frame,
- current_gdbarch or deprecated_selected_frame) and instead refer to
+ current_gdbarch or the selected frame) and instead refer to
the FRAME or REGCACHE that has been passed into the containing
function as parameters. Consequently, the change typically
involves modifying the containing function so that it takes a FRAME
void
sh64_show_regs (void)
{
- if (deprecated_selected_frame
- && pc_is_isa32 (get_frame_pc (deprecated_selected_frame)))
+ if (pc_is_isa32 (get_frame_pc (get_selected_frame (NULL))))
sh64_show_media_regs ();
else
sh64_show_compact_regs ();
if (!target_has_stack)
return 0;
- /* NOTE: cagney/2002-11-28: Why go to all this effort to not create
- a selected/current frame? Perhaps this function is called,
- indirectly, by WFI in "infrun.c" where avoiding the creation of
- an inner most frame is very important (it slows down single
- step). I suspect, though that this was true in the deep dark
- past but is no longer the case. A mindless look at all the
- callers tends to support this theory. I think we should be able
- to assume that there is always a selcted frame. */
- /* gdb_assert (deprecated_selected_frame != NULL); So, do you feel
- lucky? */
- if (!deprecated_selected_frame)
- {
- CORE_ADDR pc = read_pc ();
- if (addr_in_block != NULL)
- *addr_in_block = pc;
- return block_for_pc (pc);
- }
- return get_frame_block (deprecated_selected_frame, addr_in_block);
+ return get_frame_block (get_selected_frame (NULL), addr_in_block);
}
/* Find a frame a certain number of levels away from FRAME.
if (!found)
printf_filtered (_("'%s' not within current stack frame.\n"), arg);
- else if (frame != deprecated_selected_frame)
+ else if (frame != get_selected_frame (NULL))
select_and_print_frame (frame);
}
enum language
get_frame_language (void)
{
- struct frame_info *frame = deprecated_selected_frame;
+ struct frame_info *frame = deprecated_safe_get_selected_frame ();
if (frame)
{
content = (tui_win_content) TUI_DISASM_WIN->generic.content;
if (cursal.symtab == (struct symtab *) NULL)
- s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
+ s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
else
s = cursal.symtab;
{
struct frame_info *fi;
- fi = deprecated_selected_frame;
- if (fi && tui_refreshing_registers == 0)
+ fi = get_selected_frame (NULL);
+ if (tui_refreshing_registers == 0)
{
tui_refreshing_registers = 1;
#if 0
{
struct frame_info *fi;
- fi = deprecated_selected_frame;
- if (fi && tui_refreshing_registers == 0)
+ fi = get_selected_frame (NULL);
+ if (tui_refreshing_registers == 0)
{
tui_refreshing_registers = 1;
tui_check_data_values (fi);
{
struct frame_info *fi;
- fi = deprecated_selected_frame;
+ fi = get_selected_frame (NULL);
/* Ensure that symbols for this frame are read in. Also, determine the
source language of this frame, and switch to it if desired. */
if (fi)
int stopline, int noerror)
{
select_source_symtab (s);
- tui_show_frame_info (deprecated_selected_frame);
+ tui_show_frame_info (get_selected_frame (NULL));
}
/* Called when the target process died or is detached.
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
if (cursal.symtab == (struct symtab *) NULL)
- s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
+ s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
else
s = cursal.symtab;
tui_free_win_content (&win_info->generic);
tui_update_source_window (win_info, cursal.symtab, line_or_addr, TRUE);
}
- else if (deprecated_selected_frame != (struct frame_info *) NULL)
+ else if (deprecated_safe_get_selected_frame () != NULL)
{
struct tui_line_or_address line;
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+ struct frame_info *frame = deprecated_safe_get_selected_frame ();
-
- s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
+ s = find_pc_symtab (get_frame_pc (frame));
if (win_info->generic.type == SRC_WIN)
{
line.loa = LOA_LINE;
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
if (cursal.symtab == (struct symtab *) NULL)
- s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
+ s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
else
s = cursal.symtab;
tui_setup_io (1);
tui_active = 1;
- if (deprecated_selected_frame)
- tui_show_frame_info (deprecated_selected_frame);
+ if (deprecated_safe_get_selected_frame ())
+ tui_show_frame_info (deprecated_safe_get_selected_frame ());
/* Restore TUI keymap. */
tui_set_key_mode (tui_current_key_mode);
/* Since modifying a register can trash the frame chain, and modifying memory
can trash the frame cache, we save the old frame and then restore the new
frame afterwards. */
- old_frame = get_frame_id (deprecated_selected_frame);
+ old_frame = get_frame_id (deprecated_safe_get_selected_frame ());
switch (VALUE_LVAL (toval))
{
struct symbol *func, *sym;
struct block *b;
struct value * ret;
+ struct frame_info *frame;
- if (deprecated_selected_frame == 0)
+ if (complain)
+ frame = get_selected_frame (_("no frame selected"));
+ else
{
- if (complain)
- error (_("no frame selected"));
- else
+ frame = deprecated_safe_get_selected_frame ();
+ if (frame == 0)
return 0;
}
- func = get_frame_function (deprecated_selected_frame);
+ func = get_frame_function (frame);
if (!func)
{
if (complain)
return NULL;
}
- ret = read_var_value (sym, deprecated_selected_frame);
+ ret = read_var_value (sym, frame);
if (ret == 0 && complain)
error (_("`%s' argument unreadable"), name);
return ret;
/* Allow creator to specify context of variable */
if ((type == USE_CURRENT_FRAME) || (type == USE_SELECTED_FRAME))
- fi = deprecated_selected_frame;
+ fi = deprecated_safe_get_selected_frame ();
else
/* FIXME: cagney/2002-11-23: This code should be doing a
lookup using the frame ID and not just the frame's
if (fi != NULL)
{
var->root->frame = get_frame_id (fi);
- old_fi = deprecated_selected_frame;
+ old_fi = get_selected_frame (NULL);
select_frame (fi);
}
/* Save the selected stack frame, since we will need to change it
in order to evaluate expressions. */
- old_fid = get_frame_id (deprecated_selected_frame);
+ old_fid = get_frame_id (deprecated_safe_get_selected_frame ());
/* Update the root variable. value_of_root can return NULL
if the variable is no longer around, i.e. we stepped out of