Giter VIP home page Giter VIP logo

ella-customized's Introduction

ella-customized

A customized version of Ella used in the paper An Empirical Study of Android Test Generation Tools in Industrial Cases. See here for the original version by Saswat Anand. Some implementations are still ad-hoc and improvements are welcomed.

Basically, I added support for MultiDex, fixed numerous bugs in the original implementation, and simplified some code. The usages are mostly the same with several exceptions stated below. Note that I only preserved the cumulative method coverage recorder in this version.

Extra tips for ella.settings

  • Modify ella.x.aapath to point it to the directory containing apkanalyzer (available in recent versions of Android SDK tools).
  • It's recommended to use ADB (instead of network) as the communication channel between Ella runtime and server. To do this, keep using 127.0.0.1 in ella.server.ip, and set up adb reverse tcp:23745 tcp:23745 on the computer before running the instrumented app.
    • Note that adb reverse is not available on Android 4.4, but adb forward and one relay app accepting two incoming connections (see here) can be used. Essentially, you need to run the relay app on the device, let the Ella agent connect to one port listened by the app, use adb forward to forward the other port listened by the app to some port on the computer, and use another TCP relay program (e.g., socat, by running socat TCP:localhost:23745 TCP:localhost:PORT_BY_ADB_FORWARD) to finally connect this port to Ella server.
  • The generated keystore seemed to have some issues. Thus I (shamelessly) took the keystore from SwiftHand. BTW, thanks, Wontae :-)

Extra steps for Multidex support

The following steps are required only once before instrumenting the first app with multiple DEX files.

  • Make sure the directory containing dx (available in Android build tools) is in $PATH (or alternatively gen-ella-wrappers.py).
  • Modify MAX_COUNT in gen-ella-wrappers.py to be the maximum number of additional DEX files you want to instrument. The default value is 20.
  • Run gen-ella-wrappers.py to generate wrapper classes for additional DEX files, which would be used subsequently by instrumentation.

Known issue(s)

com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

Some DEX file contains exactly 65536 methods, and there’s no extra space to put Ella’s runtime stub (Dalvik requires each DEX to contain up to 65536 methods, and that’s why MultiDex exists.) Such APKs cannot be processed by Ella at the moment given that they require moving methods across DEX files.

License?

For my parts, just do whatever you want as long as it's for non-commercial purposes. It would be appreciated if you can cite our paper, though. :-)

ELLA: A Tool for Binary Instrumentation of Android Apps

Ella is a tool to instrument Android APK's for various purposes. Out of the box, it instruments apps to record which methods gets executed. It can also record time-stamped trace of executed methods, values of arguments passed at call-sites, values of formal parameters of methods, etc.

Several tools exist that can instrument APK's to some degree. But they usually do not work very reliably because they translate Dalvik bytecodes to another form such as Java bytecode or internal representations of other tools, and this translation is quite challenging. Thus, Ella's approach is to instrument at the Dalvik bytecode level. It does so by builiding atop the DexLib2 library (a part of the Smali project).

Pre-requisite

  1. Unix-like operating system. Minor tweaks to scripts and build files may be needed to run ella on Windows.
  2. Android SDK
  3. Java SDK
  4. Apache Ant

Before building ella

  1. Rename ella.settings.template file to ella.settings, and if needed, set values of different environment variables of ella.
  2. If the instrumented app will be executed on an emulator and the ella server will be run on the host machine of the emulator, then do nothing. Otherwise, set:
ella.use.emulator.host.loopback=false

If ella.use.emulator.host.loopback is set to false and the ella server will be running on a machine that is different from the machine on which the instrumentor is run, then set ella.server.ip to the IP address of the machine on which the ella server will be run. For example,

ella.server.ip=1.2.3.4

Otherwise, do nothing.

Build ella

Execute the following command inside ella's installation directory.

ant 

Instrument the app

Execute the following command.

ella.sh i <path-to-apk>

<path-to-apk> is the Apk that you want to instrument. This command would produce the instrumented apk named instrumented.apk inside a subdirectory inside <ella-home>/ella-out directory, where <ella-home> represents the installation directory of ella. The name of the subdirectory is derived from <path-to-apk>.

Start ella server

Before executing any instrumented app, ella server must be up and running. To start the ella server, execute the following command.

