> Well it really needs to check a range of addresses - unwinding
> a stack frame on x86 using the frame pointer requires reading
> a group of 8 bytes, which can cross a page boundary.
Hmm, true. Still, checking for page boundary crossing is something
that can be pushed into the query function.
> Interesting - using an oset or something presumably?
OSets are problematic in m_aspacemgr because we can't use dynamic
memory allocation there. I was thinking of something along the
lines of a small fixed size array of known-safe segments, perhaps
arranged as a fully associative or 2 or 4 way set associative cache.
> Well the system call stuff could use VG_(am_is_valid_for_client) at
> the moment, though that has to binary search all the current segments
> every time.
>
> Note that stack unwinding needs to allow reading of V segments as
> well as C segments, as we are sometimes unwinding valgrind's stack
> rather than the client's. The system call check will only want to
> allow C segments.
Yes. So at least as a simple start, we need a function "Bool
VG_(am_dword_is_readable)(Addr)", which returns True if arg ..
arg+2*sizeof(Word)-1 is safe to read.
One way it could be done is to have a fixed-size (16-ish?) array
of pointers to NSegments. Each NSegment is in the array only if
it is safe to read from it. Array is searched from index 0 onwards
and a hit at index > 0 causes that entry to be moved forward one
place.
Assuming that most queries hit entry 0 -- as they should do, since
this is now a cache of segments, not pages -- then the fast case is
if cache[0] != NULL // entry present
&& a >= cache[0]->start
&& a+8 <= cache[0]->end return True
So that's 3 highly predictable conditionals, plus the call and return
branches. I'd say doable in 30 ish cycles in the common case, considering
the call/return overhead. So that's an extra 360 cycles for a common-case
12-frame stack unwind. Not bad really.
J
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Valgrind-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers