base: Implement MapsSnapshot

For use in profiling.

Flag: EXEMPT NDK
Test: added test, tree-hugger
Bug: 355753084
Change-Id: I32783af7d60561c92c7a24579c2cd5e60167c788
4 files changed
tree: 06a22cfb07996f7d7096d965450bc2ca1d4da907
  1. android_api/
  2. assembler/
  3. backend/
  4. base/
  5. calling_conventions/
  6. code_gen_lib/
  7. decoder/
  8. docs/
  9. exec_region/
  10. guest_abi/
  11. guest_loader/
  12. guest_os_primitives/
  13. guest_state/
  14. heavy_optimizer/
  15. instrument/
  16. interpreter/
  17. intrinsics/
  18. jni/
  19. kernel_api/
  20. lite_translator/
  21. native_activity/
  22. native_bridge/
  23. prebuilt/
  24. program_runner/
  25. proxy_loader/
  26. runtime/
  27. runtime_primitives/
  28. test_utils/
  29. tests/
  30. tiny_loader/
  31. tools/
  32. .clang-format
  33. Android.bp
  34. berberis_config.mk
  35. enable_riscv64_to_x86_64.mk
  36. OWNERS
  37. PREUPLOAD.cfg
  38. README.md
README.md

Berberis

Dynamic binary translator to run Android apps with riscv64 native code on x86_64 devices or emulators.

Supported extensions include Zb* (bit manipulation) and most of Zv (vector). Some less commonly used vector instructions are not yet implemented, but Android CTS and some Android apps run with the current set of implemented instructions.

Getting Started

Note: Googlers, read go/berberis and go/berberis-start first.

Build

From your Android root checkout, run:

source build/envsetup.sh
lunch sdk_phone64_x86_64_riscv64-trunk_staging-eng
m berberis_all

For development, we recommend building all existing targets before uploading changes, since they are currently not always synchronized with berberis_all:

mmm frameworks/libs/binary_translation

Run Hello World

out/host/linux-x86/bin/berberis_program_runner_riscv64 \
out/target/product/emu64xr/testcases/berberis_hello_world_static.native_bridge/x86_64/berberis_hello_world_static

On success Hello! will be printed.

Run unit tests on host

m berberis_all berberis_run_host_tests

or

out/host/linux-x86/nativetest64/berberis_host_tests/berberis_host_tests

Build and run emulator with Berberis support

m
emulator -memory 4096 -writable-system -partition-size 65536 -qemu -cpu host &

Run unit tests on device or emulator

Note: Requires a running device or emulator with Berberis support.

  1. Sync tests to the device:
adb root
adb sync data
  1. Run guest loader tests:
adb shell /data/nativetest64/berberis_guest_loader_riscv64_tests/berberis_guest_loader_riscv64_tests
  1. Run program tests:
adb shell /data/nativetest64/berberis_ndk_program_tests/berberis_ndk_program_tests

Bionic unit tests

Note: Requires a running device or emulator with Berberis support.

  1. Build Bionic unit tests:
m TARGET_PRODUCT=aosp_riscv64 bionic-unit-tests
  1. Push tests to emulator or device:
adb push out/target/product/generic_riscv64/data/nativetest64/bionic-loader-test-libs /data/local/tmp
adb push out/target/product/generic_riscv64/data/nativetest64/bionic-unit-tests /data/local/tmp
  1. Run Bionic tests:
adb shell /system/bin/berberis_program_runner_riscv64 /data/local/tmp/bionic-unit-tests/bionic-unit-tests --no_isolate