mirror of
https://github.com/go-delve/delve.git
synced 2025-10-28 20:53:42 +08:00
trace command
This commit is contained in:
@ -7,7 +7,7 @@ import (
|
||||
// Takes an offset from RSP and returns the address of the
|
||||
// instruction the currect function is going to return to.
|
||||
func (thread *Thread) ReturnAddress() (uint64, error) {
|
||||
locations, err := thread.Stacktrace(1)
|
||||
_, locations, err := thread.Stacktrace(1)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -16,25 +16,30 @@ func (thread *Thread) ReturnAddress() (uint64, error) {
|
||||
|
||||
// Returns the stack trace for thread
|
||||
// Note that it doesn't include the current frame and the locations in the array are return addresses not call addresses
|
||||
func (thread *Thread) Stacktrace(depth int) ([]Location, error) {
|
||||
func (thread *Thread) Stacktrace(depth int) (*Location, []Location, error) {
|
||||
loc, err := thread.Location()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
regs, err := thread.Registers()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
locations, err := thread.dbp.stacktrace(regs.PC(), regs.SP(), depth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
return locations, nil
|
||||
return loc, locations, nil
|
||||
}
|
||||
|
||||
// Returns the stack trace for a goroutine
|
||||
// Note that it doesn't include the current frame and the locations in the array are return addresses not call addresses
|
||||
func (dbp *Process) GoroutineStacktrace(g *G, depth int) ([]Location, error) {
|
||||
func (dbp *Process) GoroutineStacktrace(g *G, depth int) (*Location, []Location, error) {
|
||||
if g.thread != nil {
|
||||
return g.thread.Stacktrace(depth)
|
||||
}
|
||||
return dbp.stacktrace(g.PC, g.SP, depth)
|
||||
locs, err := dbp.stacktrace(g.PC, g.SP, depth)
|
||||
return dbp.GoroutineLocation(g), locs, err
|
||||
}
|
||||
|
||||
func (dbp *Process) GoroutineLocation(g *G) *Location {
|
||||
|
||||
Reference in New Issue
Block a user