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: [unavailable values part 1, 04/17] map unavailable memory to unavailable value contents


> @@ -1009,12 +1009,8 @@ value_fetch_lazy (struct value *val)
>        int length = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
>  
>        if (length)
> -	{
> -	  if (value_stack (val))
> -	    read_stack (addr, value_contents_all_raw (val), length);
> -	  else
> -	    read_memory (addr, value_contents_all_raw (val), length);
> -	}
> +	read_value_memory (val, 0, value_stack (val),
> +			   addr, value_contents_all_raw (val), length);

I think here should be value_contents_raw.  It is an unrelated issue.


>      }
>    else if (VALUE_LVAL (val) == lval_register)
>      {
> @@ -1113,6 +1109,89 @@ value_fetch_lazy (struct value *val)
>    return 0;
>  }
>  
> +void
> +read_value_memory (struct value *val, int embedded_offset,
> +		   int stack, CORE_ADDR memaddr,
> +		   gdb_byte *buffer, size_t length)
> +{
> +  if (length)
> +    {
> +      VEC(mem_range_s) *available_memory;
> +
> +      if (get_traceframe_number () < 0
> +	  || !traceframe_available_memory (&available_memory, memaddr, length))
> +	{
> +	  if (stack)
> +	    read_stack (memaddr, buffer, length);
> +	  else
> +	    read_memory (memaddr, buffer, length);
> +	}
> +      else
> +	{
> +	  struct target_section_table *table;
> +	  struct cleanup *old_chain;
> +	  CORE_ADDR unavail;
> +	  mem_range_s *r;
> +	  int i;
> +
> +	  /* Fallback to reading from read-only sections.  */
> +	  table = target_get_section_table (&exec_ops);

Cannot be table NULL?


> +	  available_memory =
> +	    section_table_available_memory (available_memory,
> +					    memaddr, length,
> +					    table->sections,
> +					    table->sections_end);
> +
> +	  old_chain = make_cleanup (VEC_cleanup(mem_range_s),
> +				    &available_memory);
> +


> --- src.orig/gdb/value.h	2011-02-07 11:12:35.406706000 +0000
> +++ src/gdb/value.h	2011-02-07 11:15:02.926705996 +0000
> @@ -374,6 +374,17 @@ extern int value_bytes_available (const
>  extern void mark_value_bytes_unavailable (struct value *value,
>  					  int offset, int length);
>  
> +/* Read LENGTH bytes of memory starting at MEMADDR into BUFFER, which
> +   is (or will be copied to) VAL's contents buffer offset by
> +   EMBEDDED_OFFSET (that is, to &VAL->contents[EMBEDDED_OFFSET]).
> +   Marks value contents ranges as unavailable if the corresponding
> +   memory is likewise unavailable.  STACK indicates whether the memory
> +   is known to be stack memory.  */
> +
> +extern void read_value_memory (struct value *val, int offset,
> +			       int stack, CORE_ADDR memaddr,
> +			       gdb_byte *buffer, size_t length);
> +

Comment talks about EMBEDDED_OFFSET while the declaration parameter name does
not match the function definition parameter name.


> @@ -572,6 +572,43 @@ map_vmap (bfd *abfd, bfd *arch)
>  }
>  
>  
> +VEC(mem_range_s) *
> +section_table_available_memory (VEC(mem_range_s) *memory,
> +				CORE_ADDR memaddr, LONGEST len,

After `int', `ULONGEST' and `size_t' the type is now `LONGEST'.

Does it mean there is no intention for >2GB inferior objects handling?
I thought some Fortran simulations may use such arrays etc.


> +				struct target_section *sections,
> +				struct target_section *sections_end)
> +{
> +  struct target_section *p;
> +  ULONGEST memend = memaddr + len;

Unused variable `memend'.

> +
> +  for (p = sections; p < sections_end; p++)
> +    {
> +      if ((bfd_get_section_flags (p->bfd, p->the_bfd_section)
> +	   & SEC_READONLY) == 0)
> +	continue;
> +
> +      /* Copy the meta-data, adjusted.  */
> +      if (mem_ranges_overlap (p->addr, p->endaddr - p->addr, memaddr, len))
> +	{
> +	  ULONGEST lo1, hi1, lo2, hi2;
> +	  struct mem_range *r;
> +
> +	  lo1 = memaddr;
> +	  hi1 = memaddr + len;
> +
> +	  lo2 = p->addr;
> +	  hi2 = p->endaddr;
> +
> +	  r = VEC_safe_push (mem_range_s, memory, NULL);
> +
> +	  r->start = max (lo1, lo2);
> +	  r->length = min (hi1, hi2) - r->start;
> +	}
> +    }
> +
> +  return memory;
> +}


Thanks,
Jan


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