simpleperf: Fix ReadTargetMemory caching.
In case we found memory, but it was unsuitable for caching, set the
cached buffer's map to null, forcing us to take the slow path again.
Without this change, the buffer itself is set to null. However, the
fast path cannot tell if there was no memory found or we just did not
want to cache it. This can cause an address range to succeeded at
first, but fail on a second try.
As a test and a practical example, a binary that is smaller than a
page is added. In this case the memory found by ReadTargetMemory will
never be large enough to contain the whole mapping, preventing it from
being cached. Without this change, simpleperf inject generates almost
no output, with this change it generates the expected full output.
Test: simpleperf_unit_test
Change-Id: Ibc8d6bf6476b473b99fc787a1789344bda334ce3
6 files changed