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="id1">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="id2">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="id3">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
d4">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="id5">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="id6">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
7">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="id8">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=
"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> |
26 <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> |
27 <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> |
28 <ul class="small-gap"> | 28 <ul class="small-gap"> |
29 <li><a class="reference internal" href="#debugging-pnacl-pexes" id="id12">Debugg
ing PNaCl pexes</a></li> | 29 <li><a class="reference internal" href="#debugging-pnacl-pexes-with-pepper-35" i
d="id13">Debugging PNaCl pexes (with Pepper 35+)</a></li> |
30 <li><a class="reference internal" href="#running-nacl-gdb" id="id13">Running nac
l-gdb</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 </ul> | 32 </ul> |
32 </li> | 33 </li> |
33 </ul> | 34 </ul> |
34 </li> | 35 </li> |
35 <li><p class="first"><a class="reference internal" href="#debugging-with-other-t
ools" id="id14">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> |
36 <ul class="small-gap"> | 37 <ul class="small-gap"> |
37 <li><a class="reference internal" href="#open-source-profiling-tools" id="id15">
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> |
38 </ul> | 39 </ul> |
39 </li> | 40 </li> |
40 </ul> | 41 </ul> |
41 | 42 |
42 </div><section id="diagnostic-information"> | 43 </div><section id="diagnostic-information"> |
43 <h2 id="diagnostic-information">Diagnostic information</h2> | 44 <h2 id="diagnostic-information">Diagnostic information</h2> |
44 <section id="viewing-process-statistics-with-the-task-manager"> | 45 <section id="viewing-process-statistics-with-the-task-manager"> |
45 <h3 id="viewing-process-statistics-with-the-task-manager">Viewing process statis
tics with the task manager</h3> | 46 <h3 id="viewing-process-statistics-with-the-task-manager">Viewing process statis
tics with the task manager</h3> |
46 <p>You can use Chrome’s Task Manager to display information about a Native
Client | 47 <p>You can use Chrome’s Task Manager to display information about a Native
Client |
47 application:</p> | 48 application:</p> |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 <span id="using-gdb"></span><h3 id="debugging-with-nacl-gdb"><span id="using-gdb
"></span>Debugging with nacl-gdb</h3> | 203 <span id="using-gdb"></span><h3 id="debugging-with-nacl-gdb"><span id="using-gdb
"></span>Debugging with nacl-gdb</h3> |
203 <p>The Native Client SDK includes a command-line debugger that you can use to | 204 <p>The Native Client SDK includes a command-line debugger that you can use to |
204 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 | 205 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 |
205 <code>toolchain/<platform>_x86_newlib/bin/x86_64-nacl-gdb</code> (where <e
m><platform></em> | 206 <code>toolchain/<platform>_x86_newlib/bin/x86_64-nacl-gdb</code> (where <e
m><platform></em> |
206 is the platform of your development machine: <code>win</code>, <code>mac</code>,
or | 207 is the platform of your development machine: <code>win</code>, <code>mac</code>,
or |
207 <code>linux</code>).</p> | 208 <code>linux</code>).</p> |
208 <p>Note that this same copy of GDB can be used to debug any NaCl program, | 209 <p>Note that this same copy of GDB can be used to debug any NaCl program, |
209 whether built using newlib or glibc for x86-32, x86-64 or ARM. In the SDK, | 210 whether built using newlib or glibc for x86-32, x86-64 or ARM. In the SDK, |
210 <code>i686-nacl-gdb</code> is an alias for <code>x86_64-nacl-gdb</code>, and the
<code>newlib</code> | 211 <code>i686-nacl-gdb</code> is an alias for <code>x86_64-nacl-gdb</code>, and the
<code>newlib</code> |
211 and <code>glibc</code> toolchains both contain the same version of GDB.</p> | 212 and <code>glibc</code> toolchains both contain the same version of GDB.</p> |
212 <section id="debugging-pnacl-pexes"> | 213 <section id="debugging-pnacl-pexes-with-pepper-35"> |
213 <h4 id="debugging-pnacl-pexes">Debugging PNaCl pexes</h4> | 214 <h4 id="debugging-pnacl-pexes-with-pepper-35">Debugging PNaCl pexes (with Pepper
35+)</h4> |
| 215 <p>If you want to use GDB to debug a program that is compiled with the PNaCl |
| 216 toolchain, you must have a copy of the pexe from <strong>before</strong> running |
| 217 <code>pnacl-finalize</code>. The <code>pnacl-finalize</code> tool converts LLVM
bitcode |
| 218 to the stable PNaCl bitcode format, but it also strips out debug |
| 219 metadata, which we need for debugging.</p> |
| 220 <p><strong>Note</strong> unlike the finalized copy of the pexe, the non-finalize
d debug copy |
| 221 is not considered stable. This means that a debug copy of the PNaCl |
| 222 application created by a Pepper N SDK is only guaranteed to run |
| 223 with a matching Chrome version N. If the version of the debug bitcode pexe |
| 224 does not match that of Chrome then the translation process may fail, and |
| 225 you will see and error message in the JavaScript console.</p> |
| 226 <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. |
| 227 You might also want to omit <code>-O2</code> from the compile-time and link-time |
| 228 options, otherwise GDB not might be able to print variables’ values when |
| 229 debugging (this is more of a problem with the PNaCl/LLVM toolchain than |
| 230 with GCC).</p> |
| 231 <p>Once you have built a non-stable debug copy of the pexe, list the URL of |
| 232 that copy in your application’s manifest file:</p> |
| 233 <pre class="prettyprint"> |
| 234 { |
| 235 "program": { |
| 236 "pnacl-translate": { |
| 237 "url": "release_version.pexe", |
| 238 "optlevel": 2 |
| 239 }, |
| 240 "pnacl-debug": { |
| 241 "url": "debug_version.bc", |
| 242 "optlevel": 0 |
| 243 } |
| 244 } |
| 245 } |
| 246 </pre> |
| 247 <p>Copy the <code>debug_version.bc</code> and <code>nmf</code> files to the loca
tion that |
| 248 your local web server serves files from.</p> |
| 249 <p>When you run Chrome with <code>--enable-nacl-debug</code>, Chrome will transl
ate |
| 250 and run the <code>debug_version.bc</code> instead of <code>release_version.pexe<
/code>. |
| 251 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> |
| 252 <p>Whether you publish the NMF file containing the debug URL to the release |
| 253 web server, is up to you. One reason to avoid publishing the debug URL |
| 254 is that it is only guaranteed to work for the Chrome version that matches |
| 255 the SDK version. Developers who may have left the <code>--enable-nacl-debug</cod
e> |
| 256 flag turned on may end up loading the debug copy of your application |
| 257 (which may or may not work, depending on their version of Chrome).</p> |
| 258 </section><section id="debugging-pnacl-pexes-with-older-pepper-toolchains"> |
| 259 <h4 id="debugging-pnacl-pexes-with-older-pepper-toolchains">Debugging PNaCl pexe
s (with older Pepper toolchains)</h4> |
214 <p>If you want to use GDB to debug a program that is compiled with the PNaCl | 260 <p>If you want to use GDB to debug a program that is compiled with the PNaCl |
215 toolchain, you must convert the <code>pexe</code> file to a <code>nexe</code>.
(You can skip | 261 toolchain, you must convert the <code>pexe</code> file to a <code>nexe</code>.
(You can skip |
216 this step if you are using the GCC toolchain.)</p> | 262 this step if you are using the GCC toolchain, or if you are using |
| 263 pepper 35 or later.)</p> |
217 <ul class="small-gap"> | 264 <ul class="small-gap"> |
218 <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. | 265 <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. |
219 You might also want to omit <code>-O2</code> from the compile-time and link-time | 266 You might also want to omit <code>-O2</code> from the compile-time and link-time |
220 options, otherwise GDB not might be able to print variables’ values when | 267 options.</li> |
221 debugging (this is more of a problem with the PNaCl/LLVM toolchain than | |
222 with GCC).</li> | |
223 <li><p class="first">Secondly, use <code>pnacl-translate</code> to convert your
<code>pexe</code> to one or more | 268 <li><p class="first">Secondly, use <code>pnacl-translate</code> to convert your
<code>pexe</code> to one or more |
224 <code>nexe</code> files. For example:</p> | 269 <code>nexe</code> files. For example:</p> |
225 <pre> | 270 <pre> |
226 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-translate ^ | 271 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-translate ^ |
227 --allow-llvm-bitcode-input hello_world.pexe -arch x86-32 -o hello_world_x86_32
.nexe | 272 --allow-llvm-bitcode-input hello_world.pexe -arch x86-32 -o hello_world_x86_32
.nexe |
228 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-translate ^ | 273 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-translate ^ |
229 --allow-llvm-bitcode-input hello_world.pexe -arch x86-64 -o hello_world_x86_64
.nexe | 274 --allow-llvm-bitcode-input hello_world.pexe -arch x86-64 -o hello_world_x86_64
.nexe |
230 </pre> | 275 </pre> |
231 <p>For this, use the non-finalized <code>pexe</code> file produced by | 276 <p>For this, use the non-finalized <code>pexe</code> file produced by |
232 <code>pnacl-clang</code>, not the <code>pexe</code> file produced by <code>pnacl
-finalize</code>. | 277 <code>pnacl-clang</code>, not the <code>pexe</code> file produced by <code>pnacl
-finalize</code>. |
(...skipping 20 matching lines...) Expand all Loading... |
253 server serves files from.</li> | 298 server serves files from.</li> |
254 </ul> | 299 </ul> |
255 <aside class="note"> | 300 <aside class="note"> |
256 <strong>Note:</strong> If you know whether Chrome is using the x86-32 or x86-64 | 301 <strong>Note:</strong> If you know whether Chrome is using the x86-32 or x86-64 |
257 version of the NaCl sandbox on your system, you can translate the | 302 version of the NaCl sandbox on your system, you can translate the |
258 <code>pexe</code> once to a single x86-32 or x86-64 <code>nexe</code>. Otherwis
e, you | 303 <code>pexe</code> once to a single x86-32 or x86-64 <code>nexe</code>. Otherwis
e, you |
259 might find it easier to translate the <code>pexe</code> to both <code>nexe</code
> | 304 might find it easier to translate the <code>pexe</code> to both <code>nexe</code
> |
260 formats as described above. | 305 formats as described above. |
261 </aside> | 306 </aside> |
262 </section><section id="running-nacl-gdb"> | 307 </section><section id="running-nacl-gdb"> |
263 <h4 id="running-nacl-gdb">Running nacl-gdb</h4> | 308 <span id="id1"></span><h4 id="running-nacl-gdb"><span id="id1"></span>Running na
cl-gdb</h4> |
264 <p>Before you start using nacl-gdb, make sure you can <a class="reference intern
al" href="/native-client/devguide/devcycle/building.html"><em>build</em></a> you
r | 309 <p>Before you start using nacl-gdb, make sure you can <a class="reference intern
al" href="/native-client/devguide/devcycle/building.html"><em>build</em></a> you
r |
265 module and <a class="reference internal" href="/native-client/devguide/devcycle/
running.html"><em>run</em></a> your application normally. This will verify | 310 module and <a class="reference internal" href="/native-client/devguide/devcycle/
running.html"><em>run</em></a> your application normally. This will verify |
266 that you have created all the required <a class="reference internal" href="/nati
ve-client/devguide/coding/application-structure.html"><em>application parts</em>
</a> (.html, .nmf, and .nexe files, shared | 311 that you have created all the required <a class="reference internal" href="/nati
ve-client/devguide/coding/application-structure.html"><em>application parts</em>
</a> (.html, .nmf, and .nexe files, shared |
267 libraries, etc.), that your server can access those resources, and that you̵
7;ve | 312 libraries, etc.), that your server can access those resources, and that you̵
7;ve |
268 configured Chrome correctly to run your application. The instructions below | 313 configured Chrome correctly to run your application. The instructions below |
269 assume that you are using a <a class="reference internal" href="/native-client/d
evguide/devcycle/running.html#web-server"><em>local server</em></a> to run your | 314 assume that you are using a <a class="reference internal" href="/native-client/d
evguide/devcycle/running.html#web-server"><em>local server</em></a> to run your |
270 application; one benefit of doing it this way is that you can check the web | 315 application; one benefit of doing it this way is that you can check the web |
271 server output to confirm that your application is loading the correct | 316 server output to confirm that your application is loading the correct |
272 resources. However, some people prefer to run their application as an unpacked | 317 resources. However, some people prefer to run their application as an unpacked |
273 extension, as described in <a class="reference internal" href="/native-client/de
vguide/devcycle/running.html"><em>Running Native Client Applications</em></a>.</
p> | 318 extension, as described in <a class="reference internal" href="/native-client/de
vguide/devcycle/running.html"><em>Running Native Client Applications</em></a>.</
p> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 <dt><code>--disable-hang-monitor</code></dt> | 350 <dt><code>--disable-hang-monitor</code></dt> |
306 <dd><p class="first last">Prevents Chrome from displaying a warning when a tab i
s unresponsive.</p> | 351 <dd><p class="first last">Prevents Chrome from displaying a warning when a tab i
s unresponsive.</p> |
307 </dd> | 352 </dd> |
308 <dt><code>--user-data-dir=<directory></code></dt> | 353 <dt><code>--user-data-dir=<directory></code></dt> |
309 <dd><p class="first last">Specifies the <a class="reference external" href="http
://www.chromium.org/user-experience/user-data-directory">user data directory</a>
from which | 354 <dd><p class="first last">Specifies the <a class="reference external" href="http
://www.chromium.org/user-experience/user-data-directory">user data directory</a>
from which |
310 Chrome should load its state. You can specify a different user data | 355 Chrome should load its state. You can specify a different user data |
311 directory so that changes you make to Chrome in your debugging session do | 356 directory so that changes you make to Chrome in your debugging session do |
312 not affect your personal Chrome data (history, cookies, bookmarks, themes, | 357 not affect your personal Chrome data (history, cookies, bookmarks, themes, |
313 and settings).</p> | 358 and settings).</p> |
314 </dd> | 359 </dd> |
| 360 <dt><code>--nacl-debug-mask=<nmf_url_mask1,nmf_url_mask2,...></code></dt> |
| 361 <dd><p class="first last">Specifies a set of debug mask patterns. This allows yo
u to selectively |
| 362 choose to debug certain applications and not debug others. For example, |
| 363 if you only want to debug the NMF files for your applications at |
| 364 <code>https://example.com/app</code>, and no other NaCl applications found |
| 365 on the web, specify <code>--nacl-debug-mask=https://example.com/app/*.nmf</code>
. |
| 366 This helps prevent accidentally debugging other NaCl applications if |
| 367 you like to leave the <code>--enable-nacl-debug</code> flag turned on. |
| 368 The pattern language for the mask follows <a class="reference external" href="ht
tp://developer.chrome.com/extensions/match_patterns">chrome extension match patt
erns</a>. |
| 369 The pattern set can be inverted by prefixing the pattern set with |
| 370 the <code>!</code> character.</p> |
| 371 </dd> |
315 <dt><code><URL></code></dt> | 372 <dt><code><URL></code></dt> |
316 <dd><p class="first last">Specifies the URL Chrome should open when it launches.
The local server | 373 <dd><p class="first last">Specifies the URL Chrome should open when it launches.
The local server |
317 that comes with the SDK listens on port 5103 by default, so the URL when | 374 that comes with the SDK listens on port 5103 by default, so the URL when |
318 you’re debugging is typically <code>localhost:5103</code> (assuming that y
our | 375 you’re debugging is typically <code>localhost:5103</code> (assuming that y
our |
319 application’s page is called index.html and that you run the local server | 376 application’s page is called index.html and that you run the local server |
320 in the directory where that page is located).</p> | 377 in the directory where that page is located).</p> |
321 </dd> | 378 </dd> |
322 </dl> | 379 </dl> |
323 </li> | 380 </li> |
324 <li><p class="first">Navigate to your application’s page in Chrome. (You d
on’t need to do this if | 381 <li><p class="first">Navigate to your application’s page in Chrome. (You d
on’t need to do this if |
325 you specified a URL when you launched Chrome in the previous step.) Chrome | 382 you specified a URL when you launched Chrome in the previous step.) Chrome |
326 will start loading the application, then pause and wait until you start | 383 will start loading the application, then pause and wait until you start |
327 nacl-gdb and run the <code>continue</code> command.</p> | 384 nacl-gdb and run the <code>continue</code> command.</p> |
328 </li> | 385 </li> |
329 <li><p class="first">Go to the directory with your source code, and run nacl-gdb
from there. For | 386 <li><p class="first">Go to the directory with your source code, and run nacl-gdb
from there. For |
330 example:</p> | 387 example:</p> |
331 <pre class="prettyprint"> | 388 <pre class="prettyprint"> |
332 cd <NACL_SDK_ROOT>/examples/hello_world_gles | 389 cd <NACL_SDK_ROOT>/examples/hello_world_gles |
333 <NACL_SDK_ROOT>/toolchain/win_x86_newlib/bin/x86_64-nacl-gdb | 390 <NACL_SDK_ROOT>/toolchain/win_x86_newlib/bin/x86_64-nacl-gdb |
334 </pre> | 391 </pre> |
335 <p>The debugger will start and show you a gdb prompt:</p> | 392 <p>The debugger will start and show you a gdb prompt:</p> |
336 <pre class="prettyprint"> | 393 <pre class="prettyprint"> |
337 (gdb) | 394 (gdb) |
338 </pre> | 395 </pre> |
339 </li> | 396 </li> |
340 <li><p class="first">Run the following three commands from the gdb command line:
</p> | 397 <li><p class="first">For debugging PNaCl pexes run the following gdb command lin
es |
| 398 (skip to the next item if you are using NaCl instead of PNaCl):</p> |
341 <pre class="prettyprint"> | 399 <pre class="prettyprint"> |
| 400 (gdb) target remote localhost:4014 |
| 401 (gdb) remote get nexe <path-to-save-translated-nexe-with-debug-info> |
| 402 (gdb) file <path-to-save-translated-nexe-with-debug-info> |
| 403 (gdb) remote get irt <path-to-save-NaCl-integrated-runtime> |
| 404 (gdb) nacl-irt <path-to-saved-NaCl-integrated-runtime> |
| 405 </pre> |
| 406 </li> |
| 407 <li><p class="first">For NaCl nexes, run the following commands from the gdb com
mand line:</p> |
| 408 <pre class="prettyprint"> |
| 409 (gdb) target remote localhost:4014 |
342 (gdb) nacl-manifest <path-to-your-.nmf-file> | 410 (gdb) nacl-manifest <path-to-your-.nmf-file> |
343 (gdb) nacl-irt <path-to-Chrome-NaCl-integrated-runtime> | 411 (gdb) remote get irt <path-to-save-NaCl-integrated-runtime> |
344 (gdb) target remote localhost:4014 | 412 (gdb) nacl-irt <path-to-saved-NaCl-integrated-runtime> |
345 </pre> | 413 </pre> |
346 <p>These commands are described below:</p> | 414 </li> |
| 415 <li><p class="first">The command used for PNaCl and NaCl are described below:</p
> |
347 <dl class="docutils"> | 416 <dl class="docutils"> |
348 <dt><code>nacl-manifest <path></code></dt> | |
349 <dd><p class="first last">Tells the debugger about your Native Client applicatio
n by pointing it to | |
350 the application’s manifest (.nmf) file. The manifest file lists your | |
351 application’s executable (.nexe) files, as well as any libraries that are | |
352 linked with the application dynamically.</p> | |
353 </dd> | |
354 <dt><code>nacl-irt <path></code></dt> | |
355 <dd><p class="first last">Tells the debugger where to find the Native Client Int
egrated Runtime | |
356 (IRT). The IRT is located in the same directory as the Chrome executable, | |
357 or in a subdirectory named after the Chrome version. For example, if | |
358 you’re running Chrome canary on Windows, the path to the IRT typically | |
359 looks something like <code>C:/Users/<username>/AppData/Local/Google/Chrome | |
360 SxS/Application/23.0.1247.1/nacl_irt_x86_64.nexe</code>.</p> | |
361 </dd> | |
362 <dt><code>target remote localhost:4014</code></dt> | 417 <dt><code>target remote localhost:4014</code></dt> |
363 <dd><p class="first last">Tells the debugger how to connect to the debug stub in
the Native Client | 418 <dd><p class="first last">Tells the debugger how to connect to the debug stub in
the Native Client |
364 application loader. This connection occurs through TCP port 4014 (note | 419 application loader. This connection occurs through TCP port 4014 (note |
365 that this port is distinct from the port which the local web server uses | 420 that this port is distinct from the port which the local web server uses |
366 to listen for incoming requests, typically port 5103).</p> | 421 to listen for incoming requests, typically port 5103). If you are |
| 422 debugging multiple applications at the same time, the loader may choose |
| 423 a port that is different from the default 4014 port. See the Chrome |
| 424 task manager for the debug port.</p> |
| 425 </dd> |
| 426 <dt><code>remote get nexe <path></code></dt> |
| 427 <dd><p class="first last">This saves the application’s main executable (ne
xe) to <code><path></code>. |
| 428 For PNaCl, this provides a convenient way to access the nexe that is |
| 429 a <strong>result</strong> of translating your pexe. This can then be loaded with |
| 430 the <code>file <path></code> command.</p> |
| 431 </dd> |
| 432 <dt><code>nacl-manifest <path></code></dt> |
| 433 <dd><p class="first last">For NaCl (not PNaCl), this tells the debugger where to
find your |
| 434 application’s executable (.nexe) files. The application’s manifest |
| 435 (.nmf) file lists your application’s executable files, as well as any |
| 436 libraries that are linked with the application dynamically.</p> |
| 437 </dd> |
| 438 <dt><code>remote get irt <path></code></dt> |
| 439 <dd><p class="first last">This saves the Native Client Integrated Runtime (IRT).
Normally, |
| 440 the IRT is located in the same directory as the Chrome executable, |
| 441 or in a subdirectory named after the Chrome version. For example, if |
| 442 you’re running Chrome canary on Windows, the path to the IRT typically |
| 443 looks something like <code>C:/Users/<username>/AppData/Local/Google/Chrome |
| 444 SxS/Application/23.0.1247.1/nacl_irt_x86_64.nexe</code>. |
| 445 The <code>remote get irt <path></code> saves that to the current working |
| 446 directory so that you do not need to find where exactly the IRT |
| 447 is stored alongside Chrome.</p> |
| 448 </dd> |
| 449 <dt><code>nacl-irt <path></code></dt> |
| 450 <dd><p class="first last">Tells the debugger where to find the Native Client Int
egrated Runtime |
| 451 (IRT). <code><path></code> can either be the location of the copy saved by |
| 452 <code>remote get irt <path></code> or the copy that is installed alongside
Chrome.</p> |
367 </dd> | 453 </dd> |
368 </dl> | 454 </dl> |
369 <p>A couple of notes on how to specify path names in the nacl-gdb commands | 455 <p>A couple of notes on how to specify path names in the nacl-gdb commands |
370 above:</p> | 456 above:</p> |
371 <ul class="small-gap"> | 457 <ul class="small-gap"> |
372 <li><p class="first">You can use a forward slash to separate directories on Linu
x, Mac, and | 458 <li><p class="first">You can use a forward slash to separate directories on Linu
x, Mac, and |
373 Windows. If you use a backslash to separate directories on Windows, you | 459 Windows. If you use a backslash to separate directories on Windows, you |
374 must escape the backslash by using a double backslash “\” between | 460 must escape the backslash by using a double backslash “\” between |
375 directories.</p> | 461 directories.</p> |
376 </li> | 462 </li> |
377 <li><p class="first">If any directories in the path have spaces in their name, y
ou must put | 463 <li><p class="first">If any directories in the path have spaces in their name, y
ou must put |
378 quotation marks around the path.</p> | 464 quotation marks around the path.</p> |
379 </li> | 465 </li> |
380 </ul> | 466 </ul> |
381 <p>As an example, here is a what these nacl-gdb commands might look like on | 467 <p>As an example, here is a what these nacl-gdb commands might look like on |
382 Windows:</p> | 468 Windows:</p> |
383 <pre class="prettyprint"> | 469 <pre class="prettyprint"> |
| 470 target remote localhost:4014 |
384 nacl-manifest "C:/<NACL_SDK_ROOT>/examples/hello_world_gles/newlib/De
bug/hello_world_gles.nmf" | 471 nacl-manifest "C:/<NACL_SDK_ROOT>/examples/hello_world_gles/newlib/De
bug/hello_world_gles.nmf" |
385 nacl-irt "C:/Users/<username>/AppData/Local/Google/Chrome SxS/Applica
tion/23.0.1247.1/nacl_irt_x86_64.nexe" | 472 nacl-irt "C:/Users/<username>/AppData/Local/Google/Chrome SxS/Applica
tion/23.0.1247.1/nacl_irt_x86_64.nexe" |
386 target remote localhost:4014 | |
387 </pre> | 473 </pre> |
388 <p>To save yourself some typing, you can put put these nacl-gdb commands in a | 474 <p>To save yourself some typing, you can put put these nacl-gdb commands in a |
389 script file, and execute the file when you run nacl-gdb, like so:</p> | 475 script file, and execute the file when you run nacl-gdb, like so:</p> |
390 <pre class="prettyprint"> | 476 <pre class="prettyprint"> |
391 <NACL_SDK_ROOT>/toolchain/win_x86_newlib/bin/x86_64-nacl-gdb -x <nacl-s
cript-file> | 477 <NACL_SDK_ROOT>/toolchain/win_x86_newlib/bin/x86_64-nacl-gdb -x <nacl-s
cript-file> |
392 </pre> | 478 </pre> |
393 <p>If nacl-gdb connects successfully to Chrome, it displays a message such as | 479 <p>If nacl-gdb connects successfully to Chrome, it displays a message such as |
394 the one below, followed by a gdb prompt:</p> | 480 the one below, followed by a gdb prompt:</p> |
395 <pre class="prettyprint"> | 481 <pre class="prettyprint"> |
396 0x000000000fc00200 in _start () | 482 0x000000000fc00200 in _start () |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 build a module into a .DLL.</p> | 545 build a module into a .DLL.</p> |
460 <section id="open-source-profiling-tools"> | 546 <section id="open-source-profiling-tools"> |
461 <h3 id="open-source-profiling-tools">Open source profiling tools</h3> | 547 <h3 id="open-source-profiling-tools">Open source profiling tools</h3> |
462 <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 | 548 <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 |
463 <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> | 549 <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> |
464 and <a class="reference external" href="http://www.chromium.org/nativeclient/how
-tos/limited-profiling-with-oprofile-on-x86-64">Linux</a> | 550 and <a class="reference external" href="http://www.chromium.org/nativeclient/how
-tos/limited-profiling-with-oprofile-on-x86-64">Linux</a> |
465 machines.</p> | 551 machines.</p> |
466 </section></section></section> | 552 </section></section></section> |
467 | 553 |
468 {{/partials.standard_nacl_article}} | 554 {{/partials.standard_nacl_article}} |
OLD | NEW |