Re: [PATCH 2/9] gdb: pass frame_info_ptr to gdbarch_value_from_register

Simon Marchi
2023-12-22T16:53:24Z

On 2023-12-22 11:40, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
>
> Simon> Pass a frame_info_ptr rather than a frame_id. This avoids having to do
> Simon> a frame lookup on the callee side, when we can just pass the frame down
> Simon> directly.
>
> Simon> I think this fixes a bug in rs6000-tdep.c where the id of the wrong
> Simon> frame was set to `VALUE_NEXT_FRAME_ID (v)`.
>
> Simon> +value *
> Simon> +default_value_from_register (gdbarch *gdbarch, type *type, int regnum,
> Simon> + frame_info_ptr this_frame)
>
> FWIW I tend to think new code should use 'const frame_info_ptr &' in
> most places. It's more efficient and the design of frame_info_ptr also
> makes it harmless, as the underlying frame_info member is mutable.

I initially thought that frame_info_ptr would be a thin enough wrapper
that it would be better to pass it by value, but I see that it's 64
bytes long, so I guess you're right. I'll change my patches, but we
should probably change the existing code too.

It will also appease a frustration I had, where passing a frame_info_ptr
down to a function would call the copy constructor. So, trying to step
into that function would first step into the frame_info_ptr constructor
first. I tried to add some skips for that in gdb-gdb.gdb, but I wasn't
very successful (I didn't try very hard though).

Simon