This is the mail archive of the gdb-patches@sources.redhat.com 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: [rfa] Restore "trust-readonly-section"


On Mon, May 23, 2005 at 06:03:49PM -0700, Michael Snyder wrote:
> I suppose you're right -- but I'm bewildered by the number of
> possible entry points and paths thru this code.  In theory
> I think I could get away with just covering three points:
> target_read_memory, target_read_partial, and target_read_memory_partial,
> were it not for the fact that do_xfer_memory is also an entry point.

Yes, there really are too many.  I hope that some day soon, we can
reduce the total number.

> do_xfer_memory seems to only be called from dcache.c --
> but it's extern, so nothing prevents others from calling it.
> 
> And dcache_xfer_memory is extern too, so one can get in thru there
> (although again, no one currently does AFAICT).
> 
> >The code might be simpler if you push the trust_readonly check inside
> >target_read_trusted.  Also, could you name that something involving
> >memory?
> 
> OK -- how about the attached, which includes four entry points?

This looks much nicer to me.  Thaks for revising!  One style concern;
I'd be happier if you avoided assignments in if statement.  But I'm not
much bothered about it either way.

> +   /* Honor "trust-readonly-sections" if set.  */
> +   if ((ret = target_read_memory_trusted (memaddr, myaddr, len)) > 0)
> +     return (ret != len);
> + 

This could be:
  if (target_read_memory_trusted (memaddr, myaddr, len) == len)
    return 0;

If it fails, might as well fall through.


-- 
Daniel Jacobowitz
CodeSourcery, LLC


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