[PATCH] D57307: Implement `CopyFromTarget(...)` methods.

Dan Liew via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 27 12:48:26 PST 2019


delcypher created this revision.
delcypher added reviewers: kcc, vitalybuka, dvyukov, cryptoad, eugenis, george.karpenkov, yln.
Herald added subscribers: Sanitizers, kubamracek.

These methods provide a simple interface for getting a copy
of a `AddressSpaceView` data structure from a target process but
with the `AddressSpaceView` type replaced with `RemoteAddressSpaceView`.

To support these methods, all types that take `AddressSpaceView`
as a template parameter now provide a `ThisTASVT` templated alias
that allows a convenient way to construct a type with a different
`AddressSpaceView` from an existing type. This will also be useful
for callers of the `CopyFromTarget(...)` methods.

The implementations of these functions copy fields from
type `Type<AddressSpaceView>` to a buffer of
`Type<RemoteAddressSpaceView>`. A copy if performed field by field
because C++ does not guarantee that the types have the same data-layout.

For fields that have identical size in the source and destination type
(i.e. fields that are not templated on `AddressSpaceView`) we copy
directly.

For fields that do depend on `AddressSpaceView` we recursively
call `CopyFromTarget(...)`.

This approach might not be performant as copying the outter most data
structure directly into the buffer (i.e. CombinedAllocator) but it is
correct.  We can investigate faster solutions (e.g. Compute if data
layout is same using constexpr functions and do fast copy in that case)
if it becomes necessary.

The main downside to this implementation is that it requires manually
keeping track of the fields in a class which will add a maintance
burden.

rdar://problem/45284065


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D57307

Files:
  lib/sanitizer_common/sanitizer_allocator.h
  lib/sanitizer_common/sanitizer_allocator_bytemap.h
  lib/sanitizer_common/sanitizer_allocator_combined.h
  lib/sanitizer_common/sanitizer_allocator_local_cache.h
  lib/sanitizer_common/sanitizer_allocator_primary32.h
  lib/sanitizer_common/sanitizer_allocator_primary64.h
  lib/sanitizer_common/sanitizer_allocator_secondary.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57307.183769.patch
Type: text/x-patch
Size: 14570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190127/ad88d713/attachment.bin>


More information about the llvm-commits mailing list