[Lldb-commits] [PATCH] D77771: [lldb/Docs] Document driver and inline replay.
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 8 20:30:10 PDT 2020
JDevlieghere created this revision.
JDevlieghere added a reviewer: labath.
@@ -93,6 +93,68 @@
+No matter how a reproducer was captured, they can always be replayed with the
+command line driver. When a reproducer is passed with the `--replay` flag, the
+driver short-circuits and passes off control to the reproducer infrastructure,
+effectively bypassing its normal operation. This works because the driver is
+implemented using the SB API and is therefore nothing more than a sequence of
+SB API calls.
+Replay is driven by the ``Registry::Replay``. As long as there's data in the
+buffer holding the API data, the next SB API function call is deserialized.
+Once the function is known, the registry can retrieve its signature, and use
+that to deserialize its arguments. The function can then be invoked, most
+commonly through the synthesized default replayer, or potentially using a
+custom defined replay function. This process continues, until more data is
+available or a replay error is encountered.
+During replay only a function's side effects matter. The result returned by the
+replayed function is ignored because it cannot be observed beyond the driver.
+This is sound, because anything that is passed into a subsequent API call will
+have been serialized as an input argument. This also works for SB API objects
+because the reproducers know about every object that has crossed the API
+boundary, which is true by definition for object return values.
+Driver replay can be considered active, because the reproducers are replaying
+the SB API functions one after each other.
+Inline replay was added to the reproducers to support running the API test
+suite against a reproducer. The API test suite is written in Python and tests
+the debugger by calling into its API from Python. To make this work, the API
+must transparently replay itself when called. This is what makes inline replay
+different from driver replay. For the latter, it is lldb itself that's driving
+replay. For inline replay, the driving factor is external, e.g. the test suite.
+In order to replay API calls, the reproducers need a way to intercept them.
+Every API call is already instrumented with an ``LLDB_RECORD_*`` macro that
+captures its input arguments. Furthermore, it also contains the necessary logic
+to detect which calls cross the API boundary and should be intercepted. We were
+able to reuse all of this to implement inline replay.
+When inline replay is enabled, nothing happens until an API is called. Inside
+that API function, the macro will detect whether this call should be replayed
+(i.e. crossed the API boundary). If the answer is yes, the next function is
+deserialized from the SB API data and compared to the current function. If the
+signature matches, we deserialize its input arguments and reinvoke the current
+function with the deserialized arguments. We don't need to do anything special
+to prevent us from recursively calling the replayed version again, as the API
+boundary crossing logic knows that we're still behind the API boundary when we
+re-invoked the current function.
+Another big difference with driver replay is the return value. While this
+didn't matter for driver replay, it's key for inline replay, because that's
+what gets checked by the test suite. Luckily, the ``LLDB_RECORD_*`` macros
+contained sufficient type information to derive the result type.
+Inline replay can be considered passive, because a function is only replayed
+once it is called through the API.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3747 bytes
Desc: not available
More information about the lldb-commits