{
extern struct blockvector *blockvector_for_pc ();
register struct blockvector *bl;
- register struct block *block = get_frame_block (selected_frame);
+ register struct block *block;
int index, have_default = 0;
- struct frame_info *fi = get_frame_info (selected_frame);
- CORE_ADDR pc = fi->pc;
+ struct frame_info *fi;
+ CORE_ADDR pc;
struct symtabs_and_lines sals;
struct sal_chain *sal_chain = 0;
char *blocks_searched;
+ /* Not sure whether an error message is always the correct response,
+ but it's better than a core dump. */
+ if (selected_frame == NULL)
+ error ("No selected frame.");
+ block = get_frame_block (selected_frame);
+ fi = get_frame_info (selected_frame);
+ pc = fi->pc;
+
sals.nelts = 0;
sals.sals = NULL;
count = bfd_count_sections (some_bfd);
if (count == 0)
abort(); /* return 1? */
+ if (*start)
+ free (*start);
*start = (struct section_table *) xmalloc (count * sizeof (**start));
*end = *start;
bfd_map_over_sections (some_bfd, add_to_section_table, end);
/* Given a struct symbol for a variable,
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 the variable cannot be found, return a zero pointer.
+ If FRAME is NULL, use the selected_frame. */
value
read_var_value (var, frame)
case LOC_ARG:
fi = get_frame_info (frame);
+ if (fi == NULL)
+ return 0;
addr = FRAME_ARGS_ADDRESS (fi);
if (!addr) {
return 0;
case LOC_REF_ARG:
fi = get_frame_info (frame);
+ if (fi == NULL)
+ return 0;
addr = FRAME_ARGS_ADDRESS (fi);
if (!addr) {
return 0;
case LOC_LOCAL:
case LOC_LOCAL_ARG:
fi = get_frame_info (frame);
+ if (fi == NULL)
+ return 0;
addr = SYMBOL_VALUE (var) + FRAME_LOCALS_ADDRESS (fi);
break;
case LOC_REGISTER:
case LOC_REGPARM:
{
- struct block *b = get_frame_block (frame);
+ struct block *b;
+ if (frame == NULL)
+ return 0;
+ b = get_frame_block (frame);
+
v = value_from_register (type, SYMBOL_VALUE (var), frame);
if (REG_STRUCT_HAS_ADDR(b->gcc_compile_flag)
error ("The \"finish\" command does not take any arguments.");
if (!target_has_execution)
error ("The program is not running.");
+ if (selected_frame == NULL)
+ error ("No selected frame.");
frame = get_prev_frame (selected_frame);
if (frame == 0)
if (!query ("Kill the inferior process? "))
error ("Not confirmed.");
target_kill (arg, from_tty);
+
+ /* Killing off the inferior can leave us with a core file. If so,
+ print the state we are left in. */
+ if (target_has_stack) {
+ printf_filtered ("In %s,\n", current_target->to_longname);
+ if (selected_frame == NULL)
+ fputs_filtered ("No selected stack frame.\n", stdout);
+ else
+ print_sel_frame (0);
+ }
}
/* The inferior process has died. Long live the inferior! */
CLEAR_DEFERRED_STORES;
#endif
- select_frame ((FRAME) 0, -1);
reopen_exec_file ();
- if (target_has_stack)
+ if (target_has_stack) {
set_current_frame ( create_new_frame (read_register (FP_REGNUM),
read_pc ()));
- else
+ select_frame (get_current_frame (), 0);
+ } else {
set_current_frame (0);
+ select_frame ((FRAME) 0, -1);
+ }
/* It is confusing to the user for ignore counts to stick around
from previous runs of the inferior. So clear them. */
breakpoint_clear_ignore_counts ();
fid = find_relative_frame (get_current_frame (),
&level);
+ /* If inf_status->selected_frame_address is NULL, there was no
+ previously selected frame. */
if (fid == 0 ||
FRAME_FP (fid) != inf_status->selected_frame_address ||
level != 0)
/*
* Read a frame specification in whatever the appropriate format is.
+ * Call error() if the specification is in any way invalid (i.e.
+ * this function never returns NULL).
*/
static FRAME
parse_frame_specification (frame_exp)
switch (numargs)
{
case 0:
+ if (selected_frame == NULL)
+ error ("No selected frame.");
return selected_frame;
/* NOTREACHED */
case 1:
register FRAME trailing;
register int trailing_level;
+ if (!target_has_stack)
+ error ("No stack.");
+
/* The following code must do two things. First, it must
set the variable TRAILING to the frame from which we should start
printing. Second, it must set the variable count to the number
find_pc_symtab (get_frame_info (frame)->pc);
}
-/* Store the selected frame and its level into *FRAMEP and *LEVELP. */
+/* Store the selected frame and its level into *FRAMEP and *LEVELP.
+ If there is no selected frame, *FRAMEP is set to NULL. */
void
record_selected_frame (frameaddrp, levelp)
FRAME_ADDR *frameaddrp;
int *levelp;
{
- *frameaddrp = FRAME_FP (selected_frame);
+ *frameaddrp = selected_frame ? FRAME_FP (selected_frame) : NULL;
*levelp = selected_frame_level;
}
char *retval_exp;
int from_tty;
{
- struct symbol *thisfun = get_frame_function (selected_frame);
- FRAME_ADDR selected_frame_addr = FRAME_FP (selected_frame);
- CORE_ADDR selected_frame_pc = (get_frame_info (selected_frame))->pc;
+ struct symbol *thisfun;
+ FRAME_ADDR selected_frame_addr;
+ CORE_ADDR selected_frame_pc;
FRAME frame;
+ if (selected_frame == NULL)
+ error ("No selected frame.");
+ thisfun = get_frame_function (selected_frame);
+ selected_frame_addr = FRAME_FP (selected_frame);
+ selected_frame_pc = (get_frame_info (selected_frame))->pc;
+
/* If interactive, require confirmation. */
if (from_tty)