| OLD | NEW |
| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 * ``NACLLOG=c:\nacl.log`` | 107 * ``NACLLOG=c:\nacl.log`` |
| 108 | 108 |
| 109 .. Note:: | 109 .. Note:: |
| 110 :class: note | 110 :class: note |
| 111 | 111 |
| 112 **Note:** If you set the ``NACL_EXE_STDOUT``, ``NACL_EXE_STDERR``, or | 112 **Note:** If you set the ``NACL_EXE_STDOUT``, ``NACL_EXE_STDERR``, or |
| 113 ``NACLLOG`` variables to redirect output to a file, you must run Chrome with | 113 ``NACLLOG`` variables to redirect output to a file, you must run Chrome with |
| 114 the ``--no-sandbox`` flag. You must also be careful that each variable points | 114 the ``--no-sandbox`` flag. You must also be careful that each variable points |
| 115 to a different file. | 115 to a different file. |
| 116 | 116 |
| 117 Redirecting output to the JavaScript console | |
| 118 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 119 | |
| 120 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 | |
| 122 system, where you can then write the output to the JavaScript console. Follow | |
| 123 these steps: | |
| 124 | |
| 125 #. Set the ``NACL_EXE_STDOUT`` and ``NACL_EXE_STDERR`` environment variables as | |
| 126 follows: | |
| 127 | |
| 128 * ``NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage`` | |
| 129 * ``NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage`` | |
| 130 | |
| 131 These settings tell Native Client to use ``PostMessage()`` to send output | |
| 132 that your Native Client module writes to stdout and stderr to the JavaScript | |
| 133 side of your application. | |
| 134 | |
| 135 #. Register a JavaScript handler to receive messages from your Native Client | |
| 136 module: | |
| 137 | |
| 138 .. naclcode:: | |
| 139 | |
| 140 <div id="nacl_container"> | |
| 141 <script type="text/javascript"> | |
| 142 var container = document.getElementById('nacl_container'); | |
| 143 container.addEventListener('message', handleMessage, true); | |
| 144 </script> | |
| 145 <embed id="nacl_module" | |
| 146 src="my_application.nmf" | |
| 147 type="application/x-nacl" /> | |
| 148 </div> | |
| 149 | |
| 150 #. Implement a simple JavaScript handler that logs the messages it receives to | |
| 151 the JavaScript console: | |
| 152 | |
| 153 .. naclcode:: | |
| 154 | |
| 155 function handleMessage(message_event) { | |
| 156 console.log(message_event.data); | |
| 157 } | |
| 158 | |
| 159 This handler works in the simple case where the only messages your Native | |
| 160 Client module sends to JavaScript are messages with the output from stdout | |
| 161 and stderr. If your Native Client module also sends other messages to | |
| 162 JavaScript, your handler will need to be more complex. | |
| 163 | |
| 164 Once you've implemented a message handler and set up the environment | |
| 165 variables as described above, you can check the JavaScript console to see | |
| 166 output that your Native Client module prints to stdout and stderr. Keep in | |
| 167 mind that your module makes a call to ``PostMessage()`` every time it flushes | |
| 168 stdout or stderr. Your application's performance will degrade considerably | |
| 169 if your module prints and flushes frequently, or if it makes frequent Pepper | |
| 170 calls to begin with (e.g., to render). | |
| 171 | |
| 172 Logging calls to Pepper interfaces | 117 Logging calls to Pepper interfaces |
| 173 ---------------------------------- | 118 ---------------------------------- |
| 174 | 119 |
| 175 You can log all Pepper calls your module makes by passing the following flags | 120 You can log all Pepper calls your module makes by passing the following flags |
| 176 to Chrome on startup:: | 121 to Chrome on startup:: |
| 177 | 122 |
| 178 --vmodule=ppb*=4 --enable-logging=stderr | 123 --vmodule=ppb*=4 --enable-logging=stderr |
| 179 | 124 |
| 180 | 125 |
| 181 The ``vmodule`` flag tells Chrome to log all calls to C Pepper interfaces that | 126 The ``vmodule`` flag tells Chrome to log all calls to C Pepper interfaces that |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 <http://www.chromium.org/nativeclient>`_ that describe how to do profiling on | 541 <http://www.chromium.org/nativeclient>`_ that describe how to do profiling on |
| 597 `64-bit Windows | 542 `64-bit Windows |
| 598 <https://sites.google.com/a/chromium.org/dev/nativeclient/how-tos/profiling-nacl
-apps-on-64-bit-windows>`_ | 543 <https://sites.google.com/a/chromium.org/dev/nativeclient/how-tos/profiling-nacl
-apps-on-64-bit-windows>`_ |
| 599 and `Linux | 544 and `Linux |
| 600 <http://www.chromium.org/nativeclient/how-tos/limited-profiling-with-oprofile-on
-x86-64>`_ | 545 <http://www.chromium.org/nativeclient/how-tos/limited-profiling-with-oprofile-on
-x86-64>`_ |
| 601 machines. | 546 machines. |
| 602 | 547 |
| 603 | 548 |
| 604 .. |menu-icon| image:: /images/menu-icon.png | 549 .. |menu-icon| image:: /images/menu-icon.png |
| 605 .. |puzzle| image:: /images/puzzle.png | 550 .. |puzzle| image:: /images/puzzle.png |
| OLD | NEW |