digit@chromium.org | 434eeea | 2012-07-09 19:02:17 +0000 | [diff] [blame] | 1 | Google Breakpad for Android |
| 2 | =========================== |
| 3 | |
| 4 | This document explains how to use the Google Breakpad client library |
| 5 | on Android, and later generate valid stack traces from the minidumps |
| 6 | it generates. |
| 7 | |
digit@chromium.org | 8c88c3e | 2013-09-25 13:47:44 +0000 | [diff] [blame] | 8 | This release supports ARM, x86 and MIPS based Android systems. |
digit@chromium.org | 434eeea | 2012-07-09 19:02:17 +0000 | [diff] [blame] | 9 | |
| 10 | I. Building the client library: |
| 11 | =============================== |
| 12 | |
| 13 | The Android client is built as a static library that you can |
| 14 | link into your own Android native code. There are two ways to |
| 15 | build it: |
| 16 | |
| 17 | I.1. Building with ndk-build: |
| 18 | ----------------------------- |
| 19 | |
| 20 | If you're using the ndk-build build system, you can follow |
| 21 | these simple steps: |
| 22 | |
| 23 | 1/ Include android/google_breakpad/Android.mk from your own |
| 24 | project's Android.mk |
| 25 | |
| 26 | This can be done either directly, or using ndk-build's |
| 27 | import-module feature. |
| 28 | |
| 29 | 2/ Link the library to one of your modules by using: |
| 30 | |
| 31 | LOCAL_STATIC_LIBRARIES += breakpad_client |
| 32 | |
| 33 | NOTE: The client library requires a C++ STL implementation, |
| 34 | which you can select with APP_STL in your Application.mk |
| 35 | |
| 36 | It has been tested succesfully with both STLport and GNU libstdc++ |
| 37 | |
| 38 | |
| 39 | II.1. Building with a standalone Android toolchain: |
| 40 | --------------------------------------------------- |
| 41 | |
| 42 | All you need to do is configure your build with the right 'host' |
| 43 | value, and disable the processor and tools, as in: |
| 44 | |
| 45 | $GOOGLE_BREAKPAD_PATH/configure --host=arm-linux-androideabi \ |
| 46 | --disable-processor \ |
| 47 | --disable-tools |
| 48 | make -j4 |
| 49 | |
| 50 | The library will be under src/client/linux/libbreakpad_client.a |
| 51 | |
digit@chromium.org | e542fe2 | 2012-08-31 17:07:25 +0000 | [diff] [blame] | 52 | You can also use 'make check' to run the test suite on a connected |
| 53 | Android device. This requires the Android 'adb' tool to be in your |
| 54 | path. |
digit@chromium.org | 434eeea | 2012-07-09 19:02:17 +0000 | [diff] [blame] | 55 | |
| 56 | II. Using the client library in Android: |
| 57 | ======================================== |
| 58 | |
| 59 | The usage instructions are very similar to the Linux ones that are |
| 60 | found at http://code.google.com/p/google-breakpad/wiki/LinuxStarterGuide |
| 61 | |
| 62 | 1/ You need to include "client/linux/handler/exception_handler.h" from a C++ |
| 63 | source file. |
| 64 | |
| 65 | 2/ If you're not using ndk-build, you also need to: |
| 66 | |
digit@chromium.org | e542fe2 | 2012-08-31 17:07:25 +0000 | [diff] [blame] | 67 | - add the following to your compiler include search paths: |
| 68 | $GOOGLE_BREAKPAD_PATH/src |
| 69 | $GOOGLE_BREAKPAD_PATH/src/common/android/include |
| 70 | |
digit@chromium.org | 434eeea | 2012-07-09 19:02:17 +0000 | [diff] [blame] | 71 | - add -llog to your linker flags |
| 72 | |
| 73 | Note that ndk-build does that for your automatically. |
| 74 | |
| 75 | 3/ Keep in mind that there is no /tmp directory on Android. |
| 76 | |
| 77 | If you use the library from a regular Android applications, specify a |
| 78 | path under your app-specific storage directory. An alternative is to |
| 79 | store them on the SDCard, but this requires a specific permission. |
| 80 | |
| 81 | For a concrete example, see the sample test application under |
| 82 | android/sample_app. See its README for more information. |
| 83 | |
| 84 | |
| 85 | III. Getting a stack trace on the host: |
| 86 | ======================================= |
| 87 | |
| 88 | This process is similar to other platforms, but here's a quick example: |
| 89 | |
| 90 | 1/ Retrieve the minidumps on your development machine. |
| 91 | |
| 92 | 2/ Dump the symbols for your native libraries with the 'dump_syms' tool. |
| 93 | This first requires building the host version of Google Breakpad, then |
| 94 | calling: |
| 95 | |
| 96 | dump_syms $PROJECT_PATH/obj/local/$ABI/libfoo.so > libfoo.so.sym |
| 97 | |
| 98 | 3/ Create the symbol directory hierarchy. |
| 99 | |
| 100 | The first line of the generated libfoo.so.sym will have a "MODULE" |
| 101 | entry that carries a hexadecimal version number, e.g.: |
| 102 | |
| 103 | MODULE Linux arm D51B4A5504974FA6ECC1869CAEE3603B0 test_google_breakpad |
| 104 | |
| 105 | Note: The second field could be either 'Linux' or 'Android'. |
| 106 | |
| 107 | Extract the version number, and a 'symbol' directory, for example: |
| 108 | |
| 109 | $PROJECT_PATH/symbols/libfoo.so/$VERSION/ |
| 110 | |
| 111 | Copy/Move your libfoo.sym file there. |
| 112 | |
| 113 | 4/ Invoke minidump_stackwalk to create the stack trace: |
| 114 | |
| 115 | minidump_stackwalk $MINIDUMP_FILE $PROJECT_PATH/symbols |
| 116 | |
| 117 | Note that various helper scripts can be found on the web to automate these |
| 118 | steps. |
| 119 | |
| 120 | IV. Verifying the Android build library: |
| 121 | ======================================== |
| 122 | |
| 123 | If you modify Google Breakpad and want to check that it still works correctly |
digit@chromium.org | e542fe2 | 2012-08-31 17:07:25 +0000 | [diff] [blame] | 124 | on Android, please run the android/run-checks.sh script which will do all |
digit@chromium.org | 434eeea | 2012-07-09 19:02:17 +0000 | [diff] [blame] | 125 | necessary verifications for you. This includes: |
| 126 | |
digit@chromium.org | e542fe2 | 2012-08-31 17:07:25 +0000 | [diff] [blame] | 127 | - Rebuilding the full host binaries. |
| 128 | - Rebuilding the full Android binaries with configure/make. |
| 129 | - Rebuilding the client library unit tests, and running them on a device. |
| 130 | - Rebuilding the client library with ndk-build. |
| 131 | - Building, installing and running a test crasher program on a device. |
digit@chromium.org | 434eeea | 2012-07-09 19:02:17 +0000 | [diff] [blame] | 132 | - Extracting the corresponding minidump, dumping the test program symbols |
| 133 | and generating a stack trace. |
digit@chromium.org | e542fe2 | 2012-08-31 17:07:25 +0000 | [diff] [blame] | 134 | - Checking the generated stack trace for valid source locations. |
digit@chromium.org | 434eeea | 2012-07-09 19:02:17 +0000 | [diff] [blame] | 135 | |
| 136 | For more details, please run: |
| 137 | |
digit@chromium.org | e542fe2 | 2012-08-31 17:07:25 +0000 | [diff] [blame] | 138 | android/run-checks.sh --help-all |