mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 17:56:45 +08:00
proc: add flag to distinguish ReturnValues (#2230)
Adds a flag that distinguishes the return values of an injected function call from the return values of a function call executed by the target program.
This commit is contained in:
committed by
GitHub
parent
f7542d69fe
commit
807664b34b
@ -204,6 +204,7 @@ func EvalExpressionWithCalls(t *Target, g *G, expr string, retLoadCfg LoadConfig
|
|||||||
|
|
||||||
func finishEvalExpressionWithCalls(t *Target, g *G, contReq continueRequest, ok bool) error {
|
func finishEvalExpressionWithCalls(t *Target, g *G, contReq continueRequest, ok bool) error {
|
||||||
fncallLog("stashing return values for %d in thread=%d", g.ID, g.Thread.ThreadID())
|
fncallLog("stashing return values for %d in thread=%d", g.ID, g.Thread.ThreadID())
|
||||||
|
g.Thread.Common().CallReturn = true
|
||||||
var err error
|
var err error
|
||||||
if !ok {
|
if !ok {
|
||||||
err = errors.New("internal error EvalExpressionWithCalls didn't return anything")
|
err = errors.New("internal error EvalExpressionWithCalls didn't return anything")
|
||||||
|
|||||||
@ -50,6 +50,7 @@ func (dbp *Target) Continue() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, thread := range dbp.ThreadList() {
|
for _, thread := range dbp.ThreadList() {
|
||||||
|
thread.Common().CallReturn = false
|
||||||
thread.Common().returnValues = nil
|
thread.Common().returnValues = nil
|
||||||
}
|
}
|
||||||
dbp.CheckAndClearManualStopRequest()
|
dbp.CheckAndClearManualStopRequest()
|
||||||
|
|||||||
@ -49,6 +49,7 @@ type Location struct {
|
|||||||
// CommonThread contains fields used by this package, common to all
|
// CommonThread contains fields used by this package, common to all
|
||||||
// implementations of the Thread interface.
|
// implementations of the Thread interface.
|
||||||
type CommonThread struct {
|
type CommonThread struct {
|
||||||
|
CallReturn bool // returnValues are the return values of a call injection
|
||||||
returnValues []*Variable
|
returnValues []*Variable
|
||||||
g *G // cached g for this thread
|
g *G // cached g for this thread
|
||||||
}
|
}
|
||||||
|
|||||||
@ -128,6 +128,8 @@ type Thread struct {
|
|||||||
|
|
||||||
// ReturnValues contains the return values of the function we just stepped out of
|
// ReturnValues contains the return values of the function we just stepped out of
|
||||||
ReturnValues []Variable
|
ReturnValues []Variable
|
||||||
|
// CallReturn is true if ReturnValues are the return values of an injected call.
|
||||||
|
CallReturn bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Location holds program location information.
|
// Location holds program location information.
|
||||||
|
|||||||
@ -1142,7 +1142,7 @@ func (s *Server) onEvaluateRequest(request *dap.EvaluateRequest) {
|
|||||||
var retVars []*proc.Variable
|
var retVars []*proc.Variable
|
||||||
for _, t := range state.Threads {
|
for _, t := range state.Threads {
|
||||||
if t.GoroutineID == stateBeforeCall.SelectedGoroutine.ID &&
|
if t.GoroutineID == stateBeforeCall.SelectedGoroutine.ID &&
|
||||||
t.Line == stateBeforeCall.SelectedGoroutine.CurrentLoc.Line && t.ReturnValues != nil {
|
t.Line == stateBeforeCall.SelectedGoroutine.CurrentLoc.Line && t.CallReturn {
|
||||||
// The call completed. Get the return values.
|
// The call completed. Get the return values.
|
||||||
retVars, err = s.debugger.FindThreadReturnValues(t.ID, prcCfg)
|
retVars, err = s.debugger.FindThreadReturnValues(t.ID, prcCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -562,6 +562,7 @@ func (d *Debugger) state(retLoadCfg *proc.LoadConfig) (*api.DebuggerState, error
|
|||||||
for _, thread := range d.target.ThreadList() {
|
for _, thread := range d.target.ThreadList() {
|
||||||
th := api.ConvertThread(thread)
|
th := api.ConvertThread(thread)
|
||||||
|
|
||||||
|
th.CallReturn = thread.Common().CallReturn
|
||||||
if retLoadCfg != nil {
|
if retLoadCfg != nil {
|
||||||
th.ReturnValues = api.ConvertVars(thread.Common().ReturnValues(*retLoadCfg))
|
th.ReturnValues = api.ConvertVars(thread.Common().ReturnValues(*retLoadCfg))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user