This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 2/3] Read pseudo registers from frame instead of regcache


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, &reg_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, &reg_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

                                                                            


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]