aboutsummaryrefslogtreecommitdiff
path: root/gdb/stack.c
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1991-04-22 20:08:53 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1991-04-22 20:08:53 +0000
commit777bef06cd075ee4031187fe28381d5d5edd4f94 (patch)
tree0ca9c4eaec086bb1a36e3ae9a7f6f29757612ca7 /gdb/stack.c
parentfcb887ffcd896af0b53c7ac8808bfeed54b321e8 (diff)
downloadgdb-777bef06cd075ee4031187fe28381d5d5edd4f94.zip
gdb-777bef06cd075ee4031187fe28381d5d5edd4f94.tar.gz
gdb-777bef06cd075ee4031187fe28381d5d5edd4f94.tar.bz2
Check for NULL selected_frame in various places.
Diffstat (limited to 'gdb/stack.c')
-rw-r--r--gdb/stack.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/gdb/stack.c b/gdb/stack.c
index 0992013..e8041fb 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -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)