Creating Modules - Or How to Get the Most Out of ARTist

  • intro sentence

TODO we assume you completed setup and have an idea aobut modules

The Java Side

  • need a codelib?
  • clone Codelib from GitHub
    • change package name
    • leave singleton login
    • implement own APIs
  • examples
    • trace logging

The Compiler Side

  • create new folder
  • create module file
  • APIs: provide codelib, passes, filters

Codelib

  • decision: need a codelib?
  • idea: provide constants that correspond to java codelib
  • only add methods that you actually want to use
  • use codelib-gen (remark: outdated)

ARTist passes

  • decision: only inject method calls at well-defined places + constant args vs from scratch
  • have a look at the TODO boilerplate and utils page one in a while

Hooking Methods using Universal Artist

  • let your pass extend universal artist
  • API: ProvideInjections
  • declarative injection definition
  • where to inject: start, end, before or after calls
  • what to inject: codelib method name
  • params: declare constants

Creating an Artist Pass from Scratch

  • nodes.cc & nodes.h define the IR, have a look here TODO doc dex2oat
  • some convenience helpers:
    • MethodInfo: encapsulating all infos about the current method
    • MethodVisitor: visitor pattern to find IR nodes and react to it
    • ArtUtils: Get the codelib instruction (injected and cached automagically) AND inject method calls
    • ArtLog: Controls logging

Filters

  • idea: passes aim at methods with certain attributes
  • prevent each pass implementing this on their own:
  • use to decide which pass to return in module
  • interface: accept
  • existing: name-based, dex-file-based, more to come…

build system

  • add everything to Android.mk
  • cpp lint is very picky: header guard, style, licenses, …