annotate gcc/jit/docs/topics/locations.rst @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1 .. Copyright (C) 2014-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
2 Originally contributed by David Malcolm <dmalcolm@redhat.com>
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This is free software: you can redistribute it and/or modify it
kono
parents:
diff changeset
5 under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
6 the Free Software Foundation, either version 3 of the License, or
kono
parents:
diff changeset
7 (at your option) any later version.
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 This program is distributed in the hope that it will be useful, but
kono
parents:
diff changeset
10 WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
kono
parents:
diff changeset
12 General Public License for more details.
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
15 along with this program. If not, see
kono
parents:
diff changeset
16 <http://www.gnu.org/licenses/>.
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 .. default-domain:: c
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 Source Locations
kono
parents:
diff changeset
21 ================
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 .. type:: gcc_jit_location
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 A `gcc_jit_location` encapsulates a source code location, so that
kono
parents:
diff changeset
26 you can (optionally) associate locations in your language with
kono
parents:
diff changeset
27 statements in the JIT-compiled code, allowing the debugger to
kono
parents:
diff changeset
28 single-step through your language.
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 `gcc_jit_location` instances are optional: you can always pass NULL to
kono
parents:
diff changeset
31 any API entrypoint accepting one.
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 You can construct them using :c:func:`gcc_jit_context_new_location`.
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 You need to enable :c:macro:`GCC_JIT_BOOL_OPTION_DEBUGINFO` on the
kono
parents:
diff changeset
36 :c:type:`gcc_jit_context` for these locations to actually be usable by
kono
parents:
diff changeset
37 the debugger:
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 .. code-block:: c
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 gcc_jit_context_set_bool_option (
kono
parents:
diff changeset
42 ctxt,
kono
parents:
diff changeset
43 GCC_JIT_BOOL_OPTION_DEBUGINFO,
kono
parents:
diff changeset
44 1);
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 .. function:: gcc_jit_location *\
kono
parents:
diff changeset
47 gcc_jit_context_new_location (gcc_jit_context *ctxt,\
kono
parents:
diff changeset
48 const char *filename,\
kono
parents:
diff changeset
49 int line,\
kono
parents:
diff changeset
50 int column)
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 Create a `gcc_jit_location` instance representing the given source
kono
parents:
diff changeset
53 location.
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 The parameter ``filename`` must be non-NULL. The call takes a copy of
kono
parents:
diff changeset
56 the underlying string, so it is valid to pass in a pointer to an
kono
parents:
diff changeset
57 on-stack buffer.
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 Faking it
kono
parents:
diff changeset
60 ---------
kono
parents:
diff changeset
61 If you don't have source code for your internal representation, but need
kono
parents:
diff changeset
62 to debug, you can generate a C-like representation of the functions in
kono
parents:
diff changeset
63 your context using :c:func:`gcc_jit_context_dump_to_file()`:
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 .. code-block:: c
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 gcc_jit_context_dump_to_file (ctxt, "/tmp/something.c",
kono
parents:
diff changeset
68 1 /* update_locations */);
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 This will dump C-like code to the given path. If the `update_locations`
kono
parents:
diff changeset
71 argument is true, this will also set up `gcc_jit_location` information
kono
parents:
diff changeset
72 throughout the context, pointing at the dump file as if it were a source
kono
parents:
diff changeset
73 file, giving you *something* you can step through in the debugger.