Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: tools/android/asan/asan_device_setup.sh

Issue 130913011: Update asan_device_setup script to LLVM r200382. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash -e 1 #!/bin/bash -e
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 #===- lib/asan/scripts/asan_device_setup.py -----------------------------------= ==#
3 # Use of this source code is governed by a BSD-style license that can be 3 #
4 # found in the LICENSE file. 4 # The LLVM Compiler Infrastructure
5 5 #
6 # Prepare Android device to run ASan application. 6 # This file is distributed under the University of Illinois Open Source
7 # License. See LICENSE.TXT for details.
8 #
9 # Prepare Android device to run ASan applications.
10 #
11 #===------------------------------------------------------------------------===#
7 12
8 13
9 HERE="$(cd "$(dirname "$0")" && pwd)" 14 HERE="$(cd "$(dirname "$0")" && pwd)"
10 15
11 revert=no 16 revert=no
12 extra_options= 17 extra_options=
13 device= 18 device=
19 lib=
14 20
15 function usage { 21 function usage {
16 echo "usage: $0 [--revert] [--device device-id]" 22 echo "usage: $0 [--revert] [--device device-id] [--lib path] [--extra_option s options]"
17 echo " --revert: Uninstall ASan from the device." 23 echo " --revert: Uninstall ASan from the device."
24 echo " --lib: Path to ASan runtime library."
18 echo " --extra_options: Extra ASAN_OPTIONS." 25 echo " --extra_options: Extra ASAN_OPTIONS."
19 echo " --device: Install to the given device. Use 'adb devices' to find" 26 echo " --device: Install to the given device. Use 'adb devices' to find"
20 echo " device-id." 27 echo " device-id."
21 echo 28 echo
22 exit 1 29 exit 1
23 } 30 }
24 31
25 while [[ $# > 0 ]]; do 32 while [[ $# > 0 ]]; do
26 case $1 in 33 case $1 in
27 --revert) 34 --revert)
28 revert=yes 35 revert=yes
29 ;; 36 ;;
30 --extra-options) 37 --extra-options)
31 shift 38 shift
32 if [[ $# == 0 ]]; then 39 if [[ $# == 0 ]]; then
33 echo "--extra-options requires an argument." 40 echo "--extra-options requires an argument."
34 exit 1 41 exit 1
35 fi 42 fi
36 extra_options="$1" 43 extra_options="$1"
37 ;; 44 ;;
45 --lib)
46 shift
47 if [[ $# == 0 ]]; then
48 echo "--lib requires an argument."
49 exit 1
50 fi
51 lib="$1"
52 ;;
38 --device) 53 --device)
39 shift 54 shift
40 if [[ $# == 0 ]]; then 55 if [[ $# == 0 ]]; then
41 echo "--device requires an argument." 56 echo "--device requires an argument."
42 exit 1 57 exit 1
43 fi 58 fi
44 device="$1" 59 device="$1"
45 ;; 60 ;;
46 *) 61 *)
47 usage 62 usage
48 ;; 63 ;;
49 esac 64 esac
50 shift 65 shift
51 done 66 done
52 67
53 ADB="adb" 68 ADB="adb"
54 if [[ x$device != x ]]; then 69 if [[ x$device != x ]]; then
55 ADB="adb -s $device" 70 ADB="adb -s $device"
56 fi 71 fi
57 72
58 ASAN_RT_PATH="$HERE"
59 ASAN_RT="libclang_rt.asan-arm-android.so" 73 ASAN_RT="libclang_rt.asan-arm-android.so"
60 74
61 if [[ x$revert == xyes ]]; then 75 if [[ x$revert == xyes ]]; then
62 echo '>> Uninstalling ASan' 76 echo '>> Uninstalling ASan'
77 $ADB root
78 $ADB wait-for-device
63 $ADB remount 79 $ADB remount
64 $ADB shell mv /system/bin/app_process.real /system/bin/app_process 80 $ADB shell mv /system/bin/app_process.real /system/bin/app_process
65 $ADB shell rm /system/bin/asanwrapper 81 $ADB shell rm /system/bin/asanwrapper
66 $ADB shell rm /system/lib/$ASAN_RT 82 $ADB shell rm /system/lib/$ASAN_RT
67 83
68 echo '>> Restarting shell' 84 echo '>> Restarting shell'
69 $ADB shell stop 85 $ADB shell stop
70 $ADB shell start 86 $ADB shell start
71 87
72 echo '>> Done' 88 echo '>> Done'
73 exit 0 89 exit 0
74 fi 90 fi
75 91
76 if ! [[ -f "$ASAN_RT_PATH/$ASAN_RT" ]]; then 92 if [[ -d "$lib" ]]; then
77 echo "ASan runtime library not found at $ASAN_RT" 93 ASAN_RT_PATH="$lib"
94 elif [[ -f "$lib" && "$lib" == *"$ASAN_RT" ]]; then
95 ASAN_RT_PATH=$(dirname "$lib")
96 elif [[ -f "$HERE/$ASAN_RT" ]]; then
97 ASAN_RT_PATH="$HERE"
98 elif [[ $(basename "$HERE") == "bin" ]]; then
99 # We could be in the toolchain's base directory.
100 # Consider ../lib and ../lib/clang/$VERSION/lib/linux.
101 P=$(ls "$HERE"/../lib/"$ASAN_RT" "$HERE"/../lib/clang/*/lib/linux/"$ASAN_RT" 2>/dev/null | sort | tail -1)
102 if [[ -n "$P" ]]; then
103 ASAN_RT_PATH="$(dirname "$P")"
104 fi
105 fi
106
107 if [[ -z "$ASAN_RT_PATH" || ! -f "$ASAN_RT_PATH/$ASAN_RT" ]]; then
108 echo "ASan runtime library not found"
78 exit 1 109 exit 1
79 fi 110 fi
80 111
81 TMPDIRBASE=$(mktemp -d) 112 TMPDIRBASE=$(mktemp -d)
82 echo $TMPDIRBASE
83 TMPDIROLD="$TMPDIRBASE/old" 113 TMPDIROLD="$TMPDIRBASE/old"
84 TMPDIR="$TMPDIRBASE/new" 114 TMPDIR="$TMPDIRBASE/new"
85 mkdir "$TMPDIROLD" 115 mkdir "$TMPDIROLD"
86 116
87 echo '>> Remounting /system rw' 117 echo '>> Remounting /system rw'
118 $ADB root
119 $ADB wait-for-device
88 $ADB remount 120 $ADB remount
89 121
90 echo '>> Copying files from the device' 122 echo '>> Copying files from the device'
91 $ADB pull /system/bin/app_process "$TMPDIROLD" 123 $ADB pull /system/bin/app_process "$TMPDIROLD"
92 $ADB pull /system/bin/app_process.real "$TMPDIROLD" || true 124 $ADB pull /system/bin/app_process.real "$TMPDIROLD" || true
93 $ADB pull /system/bin/asanwrapper "$TMPDIROLD" || true 125 $ADB pull /system/bin/asanwrapper "$TMPDIROLD" || true
94 $ADB pull /system/lib/libclang_rt.asan-arm-android.so "$TMPDIROLD" || true 126 $ADB pull /system/lib/libclang_rt.asan-arm-android.so "$TMPDIROLD" || true
95 cp -r "$TMPDIROLD" "$TMPDIR" 127 cp -r "$TMPDIROLD" "$TMPDIR"
96 128
97 if ! [[ -f "$TMPDIR/app_process" ]]; then 129 if ! [[ -f "$TMPDIR/app_process" ]]; then
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 echo '>> Restarting shell (asynchronous)' 185 echo '>> Restarting shell (asynchronous)'
154 $ADB shell stop 186 $ADB shell stop
155 $ADB shell start 187 $ADB shell start
156 188
157 echo '>> Please wait until the device restarts' 189 echo '>> Please wait until the device restarts'
158 else 190 else
159 echo '>> Device is up to date' 191 echo '>> Device is up to date'
160 fi 192 fi
161 193
162 rm -r "$TMPDIRBASE" 194 rm -r "$TMPDIRBASE"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698