mirror of
https://github.com/go-delve/delve.git
synced 2025-11-02 12:59:01 +08:00
proc: stacktrace refactoring
- made GoroutineStacktrace a method of struct G - made stacktrace a method of StackIterator - renamed StackIterator to stackIterator - factored out logic to obtain a stackIterator from a goroutine that's used by both (*G).Stacktrace and by (*G).UserCurrent
This commit is contained in:
@ -317,7 +317,7 @@ func (g *G) ChanRecvBlocked() bool {
|
||||
|
||||
// chanRecvReturnAddr returns the address of the return from a channel read.
|
||||
func (g *G) chanRecvReturnAddr(dbp *Process) (uint64, error) {
|
||||
locs, err := dbp.GoroutineStacktrace(g, 4)
|
||||
locs, err := g.Stacktrace(4)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -411,15 +411,10 @@ func isExportedRuntime(name string) bool {
|
||||
// UserCurrent returns the location the users code is at,
|
||||
// or was at before entering a runtime function.
|
||||
func (g *G) UserCurrent() Location {
|
||||
pc, sp := g.PC, g.SP
|
||||
if g.thread != nil {
|
||||
regs, err := g.thread.Registers()
|
||||
if err != nil {
|
||||
return g.CurrentLoc
|
||||
}
|
||||
pc, sp = regs.PC(), regs.SP()
|
||||
it, err := g.stackIterator()
|
||||
if err != nil {
|
||||
return g.CurrentLoc
|
||||
}
|
||||
it := newStackIterator(g.dbp, pc, sp)
|
||||
for it.Next() {
|
||||
frame := it.Frame()
|
||||
if frame.Call.Fn != nil {
|
||||
|
||||
Reference in New Issue
Block a user