[PATCH] D31695: Windows asan_device_setup.bat port of linux shell script

Steven Winston via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 28 14:57:33 PDT 2017

gpx1000 added a comment.

As an aside, I have found a way to use ASan in devices using wrap.sh.  So long as the device has the ability to use su or is a eng dev build the following wrap will work:

su -c setenforcing 0
su -c setenforcing 1

I'm using it with this gradle:
static def writeWrapScriptToFullyCompileJavaApp(wrapFile, abi) {

  if(abi == "armeabi" || abi == "armeabi-v7a")
      abi = "arm"
  wrapFile.withWriter { writer ->
      writer.write('su -c setenforcing 0\n')
      writer.write('su -c setenforcing 1\n')

task createWrapScriptAddDir {

  def libDir = file("$rootProject.ext.ndkDir").absolutePath + "/toolchains/llvm/prebuilt/"
      libDir += "windows-x86_64/lib64/clang"
      libDir += "*/lib*/*"
  for (String abi : ["armeabi-v7a"]) {
      def dir = new File("app/wrap_add_dir/" + abi)
      def wrapFile = new File(dir, "wrap.sh")
      writeWrapScriptToFullyCompileJavaApp(wrapFile, abi)
      println "write file " + wrapFile.path
      println "libdir = " + libDir
      if(abi == "armeabi" || abi == "armeabi-v7a")
          abi = "arm"
      copy {
          from fileTree(libDir).files
          into dir.absolutePath
          include "**/*asan*" + abi + "*.so"


I'd note that with doing this; I'm not entirely sure there's still a need for this script to exist.   I'm creating a blog post / tutorial on how to use ASan using the above wrap implementation; complete with example project.  However, I'll make the suggested changes and resubmit.

Comment at: asan_device_setup.py:259
+    def parseArgsLoop(self):
+        argList = sys.argv[1:]
eugenis wrote:
> Is there a reason you are not using standard python argument parsing libraries?
Not a particularly *good* reason.  It's the same reasoning there's no helper class; this started its' life as a monkeyscript.  Jython's parsing of args there was a bug so had to get around that.  Force of legacy means it survived after I learned that python is used in other NDK scripts and thus would be safe to use everywhere; so it survived my refactor to pure python.
I'll refactor this bit too.


More information about the llvm-commits mailing list