Check for NULL selected_frame in various places.

This commit is contained in:
Jim Kingdon 1991-04-22 20:08:53 +00:00
parent fcb887ffcd
commit 777bef06cd
7 changed files with 64 additions and 13 deletions

View file

@ -1537,14 +1537,22 @@ get_catch_sals (this_level_only)
{
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;

View file

@ -193,6 +193,8 @@ build_section_table (some_bfd, start, end)
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);

View file

@ -354,7 +354,8 @@ supply_register (regno, val)
/* 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)
@ -411,6 +412,8 @@ 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;
@ -420,6 +423,8 @@ read_var_value (var, frame)
case LOC_REF_ARG:
fi = get_frame_info (frame);
if (fi == NULL)
return 0;
addr = FRAME_ARGS_ADDRESS (fi);
if (!addr) {
return 0;
@ -431,6 +436,8 @@ read_var_value (var, frame)
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;
@ -445,8 +452,12 @@ read_var_value (var, frame)
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)

View file

@ -529,6 +529,8 @@ finish_command (arg, from_tty)
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)

View file

@ -364,6 +364,16 @@ kill_command (arg, from_tty)
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! */
@ -381,13 +391,15 @@ generic_mourn_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 ();

View file

@ -1605,6 +1605,8 @@ restore_inferior_status (inf_status)
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)

View file

@ -221,6 +221,8 @@ extern FRAME setup_arbitrary_frame ();
/*
* 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)
@ -262,6 +264,8 @@ parse_frame_specification (frame_exp)
switch (numargs)
{
case 0:
if (selected_frame == NULL)
error ("No selected frame.");
return selected_frame;
/* NOTREACHED */
case 1:
@ -477,6 +481,9 @@ backtrace_command (count_exp, from_tty)
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
@ -846,14 +853,15 @@ select_frame (frame, level)
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;
}
@ -1028,11 +1036,17 @@ return_command (retval_exp, from_tty)
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)