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

Side by Side Diff: native_client_sdk/src/doc/devguide/devcycle/debugging.rst

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
« no previous file with comments | « native_client_sdk/src/doc/devguide/coding/nacl_io.rst ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 .. _devcycle-debugging: 1 .. _devcycle-debugging:
2 2
3 ######### 3 #########
4 Debugging 4 Debugging
5 ######### 5 #########
6 6
7 This document describes tools and techniques you can use to debug, monitor, 7 This document describes tools and techniques you can use to debug, monitor,
8 and measure your application's performance. 8 and measure your application's performance.
9 9
10 .. contents:: Table Of Contents 10 .. contents:: Table Of Contents
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 .. naclcode:: 79 .. naclcode::
80 80
81 #include <stdio.h> 81 #include <stdio.h>
82 void logmsg(const char* pMsg){ 82 void logmsg(const char* pMsg){
83 fprintf(stdout,"logmsg: %s\n",pMsg); 83 fprintf(stdout,"logmsg: %s\n",pMsg);
84 } 84 }
85 void errormsg(const char* pMsg){ 85 void errormsg(const char* pMsg){
86 fprintf(stderr,"logerr: %s\n",pMsg); 86 fprintf(stderr,"logerr: %s\n",pMsg);
87 } 87 }
88 88
89 .. _using-chromes-stdout-and-stderr:
90
91 Using Chrome's stdout and stderr Streams
92 ----------------------------------------
93
89 By default stdout and stderr will appear in Chrome's stdout and stderr stream 94 By default stdout and stderr will appear in Chrome's stdout and stderr stream
90 but they can also be redirected as described below. 95 but they can also be redirected to log files. (See the next section.) On Mac and
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't attach to an existin g
98 instance. One simple way to do this is to pass a new directory to chrome as your
99 user data directory (``chrome --user-data-dir=<newdir>``).
91 100
101 .. _redirecting-output-to-log:
92 102
93 Redirecting output to log files 103 Redirecting output to log files
94 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 104 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95 105
96 You can redirect stdout and stderr to output files by setting these environment 106 You can redirect stdout and stderr to output files by setting these environment
97 variables: 107 variables:
98 108
99 * ``NACL_EXE_STDOUT=c:\nacl_stdout.log`` 109 * ``NACL_EXE_STDOUT=c:\nacl_stdout.log``
100 * ``NACL_EXE_STDERR=c:\nacl_stderr.log`` 110 * ``NACL_EXE_STDERR=c:\nacl_stderr.log``
101 111
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 a ``.pexe`` file extension. The actual extension should not matter, but 182 a ``.pexe`` file extension. The actual extension should not matter, but
173 it helps distinguish between the two types of files. 183 it helps distinguish between the two types of files.
174 184
175 **Note** unlike the finalized copy of the pexe, the non-finalized debug copy 185 **Note** unlike the finalized copy of the pexe, the non-finalized debug copy
176 is not considered stable. This means that a debug copy of the PNaCl 186 is not considered stable. This means that a debug copy of the PNaCl
177 application created by a Pepper N SDK is only guaranteed to run 187 application created by a Pepper N SDK is only guaranteed to run
178 with a matching Chrome version N. If the version of the debug bitcode pexe 188 with a matching Chrome version N. If the version of the debug bitcode pexe
179 does not match that of Chrome then the translation process may fail, and 189 does not match that of Chrome then the translation process may fail, and
180 you will see an error message in the JavaScript console. 190 you will see an error message in the JavaScript console.
181 191
182 Also, make sure you are passing the ``-g`` :ref:`compile option 192 Also, make sure you are passing the ``-g`` :ref:`compile option <compile_flags>`
183 <compile_flags>` to ``pnacl-clang`` to enable generating debugging info. 193 to ``pnacl-clang`` to enable generating debugging info. You might also want to
184 You might also want to omit ``-O2`` from the compile-time and link-time 194 omit ``-O2`` from the compile-time and link-time options, otherwise GDB not
185 options, otherwise GDB not might be able to print variables' values when 195 might be able to print variables' values when debugging (this is more of a
186 debugging (this is more of a problem with the PNaCl/LLVM toolchain than 196 problem with the PNaCl/LLVM toolchain than with GCC).
187 with GCC).
188 197
189 Once you have built a non-stable debug copy of the pexe, list the URL of 198 Once you have built a non-stable debug copy of the pexe, list the URL of
190 that copy in your application's manifest file: 199 that copy in your application's manifest file:
191 200
192 .. naclcode:: 201 .. naclcode::
193 202
194 { 203 {
195 "program": { 204 "program": {
196 "portable": { 205 "portable": {
197 "pnacl-translate": { 206 "pnacl-translate": {
198 "url": "release_version.pexe", 207 "url": "release_version.pexe",
199 "optlevel": 2 208 "optlevel": 2
200 }, 209 },
201 "pnacl-debug": { 210 "pnacl-debug": {
202 "url": "debug_version.bc", 211 "url": "debug_version.bc",
203 "optlevel": 0 212 "optlevel": 0
204 } 213 }
205 } 214 }
206 } 215 }
207 } 216 }
208 217
209 Copy the ``debug_version.bc`` and ``nmf`` files to the location that 218 Copy the ``debug_version.bc`` and ``nmf`` files to the location that
210 your local web server serves files from. 219 your local web server serves files from.
211 220
212 When you run Chrome with ``--enable-nacl-debug``, Chrome will translate 221 When you run Chrome with ``--enable-nacl-debug``, Chrome will translate
213 and run the ``debug_version.bc`` instead of ``release_version.pexe``. 222 and run the ``debug_version.bc`` instead of ``release_version.pexe``.
214 Once the debug version is loaded, you are ready to :ref:`run nacl-gdb 223 Once the debug version is loaded, you are ready to :ref:`run nacl-gdb
215 <running_nacl_gdb>` 224 <running_nacl_gdb>`
216 225
217 Whether you publish the NMF file containing the debug URL to the release 226 Whether you publish the NMF file containing the debug URL to the
218 web server, is up to you. One reason to avoid publishing the debug URL 227 release web server, is up to you. One reason to avoid publishing the
219 is that it is only guaranteed to work for the Chrome version that matches 228 debug URL is that it is only guaranteed to work for the Chrome version
220 the SDK version. Developers who may have left the ``--enable-nacl-debug`` 229 that matches the SDK version. Developers who may have left the
221 flag turned on may end up loading the debug copy of your application 230 ``--enable-nacl-debug`` flag turned on may end up loading the debug
222 (which may or may not work, depending on their version of Chrome). 231 copy of your application (which may or may not work, depending on
232 their version of Chrome).
223 233
224 234
225 Debugging PNaCl pexes (with older Pepper toolchains) 235 Debugging PNaCl pexes (with older Pepper toolchains)
226 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 236 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
227 237
228 If you want to use GDB to debug a program that is compiled with the PNaCl 238 If you want to use GDB to debug a program that is compiled with the PNaCl
229 toolchain, you must convert the ``pexe`` file to a ``nexe``. (You can skip 239 toolchain, you must convert the ``pexe`` file to a ``nexe``. (You can skip
230 this step if you are using the GCC toolchain, or if you are using 240 this step if you are using the GCC toolchain, or if you are using
231 pepper 35 or later.) 241 pepper 35 or later.)
232 242
233 * Firstly, make sure you are passing the ``-g`` :ref:`compile option 243 * Firstly, make sure you are passing the ``-g`` :ref:`compile option
234 <compile_flags>` to ``pnacl-clang`` to enable generating debugging info. 244 <compile_flags>` to ``pnacl-clang`` to enable generating debugging info.
235 You might also want to omit ``-O2`` from the compile-time and link-time 245 You might also want to omit ``-O2`` from the compile-time and link-time
236 options. 246 options.
237 247
238 * Secondly, use ``pnacl-translate`` to convert your ``pexe`` to one or more 248 * Secondly, use ``pnacl-translate`` to convert your ``pexe`` to one or more
249
239 ``nexe`` files. For example: 250 ``nexe`` files. For example:
240 251
241 .. naclcode:: 252 .. naclcode::
242 :prettyprint: 0 253 :prettyprint: 0
243 254
244 nacl_sdk/pepper_<version>/toolchain/win_pnacl/bin/pnacl-translate \ 255 nacl_sdk/pepper_<version>/toolchain/win_pnacl/bin/pnacl-translate \
245 --allow-llvm-bitcode-input hello_world.pexe -arch x86-32 \ 256 --allow-llvm-bitcode-input hello_world.pexe -arch x86-32 \
246 -o hello_world_x86_32.nexe 257 -o hello_world_x86_32.nexe
247 nacl_sdk/pepper_<version>/toolchain/win_pnacl/bin/pnacl-translate \ 258 nacl_sdk/pepper_<version>/toolchain/win_pnacl/bin/pnacl-translate \
248 --allow-llvm-bitcode-input hello_world.pexe -arch x86-64 \ 259 --allow-llvm-bitcode-input hello_world.pexe -arch x86-64 \
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 529
519 If you cannot use the :ref:`Visual Studio add-in <visual_studio>`, or you want 530 If you cannot use the :ref:`Visual Studio add-in <visual_studio>`, or you want
520 to use a debugger other than nacl-gdb, you must manually build your module as a 531 to use a debugger other than nacl-gdb, you must manually build your module as a
521 Pepper plugin (sometimes referred to as a "`trusted 532 Pepper plugin (sometimes referred to as a "`trusted
522 <http://www.chromium.org/nativeclient/getting-started/getting-started-background -and-basics#TOC-Trusted-vs-Untrusted>`_" 533 <http://www.chromium.org/nativeclient/getting-started/getting-started-background -and-basics#TOC-Trusted-vs-Untrusted>`_"
523 or "in-process" plugin). Pepper plugins (.DLL files on Windows; .so files on 534 or "in-process" plugin). Pepper plugins (.DLL files on Windows; .so files on
524 Linux; .bundle files on Mac) are loaded directly in either the Chrome renderer 535 Linux; .bundle files on Mac) are loaded directly in either the Chrome renderer
525 process or a separate plugin process, rather than in Native Client. Building a 536 process or a separate plugin process, rather than in Native Client. Building a
526 module as a trusted Pepper plugin allows you to use standard debuggers and 537 module as a trusted Pepper plugin allows you to use standard debuggers and
527 development tools on your system, but when you're finished developing the 538 development tools on your system, but when you're finished developing the
528 plugin, you need to port it to Native Client (i.e., build the module with one 539 plugin, you need to port it to Native Client (i.e., build the module with one of
529 of the toolchains in the NaCl SDK so that the module runs in Native Client). 540 the toolchains in the NaCl SDK so that the module runs in Native Client). For
530 For details on this advanced development technique, see `Debugging a Trusted 541 details on this advanced development technique, see `Debugging a Trusted Plugin
531 Plugin
532 <http://www.chromium.org/nativeclient/how-tos/debugging-documentation/debugging- a-trusted-plugin>`_. 542 <http://www.chromium.org/nativeclient/how-tos/debugging-documentation/debugging- a-trusted-plugin>`_.
533 Note that starting with the ``pepper_22`` bundle, the NaCl SDK for Windows 543 Note that starting with the ``pepper_22`` bundle, the NaCl SDK for Windows
534 includes pre-built libraries and library source code, making it much easier to 544 includes pre-built libraries and library source code, making it much easier to
535 build a module into a .DLL. 545 build a module into a .DLL.
536 546
537
538 .. |menu-icon| image:: /images/menu-icon.png 547 .. |menu-icon| image:: /images/menu-icon.png
539 .. |puzzle| image:: /images/puzzle.png 548 .. |puzzle| image:: /images/puzzle.png
OLDNEW
« no previous file with comments | « native_client_sdk/src/doc/devguide/coding/nacl_io.rst ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698