This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 00/14] let gdb reuse gcc's C compiler
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 16 May 2014 09:26:21 -0600
- Subject: [PATCH 00/14] let gdb reuse gcc's C compiler
- Authentication-results: sourceware.org; auth=none
Hi!
This patch series is half of a project to let gdb reuse gcc (which
half depends on which list you are seeing this on), so that users can
compile small snippets of code and evaluate them in the current
context of the inferior.
This first series implements this idea for C. A user can compile a
code snippet and it will be inserted into the inferior and evaluated.
Declarations needed by the snippet are supplied by gdb, and there is a
bit of magic so that the snippets can refer to local variables in the
current frame.
The new command allows for arbitrary code to be inserted -- not just
expressions. For example:
(gdb) compile code int i; for (i = 0; i < 3; ++i) printf ("#%d\n", i)
#0
#1
#2
This series supplies a gcc plugin to do most of the work, so that any
gcc crashes -- seen during development due to translation bugs -- do
not also crash gdb.
The interface between gdb and gcc is defined by a few files added to
include/.
There is a new shared library which gdb loads in order to communicate
with the gcc plugin. This library communicates with the gcc plugin
using a simple, ad-hoc RPC mechanism.
This shared library exports a single public function which is used to
instantiate any needed objects. This makes it simple to version the
API and avoid undue synchronization between gcc and gdb.
We think the plugin is best suited to be put into the gcc repository
because it is coupled more tightly to gcc than to gdb.
To try it out, just build gcc and gdb with the patches applied. Then
set your PATH and LD_LIBRARY_PATH to point to the right subdirectories
of the new gcc install directory.
In later series we plan to extend this functionality; either on the
gcc side, say by writing a similar plugin for C++; or on the gdb side,
say by making it possible to compile breakpoint conditions. However,
we haven't yet decided exactly which future projects we will tackle or
in what order.