[SERVER-61218] coroutines: evaluate debugger support and visibility Created: 03/Nov/21  Updated: 04/Jan/22  Resolved: 04/Jan/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-61057 Does toolchain support for coroutines... Closed
Sprint: Service Arch 2022-1-10
Participants:
Story Points: 3

 Description   

(subtask of SERVER-61057)



 Comments   
Comment by Billy Donahue [ 04/Jan/22 ]

Didn't look at MSVC as the tools aren't available and it's not that important.

Comment by Billy Donahue [ 04/Jan/22 ]

wrote notes into https://docs.google.com/document/d/1-Q8XunNWffxk5vQMx46b5wUTUaSpki90m_GVKDgpogM

V4 toolchain GDB doesn’t understand how to demangle coroutine frame names.

The debugger displays the function name inside a coroutine as something like:

#0  mongo::(anonymous namespace)::fib(mongo::(anonymous namespace)::_ZN5mongo12_GLOBAL__N_13fibEPSt6vectorIiSaIiEE.frame *) (frame_ptr=0x7ffff7f9e3a0) at src/mongo/platform/coroutines_test.cpp:125

So coroutine_handle::operator() calls its resume member, which calls a compiler-generated blahblah.frame function with a frame_ptr object, the contents of which are obscure compiler-generated details. However, `info locals` will show local variables within the coroutine, but it also shows a few weird extra things injected by the codegen somehow.

(gdb) print frame_ptr
$1 = (mongo::(anonymous namespace)::_ZN5mongo12_GLOBAL__N_13fibEPSt6vectorIiSaIiEE.frame *) 0x7ffff7f9e3a0
(gdb) print *frame_ptr
$2 = {__resume = 0x55555610e647 <mongo::(anonymous namespace)::fib(mongo::(anonymous namespace)::_ZN5mongo12_GLOBAL__N_13fibEPSt6vectorIiSaIiEE.frame *)>,
  __destroy = 0x55555610ea0a <mongo::(anonymous namespace)::fib(mongo::(anonymous namespace)::_ZN5mongo12_GLOBAL__N_13fibEPSt6vectorIiSaIiEE.frame *)>, __p = {<No data fields>}, __frame_needs_free = true, __resume_at = 6,
  __self_h = {_M_fr_ptr = 0x7ffff7f9e3a0}, __parm.results = 0x7fffffffdc20, __i_a_r_c.1.1 = true, __Is.2.2 = {<No data fields>}, __a.2.3 = 1, __b.2.3 = 2, __Aw0.3.4 = {<No data fields>}, __Aw1.4.6 = {<No data fields>},
  __Fs.2.7 = {<No data fields>}}
(gdb) print a
$3 = 0
(gdb) print b
$4 = 1
(gdb) info locals
Aw1 = <optimized out>
i_a_r_c = false
Is = <optimized out>
a = 0
b = 1
Aw0 = <optimized out>
Fs = <optimized out>
(gdb)

Generated at Thu Feb 08 05:51:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.