From 7dd889867037abfa8f239f9f65f9606294e0be8d Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Mon, 8 Sep 2003 18:56:03 +0000 Subject: [PATCH] * frame.c (deprecated_safe_get_selected_frame): New function. * frame.h (deprecated_safe_get_selected_frame): Add prototype. * findvar.c (read_var_value): Call it. --- gdb/ChangeLog | 6 ++++++ gdb/findvar.c | 5 ++++- gdb/frame.c | 12 ++++++++++++ gdb/frame.h | 13 +++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c284f9c96d0..75c9e681645 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2003-09-08 Daniel Jacobowitz + + * frame.c (deprecated_safe_get_selected_frame): New function. + * frame.h (deprecated_safe_get_selected_frame): Add prototype. + * findvar.c (read_var_value): Call it. + 2003-09-08 Corinna Vinschen * Makefile.in (ALLDEPFILES): Add sh64-tdep.c. diff --git a/gdb/findvar.c b/gdb/findvar.c index 7b6191c7d68..a64ddfb84bb 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -404,8 +404,11 @@ read_var_value (register struct symbol *var, struct frame_info *frame) len = TYPE_LENGTH (type); + + /* FIXME drow/2003-09-06: this call to the selected frame should be + pushed upwards to the callers. */ if (frame == NULL) - frame = deprecated_selected_frame; + frame = deprecated_safe_get_selected_frame (); switch (SYMBOL_CLASS (var)) { diff --git a/gdb/frame.c b/gdb/frame.c index efcee75ddd2..31cb6c5fd9f 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -917,6 +917,18 @@ get_selected_frame (void) return deprecated_selected_frame; } +/* This is a variant of get_selected_frame which can be called when + the inferior does not have a frame; in that case it will return + NULL instead of calling error (). */ + +struct frame_info * +deprecated_safe_get_selected_frame (void) +{ + if (!target_has_registers || !target_has_stack || !target_has_memory) + return NULL; + return get_selected_frame (); +} + /* Select frame FI (or NULL - to invalidate the current frame). */ void diff --git a/gdb/frame.h b/gdb/frame.h index 8851b3a27b0..afbde74c8a7 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -639,6 +639,19 @@ extern void return_command (char *, int); extern struct frame_info *deprecated_selected_frame; +/* NOTE: drow/2003-09-06: + + 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. + + This function calls get_selected_frame if the inferior should have a + frame, or returns NULL otherwise. */ + +extern struct frame_info *deprecated_safe_get_selected_frame (void); /* Create a frame using the specified BASE and PC. */ -- 2.30.2