diff --git a/CHANGELOG.md b/CHANGELOG.md index f85d2838..b3118390 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ This project adheres to Semantic Versioning. All changes mention the author, unless contributed by me (@derekparker). +## [RELEASE TO BE DEFINED] DATE TO BE DEFINED + +### Added + +- Add FrameOffset field to api.Stackframe (@aarzilli) + ## [1.0.0-rc.2] DATE TO BE DEFINED ### Added diff --git a/pkg/terminal/command_test.go b/pkg/terminal/command_test.go index e22a3893..47ccaa82 100644 --- a/pkg/terminal/command_test.go +++ b/pkg/terminal/command_test.go @@ -216,7 +216,7 @@ func TestExecuteFile(t *testing.T) { func TestIssue354(t *testing.T) { printStack([]api.Stackframe{}, "") - printStack([]api.Stackframe{{api.Location{PC: 0, File: "irrelevant.go", Line: 10, Function: nil}, nil, nil}}, "") + printStack([]api.Stackframe{{api.Location{PC: 0, File: "irrelevant.go", Line: 10, Function: nil}, nil, nil, 0}}, "") } func TestIssue411(t *testing.T) { diff --git a/service/api/types.go b/service/api/types.go index aed385b1..489b3309 100644 --- a/service/api/types.go +++ b/service/api/types.go @@ -118,8 +118,9 @@ type Location struct { type Stackframe struct { Location - Locals []Variable - Arguments []Variable + Locals []Variable + Arguments []Variable + FrameOffset int64 } func (frame *Stackframe) Var(name string) *Variable { diff --git a/service/debugger/debugger.go b/service/debugger/debugger.go index 931f6e73..e88a7f0c 100644 --- a/service/debugger/debugger.go +++ b/service/debugger/debugger.go @@ -853,7 +853,10 @@ func (d *Debugger) Stacktrace(goroutineID, depth int, cfg *proc.LoadConfig) ([]a func (d *Debugger) convertStacktrace(rawlocs []proc.Stackframe, cfg *proc.LoadConfig) ([]api.Stackframe, error) { locations := make([]api.Stackframe, 0, len(rawlocs)) for i := range rawlocs { - frame := api.Stackframe{Location: api.ConvertLocation(rawlocs[i].Call)} + frame := api.Stackframe{ + Location: api.ConvertLocation(rawlocs[i].Call), + FrameOffset: rawlocs[i].CFA - int64(rawlocs[i].StackHi), + } if cfg != nil && rawlocs[i].Current.Fn != nil { var err error scope := proc.FrameToScope(d.target, rawlocs[i])