• A
    proc: allow function calls to appear inside an expression (#1503) · c30a333f
    Alessandro Arzilli 提交于
    The initial implementation of the 'call' command required the
    function call to be the root expression, i.e. something like:
    
    	double(3) + 1
    
    was not allowed, because the root expression was the binary operator
    '+', not the function call.
    
    With this change expressions like the one above and others are
    allowed.
    
    This is the first step necessary to implement nested function calls
    (where the result of a function call is used as argument to another
    function call).
    
    This is implemented by replacing proc.CallFunction with
    proc.EvalExpressionWithCalls. EvalExpressionWithCalls will run
    proc.(*EvalScope).EvalExpression in a different goroutine. This
    goroutine, the 'eval' goroutine, will communicate with the main
    goroutine of the debugger by means of two channels: continueRequest
    and continueCompleted.
    
    The eval goroutine evaluates the expression recursively, when
    a function call is encountered it takes care of setting up the
    function call on the target program and writes a request to the
    continueRequest channel, this causes the 'main' goroutine to restart
    the target program by calling proc.Continue.
    
    Whenever Continue encounters a breakpoint that belongs to the
    function call injection protocol (runtime.debugCallV1 and associated
    functions) it writes to continueCompleted which resumes the 'eval'
    goroutine.
    
    The 'eval' goroutine takes care of implementing the function call
    injection protocol.
    
    When the expression is fully evaluated the 'eval' goroutine will
    write a special message to 'continueRequest' signaling that the
    expression evaluation is terminated which will cause Continue to
    return to the user.
    
    Updates #119
    c30a333f
integration2_test.go 51.6 KB