Skip to content

Commit b547ef2

Browse files
committed
[NFC][docs][coro] Fix syntax & typos
Follow-up fixes to #142651
1 parent 7138397 commit b547ef2

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

clang/docs/DebuggingCoroutines.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ still improving their support for coroutines. As such, we recommend using the
2424
latest available version of your toolchain.
2525

2626
This document focuses on clang and lldb. The screenshots show
27-
[lldb-dap](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap)
27+
`lldb-dap <https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap>`_
2828
in combination with VS Code. The same techniques can also be used in other
2929
IDEs.
3030

@@ -44,7 +44,7 @@ Debugging generators
4444

4545
One of the two major use cases for coroutines in C++ are generators, i.e.,
4646
functions which can produce values via ``co_yield``. Values are produced
47-
lazily, on-demand. For that purpose, every time a new value is requested the
47+
lazily, on-demand. For this purpose, every time a new value is requested, the
4848
coroutine gets resumed. As soon as it reaches a ``co_yield`` and thereby
4949
returns the requested value, the coroutine is suspended again.
5050

@@ -134,7 +134,7 @@ Inspecting variables in a coroutine
134134
-----------------------------------
135135

136136
If you hit a breakpoint inside the ``fibonacci`` function, you should be able
137-
to inspect all local variables (``prev```, ``current```, ``next``) just like in
137+
to inspect all local variables (``prev``, ``current``, ``next``) just like in
138138
a regular function.
139139

140140
.. image:: ./coro-generator-variables.png
@@ -215,7 +215,7 @@ the promise type:
215215

216216
.. code-block:: c++
217217

218-
// For all promise_types we need a new `line_number variable`:
218+
// For all promise_types we need a new `_coro_return_address` variable:
219219
class promise_type {
220220
...
221221
void* _coro_return_address = nullptr;
@@ -240,8 +240,8 @@ type used below for asynchronous programming.
240240

241241
Alternatively, we can modify the C++ code to store the line number in the
242242
promise type. We can use a ``std::source_location`` to get the line number of
243-
the await and store it inside the ``promise_type``. Since we can get the
244-
promise of a suspended coroutine, we thereby get access to the line_number.
243+
the await and store it inside the ``promise_type``. In the debugger, we can
244+
then read the line number from the promise of the suspended coroutine.
245245

246246
.. code-block:: c++
247247

@@ -351,8 +351,8 @@ Note how the ``task::promise_type`` has a member variable
351351
``std::coroutine_handle<> continuation``. This is the handle of the coroutine
352352
that will be resumed when the current coroutine is finished executing (see
353353
``final_suspend``). In a sense, this is the "return address" of the coroutine.
354-
It is as soon as the caller coroutine ``co_await`` on the called coroutine in
355-
``operator co_await``.
354+
It is set inside ``operator co_await`` when another coroutine calls our
355+
generator and awaits for the next value to be produced.
356356

357357
The result value is returned via the ``int result`` member. It is written in
358358
``return_value`` and read by ``Awaiter::await_resume``. Usually, the result
@@ -425,7 +425,7 @@ script, we can run ``coro bt`` to get the following stack trace:
425425
426426
Note how the frames #1 and #2 are async frames.
427427

428-
The ``coro bt`` frame already includes logic to identify the exact suspension
428+
The ``coro bt`` command already includes logic to identify the exact suspension
429429
point of each frame based on the ``_coro_suspension_point_addr`` stored inside
430430
the promise.
431431

@@ -900,7 +900,7 @@ Note that this script requires LLDB 21.0 or newer.
900900
coro_hdl = frame.EvaluateExpression(expr)
901901
if not coro_hdl.error.Success():
902902
result.AppendMessage(
903-
f'error: expression failed {expr} => {async_root.error}'
903+
f'error: expression failed {expr} => {coro_hdl.error}'
904904
)
905905
result.SetError(f"Expression `{expr}` failed to evaluate")
906906
return
@@ -913,7 +913,7 @@ Note that this script requires LLDB 21.0 or newer.
913913
continuation_paths = continuation_paths)
914914
915915
916-
class Coroin-flightCommand(ParsedCommand):
916+
class CoroInflightCommand(ParsedCommand):
917917
def get_short_help(self):
918918
return "Identify all in-flight coroutines"
919919
@@ -974,7 +974,7 @@ Note that this script requires LLDB 21.0 or newer.
974974
return
975975
all_coros.append(entry)
976976
977-
# Remove all coroutines that have are currently waiting for other coroutines to finish
977+
# Remove all coroutines that are currently waiting for other coroutines to finish
978978
coro_roots = {c.GetChildMemberWithName("coro_frame").GetValueAsAddress(): c for c in all_coros}
979979
for coro_hdl in all_coros:
980980
parent_coro = _get_first_var_path(coro_hdl.GetChildMemberWithName("promise"), continuation_paths)
@@ -993,7 +993,7 @@ Note that this script requires LLDB 21.0 or newer.
993993
def __lldb_init_module(debugger, internal_dict):
994994
debugger.HandleCommand("command container add -h 'Debugging utilities for C++20 coroutines' coro")
995995
debugger.HandleCommand(f"command script add -o -p -c {__name__}.CoroBacktraceCommand coro bt")
996-
debugger.HandleCommand(f"command script add -o -p -c {__name__}.Coroin-flightCommand coro in-flight")
996+
debugger.HandleCommand(f"command script add -o -p -c {__name__}.CoroInflightCommand coro in-flight")
997997
print("Coro debugging utilities installed. Use `help coro` to see available commands.")
998998
999999
if __name__ == '__main__':
@@ -1012,7 +1012,7 @@ For GDB, the following script provides a couple of useful commands:
10121012

