Skip to content

Commit 0024a2c

Browse files
vogelsgesangJFinis
andauthored
Apply suggestions from code review
Co-authored-by: Jan Finis <[email protected]>
1 parent bd6da92 commit 0024a2c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

clang/docs/DebuggingCoroutines.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Debugging C++ Coroutines
88
Introduction
99
============
1010

11-
Coroutines in C++ were introduced in C++20, and their user experience for
11+
Coroutines in C++ were introduced in C++20, and the user experience for
1212
debugging them can still be challenging. This document guides you how to most
1313
efficiently debug coroutines and how to navigate existing shortcomings in
1414
debuggers and compilers.
@@ -20,7 +20,7 @@ generators section, as it will introduce foundational debugging techniques also
2020
applicable to the debugging of asynchronous programming.
2121

2222
Both compilers (clang, gcc, ...) and debuggers (lldb, gdb, ...) are
23-
still improving their support for coroutines. As such, we recommend to use the
23+
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
@@ -35,20 +35,20 @@ This guide will first showcase the more polished, bleeding-edge experience, but
3535
will also show you how to debug coroutines with older toolchains. In general,
3636
the older your toolchain, the deeper you will have to dive into the
3737
implementation details of coroutines (such as their ABI). The further down in
38-
this document, the more low-level, technical the content will become. If you
38+
this document you go, the more low-level, technical the content will become. If you
3939
are on an up-to-date toolchain, you will hopefully be able to stop reading
4040
earlier.
4141

4242
Debugging generators
4343
====================
4444

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

51-
This logic is encapsulated in a ``generator`` type similar to
51+
This logic is encapsulated in a ``generator`` type similar to this one:
5252

5353
.. code-block:: c++
5454

@@ -77,8 +77,8 @@ This logic is encapsulated in a ``generator`` type similar to
7777
generator(std::coroutine_handle<promise_type> h) : hdl(h) { hdl.resume(); }
7878
~generator() { hdl.destroy(); }
7979

80-
generator<int>& operator++() { hdl.resume(); return *this; } // resume the coroutine
81-
int operator*() const { return hdl.promise().current_value; }
80+
generator<T>& operator++() { hdl.resume(); return *this; } // resume the coroutine
81+
T operator*() const { return hdl.promise().current_value; }
8282
8383
private:
8484
std::coroutine_handle<promise_type> hdl;
@@ -159,7 +159,7 @@ If you stop at ``++fib`` and try to step into the generator, you will first
159159
find yourself inside ``operator++``. Stepping into the ``handle.resume()`` will
160160
not work by default.
161161

162-
This is because lldb does not step int functions from the standard library by
162+
This is because lldb does not step into functions from the standard library by
163163
default. To make this work, you first need to run ``settings set
164164
target.process.thread.step-avoid-regexp ""``. You can do so from the "Debug
165165
Console" towards the bottom of the screen. With that setting change, you can
@@ -267,7 +267,7 @@ Async stack traces
267267

268268
Besides generators, the second common use case for coroutines in C++ is
269269
asynchronous programming, usually involving libraries such as stdexec, folly,
270-
cppcoro, boost::asio or similar libraries. Some of those libraries already
270+
cppcoro, boost::asio, or similar libraries. Some of those libraries already
271271
provide custom debugging support, so in addition to this guide, you might want
272272
to check out their documentation.
273273

@@ -625,7 +625,7 @@ In practice, one would use the ``show-coro-frame`` command provided by the
625625

626626
LLDB comes with devirtualization support out of the box, as part of the
627627
pretty-printer for ``std::coroutine_handle``. Internally, this pretty-printer
628-
uses the second approach. We lookup the types in the destroy function and not
628+
uses the second approach. We look up the types in the destroy function and not
629629
the resume function because the resume function pointer will be set to a
630630
nullptr as soon as a coroutine reaches its final suspension point. If we used
631631
the resume function, devirtualization would hence fail for all coroutines that

0 commit comments

Comments
 (0)