summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbuild/android/gdb_content_shell89
-rw-r--r--content/content_shell.gypi10
-rw-r--r--content/shell/android/content_shell_apk.xml35
-rw-r--r--testing/android/README.chromium3
4 files changed, 128 insertions, 9 deletions
diff --git a/build/android/gdb_content_shell b/build/android/gdb_content_shell
new file mode 100755
index 0000000..54a705d
--- /dev/null
+++ b/build/android/gdb_content_shell
@@ -0,0 +1,89 @@
+#!/bin/bash
+#
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Attach gdb to a running content shell. Similar to ndk-gdb.
+# Run with --annotate=3 if running under emacs (M-x gdb).
+#
+# TODO(jrg): allow package_name and shared_lib_dir to be set on the
+# command line. Share the guts of this script with other Chromium
+# pieces (like base_unittests_apk) and friends (like WebKit bundles).
+
+adb=$(which adb)
+if [[ "$adb" = "" ]] ; then
+ echo "Need adb in your path"
+ exit 1
+fi
+
+# TODO(jrg): non-rooted path speculative and untested.
+rooted_phone=1
+
+root=$(dirname $0)/../..
+package_name=org.chromium.content_shell
+gdb_server_on_device=/data/data/$package_name/lib/gdbserver
+shared_lib_dir=$root/out/Release/lib.target
+
+# Kill any running gdbserver
+pid=$(adb shell ps | awk '/gdbserver/ {print $2}')
+if [[ "$pid" != "" ]] ; then
+ if [[ $rooted_phone -eq 1 ]] ; then
+ adb shell kill $pid
+ else
+ adb shell run-as $package_name kill $pid
+ fi
+fi
+
+pid=$(adb shell ps | awk "/$package_name/ {print \$2}")
+if [[ "$pid" = "" ]] ; then
+ echo "No $package_name running?"
+ echo "Try this: adb shell am start -a android.intent.action.VIEW " \
+ "-n $package_name/.SomethingActivity (Something might be ContentShell)"
+ exit 2
+fi
+
+no_gdb_server=$(adb shell ls $gdb_server_on_device | grep 'No such file')
+if [[ "$no_gdb_server" != "" ]] ; then
+ echo "No gdb server on device at $gdb_server_on_device"
+ echo "Please install a debug build."
+ exit 3
+fi
+
+adb forward tcp:4321 tcp:4321
+
+# TODO(jrg): Consider a closer match to ndk-gdb which uses subtly
+# different semantics for both port forwarding and launching
+# gdbserver.
+if [[ $rooted_phone -eq 1 ]] ; then
+ adb shell $gdb_server_on_device :4321 --attach $pid &
+else
+ adb shell run-as $package_name $gdb_server_on_device :4321 --attach $pid &
+fi
+sleep 2
+
+# Pull app_process and C libraries from device if needed
+app_process=${shared_lib_dir}/app_process
+if [[ ! -f ${app_process} ]] ; then
+ adb pull /system/bin/app_process ${app_process}
+ adb pull /system/lib/libc.so ${shared_lib_dir}
+fi
+
+# gdb commands
+cmdfile=$(mktemp /tmp/gdb_android_XXXXXXXX)
+cat >$cmdfile<<EOF
+set solib-absolute-prefix null
+set solib-search-path ${shared_lib_dir}
+target remote :4321
+EOF
+
+gdb=$(echo $ANDROID_TOOLCHAIN/*gdb)
+if [[ ! -f ${gdb} ]] ; then
+ echo "Wow no gdb in env var ANDROID_TOOLCHAIN which is $ANDROID_TOOLCHAIN"
+ exit 4
+else
+ echo Using $gdb
+fi
+
+${gdb} -x $cmdfile $* $app_process
+rm $cmdfile
diff --git a/content/content_shell.gypi b/content/content_shell.gypi
index 9501ff7..a33508b 100644
--- a/content/content_shell.gypi
+++ b/content/content_shell.gypi
@@ -534,10 +534,16 @@
'action': ['cp', '<@(_inputs)', '<@(_outputs)'],
},
{
- 'action_name': 'copy_content_shell_content_view',
+ 'action_name': 'copy_and_strip_so',
'inputs': ['<(SHARED_LIB_DIR)/libcontent_shell_content_view.so'],
'outputs': ['<(PRODUCT_DIR)/content_shell/libs/armeabi/libcontent_shell_content_view.so'],
- 'action': ['cp', '<@(_inputs)', '<@(_outputs)'],
+ 'action': [
+ '<!(/bin/echo -n $STRIP)',
+ '--strip-unneeded', # All symbols not needed for relocation.
+ '<@(_inputs)',
+ '-o',
+ '<@(_outputs)'
+ ],
},
{
'action_name': 'content_shell_apk',
diff --git a/content/shell/android/content_shell_apk.xml b/content/shell/android/content_shell_apk.xml
index 61a6f6e..3e89773b 100644
--- a/content/shell/android/content_shell_apk.xml
+++ b/content/shell/android/content_shell_apk.xml
@@ -12,8 +12,17 @@
<property environment="env"/>
<property name="sdk.dir" location="${env.ANDROID_SDK_ROOT}"/>
+ <property name="toolchain.dir" location="${env.ANDROID_TOOLCHAIN}"/>
<property name="source.dir" location="java"/>
<property name="target" value="android-14"/>
+ <property name="out.dir" location="${PRODUCT_DIR}/content_shell"/>
+ <property name="resource.absolute.dir" value="res"/>
+ <property name="gen.absolute.dir" value="${out.dir}/gen"/>
+ <property name="jar.libs.dir" value="${out.dir}/java/libs"/>
+ <path id="native.libs.gdbserver">
+ <fileset file="${toolchain.dir}/../../gdbserver"/>
+ </path>
+ <property name="native.libs.absolute.dir" location="${out.dir}/libs" />
<!-- We expect PRODUCT_DIR to be set like the gyp var
(e.g. $ROOT/out/Debug) -->
@@ -29,13 +38,25 @@
</else>
</if>
</target>
-
- <property name="out.dir" location="${PRODUCT_DIR}/content_shell"/>
-
- <property name="resource.absolute.dir" value="res"/>
- <property name="gen.absolute.dir" value="${out.dir}/gen"/>
- <property name="jar.libs.dir" value="${out.dir}/java/libs"/>
- <property name="native.libs.absolute.dir" location="${out.dir}/libs" />
+
+ <target name="-post-compile">
+ <!-- copy gdbserver to main libs directory if building debug.
+ TODO(jrg): for now, Chrome on Android always builds native code
+ as Release and java/ant as Debug, which means we always install
+ gdbserver. Resolve this discrepancy, possibly by making this
+ Release Official build java/ant as Release. -->
+ <if>
+ <condition>
+ <equals arg1="${build.target}" arg2="debug" />
+ </condition>
+ <then>
+ <echo message="Copying gdbserver to the apk to enable native debugging"/>
+ <copy todir="${out.dir}/libs/armeabi">
+ <path refid="native.libs.gdbserver"/>
+ </copy>
+ </then>
+ </if>
+ </target>
<import file="${sdk.dir}/tools/ant/build.xml" />
diff --git a/testing/android/README.chromium b/testing/android/README.chromium
new file mode 100644
index 0000000..37186a2
--- /dev/null
+++ b/testing/android/README.chromium
@@ -0,0 +1,3 @@
+apk-based runner for Chromium unit test bundles. Many of these files
+are templates for generating an apk specific to a test bundle.
+See generate_native_test.py or discuss with OWNERS.