OLD | NEW |
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’s performance.</p> | 6 and measure your application’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> |
(...skipping 14 matching lines...) Expand all Loading... |
25 <li><a class="reference internal" href="#debugging-with-visual-studio" id="id10"
>Debugging with Visual Studio</a></li> | 25 <li><a class="reference internal" href="#debugging-with-visual-studio" id="id10"
>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> | 26 <li><p class="first"><a class="reference internal" href="#debugging-with-nacl-gd
b" id="id11">Debugging with nacl-gdb</a></p> |
27 <ul class="small-gap"> | 27 <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> | 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-with-older-pepper
-toolchains" id="id13">Debugging PNaCl pexes (with older Pepper toolchains)</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="#running-nacl-gdb" id="id14">Running nac
l-gdb</a></li> | 30 <li><a class="reference internal" href="#running-nacl-gdb" id="id14">Running nac
l-gdb</a></li> |
31 </ul> | 31 </ul> |
32 </li> | 32 </li> |
33 </ul> | 33 </ul> |
34 </li> | 34 </li> |
35 <li><a class="reference internal" href="#debugging-with-other-tools" id="id15">D
ebugging with other tools</a></li> | 35 <li><p class="first"><a class="reference internal" href="#non-standard-debugging
" id="id15">Non-Standard Debugging</a></p> |
| 36 <ul class="small-gap"> |
| 37 <li><a class="reference internal" href="#nacl-io" id="id16">nacl_io</a></li> |
| 38 <li><a class="reference internal" href="#alternative-debuggers" id="id17">Altern
ative Debuggers</a></li> |
| 39 </ul> |
| 40 </li> |
36 </ul> | 41 </ul> |
37 | 42 |
38 </div><h2 id="diagnostic-information">Diagnostic information</h2> | 43 </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> | 44 <h3 id="viewing-process-statistics-with-the-task-manager">Viewing process statis
tics with the task manager</h3> |
40 <p>You can use Chrome’s Task Manager to display information about a Native
Client | 45 <p>You can use Chrome’s Task Manager to display information about a Native
Client |
41 application:</p> | 46 application:</p> |
42 <ol class="arabic simple"> | 47 <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 | 48 <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 > Task manager</strong>.</li> | 49 <strong>Tools > Task manager</strong>.</li> |
45 <li>When the Task Manager window appears, verify that the columns displaying | 50 <li>When the Task Manager window appears, verify that the columns displaying |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #include <stdio.h> | 89 #include <stdio.h> |
85 void logmsg(const char* pMsg){ | 90 void logmsg(const char* pMsg){ |
86 fprintf(stdout,"logmsg: %s\n",pMsg); | 91 fprintf(stdout,"logmsg: %s\n",pMsg); |
87 } | 92 } |
88 void errormsg(const char* pMsg){ | 93 void errormsg(const char* pMsg){ |
89 fprintf(stderr,"logerr: %s\n",pMsg); | 94 fprintf(stderr,"logerr: %s\n",pMsg); |
90 } | 95 } |
91 </pre> | 96 </pre> |
92 <p>By default stdout and stderr will appear in Chrome’s stdout and stderr
stream | 97 <p>By default stdout and stderr will appear in Chrome’s stdout and stderr
stream |
93 but they can also be redirected as described below.</p> | 98 but they can also be redirected as described below.</p> |
94 <h4 id="redirecting-output-to-log-files">Redirecting output to log files</h4> | 99 <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 | 100 <p>You can redirect stdout and stderr to output files by setting these environme
nt |
96 variables:</p> | 101 variables:</p> |
97 <ul class="small-gap"> | 102 <ul class="small-gap"> |
98 <li><code>NACL_EXE_STDOUT=c:\nacl_stdout.log</code></li> | 103 <li><code>NACL_EXE_STDOUT=c:\nacl_stdout.log</code></li> |
99 <li><code>NACL_EXE_STDERR=c:\nacl_stderr.log</code></li> | 104 <li><code>NACL_EXE_STDERR=c:\nacl_stderr.log</code></li> |
100 </ul> | 105 </ul> |
101 <p>There is another variable, <code>NACLLOG</code>, that you can use to redirect
Native | 106 <p>There is another variable, <code>NACLLOG</code>, that you can use to redirect
Native |
102 Client’s internally-generated messages. This variable is set to stderr by | 107 Client’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 | 108 default; you can redirect these messages to an output file by setting the |
104 variable as follows:</p> | 109 variable as follows:</p> |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 <dt><code>help <command></code></dt> | 455 <dt><code>help <command></code></dt> |
451 <dd>print documentation for the specified gdb <command></dd> | 456 <dd>print documentation for the specified gdb <command></dd> |
452 <dt><code>quit</code></dt> | 457 <dt><code>quit</code></dt> |
453 <dd>quit gdb</dd> | 458 <dd>quit gdb</dd> |
454 </dl> | 459 </dl> |
455 <p>See the <a class="reference external" href="http://sourceware.org/gdb/current
/onlinedocs/gdb/#toc_Top">gdb documentation</a> for a | 460 <p>See the <a class="reference external" href="http://sourceware.org/gdb/current
/onlinedocs/gdb/#toc_Top">gdb documentation</a> for a |
456 comprehensive list of gdb commands. Note that you can abbreviate most commands | 461 comprehensive list of gdb commands. Note that you can abbreviate most commands |
457 to just their first letter (<code>b</code> for break, <code>c</code> for continu
e, and so on).</p> | 462 to just their first letter (<code>b</code> for break, <code>c</code> for continu
e, and so on).</p> |
458 <p>To interrupt execution of your module, press <Ctrl-c>. When you’r
e done | 463 <p>To interrupt execution of your module, press <Ctrl-c>. When you’r
e done |
459 debugging, close the Chrome window and type <code>q</code> to quit gdb.</p> | 464 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> | 465 <h2 id="non-standard-debugging">Non-Standard Debugging</h2> |
| 466 <h3 id="nacl-io"><span id="nacl-io-debugging"></span>nacl_io</h3> |
| 467 <p>The logging system for the <a class="reference internal" href="/native-client
/devguide/coding/nacl_io.html"><em>nacl_io library</em></a> writes |
| 468 directly to the <code>stderr</code> stream of the NaCl process. It deliberately
bypasses |
| 469 the standard library functions implemented in nacl_io to avoid circular calls to |
| 470 itself.</p> |
| 471 <p>The stderr from the process is by default visible in the terminal that launch
ed |
| 472 chrome (at least on mac and linux). Be sure that when you launch chrome it |
| 473 doesn’t attach to an existing instance. One simple way to do this is to pa
ss a |
| 474 new directory to chrome as your user data directory (<code>chrome |
| 475 --user-data-dir=<newdir></code>). It’s also possible to redirect the
NaCl’s stderr to |
| 476 other places such as, for example, <a class="reference internal" href="#redirect
ing-output-to-log"><em>log files</em></a>.</p> |
| 477 <h3 id="alternative-debuggers">Alternative Debuggers</h3> |
461 <p>If you cannot use the <a class="reference internal" href="#visual-studio"><em
>Visual Studio add-in</em></a>, or you want | 478 <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 | 479 to use a debugger other than nacl-gdb, you must manually build your module as a |
463 Pepper plugin (sometimes referred to as a “<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>” | 480 Pepper plugin (sometimes referred to as a “<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>” |
464 or “in-process” plugin). Pepper plugins (.DLL files on Windows; .so
files on | 481 or “in-process” plugin). Pepper plugins (.DLL files on Windows; .so
files on |
465 Linux; .bundle files on Mac) are loaded directly in either the Chrome renderer | 482 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 | 483 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 | 484 module as a trusted Pepper plugin allows you to use standard debuggers and |
468 development tools on your system, but when you’re finished developing the | 485 development tools on your system, but when you’re finished developing the |
469 plugin, you need to port it to Native Client (i.e., build the module with one | 486 plugin, you need to port it to Native Client (i.e., build the module with one |
470 of the toolchains in the NaCl SDK so that the module runs in Native Client). | 487 of the toolchains in the NaCl SDK so that the module runs in Native Client). |
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 | 488 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 |
472 Plugin</a>. | 489 Plugin</a>. |
473 Note that starting with the <code>pepper_22</code> bundle, the NaCl SDK for Wind
ows | 490 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 | 491 includes pre-built libraries and library source code, making it much easier to |
475 build a module into a .DLL.</p> | 492 build a module into a .DLL.</p> |
476 </section> | 493 </section> |
477 | 494 |
478 {{/partials.standard_nacl_article}} | 495 {{/partials.standard_nacl_article}} |
OLD | NEW |