aboutsummaryrefslogtreecommitdiff
path: root/en/devices/tech/debug/valgrind.html
diff options
context:
space:
mode:
Diffstat (limited to 'en/devices/tech/debug/valgrind.html')
-rw-r--r--en/devices/tech/debug/valgrind.html75
1 files changed, 75 insertions, 0 deletions
diff --git a/en/devices/tech/debug/valgrind.html b/en/devices/tech/debug/valgrind.html
new file mode 100644
index 00000000..d8f1e42b
--- /dev/null
+++ b/en/devices/tech/debug/valgrind.html
@@ -0,0 +1,75 @@
+<html devsite>
+ <head>
+ <title>Using Valgrind</title>
+ <meta name="project_path" value="/_project.yaml" />
+ <meta name="book_path" value="/_book.yaml" />
+ </head>
+ <body>
+ <!--
+ Copyright 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<p>The <a href="http://valgrind.org/">Valgrind</a> tool suite includes Memcheck
+(for detecting memory-related errors in C and C++), Cachegrind (a cache
+profiler), Massif (a heap profiler), and several other tools.</p>
+
+<p class="note"><strong>Note:</strong> While you can use Valgrind for Android
+debugging, most Android platform developers use
+<a href="/devices/tech/debug/asan.html">AddressSanitizer</a> instead.</p>
+
+<h2 id=build-valgrind>Building Valgrind</h2>
+<p>To build Valgrind:</p>
+<pre class="no-pretty-print">
+$ mmma -j6 external/valgrind
+</pre>
+
+<h2 id=app-valgrind>Using on an application</h2>
+<p>To use Valgrind on an application:</p>
+
+<pre class="no-pretty-print">
+$ adb shell setprop wrap.<em>app_name</em> "logwrapper valgrind"
+$ adb shell am start -a android.intent.action.MAIN -n <em>app_name</em>/.MainActivity
+</pre>
+
+<code><em>app_name</em></code> must be a fully-qualified name such as
+<strong>com.google.example_app</strong>.
+
+<h2 id=server-valgrind>Using on the system server</h2>
+<p>To run the system server with Valgrind:</p>
+
+<pre class="no-pretty-print">
+$ adb shell setprop wrap.system_server "logwrapper valgrind"
+$ adb shell stop && adb shell start
+</pre>
+
+
+<h2 id=symbols-valgrind>Getting debug symbols</h2>
+<p>For debug symbols, push unstripped libraries to <code>/data/local/symbols</code>:</p>
+<pre class="no-pretty-print">
+$ adb shell mkdir /data/local/symbols
+$ adb push $OUT/symbols /data/local/symbols
+</pre>
+
+<h2 id=boot-valgrind>Using during boot up</h2>
+<p>To use Valgrind during boot up, edit
+<code>out/target/product/XXXX/root/init.rc</code> by changing</p>
+<p><code>service example /system/bin/foo --arg1 --arg2</code></p>
+<p>to:</p>
+<p><code>service example /system/bin/logwrapper /system/bin/valgrind /system/bin/foo --arg1 --arg2</code></p>
+<p>To see the effects, create a <code>boot.img</code> and reflash the
+device.</p>
+
+ </body>
+</html>