|
From: Florian K. <fl...@ei...> - 2015-02-03 17:46:22
|
On 03.02.2015 14:46, Julian Seward wrote:
>
>> I'm currently thinking of adding
>> NSegment *sorted_nsegments[VG_N_SEGMENTS]
>> as a fix. Basically, introducing another level of indirection.
>
> Can you say how that would help?
sorted_nsegments is an array of pointers to NSegment. When iterated over
the segments appear sorted by address (like nsegments today).
Moving elements in sorted_nsegments around is OK, as it is just pointers
to NSegment. We still would have the nsegments array but its elements
would never get moved around.
But this would not help with merging segments. So forget about it.
> Maybe we should split NSegment* into two different types, one for
> client segments, one for V segments? Or something like that?
I'd say, let's make the definition of NSegment private to m_aspacemgr.
If we can do this without introducing new issues, when we would have
eliminated the problem.
I have not looked at all instances where NSegment occurs in the source
code but for those I have looked at all that is needed is some kind of
wrapper function. For instance in m_redir.c
static Bool is_plausible_guest_addr(Addr a)
{
NSegment const* seg = VG_(am_find_nsegment)(a);
return seg != NULL
&& (seg->kind == SkAnonC || seg->kind == SkFileC)
&& (seg->hasX || seg->hasR);
}
could be replaced with (sketch):
return VG_(am_find_segment_with_properties)(a, AnonC | FileC,
READ | EXE);
I'm sure there are spots where it is more complex.
Florian
|