10131013
.. code-block:: python
10141014
1015-
# debugging-helper.py
1015+
# debugging-helper.py
10161016
import gdb
10171017
from gdb.FrameDecorator import FrameDecorator
10181018
@@ -1140,7 +1140,7 @@ For GDB, the following script provides a couple of useful commands:
11401140
addr = int(argv[0], 16)
11411141
block = gdb.block_for_pc(long(cast_addr2long_pointer(addr).dereference()))
11421142
if block is None:
1143-
print "block " + str(addr) + " is none."
1143+
print "block " + str(addr) + " is None."
11441144
return
11451145
11461146
# Disable demangling since gdb will treat names starting with `_Z`(The marker for Itanium ABI) specially.
@@ -1160,12 +1160,12 @@ Further Reading
11601160

11611161
The authors of the Folly libraries wrote a blog post series on how they debug coroutines:
11621162

1163-
* [Async stack traces in folly: Introduction](https://developers.facebook.com/blog/post/2021/09/16/async-stack-traces-folly-Introduction/)
1164-
* [Async stack traces in folly: Synchronous and asynchronous stack traces](https://developers.facebook.com/blog/post/2021/09/23/async-stack-traces-folly-synchronous-asynchronous-stack-traces/)
1165-
* [Async stack traces in folly: Forming an async stack from individual frames](https://developers.facebook.com/blog/post/2021/09/30/async-stack-traces-folly-forming-async-stack-individual-frames/)
1166-
* [Async Stack Traces for C++ Coroutines in Folly: Walking the async stack](https://developers.facebook.com/blog/post/2021/10/14/async-stack-traces-c-plus-plus-coroutines-folly-walking-async-stack/)
1167-
* [Async stack traces in folly: Improving debugging in the developer lifecycle](https://developers.facebook.com/blog/post/2021/10/21/async-stack-traces-folly-improving-debugging-developer-lifecycle/)
1163+
* `Async stack traces in folly: Introduction <https://developers.facebook.com/blog/post/2021/09/16/async-stack-traces-folly-Introduction/>`_
1164+
* `Async stack traces in folly: Synchronous and asynchronous stack traces <https://developers.facebook.com/blog/post/2021/09/23/async-stack-traces-folly-synchronous-asynchronous-stack-traces/>`_
1165+
* `Async stack traces in folly: Forming an async stack from individual frames <https://developers.facebook.com/blog/post/2021/09/30/async-stack-traces-folly-forming-async-stack-individual-frames/>`_
1166+
* `Async Stack Traces for C++ Coroutines in Folly: Walking the async stack <https://developers.facebook.com/blog/post/2021/10/14/async-stack-traces-c-plus-plus-coroutines-folly-walking-async-stack/>`_
1167+
* `Async stack traces in folly: Improving debugging in the developer lifecycle <https://developers.facebook.com/blog/post/2021/10/21/async-stack-traces-folly-improving-debugging-developer-lifecycle/>`_
11681168

11691169
Besides some topics also covered here (stack traces from the debugger), Folly's blog post series also covers
1170-
more additional topics, such as capturing async strack traces in performance profiles via eBPF filters
1170+
more additional topics, such as capturing async stack traces in performance profiles via eBPF filters
11711171
and printing async stack traces on crashes.

0 commit comments

Comments
 (0)