ella.sh s

Whenever needed, the ella server can be shutdown by executing the following command

ella.sh k

Execute the instrumented app

  1. Install the instrumented.apk on the emulator or device. You may have to uninstall it first if the app is already installed.
  2. Execute the instrumented app. The instrumented app will send coverage data periodically to the ella server.
  3. To end recording and uploading coverage data, either simply kill the app or execute the following command on computer connected to the device/emulator. e stands for "end" in end recording coverage data.
ella.sh e

Coverage data

The coverage data are stored inside a subdirectory of <ella-home>/ella-out directory, where <ella-home> represents the installation directory of ella. The name of the subdirectory is derived from <path-to-apk>. Currently, coverage data are stored in files coverage.dat and covids. covids contain the list of method signatures; index of a method is its identifier. coverage.dat contains the list of method identifiers that were executed.

ella-customized's People

Contributors

ms1995 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ella-customized's Issues

error: cannot bind listener: Address already in use

Following the steps in readme.md

./ella.sh s
adb forward tcp:23745 tcp:23745

it raises binding error

error: cannot bind listener: Address already in use

adb reverse is exactly closed and when I execute adb forward first, the server can not binding too.

Question!

Thanks for making mutlidex version of ella.

I have a trouble with building your ella.

Please help me. I put my execution log.

Input:
ant

Output:

BUILD FAILED
/home/kjkpoi/Documents/ella-customized/build.xml:10: The following error occurred while executing this line:
/home/kjkpoi/Documents/ella-customized/runtime/build.xml:21: java.lang.RuntimeException: The executable 'android' is not in the path
at GuessDefaultSettingsTask.findAndroidSDKPath(GuessDefaultSettingsTask.java:46)
at GuessDefaultSettingsTask.execute(GuessDefaultSettingsTask.java:11)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.Target.performTasks(Target.java:470)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:437)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.Target.performTasks(Target.java:470)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:834)
at org.apache.tools.ant.Main.startAnt(Main.java:223)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)

EllaLauncher Error

Hi,
When I run the ella.sh i command, I receive the following error;

The ella server must be run on 127.0.0.1 (explicitly specified in ella settings)
Standard output and error is redirected to /home/mmm/Documents/SWE599/ella-customized/ella-out/_home_mmm_Documents_SWE599_apks_com.jetstartgames.chess_2.7.9-74_minAPI16(nodpi)_apkmirror.com.apk/log.txt
Exception in thread "main" java.lang.Error: Error occurred while instrumenting. exit code is 1
at com.apposcopy.ella.EllaLauncher.instrument(EllaLauncher.java:259)
at com.apposcopy.ella.EllaLauncher.main(EllaLauncher.java:23)

And the log file reports:

[Fatal Error] stamp_android_manifest2779795146495251942.tmp:1:1: Content is not allowed in prolog.
Exception in thread "main" java.lang.Error: org.xml.sax.SAXParseException; systemId: file:/tmp/stamp_android_manifest2779795146495251942.tmp; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at com.apposcopy.app.ParseManifest.(ParseManifest.java:63)
at com.apposcopy.app.App.readApp(App.java:54)
at com.apposcopy.ella.Main.main(Main.java:28)
Caused by: org.xml.sax.SAXParseException; systemId: file:/tmp/stamp_android_manifest2779795146495251942.tmp; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:261)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:206)
at com.apposcopy.app.ParseManifest.(ParseManifest.java:35)
... 2 more

What may be the issue?

Thanks in advance.

Exception in thread "main" org.jf.util.ExceptionWithContext: /tmp/inputclasses1647275339239588736.dex

hi, when i execute the comman: ella.sh i , i got the error:
Exception in thread "main" org.jf.util.ExceptionWithContext: /tmp/inputclasses1647275339239588736.dex is not an apk, dex file or odex file.
at org.jf.dexlib2.DexFileFactory.loadDexFile(DexFileFactory.java:116)
at org.jf.dexlib2.DexFileFactory.loadDexFile(DexFileFactory.java:49)
at com.apposcopy.app.App.(App.java:46)
at com.apposcopy.app.App.readApp(App.java:51)
at com.apposcopy.ella.Main.main(Main.java:28)

could you tell me how to resolve the problem, thank you very much! i dont know why it has the error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.