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] Cleanup target memory reading


On Wed, Jun 28, 2006 at 11:55:57AM +0400, Vladimir Prus wrote:
> 
> Hi,
> at the moment, pretty much every read of target memory goes via 
> target_read_memory, and then via xfer_using_stratum.
> 
> The only exception is the get_target_memory_unsigned function, which calls 
> target_read function. It's the only use of 'target_read'.
> 
> The attached patch removes target_read, and makes get_target_memory_unsigned 
> use target_read_memory.
> 
> OK?

Since this was posted I added a use of target_read in the SPARC target
:-(  Let's leave it for now.

> 2006-06-28  Vladimir Prus  <vladimir@codesourcery.com>
> 
>             * target.h (target_read): Remove
>             (get_target_memory): Remove.
>             * target.c (target_read): Remove
>             (get_target_memory): Remove.
>             (get_target_memory_unsigned): Use target_read_memory.

But if you want to commit the other two parts of this patch, that's OK.
Except:

> @@ -1404,25 +1381,13 @@
>    return len;
>  }
>  
> -/* Memory transfer methods.  */
> -
> -void
> -get_target_memory (struct target_ops *ops, CORE_ADDR addr, gdb_byte *buf,
> -		   LONGEST len)
> -{
> -  if (target_read (ops, TARGET_OBJECT_MEMORY, NULL, buf, addr, len)
> -      != len)
> -    memory_error (EIO, addr);
> -}
> -
>  ULONGEST
> -get_target_memory_unsigned (struct target_ops *ops,
> -			    CORE_ADDR addr, int len)
> +get_target_memory_unsigned (CORE_ADDR addr, int len)
>  {
>    gdb_byte buf[sizeof (ULONGEST)];
>  
>    gdb_assert (len <= sizeof (buf));
> -  get_target_memory (ops, addr, buf, len);
> +  target_read_memory (addr, buf, len);
>    return extract_unsigned_integer (buf, len);
>  }
>  

get_target_memory used to call memory_error if there was a problem.
target_read_memory doesn't; it returns an error code.  So you need
to check it yourself.

-- 
Daniel Jacobowitz
CodeSourcery


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