5 PLATFORM_TOOLS_DIR
=$HOME/android-toolchain
/sdk
/platform-tools
9 $PLATFORM_TOOLS_DIR/adb
-s "$DEVICE" shell
"$@"
12 while getopts "d:" option
; do
21 # Directory with lldb binaries/debug servers
22 LLDB_MONO_DIR
=`dirname $0`
25 if [ "$DEVICE" = "" ]; then
26 DEVICE_COUNT
=`$PLATFORM_TOOLS_DIR/adb devices | grep 'device$' | wc -l`
27 if [ $DEVICE_COUNT -eq 1 ]; then
28 DEVICE
=`$PLATFORM_TOOLS_DIR/adb devices | grep 'device$' | awk -F"\t+" '{print $1}'`
31 echo "Device: $DEVICE"
33 SOCK
="platform-${NOW}.sock"
34 ARCH
=$
(shell
"getprop ro.product.cpu.abi" |
tr -d '\r')
36 LLDB_SERVER_ARCH
=$ARCH
37 if [ "$ARCH" = "armeabi-v7a" ]; then
38 LLDB_SERVER_ARCH
="armeabi"
41 echo "Architecture: $ARCH"
43 #LLDB_DIR=$HOME/Library/Android/sdk/lldb/2.2/android
44 LLDB_DIR
=$LLDB_MONO_DIR/android
47 LLDB
=/data
/data
/org.mono.android.AndroidTestRunner
/lldb
49 LLDB_SERVER
=$LLDB_BIN/lldb-server
50 START_SERVER
=$LLDB_BIN/start_lldb_server.sh
51 LLDB_LOCAL_SERVER
=$LLDB_DIR/$LLDB_SERVER_ARCH/lldb-server
53 if [ ! -f $LLDB_LOCAL_SERVER ]; then
54 echo "Unable to find llvm-server binary at $LLDB_LOCAL_SERVER."
58 echo "Copying lldb-server to device..."
59 $PLATFORM_TOOLS_DIR/adb
-s "$DEVICE" push
$LLDB_DIR/$LLDB_SERVER_ARCH/lldb-server
$R_TMP
60 $PLATFORM_TOOLS_DIR/adb
-s "$DEVICE" push
$LLDB_DIR/start_lldb_server.sh
$R_TMP
62 $PLATFORM_TOOLS_DIR/adb
-s "$DEVICE" shell
'setprop debug.mono.lldb wait:`date +%s`'
63 $PLATFORM_TOOLS_DIR/adb
-s "$DEVICE" shell
'setprop debug.mono.debug 1'
65 $PLATFORM_TOOLS_DIR/adb
-s "$DEVICE" shell
'setprop debug.mono.env MONO_LLDB=1'
67 echo "Starting app..."
68 shell
"am instrument org.mono.android.AndroidTestRunner/org.mono.android.AndroidRunner "
69 shell
"run-as org.mono.android.AndroidTestRunner mkdir -p $LLDB_BIN"
70 shell
"rm -f $LLDB_SERVER"
71 shell
"cat $R_TMP/lldb-server | run-as org.mono.android.AndroidTestRunner sh -c \"cat > $LLDB_SERVER && chmod 700 $LLDB_SERVER\""
72 shell
"cat $R_TMP/start_lldb_server.sh | run-as org.mono.android.AndroidTestRunner sh -c \"cat > $START_SERVER && chmod 700 $START_SERVER\""
74 echo "Waiting for app to start..."
76 for i
in 1 2 3 4 5; do
77 PID
=$
(shell
"ps" |
grep "org.mono.android.AndroidTestRunner\s*$" |
awk -F' +' '{print $2}')
79 if [ "$PID" != "" ]; then
85 if [ "$PID" == "" ]; then
86 echo "Can't find process pid."
91 START_FILE
=/tmp
/lldb_commands.
$NOW
92 echo "platform select remote-android
93 platform connect unix-abstract-connect://[$DEVICE]$LLDB/tmp/$SOCK
94 settings set auto-confirm true
95 settings set plugin.symbol-file.dwarf.comp-dir-symlink-paths /proc/self/cwd
96 process attach -p $PID
97 p (void)monodroid_clear_lldb_wait()
98 $COMMANDS" > $START_FILE
100 echo -n "Starting lldb server in the background"
101 shell
"run-as org.mono.android.AndroidTestRunner $START_SERVER $LLDB unix-abstract $LLDB/tmp $SOCK \"lldb process:gdb-remote packets\""&
108 declare -a PIDS
=( `pgrep -P $!` "$!" )
110 $LLDB_MONO_DIR/lldb
-s $START_FILE