Skip to content

Commit 3fe4a66

Browse files
committed
Add info on -wrapper gdb--args
1 parent ba4fa6d commit 3fe4a66

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

docs/getting-involved.rst

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,44 @@ There are three test suites:
220220
Debugging the plugin's C code
221221
-----------------------------
222222

223-
The `gcc` binary is a harness that launches subprocesses, so it can be fiddly
224-
to debug.
223+
The `gcc` binary is a harness that launches subprocesses, so it can be
224+
fiddly to debug. Exactly what it launches depend on the inputs and
225+
options. Typically, the subprocesses it launches are (in order):
225226

226-
When debugging, I've generally been adding "-v" to the gcc command line
227-
(verbose), so that it outputs the commands that it's running. I can then use
227+
* `cc1` or `cc1plus`: The C or C++ compiler, generating a .s assember
228+
file.
229+
* `as`: The assembler, converting a .s assembler file to a .o object
230+
file.
231+
* `collect2`: The linker, turning one or more .o files into an executable
232+
(if you're going all the way to building an `a.out`-style executable).
233+
234+
The easiest way to debug the plugin is to add these parameters to the gcc
235+
command line (e.g. to the end)::
236+
237+
-wrapper gdb,--args
238+
239+
Note the lack of space between the comma and the `--args`.
240+
241+
e.g.::
242+
243+
./gcc-with-python examples/show-docs.py test.c -wrapper gdb,--args
244+
245+
This will invoke each of the subprocesses in turn under gdb: e.g. `cc1`,
246+
`as` and `collect2`; the plugin runs with `cc1` (`cc1plus` for C++ code).
247+
248+
For example::
249+
250+
$ ./gcc-with-cpychecker -c -I/usr/include/python2.7 demo.c -wrapper gdb,--args
251+
252+
GNU gdb (GDB) Fedora 7.6.50.20130731-19.fc20
253+
[...snip...]
254+
Reading symbols from /usr/libexec/gcc/x86_64-redhat-linux/4.8.2/cc1...Reading symbols from /usr/lib/debug/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/cc1.debug...done.
255+
done.
256+
(gdb) run
257+
[...etc...]
258+
259+
Another way to do it is to add "-v" to the gcc command line
260+
(verbose), so that it outputs the commands that it's running. You can then use
228261
this to launch::
229262

230263
$ gdb --args ACTUAL PROGRAM WITH ACTUAL ARGS

0 commit comments

Comments
 (0)