OLD | NEW |
1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
2 | 2 |
3 <section id="running-the-sdk-examples"> | 3 <section id="running-the-sdk-examples"> |
4 <span id="sdk-examples-2"></span><h1 id="running-the-sdk-examples"><span id="sdk
-examples-2"></span>Running the SDK Examples</h1> | 4 <span id="sdk-examples-2"></span><h1 id="running-the-sdk-examples"><span id="sdk
-examples-2"></span>Running the SDK 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 <section id="configure-the-google-chrome-browser"> | |
10 <h2 id="configure-the-google-chrome-browser">Configure the Google Chrome Browser
</h2> | 9 <h2 id="configure-the-google-chrome-browser">Configure the Google Chrome Browser
</h2> |
11 <ol class="arabic"> | 10 <ol class="arabic"> |
12 <li><p class="first">Your version of Chrome must be equal to or greater than the
version of | 11 <li><p class="first">Your version of Chrome must be equal to or greater than the
version of |
13 your SDK bundle. For example, if you’re developing with the <code>pepper_3
1</code> | 12 your SDK bundle. For example, if you’re developing with the <code>pepper_3
1</code> |
14 bundle, you must use Google Chrome version 31 or greater. To find out what | 13 bundle, you must use Google Chrome version 31 or greater. To find out what |
15 version of Chrome you’re using, type <code>about:chrome</code> or <code>ab
out:version</code> | 14 version of Chrome you’re using, type <code>about:chrome</code> or <code>ab
out:version</code> |
16 in the Chrome address bar.</p> | 15 in the Chrome address bar.</p> |
17 </li> | 16 </li> |
18 <li><p class="first">For Portable Native Client, no extra Chrome flags are neede
d as of | 17 <li><p class="first">For Portable Native Client, no extra Chrome flags are neede
d as of |
19 Chrome version 31.</p> | 18 Chrome version 31.</p> |
(...skipping 25 matching lines...) Expand all Loading... |
45 choosing Tools > Developer tools.</p> | 44 choosing Tools > Developer tools.</p> |
46 </li> | 45 </li> |
47 <li><p class="first">Click the gear icon <img alt="gear-icon" src="/native-clien
t/images/gear-icon.png" /> in the bottom right corner of the | 46 <li><p class="first">Click the gear icon <img alt="gear-icon" src="/native-clien
t/images/gear-icon.png" /> in the bottom right corner of the |
48 Chrome window.</p> | 47 Chrome window.</p> |
49 </li> | 48 </li> |
50 <li><p class="first">Under the “General” settings, check the box nex
t to “Disable cache”.</p> | 49 <li><p class="first">Under the “General” settings, check the box nex
t to “Disable cache”.</p> |
51 </li> | 50 </li> |
52 </ul> | 51 </ul> |
53 </li> | 52 </li> |
54 </ol> | 53 </ol> |
55 </section><section id="build-the-sdk-examples"> | |
56 <h2 id="build-the-sdk-examples">Build the SDK examples</h2> | 54 <h2 id="build-the-sdk-examples">Build the SDK examples</h2> |
57 <p>Starting with the <code>pepper_24</code> bundle, the Makefile scripts for the
SDK | 55 <p>Starting with the <code>pepper_24</code> bundle, the Makefile scripts for the
SDK |
58 examples build multiple versions of the examples using all three SDK | 56 examples build multiple versions of the examples using all three SDK |
59 toolchains (newlib, glibc, and PNaCl) and in both release and debug | 57 toolchains (newlib, glibc, and PNaCl) and in both release and debug |
60 configurations. (Note that some examples build only with the particular | 58 configurations. (Note that some examples build only with the particular |
61 toolchains).</p> | 59 toolchains).</p> |
62 <p>To build all the examples, go to the examples directory in a specific SDK | 60 <p>To build all the examples, go to the examples directory in a specific SDK |
63 bundle and run <code>make</code>:</p> | 61 bundle and run <code>make</code>:</p> |
64 <pre class="prettyprint"> | 62 <pre class="prettyprint"> |
65 $ cd pepper_31/examples | 63 $ cd pepper_31/examples |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 </ul> | 145 </ul> |
148 <p>For the newlib and glibc toolchains the Debug and Release subdirectories | 146 <p>For the newlib and glibc toolchains the Debug and Release subdirectories |
149 contain .nexe files for all target architectures. For the PNaCl toolchain | 147 contain .nexe files for all target architectures. For the PNaCl toolchain |
150 they contain a single .pexe file. PNaCl debug also produces pre-translated | 148 they contain a single .pexe file. PNaCl debug also produces pre-translated |
151 .nexe files, for ease of debugging. All Debug and Release directories contain | 149 .nexe files, for ease of debugging. All Debug and Release directories contain |
152 a manifest (.nmf) file that references the associated .nexe or .pexe files. | 150 a manifest (.nmf) file that references the associated .nexe or .pexe files. |
153 For information about Native Client manifest files, see the <a class="reference
internal" href="/native-client/overview.html"><em>Technical | 151 For information about Native Client manifest files, see the <a class="reference
internal" href="/native-client/overview.html"><em>Technical |
154 Overview</em></a>.</p> | 152 Overview</em></a>.</p> |
155 <p>For details on how to use <code>make</code>, see the <a class="reference exte
rnal" href="http://www.gnu.org/software/make/manual/make.html">GNU ‘make&#
8217; Manual</a>. For details on how to | 153 <p>For details on how to use <code>make</code>, see the <a class="reference exte
rnal" href="http://www.gnu.org/software/make/manual/make.html">GNU ‘make&#
8217; Manual</a>. For details on how to |
156 use the SDK toolchain itself, see <a class="reference internal" href="/native-cl
ient/devguide/devcycle/building.html"><em>Building Native Client Modules</em></a
>.</p> | 154 use the SDK toolchain itself, see <a class="reference internal" href="/native-cl
ient/devguide/devcycle/building.html"><em>Building Native Client Modules</em></a
>.</p> |
157 </section><section id="run-the-sdk-examples"> | 155 <h2 id="run-the-sdk-examples"><span id="id1"></span>Run the SDK examples</h2> |
158 <span id="id1"></span><h2 id="run-the-sdk-examples"><span id="id1"></span>Run th
e SDK examples</h2> | |
159 <p>To run the SDK examples, you can use the <code>make run</code> command:</p> | 156 <p>To run the SDK examples, you can use the <code>make run</code> command:</p> |
160 <pre class="prettyprint"> | 157 <pre class="prettyprint"> |
161 $ cd pepper_31/examples/api/core | 158 $ cd pepper_31/examples/api/core |
162 $ make run | 159 $ make run |
163 </pre> | 160 </pre> |
164 <p>This will launch a local HTTP server which will serve the data for the | 161 <p>This will launch a local HTTP server which will serve the data for the |
165 example. It then launches Chrome with the address of this server, usually | 162 example. It then launches Chrome with the address of this server, usually |
166 <code>http://localhost:5103</code>. After you close Chrome, the local HTTP serve
r is | 163 <code>http://localhost:5103</code>. After you close Chrome, the local HTTP serve
r is |
167 automatically shutdown.</p> | 164 automatically shutdown.</p> |
168 <p>This command will try to find an executable named <code>google-chrome</code>
in your | 165 <p>This command will try to find an executable named <code>google-chrome</code>
in your |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 <pre class="prettyprint"> | 197 <pre class="prettyprint"> |
201 $ export CHROME_PATH=<Path to Google Chrome> | 198 $ export CHROME_PATH=<Path to Google Chrome> |
202 </pre> | 199 </pre> |
203 </li> | 200 </li> |
204 </ul> | 201 </ul> |
205 <p>You can run via a different toolchain or configuration by using the | 202 <p>You can run via a different toolchain or configuration by using the |
206 <code>TOOLCHAIN</code> and <code>CONFIG</code> parameters to make:</p> | 203 <code>TOOLCHAIN</code> and <code>CONFIG</code> parameters to make:</p> |
207 <pre class="prettyprint"> | 204 <pre class="prettyprint"> |
208 $ make run TOOLCHAIN=pnacl CONFIG=Debug | 205 $ make run TOOLCHAIN=pnacl CONFIG=Debug |
209 </pre> | 206 </pre> |
210 </section><section id="run-the-sdk-examples-as-packaged-apps"> | 207 <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> |
211 <span id="run-sdk-examples-as-packaged"></span><h2 id="run-the-sdk-examples-as-p
ackaged-apps"><span id="run-sdk-examples-as-packaged"></span>Run the SDK example
s as packaged apps</h2> | |
212 <p>Each example can also be launched as a packaged app. For more information abo
ut | 208 <p>Each example can also be launched as a packaged app. For more information abo
ut |
213 using Native Client for packaged apps, see <a class="reference internal" href="/
native-client/devguide/distributing.html#distributing-packaged"><em>Packaged app
lication</em></a>. For general information about packaged apps, see the | 209 using Native Client for packaged apps, see <a class="reference internal" href="/
native-client/devguide/distributing.html#distributing-packaged"><em>Packaged app
lication</em></a>. For general information about packaged apps, see the |
214 <a class="reference external" href="/apps/about_apps">Chrome apps documentation<
/a>.</p> | 210 <a class="reference external" href="/apps/about_apps">Chrome apps documentation<
/a>.</p> |
215 <p>Some Pepper features, such as TCP/UDP socket access, are only allowed in | 211 <p>Some Pepper features, such as TCP/UDP socket access, are only allowed in |
216 packaged apps. The examples that use these features must be run as packaged | 212 packaged apps. The examples that use these features must be run as packaged |
217 apps, by using the <code>make run_package</code> command:</p> | 213 apps, by using the <code>make run_package</code> command:</p> |
218 <pre class="prettyprint"> | 214 <pre class="prettyprint"> |
219 $ make run_package | 215 $ make run_package |
220 </pre> | 216 </pre> |
221 <p>You can use <code>TOOLCHAIN</code> and <code>CONFIG</code> parameters as abov
e to run with a | 217 <p>You can use <code>TOOLCHAIN</code> and <code>CONFIG</code> parameters as abov
e to run with a |
222 different toolchain or configuration.</p> | 218 different toolchain or configuration.</p> |
223 </section><section id="debugging-the-sdk-examples"> | 219 <h2 id="debugging-the-sdk-examples"><span id="id2"></span>Debugging the SDK exam
ples</h2> |
224 <span id="id2"></span><h2 id="debugging-the-sdk-examples"><span id="id2"></span>
Debugging the SDK examples</h2> | |
225 <p>The NaCl SDK uses <a class="reference external" href="https://www.gnu.org/sof
tware/gdb/">GDB</a> to debug Native | 220 <p>The NaCl SDK uses <a class="reference external" href="https://www.gnu.org/sof
tware/gdb/">GDB</a> to debug Native |
226 Client code. The SDK includes a prebuilt version of GDB that is compatible with | 221 Client code. The SDK includes a prebuilt version of GDB that is compatible with |
227 NaCl code. To use it, run the <code>make debug</code> command from an example di
rectory:</p> | 222 NaCl code. To use it, run the <code>make debug</code> command from an example di
rectory:</p> |
228 <pre class="prettyprint"> | 223 <pre class="prettyprint"> |
229 $ make debug | 224 $ make debug |
230 </pre> | 225 </pre> |
231 <p>This will launch Chrome with the <code>--enable-nacl-debug</code> flag set. T
his flag | 226 <p>This will launch Chrome with the <code>--enable-nacl-debug</code> flag set. T
his flag |
232 will cause Chrome to pause when a NaCl module is first loaded, waiting for a | 227 will cause Chrome to pause when a NaCl module is first loaded, waiting for a |
233 connection from gdb. The <code>make debug</code> command also simultaneously lau
nches | 228 connection from gdb. The <code>make debug</code> command also simultaneously lau
nches |
234 GDB and loads the symbols for that NEXE. To connect GDB to Chrome, in the GDB | 229 GDB and loads the symbols for that NEXE. To connect GDB to Chrome, in the GDB |
235 console, type:</p> | 230 console, type:</p> |
236 <pre class="prettyprint"> | 231 <pre class="prettyprint"> |
237 (gdb) target remote :4014 | 232 (gdb) target remote :4014 |
238 </pre> | 233 </pre> |
239 <p>This tells GDB to connect to a TCP port on <code>localhost:4014</code>–
the port that | 234 <p>This tells GDB to connect to a TCP port on <code>localhost:4014</code>–
the port that |
240 Chrome is listening on. GDB will respond:</p> | 235 Chrome is listening on. GDB will respond:</p> |
241 <pre class="prettyprint"> | 236 <pre class="prettyprint"> |
242 Remote debugging using :4014 | 237 Remote debugging using :4014 |
243 0x000000000fa00080 in ?? () | 238 0x000000000fa00080 in ?? () |
244 </pre> | 239 </pre> |
245 <p>At this point, you can use the standard GDB commands to debug your NaCl modul
e. | 240 <p>At this point, you can use the standard GDB commands to debug your NaCl modul
e. |
246 The most common commands you will use to debug are <code>continue</code>, <code>
step</code>, | 241 The most common commands you will use to debug are <code>continue</code>, <code>
step</code>, |
247 <code>next</code>, <code>break</code> and <code>backtrace</code>. See <a class="
reference internal" href="/native-client/devguide/devcycle/debugging.html"><em>D
ebugging</em></a> for more information about debugging a Native Client | 242 <code>next</code>, <code>break</code> and <code>backtrace</code>. See <a class="
reference internal" href="/native-client/devguide/devcycle/debugging.html"><em>D
ebugging</em></a> for more information about debugging a Native Client |
248 application.</p> | 243 application.</p> |
249 </section></section> | 244 </section> |
250 | 245 |
251 {{/partials.standard_nacl_article}} | 246 {{/partials.standard_nacl_article}} |
OLD | NEW |