forked from zheka/nacl-gdb-release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
184 lines (128 loc) · 5.46 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
Getting Started with x86-64 NaCl GDB
------------------------------------
Check updates of this document online at
http://www.chromium.org/nativeclient/how-tos/debugging-documentation/getting-started-with-x86-64-nacl-gdb
Introduction
------------
The alpha version of nacl64-gdb – a debugger based on gdb – allows you to debug
statically linked as well as dynamically linked Native Client applications
running in Chrome. Currently, only 64-bit Windows and 64-bit Linux are
supported.
Get the Debugger
----------------
You can download a binary package that contains the debugger itself together
with few sample NaCl applications to try. Alternatively, you can build the
debugger from source.
(Windows) Get the Debugger
--------------------------
Download and unpack
http://gsdview.appspot.com/nativeclient-archive2/gdb/latest/nacl64-gdb-win64.zip
(Linux) Get the Debugger
------------------------
Download and unpack
http://gsdview.appspot.com/nativeclient-archive2/gdb/latest/nacl64-gdb-linux64.zip
Build from Source
-----------------
Download and unpack
http://gsdview.appspot.com/nativeclient-archive2/gdb/latest/nacl64-gdb-src.zip
Coming soon: Guide to compiling nac64-gdb.
Prepare Your Chrome
-------------------
(Windows) Get Chrome
--------------------
On Windows, this debugging method is supported only in very recent versions of
Chrome. Check that your version is 19.0.1045 or newer (in dev channel as of
Feb 29, 2012).
If your Chrome version is older and you don't want to upgrade, we suggest
debugging using a recent build of Chromium from
http://gsdview.appspot.com/chromium-browser-continuous/
Try revision 122720 or higher:
http://gsdview.appspot.com/chromium-browser-continuous/Win/122720/chrome-win32.zip
(Linux) Get Chrome
------------------
ATTENTION! Unfortunately, Linux build of Google Chrome does not include symbol
information, which is required for debugging, so you can't debug within your
Google Chrome.
Instead, debug using a recent build of Chromium from
http://gsdview.appspot.com/chromium-browser-continuous/
Try revision 122720 or higher:
http://gsdview.appspot.com/chromium-browser-continuous/Linux_x64/122720/chrome-linux.zip
Configure Chrome
----------------
To run NaCl applications not installed from Chrome Web Store, you have to enable
Native Client for all web pages in Chrome. Navigate to about:flags, find
"Native Client", and click Enable – then scroll to bottom and click
"Relaunch Now".
When the app is stopped in the debugger, Chrome might consider the page is
hanging. You can use command line flag --disable-hang-monitor to prevent Chrome
asking to kill what it thinks is hanging.
Try the Examples
----------------
Let's refer to the folder you've got after unpacking the debugger as GDB.
Change directory to
GDB\examples
Here you have a number of NaCl examples to try the debugger on. Start an http
server to serve the files from this directory. For example, if you have Python
installed, you can use it for this task by running
python -m SimpleHTTPServer
to serve on port 8000 or
python -m SimpleHTTPServer PORT
to serve on PORT.
Now launch Chrome, and navigate to http://localhost:8000. Try the links to the
individual examples, check they all work.
Run "Hello, World! (C)" Example
-------------------------------
For simplicity, let's focus on a particular example
GDB\examples\hello_world_c
Navigate your browser to http://localhost:8000 and click a link to
"Hello, World! (C)".
Run the Debugger
----------------
For even more simplicity, let's make the directory that contains the example our
working directory. Change directory to
GDB\examples\hello_world_c
Now run the debugger and specify NaCl binaries to debug.
(Windows) Run the Debugger
--------------------------
GDB/win64/nacl64-gdb.exe
(Linux) Run the Debugger
------------------------
GDB\linux64\nacl64-gdb
Specify NaCl Binaries to Debug
------------------------------
At the debugger command prompt, specify full paths to your local NaCl binaries.
First, tell the debugger about where to find the NaCl Integrated Runtime (IRT).
It should be located in the directory where your Chrome executable is, or in a
sub-directory named after the Chrome version. If your Chrome is installed in a
directory named CHROME, issue
(gdb) nacl-irt CHROME\nacl_irt_x86_64.nexe
Next, tell the debugger about the NaCl application itself. Do this by telling
the debugger where the corresponding manifest file is
(gdb) nacl-manifest GDB\examples\hello_world_c\hello_world_dbg.nmf
Attach the Debugger
-------------------
Navigate your Chrome to about:memory. Find the "Native Client module" process
and notice its PID (process id).
Now tell the debugger to attach
(gdb) attach PID
Try Debugging "Hello, World! (C)" Example
-----------------------------------------
Set the breakpoint and continue
(gdb) b FortyTwo
(gdb) c
In the browser, in our "Hello, World! (C)" example window, press
"call fortyTwo()" button. Execution should now stop in the debugger.
Continue at will. Try checking the source, the backtrace, etc.
(gdb) li
(gdb) bt
See the official gdb documentation for more information on using gdb.
Try Debugging "Interactive Cube (C++)" Example
----------------------------------------------
The "Interactive Cube (C++)" is much more complex than "Hello, World! (C)".
You'll be able to try more interesting debugging commands, for example, to
examine local variables.
"Interactive Cube (C++)" sources and binaries reside in
GDB\examples\tumbler
Breakpoint to begin with might be
(gdb) b tumbler::Tumbler::DrawSelf
Happy debugging!