• Heschi Kreinick's avatar
    runtime: handle morestack system stack transition in gentraceback · ae6361e4
    Heschi Kreinick authored
    gentraceback handles system stack transitions, but only when they're
    done by systemstack(). Handle morestack() too.
    
    I tried to do this generically but systemstack and morestack are
    actually *very* different functions. Most notably, systemstack returns
    "normally", just messes with $sp along the way. morestack never
    returns at all -- it calls newstack, and newstack then jumps both
    stacks and functions back to whoever called morestack. I couldn't
    think of a way to handle both of them generically. So don't.
    
    The current implementation does not include systemstack on the generated
    traceback. That's partly because I don't know how to find its stack frame
    reliably, and partly because the current structure of the code wants to
    do the transition before the call, not after. If we're willing to
    assume that morestack's stack frame is 0 size, this could probably be
    fixed.
    
    For posterity's sake, alternatives tried:
    
    - Have morestack put a dummy function into schedbuf, like systemstack
    does. This actually worked (see patchset 1) but more by a series of
    coincidences than by deliberate design. The biggest coincidence was that
    because morestack_switch was a RET and its stack was 0 size, it actually
    worked to jump back to it at the end of newstack -- it would just return
    to the caller of morestack. Way too subtle for me, and also a little
    slower than just jumping directly.
    
    - Put morestack's PC and SP into schedbuf, so that gentraceback could
    treat it like a normal function except for the changing SP. This was a
    terrible idea and caused newstack to reenter morestack in a completely
    unreasonable state.
    
    To make testing possible I did a small redesign of testCPUProfile to
    take a callback that defines how to check if the conditions pass to it
    are satisfied. This seemed better than making the syntax of the "need"
    strings even more complicated.
    
    Updates #25943
    
    Change-Id: I9271a30a976f80a093a3d4d1c7e9ec226faf74b4
    Reviewed-on: https://go-review.googlesource.com/126795
    Run-TryBot: Heschi Kreinick <heschi@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarAustin Clements <austin@google.com>
    ae6361e4
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...