mirror of
				https://github.com/go-delve/delve.git
				synced 2025-10-31 18:57:18 +08:00 
			
		
		
		
	proc: cleanup: attach FDE to Stackframe structure
This commit is contained in:
		| @ -23,7 +23,11 @@ type Stackframe struct { | |||||||
| 	Current Location | 	Current Location | ||||||
| 	// Address of the call instruction for the function above on the call stack. | 	// Address of the call instruction for the function above on the call stack. | ||||||
| 	Call Location | 	Call Location | ||||||
|  | 	// Start address of the stack frame. | ||||||
| 	CFA  int64 | 	CFA  int64 | ||||||
|  | 	// Description of the stack frame. | ||||||
|  | 	FDE  *frame.FrameDescriptionEntry | ||||||
|  | 	// Return address for this stack frame (as read from the stack frame itself). | ||||||
| 	Ret  uint64 | 	Ret  uint64 | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -179,7 +183,7 @@ func (dbp *Process) frameInfo(pc, sp uint64, top bool) (Stackframe, error) { | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return Stackframe{}, err | 		return Stackframe{}, err | ||||||
| 	} | 	} | ||||||
| 	r := Stackframe{Current: Location{PC: pc, File: f, Line: l, Fn: fn}, CFA: cfa, Ret: binary.LittleEndian.Uint64(data)} | 	r := Stackframe{Current: Location{PC: pc, File: f, Line: l, Fn: fn}, CFA: cfa, FDE: fde, Ret: binary.LittleEndian.Uint64(data)} | ||||||
| 	if !top { | 	if !top { | ||||||
| 		r.Call.File, r.Call.Line, r.Call.Fn = dbp.PCToLine(pc - 1) | 		r.Call.File, r.Call.Line, r.Call.Fn = dbp.PCToLine(pc - 1) | ||||||
| 		r.Call.PC, _, _ = dbp.goSymTable.LineToPC(r.Call.File, r.Call.Line) | 		r.Call.PC, _, _ = dbp.goSymTable.LineToPC(r.Call.File, r.Call.Line) | ||||||
|  | |||||||
| @ -11,7 +11,6 @@ import ( | |||||||
| 	"runtime" | 	"runtime" | ||||||
|  |  | ||||||
| 	"github.com/derekparker/delve/dwarf/debug/dwarf" | 	"github.com/derekparker/delve/dwarf/debug/dwarf" | ||||||
| 	"github.com/derekparker/delve/dwarf/frame" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // Thread represents a single thread in the traced process | // Thread represents a single thread in the traced process | ||||||
| @ -153,25 +152,17 @@ func (dbp *Process) setNextBreakpoints() (err error) { | |||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Grab info on our current stack frame. Used to determine |  | ||||||
| 	// whether we may be stepping outside of the current function. |  | ||||||
| 	fde, err := dbp.frameEntries.FDEForPC(topframe.Current.PC) |  | ||||||
| 	if err != nil { |  | ||||||
| 		return err |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	if filepath.Ext(topframe.Current.File) != ".go" { | 	if filepath.Ext(topframe.Current.File) != ".go" { | ||||||
| 		return dbp.cnext(topframe, fde) | 		return dbp.cnext(topframe) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return dbp.next(dbp.SelectedGoroutine, topframe, fde) | 	return dbp.next(dbp.SelectedGoroutine, topframe) | ||||||
| } | } | ||||||
|  |  | ||||||
| // Set breakpoints at every line, and the return address. Also look for | // Set breakpoints at every line, and the return address. Also look for | ||||||
| // a deferred function and set a breakpoint there too. | // a deferred function and set a breakpoint there too. | ||||||
| // The first return value is set to true if the goroutine is in the process of exiting | func (dbp *Process) next(g *G, topframe Stackframe) error { | ||||||
| func (dbp *Process) next(g *G, topframe Stackframe, fde *frame.FrameDescriptionEntry) error { | 	pcs := dbp.lineInfo.AllPCsBetween(topframe.FDE.Begin(), topframe.FDE.End()-1, topframe.Current.File) | ||||||
| 	pcs := dbp.lineInfo.AllPCsBetween(fde.Begin(), fde.End()-1, topframe.Current.File) |  | ||||||
|  |  | ||||||
| 	var deferpc uint64 = 0 | 	var deferpc uint64 = 0 | ||||||
| 	if g != nil && g.DeferPC != 0 { | 	if g != nil && g.DeferPC != 0 { | ||||||
| @ -185,7 +176,7 @@ func (dbp *Process) next(g *G, topframe Stackframe, fde *frame.FrameDescriptionE | |||||||
|  |  | ||||||
| 	var covered bool | 	var covered bool | ||||||
| 	for i := range pcs { | 	for i := range pcs { | ||||||
| 		if fde.Cover(pcs[i]) { | 		if topframe.FDE.Cover(pcs[i]) { | ||||||
| 			covered = true | 			covered = true | ||||||
| 			break | 			break | ||||||
| 		} | 		} | ||||||
| @ -207,8 +198,8 @@ func (dbp *Process) next(g *G, topframe Stackframe, fde *frame.FrameDescriptionE | |||||||
| // Set a breakpoint at every reachable location, as well as the return address. Without | // Set a breakpoint at every reachable location, as well as the return address. Without | ||||||
| // the benefit of an AST we can't be sure we're not at a branching statement and thus | // the benefit of an AST we can't be sure we're not at a branching statement and thus | ||||||
| // cannot accurately predict where we may end up. | // cannot accurately predict where we may end up. | ||||||
| func (dbp *Process) cnext(topframe Stackframe, fde *frame.FrameDescriptionEntry) error { | func (dbp *Process) cnext(topframe Stackframe) error { | ||||||
| 	pcs := dbp.lineInfo.AllPCsBetween(fde.Begin(), fde.End(), topframe.Current.File) | 	pcs := dbp.lineInfo.AllPCsBetween(topframe.FDE.Begin(), topframe.FDE.End(), topframe.Current.File) | ||||||
| 	pcs = append(pcs, topframe.Ret) | 	pcs = append(pcs, topframe.Ret) | ||||||
| 	return dbp.setTempBreakpoints(topframe.Current.PC, pcs, sameGoroutineCondition(dbp.SelectedGoroutine)) | 	return dbp.setTempBreakpoints(topframe.Current.PC, pcs, sameGoroutineCondition(dbp.SelectedGoroutine)) | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 aarzilli
					aarzilli