[6/7] gdb: add missing prepare_reinflate call in print_frame_info

Message ID 20221107155310.2590069-6-simon.marchi@polymtl.ca
State Committed
Commit aeba2026b58a8abfc35c390f07bcdaf42728e7b5
Headers
Series [1/7] gdb: clear other.m_cached_id in frame_info_ptr's move ctor |

Commit Message

Simon Marchi Nov. 7, 2022, 3:53 p.m. UTC
  print_frame_info calls frame_info_ptr::reinflate, but not
frame_info_ptr::prepare_reinflate, add the call to reinflate.  It works
right now, because all callers of print_frame_info that could possibly
lead to the pretty printers being called, and the frame_info objects
being invalidated, do call prepare_reinflate themselves.  And since the
cached frame id is copied when passing a frame_info_ptr by value,
print_frame_info does have a cached frame id on entry.  So technically,
this change isn't needed.  But I don't think it's good for a function to
rely on its callers to have called prepare_reinflate, if it intends to
call reinflate.

Change-Id: Ie332b2d5479aef46f83fdc1120c7c83f4e84d1b0
---
 gdb/stack.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Guinevere Larsen Nov. 8, 2022, 10:28 a.m. UTC | #1
On 07/11/2022 16:53, Simon Marchi via Gdb-patches wrote:
> print_frame_info calls frame_info_ptr::reinflate, but not
> frame_info_ptr::prepare_reinflate, add the call to reinflate.  It works
> right now, because all callers of print_frame_info that could possibly
> lead to the pretty printers being called, and the frame_info objects
> being invalidated, do call prepare_reinflate themselves.  And since the
> cached frame id is copied when passing a frame_info_ptr by value,
> print_frame_info does have a cached frame id on entry.  So technically,
> this change isn't needed.  But I don't think it's good for a function to
> rely on its callers to have called prepare_reinflate, if it intends to
> call reinflate.

oops, my bad. Looks simple enough:

Reviewed-By: Bruno Larsen <blarsen@redhat.com>
  
Lancelot SIX Nov. 8, 2022, 11:31 a.m. UTC | #2
On Mon, Nov 07, 2022 at 10:53:09AM -0500, Simon Marchi via Gdb-patches wrote:
> print_frame_info calls frame_info_ptr::reinflate, but not
> frame_info_ptr::prepare_reinflate, add the call to reinflate.  It works

Did you mean "add the call to prepare_reinflate" instead?

Best,
Lancelot.

> right now, because all callers of print_frame_info that could possibly
> lead to the pretty printers being called, and the frame_info objects
> being invalidated, do call prepare_reinflate themselves.  And since the
> cached frame id is copied when passing a frame_info_ptr by value,
> print_frame_info does have a cached frame id on entry.  So technically,
> this change isn't needed.  But I don't think it's good for a function to
> rely on its callers to have called prepare_reinflate, if it intends to
> call reinflate.
> 
> Change-Id: Ie332b2d5479aef46f83fdc1120c7c83f4e84d1b0
> ---
>  gdb/stack.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/gdb/stack.c b/gdb/stack.c
> index 5f29566fcfe9..4ad51c2eb50e 100644
> --- a/gdb/stack.c
> +++ b/gdb/stack.c
> @@ -1047,6 +1047,8 @@ print_frame_info (const frame_print_options &fp_opts,
>    int location_print;
>    struct ui_out *uiout = current_uiout;
>  
> +  frame.prepare_reinflate ();
> +
>    if (!current_uiout->is_mi_like_p ()
>        && fp_opts.print_frame_info != print_frame_info_auto)
>      {
> -- 
> 2.38.1
>
  
Simon Marchi Nov. 8, 2022, 4:08 p.m. UTC | #3
On 11/8/22 06:31, Lancelot SIX wrote:
> On Mon, Nov 07, 2022 at 10:53:09AM -0500, Simon Marchi via Gdb-patches wrote:
>> print_frame_info calls frame_info_ptr::reinflate, but not
>> frame_info_ptr::prepare_reinflate, add the call to reinflate.  It works
> 
> Did you mean "add the call to prepare_reinflate" instead?

Indeed, thanks.

Simon
  

Patch

diff --git a/gdb/stack.c b/gdb/stack.c
index 5f29566fcfe9..4ad51c2eb50e 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1047,6 +1047,8 @@  print_frame_info (const frame_print_options &fp_opts,
   int location_print;
   struct ui_out *uiout = current_uiout;
 
+  frame.prepare_reinflate ();
+
   if (!current_uiout->is_mi_like_p ()
       && fp_opts.print_frame_info != print_frame_info_auto)
     {