This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 2/3] Read pseudo registers from frame instead of regcache
- From: John Baldwin <jhb at FreeBSD dot org>
- To: Simon Marchi <simon dot marchi at polymtl dot ca>, gdb-patches at sourceware dot org
- Cc: Ulrich Weigand <uweigand at de dot ibm dot com>, Tom Tromey <tom at tromey dot com>, Simon Marchi <simon dot marchi at ericsson dot com>
- Date: Fri, 8 Feb 2019 08:52:28 -0800
- Subject: Re: [PATCH v2 2/3] Read pseudo registers from frame instead of regcache
- References: <20181024014333.14143-1-simon.marchi@polymtl.ca> <20181024014333.14143-3-simon.marchi@polymtl.ca>
On 10/23/18 6:43 PM, Simon Marchi wrote:
> From: Simon Marchi <simon.marchi@ericsson.com>
>
> Reading pseudo registers (made of one or more raw register) from an
> unwound stack frame (frame number > #0) does not work. The raw
> registers needed to compose the pseudo registers are always read from
> the current thread's regcache, which is effectively frame #0.
>
> ...
>
> @@ -1203,9 +1263,41 @@ frame_unwind_register_value (frame_info *next_frame, int regnum)
> frame_unwind_find_by_frame (next_frame, &next_frame->prologue_cache);
>
> /* Ask this frame to unwind its register. */
> - value = next_frame->unwind->prev_register (next_frame,
> - &next_frame->prologue_cache,
> - regnum);
> + struct value *value
> + = next_frame->unwind->prev_register (next_frame,
> + &next_frame->prologue_cache, regnum);
> +
> + if (value == nullptr)
> + {
> + frame_register_reader reg_read (next_frame);
> +
> + if (gdbarch_pseudo_register_read_value_p (gdbarch))
> + {
> + /* This is a pseudo register, we don't know how how what raw registers
> + this pseudo register is made of. Ask the gdbarch to read the
> + value, it will itself ask the next frame to unwind the values of
> + the raw registers it needs to compose the value of the pseudo
> + register. */
> + value
> + = gdbarch_pseudo_register_read_value (gdbarch, ®_read, regnum);
> + VALUE_LVAL (value) = not_lval;
> + }
> + else if (gdbarch_pseudo_register_read_p (gdbarch))
> + {
> + value = allocate_value (register_type (gdbarch, regnum));
> + VALUE_LVAL (value) = not_lval;
> +
> + register_status st
> + = gdbarch_pseudo_register_read (gdbarch, ®_read, regnum,
> + value_contents_raw (value));
> + if (st == REG_UNAVAILABLE)
> + mark_value_bytes_unavailable (value, 0,
> + TYPE_LENGTH (value_type (value)));
> + }
> + else
> + error (_("Can't unwind value of register %d (%s)"), regnum,
> + user_reg_map_regnum_to_name (gdbarch, regnum));
> + }
The only thought I have here (which is a bit orthogonal I think) is if
gdbarch shouldn't have a default implementation of
gdbarch_pseudo_register_read_value that does what your else branch does
above?
--
John Baldwin