blob: 2d21bfb282149d696567351337ead58f515d8bb9 [file] [log] [blame] [view]
andybons222c4ee2015-08-25 16:51:031# Chromoting Android Hacking
andybons3322f762015-08-24 21:37:092
andybons222c4ee2015-08-25 16:51:033This guide, which is meant to accompany the
Amos Limf916d572018-05-21 23:10:354[compilation guide](old_chromoting_build_instructions.md), explains the process of
andybons222c4ee2015-08-25 16:51:035viewing the logs and debugging the CRD Android client. I'll assume you've
6already built the APK as described in the aforementioned guide, that you're in
7the `src/` directory, and that your binary is at
8`out/Release/apks/Chromoting.apk`. Additionally, you should have installed the
9app on at least one (still) connected device.
andybons3322f762015-08-24 21:37:0910
andybons222c4ee2015-08-25 16:51:0311[TOC]
andybons3322f762015-08-24 21:37:0912
andybons222c4ee2015-08-25 16:51:0313## Viewing logging output
andybons3322f762015-08-24 21:37:0914
andybons222c4ee2015-08-25 16:51:0315In order to access LogCat and view the app's logging output, we need to launch
Yun Liuf57cceaf2019-03-18 21:31:2316the Android Device Monitor. Run `third_party/android_sdk/public/tools/monitor`
andybons222c4ee2015-08-25 16:51:0317and select the desired device under `Devices`. Using the app as normal will
18display log messages to the `LogCat` pane.
andybons3322f762015-08-24 21:37:0919
andybons222c4ee2015-08-25 16:51:0320## Attaching debuggers for Java code
21
22### Eclipse
23
xiaoyin.l1003c0b2016-12-06 02:51:17241. Go to https://developer.android.com/sdk/index.html and click "Download the
andybons222c4ee2015-08-25 16:51:0325 SDK ADT Bundle for Linux"
261. Configure eclipse
27 1. Select General > Workspace from the tree on the left.
28 1. Uncheck Refresh workspace on startup (if present)
29 1. Uncheck Refresh using native hooks or polling (if present)
30 1. Disable build before launching
31 1. Select Run/Debug > Launching
32 1. Uncheck Build (if required) before launching
331. Create a project
34 1. Select File > New > Project... from the main menu.
35 1. Choose Java/Java Project
36 1. Eclipse should have generated .project and perhaps a .classpath file in
37 your <project root>/src/ directory.
38 1. Replace/Add the .classpath file with the content from Below. Remember
39 that the path field should be the location of the chromium source
40 relative to the current directory of your project.
41
42```xml
andybons3322f762015-08-24 21:37:0943<?xml version="1.0" encoding="UTF-8"?>
44<classpath>
45<classpathentry kind="src" path="net/test/android/javatests/src"/>
46<classpathentry kind="src" path="net/android/java/src"/>
47<classpathentry kind="src" path="net/android/javatests/src"/>
48<classpathentry kind="src" path="base/test/android/java/src"/>
49<classpathentry kind="src" path="base/test/android/javatests/src"/>
50<classpathentry kind="src" path="base/android/jni_generator/java/src"/>
51<classpathentry kind="src" path="base/android/java/src"/>
52<classpathentry kind="src" path="base/android/javatests/src"/>
53<classpathentry kind="src" path="components/cronet/android/java/src"/>
54<classpathentry kind="src" path="components/cronet/android/sample/src"/>
55<classpathentry kind="src" path="components/cronet/android/sample/javatests/src"/>
56<classpathentry kind="src" path="components/autofill/core/browser/android/java/src"/>
Jinsuk Kim351a9252018-07-11 23:23:3657<classpathentry kind="src" path="components/embedder_support/android/java/src"/>
andybons3322f762015-08-24 21:37:0958<classpathentry kind="src" path="components/dom_distiller/android/java/src"/>
59<classpathentry kind="src" path="components/navigation_interception/android/java/src"/>
60<classpathentry kind="src" path="ui/android/java/src"/>
61<classpathentry kind="src" path="media/base/android/java/src"/>
62<classpathentry kind="src" path="chrome/test/android/unit_tests_apk/src"/>
63<classpathentry kind="src" path="chrome/test/android/javatests/src"/>
64<classpathentry kind="src" path="chrome/test/chromedriver/test/webview_shell/java/src"/>
65<classpathentry kind="src" path="chrome/common/extensions/docs/examples/extensions/irc/servlet/src"/>
66<classpathentry kind="src" path="chrome/android/java/src"/>
67<classpathentry kind="src" path="chrome/android/uiautomator_tests/src"/>
andybons3322f762015-08-24 21:37:0968<classpathentry kind="src" path="chrome/android/javatests/src"/>
69<classpathentry kind="src" path="sync/test/android/javatests/src"/>
70<classpathentry kind="src" path="sync/android/java/src"/>
71<classpathentry kind="src" path="sync/android/javatests/src"/>
Ken Rockot131fb17f2018-07-06 21:44:2072<classpathentry kind="src" path="mojo/public/java/base/src"/>
73<classpathentry kind="src" path="mojo/public/java/bindings/src"/>
74<classpathentry kind="src" path="mojo/public/java/system/javatests/src"/>
75<classpathentry kind="src" path="mojo/public/java/system/src"/>
andybons3322f762015-08-24 21:37:0976<classpathentry kind="src" path="testing/android/java/src"/>
77<classpathentry kind="src" path="printing/android/java/src"/>
78<classpathentry kind="src" path="tools/binary_size/java/src"/>
79<classpathentry kind="src" path="tools/android/memconsumer/java/src"/>
andybons3322f762015-08-24 21:37:0980<classpathentry kind="src" path="remoting/android/java/src"/>
81<classpathentry kind="src" path="remoting/android/apk/src"/>
82<classpathentry kind="src" path="remoting/android/javatests/src"/>
andybons3322f762015-08-24 21:37:0983<classpathentry kind="src" path="third_party/webrtc/voice_engine/test/android/android_test/src"/>
84<classpathentry kind="src" path="third_party/webrtc/modules/video_capture/android/java/src"/>
85<classpathentry kind="src" path="third_party/webrtc/modules/video_render/android/java/src"/>
86<classpathentry kind="src" path="third_party/webrtc/modules/audio_device/test/android/audio_device_android_test/src"/>
87<classpathentry kind="src" path="third_party/webrtc/modules/audio_device/android/java/src"/>
88<classpathentry kind="src" path="third_party/webrtc/examples/android/media_demo/src"/>
89<classpathentry kind="src" path="third_party/webrtc/examples/android/opensl_loopback/src"/>
90<classpathentry kind="src" path="third_party/webrtc/video_engine/test/auto_test/android/src"/>
91<classpathentry kind="src" path="third_party/libjingle/source/talk/app/webrtc/java/src"/>
92<classpathentry kind="src" path="third_party/libjingle/source/talk/app/webrtc/javatests/src"/>
93<classpathentry kind="src" path="third_party/libjingle/source/talk/examples/android/src"/>
94<classpathentry kind="src" path="android_webview/java/src"/>
andybons3322f762015-08-24 21:37:0995<classpathentry kind="src" path="android_webview/test/shell/src"/>
96<classpathentry kind="src" path="android_webview/unittestjava/src"/>
97<classpathentry kind="src" path="android_webview/javatests/src"/>
danakjb793785e2019-06-04 16:44:3398<classpathentry kind="src" path="chrome/test/android/browsertests_apk/src"/>
99<classpathentry kind="src" path="components/test/android/browsertests_apk/src"/>
andybons3322f762015-08-24 21:37:09100<classpathentry kind="src" path="content/public/test/android/javatests/src"/>
101<classpathentry kind="src" path="content/public/android/java/src"/>
102<classpathentry kind="src" path="content/public/android/javatests/src"/>
103<classpathentry kind="src" path="content/shell/android/browsertests_apk/src"/>
104<classpathentry kind="src" path="content/shell/android/java/src"/>
105<classpathentry kind="src" path="content/shell/android/shell_apk/src"/>
106<classpathentry kind="src" path="content/shell/android/javatests/src"/>
Yun Liuf57cceaf2019-03-18 21:31:23107<classpathentry kind="lib" path="third_party/android_sdk/public/platforms/android-27/data/layoutlib.jar"/>
108<classpathentry kind="lib" path="third_party/android_sdk/public/platforms/android-27/android.jar"/>
andybons222c4ee2015-08-25 16:51:03109<classpathentry kind="output" path="out/bin"/>
andybons3322f762015-08-24 21:37:09110</classpath>
111```
andybons3322f762015-08-24 21:37:09112
andybons222c4ee2015-08-25 16:51:031131. Obtain the debug port
114 1. Go to Window > Open Perspective > DDMS
115 1. In order for the app org.chromium.chromoting to show up, you must build
116 Debug instead of Retail
117 1. Note down the port number, should be 8600 or 8700
1181. Setup a debug configuration
119 1. Go to Window > Open Perspective > Debug
120 1. Run > Debug > Configurations
121 1. Select "Remote Java Application" and click "New"
122 1. Put Host: localhost and Port: <the port from DDMS>
123 1. Hit Debug
1241. Configure source path
125 1. Right click on the Chromoting [Application](Remoting.md) and select Edit
126 source Lookup Path
127 1. Click "Add" and select File System Directory
128 1. Select the location of your chromium checkout,
129 e.g. <project root>/src/remoting/android
1301. Debugging
131 1. To add a breakpoint, simply open the source file and hit Ctrl+Shift+B to
132 toggle the breakpoint. Happy hacking.
andybons3322f762015-08-24 21:37:09133
andybons222c4ee2015-08-25 16:51:03134### Command line debugger
andybons3322f762015-08-24 21:37:09135
andybons222c4ee2015-08-25 16:51:03136With the Android Device Monitor open, look under `Devices`, expand the entry for
137the device on which you want to debug, and select the entry for
138`org.chromium.chromoting` (it must already be running). This forwards the JVM
139debugging connection to your local port 8700. In your shell, do `$ jdb -attach
140localhost:8700`.
141
142## Attaching GDB to debug native code
143
144The Chromium build system provides a convenience wrapper script that can be used
145to easily launch GDB. Run
146
147```shell
148$ build/android/adb_gdb --package-name=org.chromium.chromoting \
149--activity=.Chromoting --start
150```
151
152Note that if you have multiple devices connected, you must export
153`ANDROID_SERIAL` to select one; set it to the serial number of the desired
154device as output by `$ adb devices`.