OLD | NEW |
1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
2 | 2 |
3 <span class="target" id="sdk-examples-2"></span><section id="examples"> | 3 <span class="target" id="sdk-examples-2"></span><section id="examples"> |
4 <h1 id="examples">Examples</h1> | 4 <h1 id="examples">Examples</h1> |
5 <p>Every Native Client SDK bundle comes with a folder of example applications. | 5 <p>Every Native Client SDK bundle comes with a folder of example applications. |
6 Each example demonstrates one or two key Native Client programming concepts. | 6 Each example demonstrates one or two key Native Client programming concepts. |
7 After you’ve <a class="reference internal" href="/native-client/sdk/downlo
ad.html"><em>downloaded the SDK</em></a>, follow the instructions | 7 After you’ve <a class="reference internal" href="/native-client/sdk/downlo
ad.html"><em>downloaded the SDK</em></a>, follow the instructions |
8 on this page to build and run the examples.</p> | 8 on this page to build and run the examples.</p> |
9 <p>Your version of Chrome must be equal to or greater than the version of your S
DK | 9 <p>Your version of Chrome must be equal to or greater than the version of your S
DK |
10 bundle. For example, if you’re developing with the <code>pepper_35</code>
bundle, you | 10 bundle. For example, if you’re developing with the <code>pepper_35</code>
bundle, you |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 application bundle, not the top-level <code>.app</code> directory:</p> | 161 application bundle, not the top-level <code>.app</code> directory:</p> |
162 <pre class="prettyprint"> | 162 <pre class="prettyprint"> |
163 $ export CHROME_PATH=<Path to Google Chrome> | 163 $ export CHROME_PATH=<Path to Google Chrome> |
164 </pre> | 164 </pre> |
165 </li> | 165 </li> |
166 </ul> | 166 </ul> |
167 <h2 id="run-the-sdk-examples-as-packaged-apps"><span id="run-sdk-examples-as-pac
kaged"></span>Run the SDK examples as packaged apps</h2> | 167 <h2 id="run-the-sdk-examples-as-packaged-apps"><span id="run-sdk-examples-as-pac
kaged"></span>Run the SDK examples as packaged apps</h2> |
168 <p>Each example can also be launched as a packaged application. A packaged | 168 <p>Each example can also be launched as a packaged application. A packaged |
169 application is a special zip file (with a .crx extension) hosted in the Chrome | 169 application is a special zip file (with a .crx extension) hosted in the Chrome |
170 Web Store. This file contains all of the application parts: A Chrome Web Store | 170 Web Store. This file contains all of the application parts: A Chrome Web Store |
171 manifest file (manifest.json), an icon, and all of the regular Native Client | 171 manifest file (<code>manifest.json</code>), an icon, and all of the regular Nati
ve Client |
172 application files. Refer to <a class="reference external" href="/apps/about_apps
">What are Chrome Apps</a> for more | 172 application files. Refer to <a class="reference external" href="/apps/about_apps
">What are Chrome Apps</a> for more |
173 information about creating a packaged application.</p> | 173 information about creating a packaged application.</p> |
174 <p>Some Pepper features, such as TCP/UDP socket access, are only allowed in | 174 <p>Some Pepper features, such as <a class="reference external" href="pepper_stab
le/cpp/classpp_1_1_u_d_p_socket">TCP</a> or <a class="reference external" href="
pepper_stable/cpp/classpp_1_1_u_d_p_socket">UDP</a> socket access, are only allo
wed |
175 packaged applications. The examples that use these features must be run as | 175 in <a class="reference external" href="/apps/about_apps">packaged applications</
a>. The examples that use these |
176 packaged applications, by using the following command:</p> | 176 features must be run as <a class="reference external" href="/apps/about_apps">pa
ckaged applications</a>, by using |
| 177 the following command:</p> |
177 <pre class="prettyprint"> | 178 <pre class="prettyprint"> |
178 $ make run_package | 179 $ make run_package |
179 </pre> | 180 </pre> |
180 <p>You can use <code>TOOLCHAIN</code> and <code>CONFIG</code> parameters as desc
ribed above to run | 181 <p>You can use <code>TOOLCHAIN</code> and <code>CONFIG</code> parameters as desc
ribed above to run |
181 with a different toolchain or configuration.</p> | 182 with a different toolchain or configuration.</p> |
182 <h2 id="debugging-the-sdk-examples"><span id="id4"></span>Debugging the SDK exam
ples</h2> | 183 <h2 id="debugging-the-sdk-examples"><span id="id5"></span>Debugging the SDK exam
ples</h2> |
183 <p>The NaCl SDK uses <a class="reference external" href="https://www.gnu.org/sof
tware/gdb/">GDB</a> to debug Native | 184 <p>The NaCl SDK uses <a class="reference external" href="https://www.gnu.org/sof
tware/gdb/">GDB</a> to debug Native |
184 Client code. The SDK includes a prebuilt version of GDB that is compatible with | 185 Client code. The SDK includes a prebuilt version of GDB that is compatible with |
185 NaCl code. To use it, run the <code>make debug</code> command from an example di
rectory:</p> | 186 NaCl code. To use it, run the <code>make debug</code> command from an example di
rectory:</p> |
186 <pre class="prettyprint"> | 187 <pre class="prettyprint"> |
187 $ make debug | 188 $ make debug |
188 </pre> | 189 </pre> |
189 <p>This launches Chrome with the <code>--enable-nacl-debug</code> flag set. This
flag causes | 190 <p>This launches Chrome with the <code>--enable-nacl-debug</code> flag set. This
flag causes |
190 Chrome to pause when a NaCl module is first loaded, waiting for a connection | 191 Chrome to pause when a NaCl module is first loaded, waiting for a connection |
191 from gdb. The <code>make debug</code> command also simultaneously launches GDB a
nd loads | 192 from gdb. The <code>make debug</code> command also simultaneously launches GDB a
nd loads |
192 the symbols for that NEXE. To connect GDB to Chrome, in the GDB console, type:</
p> | 193 the symbols for that NEXE. To connect GDB to Chrome, in the GDB console, type:</
p> |
193 <pre class="prettyprint"> | 194 <pre class="prettyprint"> |
194 (gdb) target remote :4014 | 195 (gdb) target remote :4014 |
195 </pre> | 196 </pre> |
196 <p>This tells GDB to connect to a TCP port on <code>localhost:4014</code>, the p
ort that | 197 <p>This tells GDB to connect to a TCP port on <code>localhost:4014</code>, the p
ort that |
197 Chrome is listening on. GDB will respond:</p> | 198 Chrome is listening on. GDB will respond:</p> |
198 <pre class="prettyprint"> | 199 <pre class="prettyprint"> |
199 Remote debugging using :4014 | 200 Remote debugging using :4014 |
200 0x000000000fa00080 in ?? () | 201 0x000000000fa00080 in ?? () |
201 </pre> | 202 </pre> |
202 <p>At this point, you can use the standard GDB commands to debug your NaCl modul
e. | 203 <p>At this point, you can use the standard GDB commands to debug your NaCl modul
e. |
203 The most common commands you will use to debug are <code>continue</code>, <code>
step</code>, | 204 The most common commands you will use to debug are <code>continue</code>, <code>
step</code>, |
204 <code>next</code>, <code>break</code> and <code>backtrace</code>. See | 205 <code>next</code>, <code>break</code> and <code>backtrace</code>. See |
205 <a class="reference internal" href="/native-client/devguide/devcycle/debugging.h
tml"><em>Debugging</em></a> for more information about | 206 <a class="reference internal" href="/native-client/devguide/devcycle/debugging.h
tml"><em>Debugging</em></a> for more information about |
206 debugging a Native Client application.</p> | 207 debugging a Native Client application.</p> |
207 </section> | 208 </section> |
208 | 209 |
209 {{/partials.standard_nacl_article}} | 210 {{/partials.standard_nacl_article}} |
OLD | NEW |