versatile yet lightweight record-and-replay for android yongjian hu tanzirul azim iulian neamtiu

22
Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Upload: milton-hall

Post on 18-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Versatile yet Lightweight Record-and-Replay for

Android

Yongjian Hu Tanzirul Azim Iulian Neamtiu

Page 2: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Replay GPS trace Debug Shazam

Debug Barcode Scanner

Record-and-replay isuseful in a variety ofAndroid development scenarios

Reproduce event-driven race in Tomdroid

Crash!

Page 3: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Challenges:

• Sensor driven• High-throughput parallel

sensor streams

Record-and-replay isuseful in a variety ofAndroid development scenarios.

Replay GPS trace Debug Shazam

Debug Barcode Scanner Reproduce event-driven race in Tomdroid

Crash!

Page 4: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Challenges:

• Sensor-driven: high-throughput parallel sensor streams

• Timing is essential: incorrect timing may cause replay to diverge

Record-and-replay isuseful in a variety ofAndroid development scenarios

Replay GPS trace Debug Shazam

Debug Barcode Scanner Reproduce event-driven race in Tomdroid

Crash!

Page 5: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Challenges:

• Sensor-driven• High-throughput parallel

sensor streams

• Timing is essential• Incorrect timing may

cause replay to diverge

• Event-oriented• Event schedule matters

Record-and-replay isuseful in a variety ofAndroid development scenarios.

Replay GPS trace Debug Shazam

Debug Barcode Scanner Reproduce event-driven race in Tomdroid

Crash!

Page 6: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Goal: record and replay Android app executions

Linux Kernel

VM/ART, Libraries, Android Runtime

Application Framework

Apps App1 App2 App3

CPU instructions, e.g., PinPlay High fidelity, very high overhead

GUI actions, e.g., RERAN (ICSE’13) Low fidelity, low overhead

Record and replay level

Dalvik (VM) instructions Moderate fidelity, high overhead

Page 7: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

VALERA

Touchscreen

Compass

Accelerometer

Light sensor

GPS

Camera

Microphone

Schedule Runs on real phonesApp source code not requiredHandles complex sensor inputLow overheadReplay fidelity guarantees (observable state)

VALERA: VersAtile yet Lightweight rEcord and Replay for Android

Page 8: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Dalvik VM

Linux kernel

Instrumented

App GPS Mic. IntentsCamera

Event schedule

Touchscreen Accelerometer …

mod

ified

Network

Sche

dule

Repl

ayer

AndroidFramework

VALERA runtime

AppVALERA

binary rewriting

VALERA Architecture

Page 9: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Redexer

Original app

Instrumented app

GPS

Interceptor specification

Interceptorgenerator

Scanner

Mic Intents . . .Camera

APK

APK

VALERA Intercepts the (Sensor) API via Bytecode Rewriting

[Location][downcall]public Location getLastKnownLocation(…)[upcall]public void onLocationChanged(…)……

[Camera][upcall]public void onPictureTaken(byte[] data, …)public void onPreviewFrame(byte[] data, …)……

[AudioRecorder][downcall]public int read(byte[] audioData, ……)public int read(ByteBuffer audioBuffer, ……)……

Page 10: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Event Schedule is Essential

UI ThreadDecoder Thread

onResume()init()

Fork thread

Start decoding

Show decode failed

Start decoding

Decode failed

Decode successShow decode success

decode()

decode()

Frame 1

Frame 2

Frame 3

Page 11: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

UI ThreadDecoder Thread

onResume()init()

Fork thread

Start decoding

Show decode failedDecode failed

decode()

Frame 1

Frame 2

Frame 3

Event Schedule is Essential

Page 12: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Prior Work on Deterministic Replay

• Hardware-based approaches• Special HW required: [FDR’03, BugNet’05, ReRun’09, DeLorean’09,

DMP’09]

• Software-based approaches• VM-level: [SMP-ReVirt’08, King et al. ATC’05]• User-level:

• Sync-Sched: [Recplay’99, JaRec’04, Kendo’09]• Mem-Sched: [CoreDet’10, LEAP’10, STRIDE’12, CLAP’13]

• Probabilistic: [ODR’09, PRES’09]

• Limitations• HW approach too expensive• VM/Mem-Sched approaches’ overhead too high• Not suitable for Android’s event-driven scheduling

Page 13: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Android Event Handling

UI Thread

Looper msg evt

Message Queue

Thread

Thread

Handler

Handler

msg

Hardware Events

Page 14: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

UI Thread

Looper

Message Queue

A B C DEvent Log

1 2 3 4

Deterministic Event Schedule: Recording

Page 15: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

UI Thread

Looper

Message Queue

Pending Queue

B D C A

Deterministic Event Schedule: Replaying

A B C DEvent Log

1 2 3 4

Controller = 1243

Reconciling different event orders between record and replay

Page 16: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Example: Reproducing Tomdroid’s Event Bug

Syncing…Done!

Back

Page 17: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Example: Reproducing Tomdroid’s Event Bug

Syncing…

Back

Crash!

Page 18: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Application: Reproducing Event-driven Races

1. Get potential race bugs from state-of-art race detectors for Android• DroidRacer [PLDI’14], CAFA [PLDI’14]• EventRacer [OOPSLA’15]

2. Use VALERA to reproduce event-driven race bugs by alternative schedule

3. See the paper for examples:• NPR News, Tomdroid, Anymemo

Page 19: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Evaluation: Event Throughput

Main Intercept

orApps GPS Camera

/Buffer Audio Intent Network Sched

GPS 70 128 1,603

Camera 53 35 1,352

Audio 386 41 1,545

Intent 9 48 1,849

Replaying sensors, schedules is crucial!

Page 20: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Evaluation: Performance

Main Interceptor Apps

Record Time (sec)

Replay Time (sec)

Overhead (%)

Log Size (KB)

Log Rate (KB/s)

GPS 247 249 0.766 28 0.095

Camera 111 113 1.137 91,758 881

Audio 126 128 1.35 11,171 239

Intent 65 66 1.459 <1 <0.03

Page 21: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Conclusions

• Record-and-Replay on Android is challenging• Rich sensors• Timing is essential• Event schedule non-determinism

• Our approach: sensor-oriented replay (VALERA) • High fidelity, low overhead• Scalable and extensible via API interceptors• Deterministic event schedule replay• Reproduce and verify event-driven races

Page 22: Versatile yet Lightweight Record-and-Replay for Android Yongjian Hu Tanzirul Azim Iulian Neamtiu

Y. Hu, T. Azim, I. Neamtiu Versatile yet Lightweight Record and Replay for Android

Q & A