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

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

Issue 488133003: Second batch of corrections for incorrect paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix more paths. Created 6 years, 4 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><p class="first"><a class="reference internal" href="#debugging-with-printf" id="id7">Debugging with printf</a></p>
20 <ul class="small-gap"> 20 <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> 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-the-javascript-co nsole" id="id9">Redirecting output to the JavaScript console</a></li> 22 <li><a class="reference internal" href="#redirecting-output-to-the-javascript-co nsole" id="id9">Redirecting output to the JavaScript console</a></li>
23 </ul> 23 </ul>
24 </li> 24 </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="#logging-calls-to-pepper-interfaces" id= "id10">Logging calls to Pepper interfaces</a></li>
26 <li><a class="reference internal" href="#debugging-with-visual-studio" id="id11" >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>
27 <li><p class="first"><a class="reference internal" href="#debugging-with-nacl-gd b" id="id12">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>
28 <ul class="small-gap"> 28 <ul class="small-gap">
29 <li><a class="reference internal" href="#debugging-pnacl-pexes-with-pepper-35" i d="id13">Debugging PNaCl pexes (with Pepper 35+)</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>
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="#debugging-pnacl-pexes-with-older-pepper -toolchains" id="id14">Debugging PNaCl pexes (with older Pepper toolchains)</a>< /li>
31 <li><a class="reference internal" href="#running-nacl-gdb" id="id15">Running nac l-gdb</a></li> 31 <li><a class="reference internal" href="#running-nacl-gdb" id="id15">Running nac l-gdb</a></li>
32 </ul> 32 </ul>
33 </li> 33 </li>
34 </ul> 34 </ul>
35 </li> 35 </li>
36 <li><p class="first"><a class="reference internal" href="#debugging-with-other-t ools" id="id16">Debugging with other tools</a></p> 36 <li><p class="first"><a class="reference internal" href="#debugging-with-other-t ools" id="id16">Debugging with other tools</a></p>
37 <ul class="small-gap"> 37 <ul class="small-gap">
38 <li><a class="reference internal" href="#open-source-profiling-tools" id="id17"> Open source profiling tools</a></li> 38 <li><a class="reference internal" href="#open-source-profiling-tools" id="id17"> Open source profiling tools</a></li>
39 </ul> 39 </ul>
40 </li> 40 </li>
41 </ul> 41 </ul>
42 42
43 </div><h2 id="diagnostic-information">Diagnostic information</h2> 43 </div><h2 id="diagnostic-information">Diagnostic information</h2>
44 <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>
45 <p>You can use Chrome&#8217;s Task Manager to display information about a Native Client 45 <p>You can use Chrome&#8217;s Task Manager to display information about a Native Client
46 application:</p> 46 application:</p>
47 <ol class="arabic simple"> 47 <ol class="arabic simple">
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 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
49 <strong>Tools &gt; Task manager</strong>.</li> 49 <strong>Tools &gt; Task manager</strong>.</li>
50 <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
51 memory information are visible. If they are not, right click in the header 51 memory information are visible. If they are not, right click in the header
52 row and select the memory items from the popup menu that appears.</li> 52 row and select the memory items from the popup menu that appears.</li>
53 </ol> 53 </ol>
54 <p>A browser window running a Native Client application will have at least two 54 <p>A browser window running a Native Client application has at least two process es
55 processes associated with it: a process for the app&#8217;s top level (the rende r 55 associated with it: a process for the app&#8217;s top level (the render process
56 process managing the page including its HTML and any JavaScript) and one or 56 managing the page including its HTML and JavaScript) and one or more
57 more processes for each instance of a Native Client module embedded in the page 57 processes for each instance of a Native Client module embedded in the page
58 (each process running native code from one nexe file). The top-level process 58 (each process running native code from one nexe or pexe file). The top-level
59 appears with the application&#8217;s icon and begins with the text &#8220;App:&# 8221;. A Native 59 process appears with the application&#8217;s icon and begins with the text &#822 0;Tab:&#8221;.
60 Client process appears with a Chrome extension icon (a jigsaw puzzle piece 60 A Native Client process appears with a Chrome extension icon (a jigsaw puzzle
61 <img alt="puzzle" src="/native-client/images/puzzle.png" />) and begins with the text &#8220;Native Client module&#8221; followed by the URL 61 piece <img alt="puzzle" src="/native-client/images/puzzle.png" />) and begins wi th the text &#8220;Native Client module:&#8221; followed by the
62 of its manifest file.</p> 62 URL of its manifest file.</p>
63 <p>From the Task Manager you can view the changing memory allocations of all the 63 <p>From the Task Manager you can view the changing memory allocations of all the
64 processes associated with a Native Client application. Each process has its own 64 processes associated with a Native Client application. Each process has its own
65 memory footprint. You can also see the rendering rate displayed as frames per 65 memory footprint. You can also see the rendering rate displayed as frames per
66 second (FPS). Note that the computation of render frames can be performed in 66 second (FPS). Note that the computation of render frames can be performed in
67 any process, but the rendering itself is always done in the top level 67 any process, but the rendering itself is always done in the top level
68 application process, so look for the rendering rate there.</p> 68 application process, so look for the rendering rate there.</p>
69 <h3 id="controlling-the-level-of-native-client-error-and-warning-messages">Contr olling the level of Native Client error and warning messages</h3> 69 <h3 id="controlling-the-level-of-native-client-error-and-warning-messages">Contr olling the level of Native Client error and warning messages</h3>
70 <p>Native Client prints warning and error messages to stdout and stderr. You can 70 <p>Native Client prints warning and error messages to stdout and stderr. You can
71 increase the amount of Native Client&#8217;s diagnostic output by setting the 71 increase the amount of Native Client&#8217;s diagnostic output by setting the
72 following <a class="reference external" href="http://en.wikipedia.org/wiki/Envir onment_variable">environment variables</a>:</p> 72 following <a class="reference external" href="http://en.wikipedia.org/wiki/Envir onment_variable">environment variables</a>:</p>
73 <ul class="small-gap"> 73 <ul class="small-gap">
74 <li>NACL_PLUGIN_DEBUG=1</li> 74 <li><code>NACL_PLUGIN_DEBUG=1</code></li>
75 <li>NACL_SRPC_DEBUG=[1-255] (use a higher number for more verbose debug output)< /li> 75 <li><code>NACL_SRPC_DEBUG=[1-255]</code> (use a higher number for more verbose d ebug
76 <li>NACLVERBOSITY=[1-255]</li> 76 output)</li>
77 <li><code>NACLVERBOSITY=[1-255]</code></li>
77 </ul> 78 </ul>
78 <h2 id="basic-debugging">Basic debugging</h2> 79 <h2 id="basic-debugging">Basic debugging</h2>
79 <h3 id="writing-messages-to-the-javascript-console">Writing messages to the Java Script console</h3> 80 <h3 id="writing-messages-to-the-javascript-console">Writing messages to the Java Script console</h3>
80 <p>You can send messages from your C/C++ code to JavaScript using the PostMessag e 81 <p>You can send messages from your C/C++ code to JavaScript using the
81 call in the <a class="reference internal" href="/native-client/devguide/coding/m essage-system.html"><em>Pepper messaging system</em></a>. When the 82 <code>PostMessage()</code> call in the <a class="reference internal" href="/nati ve-client/devguide/coding/message-system.html"><em>Pepper messaging system</em>< /a>. When the JavaScript code receives a message, its
82 JavaScript code receives a message, its message event handler can call 83 message event handler can call <a class="reference external" href="https://devel oper.mozilla.org/en/DOM/console.log">console.log()</a> to write the message to t he
83 <a class="reference external" href="https://developer.mozilla.org/en/DOM/console .log">console.log()</a> to write 84 JavaScript <a class="reference external" href="/devtools/docs/console-api">conso le</a> in Chrome&#8217;s Developer Tools.</p>
84 the message to the JavaScript <a class="reference external" href="/devtools/docs /console-api">console</a> in
85 Chrome&#8217;s Developer Tools.</p>
86 <h3 id="debugging-with-printf">Debugging with printf</h3> 85 <h3 id="debugging-with-printf">Debugging with printf</h3>
87 <p>Your C/C++ code can perform inline printf debugging to stdout and stderr by 86 <p>Your C/C++ code can perform inline printf debugging to stdout and stderr by
88 calling fprintf() directly, or by using cover functions like these:</p> 87 calling fprintf() directly, or by using cover functions like these:</p>
89 <pre class="prettyprint"> 88 <pre class="prettyprint">
90 #include &lt;stdio.h&gt; 89 #include &lt;stdio.h&gt;
91 void logmsg(const char* pMsg){ 90 void logmsg(const char* pMsg){
92 fprintf(stdout,&quot;logmsg: %s\n&quot;,pMsg); 91 fprintf(stdout,&quot;logmsg: %s\n&quot;,pMsg);
93 } 92 }
94 void errormsg(const char* pMsg){ 93 void errormsg(const char* pMsg){
95 fprintf(stderr,&quot;logerr: %s\n&quot;,pMsg); 94 fprintf(stderr,&quot;logerr: %s\n&quot;,pMsg);
96 } 95 }
97 </pre> 96 </pre>
98 <p>By default stdout and stderr will appear in Chrome&#8217;s stdout and stderr stream 97 <p>By default stdout and stderr will appear in Chrome&#8217;s stdout and stderr stream
99 but they can also be redirected as described below.</p> 98 but they can also be redirected as described below.</p>
100 <h4 id="redirecting-output-to-log-files">Redirecting output to log files</h4> 99 <h4 id="redirecting-output-to-log-files">Redirecting output to log files</h4>
101 <p>You can redirect stdout and stderr to output files by setting these environme nt variables:</p> 100 <p>You can redirect stdout and stderr to output files by setting these environme nt
101 variables:</p>
102 <ul class="small-gap"> 102 <ul class="small-gap">
103 <li><code>NACL_EXE_STDOUT=c:\nacl_stdout.log</code></li> 103 <li><code>NACL_EXE_STDOUT=c:\nacl_stdout.log</code></li>
104 <li><code>NACL_EXE_STDERR=c:\nacl_stderr.log</code></li> 104 <li><code>NACL_EXE_STDERR=c:\nacl_stderr.log</code></li>
105 </ul> 105 </ul>
106 <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
107 Client&#8217;s internally-generated messages. This variable is set to stderr by 107 Client&#8217;s internally-generated messages. This variable is set to stderr by
108 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
109 variable as follows:</p> 109 variable as follows:</p>
110 <ul class="small-gap"> 110 <ul class="small-gap">
111 <li><code>NACLLOG=c:\nacl.log</code></li> 111 <li><code>NACLLOG=c:\nacl.log</code></li>
112 </ul> 112 </ul>
113 <aside class="note"> 113 <aside class="note">
114 <strong>Note:</strong> If you set the NACL_EXE_STDOUT, NACL_EXE_STDERR, or NACLL OG 114 <strong>Note:</strong> If you set the <code>NACL_EXE_STDOUT</code>, <code>NACL_E XE_STDERR</code>, or
115 variables to redirect output to a file, you must run Chrome with the 115 <code>NACLLOG</code> variables to redirect output to a file, you must run Chrome with
116 <code>--no-sandbox</code> flag. You must also be careful that each variable poi nts to 116 the <code>--no-sandbox</code> flag. You must also be careful that each variable points
117 a different file. 117 to a different file.
118 </aside> 118 </aside>
119 <h4 id="redirecting-output-to-the-javascript-console">Redirecting output to the JavaScript console</h4> 119 <h4 id="redirecting-output-to-the-javascript-console">Redirecting output to the JavaScript console</h4>
120 <p>You can also cause output from printf statements in your C/C++ code to be 120 <p>You can also cause output from printf statements in your C/C++ code to be
121 relayed to the JavaScript side of your application through the Pepper messaging 121 relayed to the JavaScript side of your application through the Pepper messaging
122 system, where you can then write the output to the JavaScript console. Follow 122 system, where you can then write the output to the JavaScript console. Follow
123 these steps:</p> 123 these steps:</p>
124 <ol class="arabic"> 124 <ol class="arabic">
125 <li><p class="first">Set the NACL_EXE_STDOUT and NACL_EXE_STDERR environment var iables as 125 <li><p class="first">Set the <code>NACL_EXE_STDOUT</code> and <code>NACL_EXE_STD ERR</code> environment variables as
126 follows:</p> 126 follows:</p>
127 <ul class="small-gap"> 127 <ul class="small-gap">
128 <li><p class="first">NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage</p> 128 <li><p class="first"><code>NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage</code></ p>
129 </li> 129 </li>
130 <li><p class="first">NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage</p> 130 <li><p class="first"><code>NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage</code></ p>
131 </li> 131 </li>
132 </ul> 132 </ul>
133 <p>These settings tell Native Client to use PostMessage() to send output that 133 <p>These settings tell Native Client to use <code>PostMessage()</code> to send o utput
134 your Native Client module writes to stdout and stderr to the JavaScript side 134 that your Native Client module writes to stdout and stderr to the JavaScript
135 of your application.</p> 135 side of your application.</p>
136 </li> 136 </li>
137 <li><p class="first">Register a JavaScript handler to receive messages from your Native Client 137 <li><p class="first">Register a JavaScript handler to receive messages from your Native Client
138 module:</p> 138 module:</p>
139 <pre class="prettyprint"> 139 <pre class="prettyprint">
140 &lt;div id=&quot;nacl_container&quot;&gt; 140 &lt;div id=&quot;nacl_container&quot;&gt;
141 &lt;script type=&quot;text/javascript&quot;&gt; 141 &lt;script type=&quot;text/javascript&quot;&gt;
142 var container = document.getElementById('nacl_container'); 142 var container = document.getElementById('nacl_container');
143 container.addEventListener('message', handleMessage, true); 143 container.addEventListener('message', handleMessage, true);
144 &lt;/script&gt; 144 &lt;/script&gt;
145 &lt;embed id=&quot;nacl_module&quot; 145 &lt;embed id=&quot;nacl_module&quot;
146 src=&quot;my_application.nmf&quot; 146 src=&quot;my_application.nmf&quot;
147 type=&quot;application/x-nacl&quot; /&gt; 147 type=&quot;application/x-nacl&quot; /&gt;
148 &lt;/div&gt; 148 &lt;/div&gt;
149 </pre> 149 </pre>
150 </li> 150 </li>
151 <li><p class="first">Implement a simple JavaScript handler that logs the message s it receives to 151 <li><p class="first">Implement a simple JavaScript handler that logs the message s it receives to
152 the JavaScript console:</p> 152 the JavaScript console:</p>
153 <pre class="prettyprint"> 153 <pre class="prettyprint">
154 function handleMessage(message_event) { 154 function handleMessage(message_event) {
155 console.log(message_event.data); 155 console.log(message_event.data);
156 } 156 }
157 </pre> 157 </pre>
158 <p>This handler works in the simple case where the only messages your Native 158 <p>This handler works in the simple case where the only messages your Native
159 Client module sends to JavaScript are messages with the output from stdout 159 Client module sends to JavaScript are messages with the output from stdout
160 and stderr. If your Native Client module also sends other messages to 160 and stderr. If your Native Client module also sends other messages to
161 JavaScript, your handler will need to be more complex.</p> 161 JavaScript, your handler will need to be more complex.</p>
162 <p>Once you&#8217;ve implemented a message handler and set up the environment 162 <p>Once you&#8217;ve implemented a message handler and set up the environment
163 variables as described above, you can check the JavaScript console to see 163 variables as described above, you can check the JavaScript console to see
164 output that your Native Client module prints to stdout and stderr. Keep in 164 output that your Native Client module prints to stdout and stderr. Keep in
165 mind that your module makes a call to PostMessage() every time it flushes 165 mind that your module makes a call to <code>PostMessage()</code> every time it f lushes
166 stdout or stderr. Your application&#8217;s performance will degrade considerabl y 166 stdout or stderr. Your application&#8217;s performance will degrade considerabl y
167 if your module prints and flushes frequently, or if it makes frequent Pepper 167 if your module prints and flushes frequently, or if it makes frequent Pepper
168 calls to begin with (e.g., to render).</p> 168 calls to begin with (e.g., to render).</p>
169 </li> 169 </li>
170 </ol> 170 </ol>
171 <h3 id="logging-calls-to-pepper-interfaces">Logging calls to Pepper interfaces</ h3> 171 <h3 id="logging-calls-to-pepper-interfaces">Logging calls to Pepper interfaces</ h3>
172 <p>You can log all Pepper calls your module makes by passing the following flags 172 <p>You can log all Pepper calls your module makes by passing the following flags
173 to Chrome on startup:</p> 173 to Chrome on startup:</p>
174 <pre class="prettyprint"> 174 <pre class="prettyprint">
175 --vmodule=ppb*=4 --enable-logging=stderr 175 --vmodule=ppb*=4 --enable-logging=stderr
176 </pre> 176 </pre>
177 <p>The <code>vmodule</code> flag tells Chrome to log all calls to C Pepper inter faces that 177 <p>The <code>vmodule</code> flag tells Chrome to log all calls to C Pepper inter faces that
178 begin with &#8220;ppb&#8221; (that is, the interfaces that are implemented by th e browser 178 begin with &#8220;ppb&#8221; (that is, the interfaces that are implemented by th e browser
179 and that your module calls). The <code>enable-logging</code> flag tells Chrome t o log 179 and that your module calls). The <code>enable-logging</code> flag tells Chrome t o log
180 the calls to stderr.</p> 180 the calls to stderr.</p>
181 <h3 id="debugging-with-visual-studio"><span id="visual-studio"></span>Debugging with Visual Studio</h3> 181 <h3 id="debugging-with-visual-studio"><span id="visual-studio"></span>Debugging with Visual Studio</h3>
182 <p>If you develop on a Windows platform you can use the <a class="reference inte rnal" href="/native-client/devguide/devcycle/vs-addin.html"><em>Native Client Vi sual 182 <p>If you develop on a Windows platform you can use the <a class="reference inte rnal" href="/native-client/devguide/devcycle/vs-addin.html"><em>Native Client Vi sual
183 Studio add-in</em></a> to write and debug your code. The add-in defines new 183 Studio add-in</em></a> to write and debug your code. The add-in defines new
184 project platforms that let you run your module in two different modes: As a 184 project platforms that let you run your module in two different modes: As a
185 Pepper plugin and as a Native Client module. When running as a Pepper plugin 185 Pepper plugin and as a Native Client module. When running as a Pepper plugin
186 you can use the built-in Visual Studio debugger. When running as a Native 186 you can use the built-in Visual Studio debugger. When running as a Native
187 Client module Visual Studio will launch an instance of nacl-gdb for you and 187 Client module Visual Studio will launch an instance of nacl-gdb for you and
188 link it to the running code.</p> 188 link it to the running code.</p>
189 <h3 id="debugging-with-nacl-gdb"><span id="using-gdb"></span>Debugging with nacl -gdb</h3> 189 <h3 id="debugging-with-nacl-gdb"><span id="using-gdb"></span>Debugging with nacl -gdb</h3>
190 <p>The Native Client SDK includes a command-line debugger that you can use to 190 <p>The Native Client SDK includes a command-line debugger that you can use to
191 debug Native Client modules. The debugger is based on the GNU debugger <a class= "reference external" href="http://www.gnu.org/software/gdb/">gdb</a>, and is loc ated at 191 debug Native Client modules. The debugger is based on the GNU debugger <a class= "reference external" href="http://www.gnu.org/software/gdb/">gdb</a>, and is loc ated at
192 <code>toolchain/&lt;platform&gt;_x86_newlib/bin/x86_64-nacl-gdb</code> (where <e m>&lt;platform&gt;</em> 192 <code>pepper_&lt;version&gt;/toolchain/&lt;platform&gt;_x86_newlib/bin/x86_64-na cl-gdb</code> (where
193 is the platform of your development machine: <code>win</code>, <code>mac</code>, or 193 <em>&lt;platform&gt;</em> is the platform of your development machine: <code>win </code>, <code>mac</code>, or
194 <code>linux</code>).</p> 194 <code>linux</code>).</p>
195 <p>Note that this same copy of GDB can be used to debug any NaCl program, 195 <p>Note that this same copy of GDB can be used to debug any NaCl program,
196 whether built using newlib or glibc for x86-32, x86-64 or ARM. In the SDK, 196 whether built using newlib or glibc for x86-32, x86-64 or ARM. In the SDK,
197 <code>i686-nacl-gdb</code> is an alias for <code>x86_64-nacl-gdb</code>, and the <code>newlib</code> 197 <code>i686-nacl-gdb</code> is an alias for <code>x86_64-nacl-gdb</code>, and the <code>newlib</code>
198 and <code>glibc</code> toolchains both contain the same version of GDB.</p> 198 and <code>glibc</code> toolchains both contain the same version of GDB.</p>
199 <h4 id="debugging-pnacl-pexes-with-pepper-35"><span id="debugging-pnacl-pexes">< /span>Debugging PNaCl pexes (with Pepper 35+)</h4> 199 <h4 id="debugging-pnacl-pexes-pepper-35-or-later"><span id="debugging-pnacl-pexe s"></span>Debugging PNaCl pexes (Pepper 35 or later)</h4>
200 <p>If you want to use GDB to debug a program that is compiled with the PNaCl 200 <p>If you want to use GDB to debug a program that is compiled with the PNaCl
201 toolchain, you must have a copy of the pexe from <strong>before</strong> running 201 toolchain, you must have a copy of the pexe from <strong>before</strong> running
202 <code>pnacl-finalize</code>. The <code>pnacl-finalize</code> tool converts LLVM bitcode 202 <code>pnacl-finalize</code>. The <code>pnacl-finalize</code> tool converts LLVM bitcode
203 to the stable PNaCl bitcode format, but it also strips out debug 203 to the stable PNaCl bitcode format, but it also strips out debug
204 metadata, which we need for debugging. In this section we&#8217;ll give the 204 metadata, which we need for debugging. In this section we&#8217;ll give the
205 LLVM bitcode file a <code>.bc</code> file extension, and the PNaCl bitcode file 205 LLVM bitcode file a <code>.bc</code> file extension, and the PNaCl bitcode file
206 a <code>.pexe</code> file extension. The actual extension should not matter, but 206 a <code>.pexe</code> file extension. The actual extension should not matter, but
207 it helps distinguish between the two types of files.</p> 207 it helps distinguish between the two types of files.</p>
208 <p><strong>Note</strong> unlike the finalized copy of the pexe, the non-finalize d debug copy 208 <p><strong>Note</strong> unlike the finalized copy of the pexe, the non-finalize d debug copy
209 is not considered stable. This means that a debug copy of the PNaCl 209 is not considered stable. This means that a debug copy of the PNaCl
210 application created by a Pepper N SDK is only guaranteed to run 210 application created by a Pepper N SDK is only guaranteed to run
211 with a matching Chrome version N. If the version of the debug bitcode pexe 211 with a matching Chrome version N. If the version of the debug bitcode pexe
212 does not match that of Chrome then the translation process may fail, and 212 does not match that of Chrome then the translation process may fail, and
213 you will see and error message in the JavaScript console.</p> 213 you will see an error message in the JavaScript console.</p>
214 <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. 214 <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.
215 You might also want to omit <code>-O2</code> from the compile-time and link-time 215 You might also want to omit <code>-O2</code> from the compile-time and link-time
216 options, otherwise GDB not might be able to print variables&#8217; values when 216 options, otherwise GDB not might be able to print variables&#8217; values when
217 debugging (this is more of a problem with the PNaCl/LLVM toolchain than 217 debugging (this is more of a problem with the PNaCl/LLVM toolchain than
218 with GCC).</p> 218 with GCC).</p>
219 <p>Once you have built a non-stable debug copy of the pexe, list the URL of 219 <p>Once you have built a non-stable debug copy of the pexe, list the URL of
220 that copy in your application&#8217;s manifest file:</p> 220 that copy in your application&#8217;s manifest file:</p>
221 <pre class="prettyprint"> 221 <pre class="prettyprint">
222 { 222 {
223 &quot;program&quot;: { 223 &quot;program&quot;: {
(...skipping 26 matching lines...) Expand all
250 toolchain, you must convert the <code>pexe</code> file to a <code>nexe</code>. (You can skip 250 toolchain, you must convert the <code>pexe</code> file to a <code>nexe</code>. (You can skip
251 this step if you are using the GCC toolchain, or if you are using 251 this step if you are using the GCC toolchain, or if you are using
252 pepper 35 or later.)</p> 252 pepper 35 or later.)</p>
253 <ul class="small-gap"> 253 <ul class="small-gap">
254 <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. 254 <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.
255 You might also want to omit <code>-O2</code> from the compile-time and link-time 255 You might also want to omit <code>-O2</code> from the compile-time and link-time
256 options.</li> 256 options.</li>
257 <li><p class="first">Secondly, use <code>pnacl-translate</code> to convert your <code>pexe</code> to one or more 257 <li><p class="first">Secondly, use <code>pnacl-translate</code> to convert your <code>pexe</code> to one or more
258 <code>nexe</code> files. For example:</p> 258 <code>nexe</code> files. For example:</p>
259 <pre> 259 <pre>
260 &lt;NACL_SDK_ROOT&gt;/toolchain/win_pnacl/bin/pnacl-translate ^ 260 nacl_sdk/pepper_&lt;version&gt;/toolchain/win_pnacl/bin/pnacl-translate \
261 --allow-llvm-bitcode-input hello_world.pexe -arch x86-32 -o hello_world_x86_32 .nexe 261 --allow-llvm-bitcode-input hello_world.pexe -arch x86-32 \
262 &lt;NACL_SDK_ROOT&gt;/toolchain/win_pnacl/bin/pnacl-translate ^ 262 -o hello_world_x86_32.nexe
263 --allow-llvm-bitcode-input hello_world.pexe -arch x86-64 -o hello_world_x86_64 .nexe 263 nacl_sdk/pepper_&lt;version&gt;/toolchain/win_pnacl/bin/pnacl-translate \
264 --allow-llvm-bitcode-input hello_world.pexe -arch x86-64 \
265 -o hello_world_x86_64.nexe
264 </pre> 266 </pre>
265 <p>For this, use the non-finalized <code>pexe</code> file produced by 267 <p>For this, use the non-finalized <code>pexe</code> file produced by
266 <code>pnacl-clang</code>, not the <code>pexe</code> file produced by <code>pnacl -finalize</code>. 268 <code>pnacl-clang</code>, not the <code>pexe</code> file produced by <code>pnacl -finalize</code>.
267 The latter <code>pexe</code> has debugging info stripped out. The option 269 The latter <code>pexe</code> has debugging info stripped out. The option
268 <code>--allow-llvm-bitcode-input</code> tells <code>pnacl-translate</code> to ac cept a 270 <code>--allow-llvm-bitcode-input</code> tells <code>pnacl-translate</code> to ac cept a
269 non-finalized <code>pexe</code>.</p> 271 non-finalized <code>pexe</code>.</p>
270 </li> 272 </li>
271 <li><p class="first">Replace the <code>nmf</code> <a class="reference internal" href="/native-client/devguide/coding/application-structure.html#manifest-file">< em>manifest file</em></a> that points to 273 <li><p class="first">Replace the <code>nmf</code> <a class="reference internal" href="/native-client/devguide/coding/application-structure.html#manifest-file">< em>manifest file</em></a> that points to
272 your <code>pexe</code> file with one that points to the <code>nexe</code> files. For the 274 your <code>pexe</code> file with one that points to the <code>nexe</code> files. For the
273 example <code>nexe</code> filenames above, the new <code>nmf</code> file would c ontain:</p> 275 example <code>nexe</code> filenames above, the new <code>nmf</code> file would c ontain:</p>
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 </dl> 368 </dl>
367 </li> 369 </li>
368 <li><p class="first">Navigate to your application&#8217;s page in Chrome. (You d on&#8217;t need to do this if 370 <li><p class="first">Navigate to your application&#8217;s page in Chrome. (You d on&#8217;t need to do this if
369 you specified a URL when you launched Chrome in the previous step.) Chrome 371 you specified a URL when you launched Chrome in the previous step.) Chrome
370 will start loading the application, then pause and wait until you start 372 will start loading the application, then pause and wait until you start
371 nacl-gdb and run the <code>continue</code> command.</p> 373 nacl-gdb and run the <code>continue</code> command.</p>
372 </li> 374 </li>
373 <li><p class="first">Go to the directory with your source code, and run nacl-gdb from there. For 375 <li><p class="first">Go to the directory with your source code, and run nacl-gdb from there. For
374 example:</p> 376 example:</p>
375 <pre class="prettyprint"> 377 <pre class="prettyprint">
376 cd &lt;NACL_SDK_ROOT&gt;/examples/hello_world_gles 378 cd nacl_sdk/pepper_&lt;version&gt;/examples/demo/drive
377 &lt;NACL_SDK_ROOT&gt;/toolchain/win_x86_newlib/bin/x86_64-nacl-gdb 379 nacl_sdk/pepper_&lt;version&gt;/toolchain/win_x86_newlib/bin/x86_64-nacl-gdb
378 </pre> 380 </pre>
379 <p>The debugger will start and show you a gdb prompt:</p> 381 <p>The debugger will start and show you a gdb prompt:</p>
380 <pre class="prettyprint"> 382 <pre class="prettyprint">
381 (gdb) 383 (gdb)
382 </pre> 384 </pre>
383 </li> 385 </li>
384 <li><p class="first">For debugging PNaCl pexes run the following gdb command lin es 386 <li><p class="first">Run the debugging command lines.</p>
385 (skip to the next item if you are using NaCl instead of PNaCl):</p> 387 <p><strong>For PNaCl</strong>:</p>
386 <pre class="prettyprint"> 388 <pre class="prettyprint">
387 (gdb) target remote localhost:4014 389 (gdb) target remote localhost:4014
388 (gdb) remote get nexe &lt;path-to-save-translated-nexe-with-debug-info&gt; 390 (gdb) remote get nexe &lt;path-to-save-translated-nexe-with-debug-info&gt;
389 (gdb) file &lt;path-to-save-translated-nexe-with-debug-info&gt; 391 (gdb) file &lt;path-to-save-translated-nexe-with-debug-info&gt;
390 (gdb) remote get irt &lt;path-to-save-NaCl-integrated-runtime&gt; 392 (gdb) remote get irt &lt;path-to-save-NaCl-integrated-runtime&gt;
391 (gdb) nacl-irt &lt;path-to-saved-NaCl-integrated-runtime&gt; 393 (gdb) nacl-irt &lt;path-to-saved-NaCl-integrated-runtime&gt;
392 </pre> 394 </pre>
393 </li> 395 <p><strong>For NaCl</strong>:</p>
394 <li><p class="first">For NaCl nexes, run the following commands from the gdb com mand line:</p>
395 <pre class="prettyprint"> 396 <pre class="prettyprint">
396 (gdb) target remote localhost:4014 397 (gdb) target remote localhost:4014
397 (gdb) nacl-manifest &lt;path-to-your-.nmf-file&gt; 398 (gdb) nacl-manifest &lt;path-to-your-.nmf-file&gt;
398 (gdb) remote get irt &lt;path-to-save-NaCl-integrated-runtime&gt; 399 (gdb) remote get irt &lt;path-to-save-NaCl-integrated-runtime&gt;
399 (gdb) nacl-irt &lt;path-to-saved-NaCl-integrated-runtime&gt; 400 (gdb) nacl-irt &lt;path-to-saved-NaCl-integrated-runtime&gt;
400 </pre> 401 </pre>
401 </li> 402 </li>
402 <li><p class="first">The command used for PNaCl and NaCl are described below:</p > 403 <li><p class="first">The command used for PNaCl and NaCl are described below:</p >
403 <dl class="docutils"> 404 <dl class="docutils">
404 <dt><code>target remote localhost:4014</code></dt> 405 <dt><code>target remote localhost:4014</code></dt>
(...skipping 19 matching lines...) Expand all
424 </dd> 425 </dd>
425 <dt><code>remote get irt &lt;path&gt;</code></dt> 426 <dt><code>remote get irt &lt;path&gt;</code></dt>
426 <dd><p class="first last">This saves the Native Client Integrated Runtime (IRT). Normally, 427 <dd><p class="first last">This saves the Native Client Integrated Runtime (IRT). Normally,
427 the IRT is located in the same directory as the Chrome executable, 428 the IRT is located in the same directory as the Chrome executable,
428 or in a subdirectory named after the Chrome version. For example, if 429 or in a subdirectory named after the Chrome version. For example, if
429 you&#8217;re running Chrome canary on Windows, the path to the IRT typically 430 you&#8217;re running Chrome canary on Windows, the path to the IRT typically
430 looks something like <code>C:/Users/&lt;username&gt;/AppData/Local/Google/Chrome 431 looks something like <code>C:/Users/&lt;username&gt;/AppData/Local/Google/Chrome
431 SxS/Application/23.0.1247.1/nacl_irt_x86_64.nexe</code>. 432 SxS/Application/23.0.1247.1/nacl_irt_x86_64.nexe</code>.
432 The <code>remote get irt &lt;path&gt;</code> saves that to the current working 433 The <code>remote get irt &lt;path&gt;</code> saves that to the current working
433 directory so that you do not need to find where exactly the IRT 434 directory so that you do not need to find where exactly the IRT
434 is stored alongside Chrome.</p> 435 is stored.</p>
435 </dd> 436 </dd>
436 <dt><code>nacl-irt &lt;path&gt;</code></dt> 437 <dt><code>nacl-irt &lt;path&gt;</code></dt>
437 <dd><p class="first last">Tells the debugger where to find the Native Client Int egrated Runtime 438 <dd><p class="first last">Tells the debugger where to find the Native Client Int egrated Runtime
438 (IRT). <code>&lt;path&gt;</code> can either be the location of the copy saved by 439 (IRT). <code>&lt;path&gt;</code> can either be the location of the copy saved by
439 <code>remote get irt &lt;path&gt;</code> or the copy that is installed alongside Chrome.</p> 440 <code>remote get irt &lt;path&gt;</code> or the copy that is installed alongside Chrome.</p>
440 </dd> 441 </dd>
441 </dl> 442 </dl>
442 <p>A couple of notes on how to specify path names in the nacl-gdb commands 443 <p>A couple of notes on how to specify path names in the nacl-gdb commands
443 above:</p> 444 above:</p>
444 <ul class="small-gap"> 445 <ul class="small-gap">
445 <li><p class="first">You can use a forward slash to separate directories on Linu x, Mac, and 446 <li><p class="first">You can use a forward slash to separate directories on Linu x, Mac, and
446 Windows. If you use a backslash to separate directories on Windows, you 447 Windows. If you use a backslash to separate directories on Windows, you
447 must escape the backslash by using a double backslash &#8220;\&#8221; between 448 must escape the backslash by using a double backslash &#8220;\&#8221; between
448 directories.</p> 449 directories.</p>
449 </li> 450 </li>
450 <li><p class="first">If any directories in the path have spaces in their name, y ou must put 451 <li><p class="first">If any directories in the path have spaces in their name, y ou must put
451 quotation marks around the path.</p> 452 quotation marks around the path.</p>
452 </li> 453 </li>
453 </ul> 454 </ul>
454 <p>As an example, here is a what these nacl-gdb commands might look like on 455 <p>As an example, here is a what these nacl-gdb commands might look like on
455 Windows:</p> 456 Windows:</p>
456 <pre class="prettyprint"> 457 <pre class="prettyprint">
457 target remote localhost:4014 458 target remote localhost:4014
458 nacl-manifest &quot;C:/&lt;NACL_SDK_ROOT&gt;/examples/hello_world_gles/newlib/De bug/hello_world_gles.nmf&quot; 459 nacl-manifest &quot;C:/nacl_sdk/pepper_&lt;version&gt;/examples/hello_world_gles /newlib/Debug/hello_world_gles.nmf&quot;
459 nacl-irt &quot;C:/Users/&lt;username&gt;/AppData/Local/Google/Chrome SxS/Applica tion/23.0.1247.1/nacl_irt_x86_64.nexe&quot; 460 nacl-irt &quot;C:/Users/&lt;username&gt;/AppData/Local/Google/Chrome SxS/Applica tion/23.0.1247.1/nacl_irt_x86_64.nexe&quot;
460 </pre> 461 </pre>
461 <p>To save yourself some typing, you can put put these nacl-gdb commands in a 462 <p>To save yourself some typing, you can put put these nacl-gdb commands in a
462 script file, and execute the file when you run nacl-gdb, like so:</p> 463 script file, and execute the file when you run nacl-gdb, like so:</p>
463 <pre class="prettyprint"> 464 <pre class="prettyprint">
464 &lt;NACL_SDK_ROOT&gt;/toolchain/win_x86_newlib/bin/x86_64-nacl-gdb -x &lt;nacl-s cript-file&gt; 465 nacl_sdk/pepper_&lt;version&gt;/toolchain/win_x86_newlib/bin/x86_64-nacl-gdb -x &lt;nacl-script-file&gt;
465 </pre> 466 </pre>
466 <p>If nacl-gdb connects successfully to Chrome, it displays a message such as 467 <p>If nacl-gdb connects successfully to Chrome, it displays a message such as
467 the one below, followed by a gdb prompt:</p> 468 the one below, followed by a gdb prompt:</p>
468 <pre class="prettyprint"> 469 <pre class="prettyprint">
469 0x000000000fc00200 in _start () 470 0x000000000fc00200 in _start ()
470 (gdb) 471 (gdb)
471 </pre> 472 </pre>
472 <p>If nacl-gdb can&#8217;t connect to Chrome, it displays a message such as 473 <p>If nacl-gdb can&#8217;t connect to Chrome, it displays a message such as
473 &#8220;<code>localhost:4014: A connection attempt failed</code>&#8221; or &#8220 ;<code>localhost:4014: 474 &#8220;<code>localhost:4014: A connection attempt failed</code>&#8221; or &#8220 ;<code>localhost:4014:
474 Connection timed out.</code>&#8221; If you see a message like that, make sure th at you 475 Connection timed out.</code>&#8221; If you see a message like that, make sure th at you
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 includes pre-built libraries and library source code, making it much easier to 531 includes pre-built libraries and library source code, making it much easier to
531 build a module into a .DLL.</p> 532 build a module into a .DLL.</p>
532 <h3 id="open-source-profiling-tools">Open source profiling tools</h3> 533 <h3 id="open-source-profiling-tools">Open source profiling tools</h3>
533 <p>For the brave-hearted there are open source tools at <a class="reference exte rnal" href="http://www.chromium.org/nativeclient">Chromium.org</a> that describe how to do profiling on 534 <p>For the brave-hearted there are open source tools at <a class="reference exte rnal" href="http://www.chromium.org/nativeclient">Chromium.org</a> that describe how to do profiling on
534 <a class="reference external" href="https://sites.google.com/a/chromium.org/dev/ nativeclient/how-tos/profiling-nacl-apps-on-64-bit-windows">64-bit Windows</a> 535 <a class="reference external" href="https://sites.google.com/a/chromium.org/dev/ nativeclient/how-tos/profiling-nacl-apps-on-64-bit-windows">64-bit Windows</a>
535 and <a class="reference external" href="http://www.chromium.org/nativeclient/how -tos/limited-profiling-with-oprofile-on-x86-64">Linux</a> 536 and <a class="reference external" href="http://www.chromium.org/nativeclient/how -tos/limited-profiling-with-oprofile-on-x86-64">Linux</a>
536 machines.</p> 537 machines.</p>
537 </section> 538 </section>
538 539
539 {{/partials.standard_nacl_article}} 540 {{/partials.standard_nacl_article}}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698