Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: native_client_sdk/doc_generated/devguide/devcycle/debugging.html

Issue 618823003: Add debugging information for nacl_io library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to feedback from Patch Set 5. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 {{+bindTo:partials.standard_nacl_article}} 1 {{+bindTo:partials.standard_nacl_article}}
2 2
3 <section id="debugging"> 3 <section id="debugging">
4 <span id="devcycle-debugging"></span><h1 id="debugging"><span id="devcycle-debug ging"></span>Debugging</h1> 4 <span id="devcycle-debugging"></span><h1 id="debugging"><span id="devcycle-debug ging"></span>Debugging</h1>
5 <p>This document describes tools and techniques you can use to debug, monitor, 5 <p>This document describes tools and techniques you can use to debug, monitor,
6 and measure your application&#8217;s performance.</p> 6 and measure your application&#8217;s performance.</p>
7 <div class="contents local" id="table-of-contents" style="display: none"> 7 <div class="contents local" id="table-of-contents" style="display: none">
8 <p class="topic-title first">Table Of Contents</p> 8 <p class="topic-title first">Table Of Contents</p>
9 <ul class="small-gap"> 9 <ul class="small-gap">
10 <li><p class="first"><a class="reference internal" href="#diagnostic-information " id="id2">Diagnostic information</a></p> 10 <li><p class="first"><a class="reference internal" href="#diagnostic-information " id="id2">Diagnostic information</a></p>
11 <ul class="small-gap"> 11 <ul class="small-gap">
12 <li><a class="reference internal" href="#viewing-process-statistics-with-the-tas k-manager" id="id3">Viewing process statistics with the task manager</a></li> 12 <li><a class="reference internal" href="#viewing-process-statistics-with-the-tas k-manager" id="id3">Viewing process statistics with the task manager</a></li>
13 <li><a class="reference internal" href="#controlling-the-level-of-native-client- error-and-warning-messages" id="id4">Controlling the level of Native Client erro r and warning messages</a></li> 13 <li><a class="reference internal" href="#controlling-the-level-of-native-client- error-and-warning-messages" id="id4">Controlling the level of Native Client erro r and warning messages</a></li>
14 </ul> 14 </ul>
15 </li> 15 </li>
16 <li><p class="first"><a class="reference internal" href="#basic-debugging" id="i d5">Basic debugging</a></p> 16 <li><p class="first"><a class="reference internal" href="#basic-debugging" id="i d5">Basic debugging</a></p>
17 <ul class="small-gap"> 17 <ul class="small-gap">
18 <li><a class="reference internal" href="#writing-messages-to-the-javascript-cons ole" id="id6">Writing messages to the JavaScript console</a></li> 18 <li><a class="reference internal" href="#writing-messages-to-the-javascript-cons ole" id="id6">Writing messages to the JavaScript console</a></li>
19 <li><p class="first"><a class="reference internal" href="#debugging-with-printf" id="id7">Debugging with printf</a></p> 19 <li><a class="reference internal" href="#debugging-with-printf" id="id7">Debuggi ng with printf</a></li>
20 <li><p class="first"><a class="reference internal" href="#using-chrome-s-stdout- and-stderr-streams" id="id8">Using Chrome&#8217;s stdout and stderr Streams</a>< /p>
20 <ul class="small-gap"> 21 <ul class="small-gap">
21 <li><a class="reference internal" href="#redirecting-output-to-log-files" id="id 8">Redirecting output to log files</a></li> 22 <li><a class="reference internal" href="#redirecting-output-to-log-files" id="id 9">Redirecting output to log files</a></li>
22 </ul> 23 </ul>
23 </li> 24 </li>
24 <li><a class="reference internal" href="#logging-calls-to-pepper-interfaces" id= "id9">Logging calls to Pepper interfaces</a></li> 25 <li><a class="reference internal" href="#logging-calls-to-pepper-interfaces" id= "id10">Logging calls to Pepper interfaces</a></li>
25 <li><a class="reference internal" href="#debugging-with-visual-studio" id="id10" >Debugging with Visual Studio</a></li> 26 <li><a class="reference internal" href="#debugging-with-visual-studio" id="id11" >Debugging with Visual Studio</a></li>
26 <li><p class="first"><a class="reference internal" href="#debugging-with-nacl-gd b" id="id11">Debugging with nacl-gdb</a></p> 27 <li><p class="first"><a class="reference internal" href="#debugging-with-nacl-gd b" id="id12">Debugging with nacl-gdb</a></p>
27 <ul class="small-gap"> 28 <ul class="small-gap">
28 <li><a class="reference internal" href="#debugging-pnacl-pexes-pepper-35-or-late r" id="id12">Debugging PNaCl pexes (Pepper 35 or later)</a></li> 29 <li><a class="reference internal" href="#debugging-pnacl-pexes-pepper-35-or-late r" id="id13">Debugging PNaCl pexes (Pepper 35 or later)</a></li>
29 <li><a class="reference internal" href="#debugging-pnacl-pexes-with-older-pepper -toolchains" id="id13">Debugging PNaCl pexes (with older Pepper toolchains)</a>< /li> 30 <li><a class="reference internal" href="#debugging-pnacl-pexes-with-older-pepper -toolchains" id="id14">Debugging PNaCl pexes (with older Pepper toolchains)</a>< /li>
30 <li><a class="reference internal" href="#running-nacl-gdb" id="id14">Running nac l-gdb</a></li> 31 <li><a class="reference internal" href="#running-nacl-gdb" id="id15">Running nac l-gdb</a></li>
31 </ul> 32 </ul>
32 </li> 33 </li>
33 </ul> 34 </ul>
34 </li> 35 </li>
35 <li><a class="reference internal" href="#debugging-with-other-tools" id="id15">D ebugging with other tools</a></li> 36 <li><a class="reference internal" href="#debugging-with-other-tools" id="id16">D ebugging with other tools</a></li>
36 </ul> 37 </ul>
37 38
38 </div><h2 id="diagnostic-information">Diagnostic information</h2> 39 </div><h2 id="diagnostic-information">Diagnostic information</h2>
39 <h3 id="viewing-process-statistics-with-the-task-manager">Viewing process statis tics with the task manager</h3> 40 <h3 id="viewing-process-statistics-with-the-task-manager">Viewing process statis tics with the task manager</h3>
40 <p>You can use Chrome&#8217;s Task Manager to display information about a Native Client 41 <p>You can use Chrome&#8217;s Task Manager to display information about a Native Client
41 application:</p> 42 application:</p>
42 <ol class="arabic simple"> 43 <ol class="arabic simple">
43 <li>Open the Task Manager by clicking the menu icon <img alt="menu-icon" src="/n ative-client/images/menu-icon.png" /> and choosing 44 <li>Open the Task Manager by clicking the menu icon <img alt="menu-icon" src="/n ative-client/images/menu-icon.png" /> and choosing
44 <strong>Tools &gt; Task manager</strong>.</li> 45 <strong>Tools &gt; Task manager</strong>.</li>
45 <li>When the Task Manager window appears, verify that the columns displaying 46 <li>When the Task Manager window appears, verify that the columns displaying
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 calling fprintf() directly, or by using cover functions like these:</p> 83 calling fprintf() directly, or by using cover functions like these:</p>
83 <pre class="prettyprint"> 84 <pre class="prettyprint">
84 #include &lt;stdio.h&gt; 85 #include &lt;stdio.h&gt;
85 void logmsg(const char* pMsg){ 86 void logmsg(const char* pMsg){
86 fprintf(stdout,&quot;logmsg: %s\n&quot;,pMsg); 87 fprintf(stdout,&quot;logmsg: %s\n&quot;,pMsg);
87 } 88 }
88 void errormsg(const char* pMsg){ 89 void errormsg(const char* pMsg){
89 fprintf(stderr,&quot;logerr: %s\n&quot;,pMsg); 90 fprintf(stderr,&quot;logerr: %s\n&quot;,pMsg);
90 } 91 }
91 </pre> 92 </pre>
93 <h3 id="using-chrome-s-stdout-and-stderr-streams"><span id="using-chromes-stdout -and-stderr"></span>Using Chrome&#8217;s stdout and stderr Streams</h3>
92 <p>By default stdout and stderr will appear in Chrome&#8217;s stdout and stderr stream 94 <p>By default stdout and stderr will appear in Chrome&#8217;s stdout and stderr stream
93 but they can also be redirected as described below.</p> 95 but they can also be redirected to log files. (See the next section.) On Mac and
94 <h4 id="redirecting-output-to-log-files">Redirecting output to log files</h4> 96 Linux, launching Chrome from a terminal makes stderr and stdout appear in that
97 terminal. If you launch Chrome this way, be sure it doesn&#8217;t attach to an e xisting
98 instance. One simple way to do this is to pass a new directory to chrome as your
99 user data directory (<code>chrome --user-data-dir=&lt;newdir&gt;</code>).</p>
100 <h4 id="redirecting-output-to-log-files"><span id="redirecting-output-to-log"></ span>Redirecting output to log files</h4>
95 <p>You can redirect stdout and stderr to output files by setting these environme nt 101 <p>You can redirect stdout and stderr to output files by setting these environme nt
96 variables:</p> 102 variables:</p>
97 <ul class="small-gap"> 103 <ul class="small-gap">
98 <li><code>NACL_EXE_STDOUT=c:\nacl_stdout.log</code></li> 104 <li><code>NACL_EXE_STDOUT=c:\nacl_stdout.log</code></li>
99 <li><code>NACL_EXE_STDERR=c:\nacl_stderr.log</code></li> 105 <li><code>NACL_EXE_STDERR=c:\nacl_stderr.log</code></li>
100 </ul> 106 </ul>
101 <p>There is another variable, <code>NACLLOG</code>, that you can use to redirect Native 107 <p>There is another variable, <code>NACLLOG</code>, that you can use to redirect Native
102 Client&#8217;s internally-generated messages. This variable is set to stderr by 108 Client&#8217;s internally-generated messages. This variable is set to stderr by
103 default; you can redirect these messages to an output file by setting the 109 default; you can redirect these messages to an output file by setting the
104 variable as follows:</p> 110 variable as follows:</p>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 metadata, which we need for debugging. In this section we&#8217;ll give the 153 metadata, which we need for debugging. In this section we&#8217;ll give the
148 LLVM bitcode file a <code>.bc</code> file extension, and the PNaCl bitcode file 154 LLVM bitcode file a <code>.bc</code> file extension, and the PNaCl bitcode file
149 a <code>.pexe</code> file extension. The actual extension should not matter, but 155 a <code>.pexe</code> file extension. The actual extension should not matter, but
150 it helps distinguish between the two types of files.</p> 156 it helps distinguish between the two types of files.</p>
151 <p><strong>Note</strong> unlike the finalized copy of the pexe, the non-finalize d debug copy 157 <p><strong>Note</strong> unlike the finalized copy of the pexe, the non-finalize d debug copy
152 is not considered stable. This means that a debug copy of the PNaCl 158 is not considered stable. This means that a debug copy of the PNaCl
153 application created by a Pepper N SDK is only guaranteed to run 159 application created by a Pepper N SDK is only guaranteed to run
154 with a matching Chrome version N. If the version of the debug bitcode pexe 160 with a matching Chrome version N. If the version of the debug bitcode pexe
155 does not match that of Chrome then the translation process may fail, and 161 does not match that of Chrome then the translation process may fail, and
156 you will see an error message in the JavaScript console.</p> 162 you will see an error message in the JavaScript console.</p>
157 <p>Also, make sure you are passing the <code>-g</code> <a class="reference inter nal" href="/native-client/devguide/devcycle/building.html#compile-flags"><em>com pile option</em></a> to <code>pnacl-clang</code> to enable generating debugging info. 163 <p>Also, make sure you are passing the <code>-g</code> <a class="reference inter nal" href="/native-client/devguide/devcycle/building.html#compile-flags"><em>com pile option</em></a>
158 You might also want to omit <code>-O2</code> from the compile-time and link-time 164 to <code>pnacl-clang</code> to enable generating debugging info. You might also want to
159 options, otherwise GDB not might be able to print variables&#8217; values when 165 omit <code>-O2</code> from the compile-time and link-time options, otherwise GDB not
160 debugging (this is more of a problem with the PNaCl/LLVM toolchain than 166 might be able to print variables&#8217; values when debugging (this is more of a
161 with GCC).</p> 167 problem with the PNaCl/LLVM toolchain than with GCC).</p>
162 <p>Once you have built a non-stable debug copy of the pexe, list the URL of 168 <p>Once you have built a non-stable debug copy of the pexe, list the URL of
163 that copy in your application&#8217;s manifest file:</p> 169 that copy in your application&#8217;s manifest file:</p>
164 <pre class="prettyprint"> 170 <pre class="prettyprint">
165 { 171 {
166 &quot;program&quot;: { 172 &quot;program&quot;: {
167 &quot;portable&quot;: { 173 &quot;portable&quot;: {
168 &quot;pnacl-translate&quot;: { 174 &quot;pnacl-translate&quot;: {
169 &quot;url&quot;: &quot;release_version.pexe&quot;, 175 &quot;url&quot;: &quot;release_version.pexe&quot;,
170 &quot;optlevel&quot;: 2 176 &quot;optlevel&quot;: 2
171 }, 177 },
172 &quot;pnacl-debug&quot;: { 178 &quot;pnacl-debug&quot;: {
173 &quot;url&quot;: &quot;debug_version.bc&quot;, 179 &quot;url&quot;: &quot;debug_version.bc&quot;,
174 &quot;optlevel&quot;: 0 180 &quot;optlevel&quot;: 0
175 } 181 }
176 } 182 }
177 } 183 }
178 } 184 }
179 </pre> 185 </pre>
180 <p>Copy the <code>debug_version.bc</code> and <code>nmf</code> files to the loca tion that 186 <p>Copy the <code>debug_version.bc</code> and <code>nmf</code> files to the loca tion that
181 your local web server serves files from.</p> 187 your local web server serves files from.</p>
182 <p>When you run Chrome with <code>--enable-nacl-debug</code>, Chrome will transl ate 188 <p>When you run Chrome with <code>--enable-nacl-debug</code>, Chrome will transl ate
183 and run the <code>debug_version.bc</code> instead of <code>release_version.pexe< /code>. 189 and run the <code>debug_version.bc</code> instead of <code>release_version.pexe< /code>.
184 Once the debug version is loaded, you are ready to <a class="reference internal" href="#running-nacl-gdb"><em>run nacl-gdb</em></a></p> 190 Once the debug version is loaded, you are ready to <a class="reference internal" href="#running-nacl-gdb"><em>run nacl-gdb</em></a></p>
185 <p>Whether you publish the NMF file containing the debug URL to the release 191 <p>Whether you publish the NMF file containing the debug URL to the
186 web server, is up to you. One reason to avoid publishing the debug URL 192 release web server, is up to you. One reason to avoid publishing the
187 is that it is only guaranteed to work for the Chrome version that matches 193 debug URL is that it is only guaranteed to work for the Chrome version
188 the SDK version. Developers who may have left the <code>--enable-nacl-debug</cod e> 194 that matches the SDK version. Developers who may have left the
189 flag turned on may end up loading the debug copy of your application 195 <code>--enable-nacl-debug</code> flag turned on may end up loading the debug
190 (which may or may not work, depending on their version of Chrome).</p> 196 copy of your application (which may or may not work, depending on
197 their version of Chrome).</p>
191 <h4 id="debugging-pnacl-pexes-with-older-pepper-toolchains">Debugging PNaCl pexe s (with older Pepper toolchains)</h4> 198 <h4 id="debugging-pnacl-pexes-with-older-pepper-toolchains">Debugging PNaCl pexe s (with older Pepper toolchains)</h4>
192 <p>If you want to use GDB to debug a program that is compiled with the PNaCl 199 <p>If you want to use GDB to debug a program that is compiled with the PNaCl
193 toolchain, you must convert the <code>pexe</code> file to a <code>nexe</code>. (You can skip 200 toolchain, you must convert the <code>pexe</code> file to a <code>nexe</code>. (You can skip
194 this step if you are using the GCC toolchain, or if you are using 201 this step if you are using the GCC toolchain, or if you are using
195 pepper 35 or later.)</p> 202 pepper 35 or later.)</p>
196 <ul class="small-gap"> 203 <ul class="small-gap">
197 <li>Firstly, make sure you are passing the <code>-g</code> <a class="reference i nternal" href="/native-client/devguide/devcycle/building.html#compile-flags"><em >compile option</em></a> to <code>pnacl-clang</code> to enable generating debugg ing info. 204 <li>Firstly, make sure you are passing the <code>-g</code> <a class="reference i nternal" href="/native-client/devguide/devcycle/building.html#compile-flags"><em >compile option</em></a> to <code>pnacl-clang</code> to enable generating debugg ing info.
198 You might also want to omit <code>-O2</code> from the compile-time and link-time 205 You might also want to omit <code>-O2</code> from the compile-time and link-time
199 options.</li> 206 options.</li>
200 <li><p class="first">Secondly, use <code>pnacl-translate</code> to convert your <code>pexe</code> to one or more 207 <li><p class="first">Secondly, use <code>pnacl-translate</code> to convert your <code>pexe</code> to one or more</p>
201 <code>nexe</code> files. For example:</p> 208 <p><code>nexe</code> files. For example:</p>
202 <pre> 209 <pre>
203 nacl_sdk/pepper_&lt;version&gt;/toolchain/win_pnacl/bin/pnacl-translate \ 210 nacl_sdk/pepper_&lt;version&gt;/toolchain/win_pnacl/bin/pnacl-translate \
204 --allow-llvm-bitcode-input hello_world.pexe -arch x86-32 \ 211 --allow-llvm-bitcode-input hello_world.pexe -arch x86-32 \
205 -o hello_world_x86_32.nexe 212 -o hello_world_x86_32.nexe
206 nacl_sdk/pepper_&lt;version&gt;/toolchain/win_pnacl/bin/pnacl-translate \ 213 nacl_sdk/pepper_&lt;version&gt;/toolchain/win_pnacl/bin/pnacl-translate \
207 --allow-llvm-bitcode-input hello_world.pexe -arch x86-64 \ 214 --allow-llvm-bitcode-input hello_world.pexe -arch x86-64 \
208 -o hello_world_x86_64.nexe 215 -o hello_world_x86_64.nexe
209 </pre> 216 </pre>
210 <p>For this, use the non-finalized <code>pexe</code> file produced by 217 <p>For this, use the non-finalized <code>pexe</code> file produced by
211 <code>pnacl-clang</code>, not the <code>pexe</code> file produced by <code>pnacl -finalize</code>. 218 <code>pnacl-clang</code>, not the <code>pexe</code> file produced by <code>pnacl -finalize</code>.
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 debugging, close the Chrome window and type <code>q</code> to quit gdb.</p> 466 debugging, close the Chrome window and type <code>q</code> to quit gdb.</p>
460 <h2 id="debugging-with-other-tools">Debugging with other tools</h2> 467 <h2 id="debugging-with-other-tools">Debugging with other tools</h2>
461 <p>If you cannot use the <a class="reference internal" href="#visual-studio"><em >Visual Studio add-in</em></a>, or you want 468 <p>If you cannot use the <a class="reference internal" href="#visual-studio"><em >Visual Studio add-in</em></a>, or you want
462 to use a debugger other than nacl-gdb, you must manually build your module as a 469 to use a debugger other than nacl-gdb, you must manually build your module as a
463 Pepper plugin (sometimes referred to as a &#8220;<a class="reference external" h ref="http://www.chromium.org/nativeclient/getting-started/getting-started-backgr ound-and-basics#TOC-Trusted-vs-Untrusted">trusted</a>&#8221; 470 Pepper plugin (sometimes referred to as a &#8220;<a class="reference external" h ref="http://www.chromium.org/nativeclient/getting-started/getting-started-backgr ound-and-basics#TOC-Trusted-vs-Untrusted">trusted</a>&#8221;
464 or &#8220;in-process&#8221; plugin). Pepper plugins (.DLL files on Windows; .so files on 471 or &#8220;in-process&#8221; plugin). Pepper plugins (.DLL files on Windows; .so files on
465 Linux; .bundle files on Mac) are loaded directly in either the Chrome renderer 472 Linux; .bundle files on Mac) are loaded directly in either the Chrome renderer
466 process or a separate plugin process, rather than in Native Client. Building a 473 process or a separate plugin process, rather than in Native Client. Building a
467 module as a trusted Pepper plugin allows you to use standard debuggers and 474 module as a trusted Pepper plugin allows you to use standard debuggers and
468 development tools on your system, but when you&#8217;re finished developing the 475 development tools on your system, but when you&#8217;re finished developing the
469 plugin, you need to port it to Native Client (i.e., build the module with one 476 plugin, you need to port it to Native Client (i.e., build the module with one of
470 of the toolchains in the NaCl SDK so that the module runs in Native Client). 477 the toolchains in the NaCl SDK so that the module runs in Native Client). For
471 For details on this advanced development technique, see <a class="reference exte rnal" href="http://www.chromium.org/nativeclient/how-tos/debugging-documentation /debugging-a-trusted-plugin">Debugging a Trusted 478 details on this advanced development technique, see <a class="reference external " href="http://www.chromium.org/nativeclient/how-tos/debugging-documentation/deb ugging-a-trusted-plugin">Debugging a Trusted Plugin</a>.
472 Plugin</a>.
473 Note that starting with the <code>pepper_22</code> bundle, the NaCl SDK for Wind ows 479 Note that starting with the <code>pepper_22</code> bundle, the NaCl SDK for Wind ows
474 includes pre-built libraries and library source code, making it much easier to 480 includes pre-built libraries and library source code, making it much easier to
475 build a module into a .DLL.</p> 481 build a module into a .DLL.</p>
476 </section> 482 </section>
477 483
478 {{/partials.standard_nacl_article}} 484 {{/partials.standard_nacl_article}}
OLDNEW
« no previous file with comments | « native_client_sdk/doc_generated/devguide/coding/nacl_io.html ('k') | native_client_sdk/doc_generated/sitemap.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698