Skip to content

Commit d0727ec

Browse files
committed
[Docs] Document lldb-instr
This adds some information on how to instrument the API classes. llvm-svn: 373277
1 parent 9a84dc0 commit d0727ec

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

lldb/docs/resources/sbapi.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,43 @@ file, and adding documentation and the Python decorations, etc. We do this in a
5353
decidedly low-tech way, by maintaining the two files in parallel. That
5454
simplifies the build process, but it does mean that if you add a method to the
5555
C++ API's for an SB class, you have to copy the interface to the .i file.
56+
57+
API Instrumentation
58+
-------------------
59+
60+
The reproducer infrastructure requires API methods to be instrumented so that
61+
they can be captured and replayed. Instrumentation consists of two macros,
62+
``LLDB_REGISTER`` and ``LLDB_RECORD``. Both can be automatically generated with
63+
the ``lldb-instr`` utility.
64+
65+
To add instrumentation for a given file, pass it to the ``lldb-instr`` tool.
66+
Like other clang-based tools it requires a compilation database
67+
(``compile_commands.json``) to be present in the current working directory.
68+
69+
::
70+
71+
./bin/lldb-instr /path/to/lldb/source/API/SBDebugger.cpp
72+
73+
74+
The tool will automatically insert ``LLDB_RECORD`` macros inline, however you
75+
will need to run ``clang-format`` over the processed file, as the tool
76+
(intentionally) makes no attempt to get that right.
77+
78+
The ``LLDB_REGISTER`` macros are printed to standard out between curly braces.
79+
You'll have to copy-paste those into the corresponding `RegsiterMethods`
80+
function in the implementation file. This function is fully specialized in the
81+
corresponding type.
82+
83+
::
84+
85+
template <> void RegisterMethods<SBDebugger>(Registry &R) {
86+
...
87+
}
88+
89+
90+
When adding a new class, you'll also have to add a call to ``RegisterMethods``
91+
in the ``SBRegistry`` constructor.
92+
93+
The tool can be used incrementally. However, it will ignore existing macros
94+
even if their signature is wrong. It will only generate a ``LLDB_REGISTER`` if
95+
it emitted a corresponding ``LLDB_RECORD`` macro.

0 commit comments

Comments
 (0)