Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 1 | # AddressSanitizer (ASan) |
| 2 | |
| 3 | [AddressSanitizer](https://github.com/google/sanitizers) (ASan) is a fast memory |
| 4 | error detector based on compiler instrumentation (LLVM). It is fully usable for |
Nico Weber | 3b6c255 | 2020-09-09 19:49:45 | [diff] [blame] | 5 | Chrome on Android, Chrome OS, iOS simulator, Linux, Mac, and 64-bit Windows. |
| 6 | Additional info on the tool itself is available at |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 7 | https://clang.llvm.org/docs/AddressSanitizer.html. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 8 | |
| 9 | For the memory leak detector built into ASan, see |
| 10 | [LeakSanitizer](https://sites.google.com/a/chromium.org/dev/developers/testing/leaksanitizer). |
| 11 | If you want to debug memory leaks, please refer to the instructions on that page |
| 12 | instead. |
| 13 | |
| 14 | ## Buildbots and trybots |
| 15 | |
| 16 | The [Chromium Memory |
Nico Weber | 3b6c255 | 2020-09-09 19:49:45 | [diff] [blame] | 17 | waterfall](https://ci.chromium.org/p/chromium/g/chromium.memory/console) |
| 18 | contains buildbots running Chromium tests under ASan on Linux (Linux ASan/LSan |
| 19 | bots for the regular Linux build, Linux Chromium OS ASan for the chromeos=1 |
| 20 | build running on Linux), macOS, Chromium OS. Linux and Linux Chromium OS bots |
| 21 | run with --no-sandbox, but there's an extra Linux bot that enables the sandbox |
| 22 | (but disables LeakSanitizer). |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 23 | |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 24 | The trybots running Chromium tests on Linux and macOS are: |
Lei Zhang | 2804210e | 2023-07-20 01:25:42 | [diff] [blame] | 25 | - linux\_chromium\_asan\_rel\_ng |
| 26 | - mac\_chromium\_asan\_rel\_ng |
| 27 | - linux\_chromium\_chromeos\_asan\_rel\_ng (the chromeos=1 build running on a |
| 28 | Linux machine) |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 29 | |
| 30 | ## Pre-built Chrome binaries |
| 31 | |
| 32 | You can grab fresh Chrome binaries built with ASan |
| 33 | [here](https://commondatastorage.googleapis.com/chromium-browser-asan/index.html). |
Chris Thompson | 4c93a6e | 2020-12-17 02:20:51 | [diff] [blame] | 34 | The lists of ASan binaries are _very_ long, but you can filter down to more |
| 35 | specific releases by specifying a prefix like |
| 36 | [linux-debug/asan-linux-debug-83](https://commondatastorage.googleapis.com/chromium-browser-asan/index.html?prefix=linux-debug/asan-linux-debug-83). |
| 37 | This is useful for finding a build for a specific revision, since filenames are of |
| 38 | the form `asan-<platform>-<buildtype>-<revision>` (but not every revision has an |
Chris Bookholt | d3002920 | 2022-09-08 22:39:31 | [diff] [blame] | 39 | archived ASan build). The |
| 40 | [get_asan_chrome](https://source.chromium.org/chromium/chromium/src/+/main:tools/get_asan_chrome/get_asan_chrome.py) |
| 41 | helper script is a handy way to download builds; its --help flag provides |
| 42 | usage instructions. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 43 | |
| 44 | ## Build tests with ASan |
| 45 | |
Nico Weber | 3b6c255 | 2020-09-09 19:49:45 | [diff] [blame] | 46 | Building with ASan is easy. Start by compiling `base_unittests` to verify the |
| 47 | build is working for you (see below). Then, you can compile `chrome`, |
| 48 | `browser_tests`, etc.. Make sure to compile release builds. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 49 | |
| 50 | ### Configuring the build |
| 51 | |
| 52 | Create an asan build directory by running: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 53 | ```shell |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 54 | gn args out/asan |
| 55 | ``` |
| 56 | |
| 57 | Enter the following build variables in the editor that will pop up: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 58 | ```python |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 59 | is_asan = true |
| 60 | is_debug = false # Release build. |
| 61 | ``` |
| 62 | |
| 63 | Build with: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 64 | ```shell |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 65 | ninja -C out/asan base_unittests |
| 66 | ``` |
| 67 | |
| 68 | ### Goma build |
| 69 | |
Nico Weber | 3b6c255 | 2020-09-09 19:49:45 | [diff] [blame] | 70 | ASan builds should work seamlessly with Goma; just add `use_goma=true` in your |
| 71 | "gn args" Don't forget to use `ninja -j <jobs>` to take advantage of goma. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 72 | |
| 73 | ### Build options |
| 74 | |
| 75 | If you want your stack traces to be precise, you will have to disable inlining |
| 76 | by setting the GN arg: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 77 | ```shell |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 78 | enable_full_stack_frames_for_profiling = true |
| 79 | ``` |
| 80 | |
| 81 | Note that this incurs a significant performance hit. Please do not do this on |
| 82 | buildbots. |
| 83 | |
| 84 | If you're working on reproducing ClusterFuzz reports, you might want to add: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 85 | ```shell |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 86 | v8_enable_verify_heap = true |
| 87 | ``` |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 88 | in order to enable the `--verify-heap` command line flag for v8 in Release builds. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 89 | |
| 90 | ## Verify the ASan tool works |
| 91 | |
| 92 | **ATTENTION (Linux only)**: These instructions are for running ASan in a way |
| 93 | that is compatible with the sandbox. However, this is not compatible with |
| 94 | LeakSanitizer. If you want to debug memory leaks, please use the instructions on |
| 95 | the |
| 96 | [LeakSanitizer](https://sites.google.com/a/chromium.org/dev/developers/testing/leaksanitizer) |
| 97 | page instead. |
| 98 | |
| 99 | Now, check that the tool works. Run the following: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 100 | ```shell |
| 101 | out/asan/base_unittests \ |
| 102 | --gtest_filter=ToolsSanityTest.DISABLED_AddressSanitizerLocalOOBCrashTest \ |
Amy Huang | aaa8dcb | 2021-03-16 18:54:34 | [diff] [blame] | 103 | --gtest_also_run_disabled_tests |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 104 | ``` |
| 105 | |
| 106 | The test will crash with the following error report: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 107 | ```shell |
| 108 | ==26552== ERROR: AddressSanitizer stack-buffer-overflow on address \ |
| 109 | 0x7fff338adb14 at pc 0xac20a7 bp 0x7fff338adad0 sp 0x7fff338adac8 |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 110 | WRITE of size 4 at 0x7fff338adb14 thread T0 |
| 111 | #0 0xac20a7 in base::ToolsSanityTest_DISABLED_AddressSanitizerLocalOOBCrashTest_Test::TestBody() ???:0 |
| 112 | #1 0xcddbd6 in testing::Test::Run() testing/gtest/src/gtest.cc:2161 |
| 113 | #2 0xcdf63b in testing::TestInfo::Run() testing/gtest/src/gtest.cc:2338 |
| 114 | ... lots more stuff |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 115 | Address 0x7fff338adb14 is located at offset 52 in frame \ |
| 116 | base::ToolsSanityTest_DISABLED_AddressSanitizerLocalOOBCrashTest_Test::TestBody()> of T0's stack: |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 117 | This frame has 2 object(s): |
| 118 | [32, 52) 'array' |
| 119 | [96, 104) 'access' |
| 120 | ==26552== ABORTING |
| 121 | ... lots more stuff |
| 122 | ``` |
| 123 | |
Samuel Huang | e9a7bff9d | 2020-03-04 16:16:03 | [diff] [blame] | 124 | Congrats, you have a working ASan build! 🙌 |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 125 | |
| 126 | ## Run chrome under ASan |
| 127 | |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 128 | And finally, have fun with the `out/Release/chrome` binary. The filter script |
Amy Huang | aaa8dcb | 2021-03-16 18:54:34 | [diff] [blame] | 129 | `tools/valgrind/asan/asan_symbolize.py` can be used to symbolize the output, |
| 130 | although it shouldn't be necessary on Linux and Windows, where Chrome uses the |
| 131 | llvm-symbolizer in its source tree by default. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 132 | |
| 133 | ASan should perfectly work with Chrome's sandbox. You should only need to run |
| 134 | with `--no-sandbox` on Linux if you're debugging ASan. |
| 135 | Note: you have to disable the sandbox on Windows until it is supported. |
| 136 | |
| 137 | You may need to run with `--disable-gpu` on Linux with NVIDIA driver older than |
| 138 | 295.20. |
| 139 | |
| 140 | You will likely need to define environment variable |
| 141 | [`G_SLICE=always-malloc`](https://developer.gnome.org/glib/unstable/glib-running.html) |
| 142 | to avoid crashes inside gtk. |
Nico Weber | 3b6c255 | 2020-09-09 19:49:45 | [diff] [blame] | 143 | `NSS_DISABLE_ARENA_FREE_LIST=1` and `NSS_DISABLE_UNLOAD=1` are required as well. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 144 | |
| 145 | When filing a bug found by AddressSanitizer, please add a label |
Bruce Dawson | 07f51d2 | 2022-07-01 10:51:53 | [diff] [blame] | 146 | `Stability-Memory-AddressSanitizer`. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 147 | |
| 148 | ## ASan runtime options |
| 149 | |
| 150 | ASan's behavior can be changed by exporting the `ASAN_OPTIONS` env var. Some of |
| 151 | the useful options are listed on this page, others can be obtained from running |
| 152 | an ASanified binary with `ASAN_OPTIONS=help=1`. Note that Chromium sets its own |
| 153 | defaults for some options, so the default behavior may be different from that |
| 154 | observed in other projects. |
Michael Lippautz | 9236a2c | 2021-07-22 21:53:19 | [diff] [blame] | 155 | See `build/sanitizers/sanitizer_options.cc` for more details. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 156 | |
| 157 | ## NaCl support under ASan |
| 158 | |
Nico Weber | 3b6c255 | 2020-09-09 19:49:45 | [diff] [blame] | 159 | On Linux (and soon on macOS) you can build and run Chromium with NaCl under ASan. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 160 | Untrusted code (nexe) itself is not instrumented with ASan in this mode, but |
| 161 | everything else is. |
| 162 | |
Nico Weber | 3b6c255 | 2020-09-09 19:49:45 | [diff] [blame] | 163 | To do this, remove `enable_nacl=false` from your `args.gn`, and define |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 164 | `NACL_DANGEROUS_SKIP_QUALIFICATION_TEST=1` in your environment at run time. |
| 165 | |
| 166 | Pipe chromium output (stderr) through ``tools/valgrind/asan/asan_symbolize.py |
| 167 | `pwd`/`` to get function names and line numbers in ASan reports. |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 168 | If you're seeing crashes within `nacl_helper_bootstrap`, try deleting |
| 169 | `out/Release/nacl_helper`. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 170 | |
| 171 | ## Building on iOS |
| 172 | |
| 173 | It's possible to build and run Chrome tests for iOS simulator (which are x86 |
| 174 | binaries essentially) under ASan. Note that you'll need a Chrome iOS checkout |
| 175 | for that. It isn't currently possible to build iOS binaries targeting ARM. |
| 176 | |
| 177 | Configure your build with `is_asan = true` as described above. Replace your |
| 178 | build directory as needed: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 179 | ```shell |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 180 | ninja -C out/Release-iphonesimulator base_unittests |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 181 | out/Release-iphonesimulator/iossim -d "iPhone" -s 7.0 \ |
| 182 | out/Release-iphonesimulator/base_unittests.app/ \ |
| 183 | --gtest_filter=ToolsSanityTest.DISABLED_AddressSanitizerLocalOOBCrashTest \ |
| 184 | --gtest_also_run_disabled_tests 2>&1 | |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 185 | tools/valgrind/asan/asan_symbolize.py |
| 186 | ``` |
| 187 | |
| 188 | You'll see the same report as shown above (see the "Verify the ASan tool works" |
| 189 | section), with a number of iOS-specific frames. |
| 190 | |
| 191 | ## Building on Android |
| 192 | |
| 193 | Follow [AndroidBuildInstructions](android_build_instructions.md) with minor |
| 194 | changes: |
| 195 | |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 196 | ```python |
| 197 | target_os="android" |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 198 | is_asan=true |
| 199 | is_debug=false |
| 200 | ``` |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 201 | |
| 202 | Running ASan applications on Android requires additional device setup. Chromium |
| 203 | testing scripts take care of this, so testing works as expected: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 204 | ```shell |
| 205 | build/android/test_runner.py instrumentation --test-apk ContentShellTest \ |
| 206 | --test_data content:content/test/data/android/device_files -v -v -v \ |
| 207 | --tool=asan --release |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 208 | ``` |
| 209 | |
Hazem Ashmawy | 382171a | 2021-06-29 22:05:32 | [diff] [blame] | 210 | If the above step fails or to run stuff without Chromium testing script (ex. |
| 211 | ContentShell.apk, or any third party apk or binary), device setup is needed: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 212 | ```shell |
Samuel Huang | e9a7bff9d | 2020-03-04 16:16:03 | [diff] [blame] | 213 | tools/android/asan/third_party/asan_device_setup.sh \ |
Prashanth Swaminathan | c2e7afa5 | 2023-06-07 18:12:33 | [diff] [blame] | 214 | --lib third_party/android_toolchain/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/*/lib/linux |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 215 | # wait a few seconds for the device to reload |
| 216 | ``` |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 217 | It only needs to be run once per device. It is safe to run it multiple times. |
Samuel Huang | e9a7bff9d | 2020-03-04 16:16:03 | [diff] [blame] | 218 | Examine the output to ensure that setup was successful (you may need to run |
| 219 | `adb disable-verity` and restart the device first). When this is done, the |
| 220 | device will run ASan apks as well as normal apks without any further setup. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 221 | |
| 222 | To run command-line tools (i.e. binaries), prefix them with `asanwrapper`: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 223 | ```shell |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 224 | adb shell /system/bin/asanwrapper /path/to/binary |
| 225 | ``` |
| 226 | |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 227 | Use `build/android/asan_symbolize.py` to symbolize stack from `adb logcat`. It |
| 228 | needs the `--output-directory` argument and takes care of translating the device |
| 229 | path to the unstripped binary in the output directory. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 230 | |
Nico Weber | 3b6c255 | 2020-09-09 19:49:45 | [diff] [blame] | 231 | ## Building with v8\_target\_arch="arm" |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 232 | |
| 233 | This is needed to detect addressability bugs in the ARM code emitted by V8 and |
| 234 | running on an instrumented ARM emulator in a 32-bit x86 Linux Chromium. **You |
| 235 | probably don't want this, and these instructions have bitrotted because they |
| 236 | still reference GYP. If you do this successfully, please update!** See |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 237 | https://crbug.com/324207 for some context. |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 238 | |
| 239 | First, you need to install the 32-bit chroot environment using the |
| 240 | `build/install-chroot.sh` script (as described in |
| 241 | https://code.google.com/p/chromium/wiki/LinuxBuild32On64). Second, install the |
| 242 | build deps: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 243 | ```shell |
| 244 | precise32 build/install-build-deps.sh \ |
| 245 | # assuming your schroot wrapper is called 'precise32' |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 246 | ``` |
| 247 | |
| 248 | You'll need to make two symlinks to avoid linking errors: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 249 | ```shell |
| 250 | sudo ln -s $CHROOT/usr/lib/i386-linux-gnu/libc_nonshared.a \ |
| 251 | /usr/lib/i386-linux-gnu/libc_nonshared.a |
| 252 | sudo ln -s $CHROOT/usr/lib/i386-linux-gnu/libpthread_nonshared.a \ |
| 253 | /usr/lib/i386-linux-gnu/libpthread_nonshared.a |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 254 | ``` |
| 255 | |
| 256 | Now configure and build your Chrome: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 257 | ```shell |
| 258 | GYP_GENERATOR_FLAGS="output_dir=out_asan_chroot" GYP_DEFINES="asan=1 \ |
| 259 | disable_nacl=1 v8_target_arch=arm sysroot=/var/lib/chroot/precise32bit/ \ |
| 260 | chroot_cmd=precise32 host_arch=x86_64 target_arch=ia32" gclient runhooks |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 261 | ninja -C out_asan_chroot/Release chrome |
| 262 | ``` |
| 263 | |
| 264 | **Note**: `disable_nacl=1` is needed for now. |
| 265 | |
James Cook | 0c3837bc | 2021-08-12 01:30:36 | [diff] [blame] | 266 | ## Running on Chrome OS |
| 267 | |
| 268 | For the linux-chromeos "emulator" build, run Asan following the instructions |
| 269 | above, just like you would for Linux. |
| 270 | |
| 271 | For Chromebook hardware, add `is_asan = true` to your args.gn and build. |
| 272 | `deploy_chrome` with `--mount` and `--nostrip`. ASan logs can be found in |
| 273 | `/var/log/asan/`. |
| 274 | |
| 275 | To catch crashes in gdb: |
| 276 | |
| 277 | - Edit `/etc/chrome_dev.conf` and add `ASAN_OPTIONS=abort_on_error=1` |
| 278 | - `restart ui` |
| 279 | - gdb -p 12345 # Find the pid from /var/log/chrome/chrome |
| 280 | |
| 281 | When you trigger the crash, you'll get a SIGABRT in gdb. `bt` will show the |
| 282 | stack. |
| 283 | |
| 284 | See |
| 285 | [Chrome OS stack traces](https://chromium.googlesource.com/chromiumos/docs/+/main/stack_traces.md) |
| 286 | for more details. |
| 287 | |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 288 | ## AsanCoverage |
| 289 | |
| 290 | AsanCoverage is a minimalistic code coverage implementation built into ASan. For |
| 291 | general information see |
| 292 | [https://code.google.com/p/address-sanitizer/wiki/AsanCoverage](https://github.com/google/sanitizers) |
| 293 | To use AsanCoverage in Chromium, add `use_sanitizer_coverage = true` to your GN |
| 294 | args. See also the `sanitizer_coverage_flags` variable for configuring it. |
| 295 | |
| 296 | Chrome must be terminated gracefully in order for coverage to work. Either close |
| 297 | the browser, or SIGTERM the browser process. Do not do `killall chrome` or send |
| 298 | SIGKILL. |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 299 | ```shell |
| 300 | kill <browser_process_pid> |
| 301 | ls |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 302 | ... |
| 303 | chrome.22575.sancov |
| 304 | gpu.6916123572022919124.sancov.packed |
| 305 | zygote.13651804083035800069.sancov.packed |
| 306 | ... |
| 307 | ``` |
| 308 | |
| 309 | The `gpu.*.sancov.packed` file contains coverage data for the GPU process, |
| 310 | whereas the `zygote.*.sancov.packed` file contains coverage data for the |
| 311 | renderers (but not the zygote process). Unpack them to regular `.sancov` files |
| 312 | like so: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 313 | ```shell |
| 314 | $ $LLVM/projects/compiler-rt/lib/sanitizer_common/scripts/sancov.py unpack \ |
| 315 | *.sancov.packed |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 316 | sancov.py: unpacking gpu.6916123572022919124.sancov.packed |
| 317 | sancov.py: extracting chrome.22610.sancov |
| 318 | sancov.py: unpacking zygote.13651804083035800069.sancov.packed |
| 319 | sancov.py: extracting libpdf.so.12.sancov |
| 320 | sancov.py: extracting chrome.12.sancov |
| 321 | sancov.py: extracting libpdf.so.10.sancov |
| 322 | sancov.py: extracting chrome.10.sancov |
| 323 | ``` |
| 324 | |
| 325 | Now, e.g., to list the offsets of covered functions in the libpdf.so binary in |
| 326 | renderer with pid 10: |
Darwin Huang | 7d3b5f05 | 2019-12-23 19:25:52 | [diff] [blame] | 327 | ```shell |
| 328 | $ $LLVM/projects/compiler-rt/lib/sanitizer_common/scripts/sancov.py print \ |
| 329 | libpdf.so.10.sancov |
Staphany Park | 384b99a | 2019-12-18 03:23:34 | [diff] [blame] | 330 | ``` |