Remove some frame invalidation code

Message ID 20231030223001.1714967-1-tom@tromey.com
State New
Headers
Series Remove some frame invalidation code |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Tom Tromey Oct. 30, 2023, 10:30 p.m. UTC
  I stumbled across a few spots that mention that a function
"invalidates frame" and also assignments of NULL to a frame_info_ptr.
This code isn't harmful, but is also unnecessary since the
introduction of frame_info_ptr -- nowadays frame invalidations are
handled automatically.

Regression tested on x86-64 Fedora 38.
---
 gdb/breakpoint.c |  3 ---
 gdb/printcmd.c   |  8 +-------
 gdb/stack.c      | 11 ++---------
 3 files changed, 3 insertions(+), 19 deletions(-)
  

Comments

Simon Marchi Oct. 31, 2023, 1:23 a.m. UTC | #1
On 2023-10-30 18:30, Tom Tromey wrote:
> I stumbled across a few spots that mention that a function
> "invalidates frame" and also assignments of NULL to a frame_info_ptr.
> This code isn't harmful, but is also unnecessary since the
> introduction of frame_info_ptr -- nowadays frame invalidations are
> handled automatically.

LGTM, thanks.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon
  

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 828c99cabc0..fe09dbcbeee 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -10952,9 +10952,6 @@  until_break_command (const char *arg, int from_tty, int anywhere)
       lj_deleter.emplace (thread);
     }
 
-  /* set_momentary_breakpoint could invalidate FRAME.  */
-  frame = NULL;
-
   /* If the user told us to continue until a specified location, we
      don't specify a frame at which we need to stop.  Otherwise,
      specify the selected frame, because we want to stop only at the
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index b9b6a3b8648..06cc5316eec 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2391,9 +2391,7 @@  clear_dangling_display_expressions (struct objfile *objfile)
    struct symbol.  NAME is the name to print; if NULL then VAR's print
    name will be used.  STREAM is the ui_file on which to print the
    value.  INDENT specifies the number of indent levels to print
-   before printing the variable name.
-
-   This function invalidates FRAME.  */
+   before printing the variable name.  */
 
 void
 print_variable_and_value (const char *name, struct symbol *var,
@@ -2420,10 +2418,6 @@  print_variable_and_value (const char *name, struct symbol *var,
       get_user_print_options (&opts);
       opts.deref_ref = true;
       common_val_print_checked (val, stream, indent, &opts, current_language);
-
-      /* common_val_print invalidates FRAME when a pretty printer calls inferior
-	 function.  */
-      frame = NULL;
     }
   catch (const gdb_exception_error &except)
     {
diff --git a/gdb/stack.c b/gdb/stack.c
index 0b35d62f82f..39dcefa87b8 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2326,9 +2326,7 @@  prepare_reg (const char *regexp, gdb::optional<compiled_regex> *reg)
    If T_REGEXP is not NULL, only print local variables whose type
    matches T_REGEXP.
    If no local variables have been printed and !QUIET, prints a message
-   explaining why no local variables could be printed.
-
-   This function will invalidate FRAME.  */
+   explaining why no local variables could be printed.  */
 
 static void
 print_frame_local_vars (frame_info_ptr frame,
@@ -2490,9 +2488,7 @@  iterate_over_block_arg_vars (const struct block *b,
    If T_REGEXP is not NULL, only print argument variables whose type
    matches T_REGEXP.
    If no argument variables have been printed and !QUIET, prints a message
-   explaining why no argument variables could be printed.
-
-   This function will invalidate FRAME.  */
+   explaining why no argument variables could be printed.  */
 
 static void
 print_frame_arg_vars (frame_info_ptr frame,
@@ -2531,9 +2527,6 @@  print_frame_arg_vars (frame_info_ptr frame,
 
   iterate_over_block_arg_vars (func->value_block (), cb_data);
 
-  /* do_print_variable_and_value invalidates FRAME.  */
-  frame = NULL;
-
   if (!cb_data.values_printed && !quiet)
     {
       if (regexp == NULL && t_regexp == NULL)