
Changes implementations of proc.Registers interface and the op.DwarfRegisters struct so that floating point registers can be loaded only when they are needed. Removes the floatingPoint parameter from proc.Thread.Registers. This accomplishes three things: 1. it simplifies the proc.Thread.Registers interface 2. it makes it impossible to accidentally create a broken set of saved registers or of op.DwarfRegisters by accidentally calling Registers(false) 3. it improves general performance of Delve by avoiding to load floating point registers as much as possible Floating point registers are loaded under two circumstances: 1. When the Slice method is called with floatingPoint == true 2. When the Copy method is called Benchmark before: BenchmarkConditionalBreakpoints-4 1 4327350142 ns/op Benchmark after: BenchmarkConditionalBreakpoints-4 1 3852642917 ns/op Updates #1549
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
package core
|
|
|
|
import (
|
|
"github.com/go-delve/delve/pkg/logflags"
|
|
"github.com/go-delve/delve/pkg/proc"
|
|
"github.com/go-delve/delve/pkg/proc/core/minidump"
|
|
"github.com/go-delve/delve/pkg/proc/winutil"
|
|
)
|
|
|
|
func readAMD64Minidump(minidumpPath, exePath string) (*process, error) {
|
|
var logfn func(string, ...interface{})
|
|
if logflags.Minidump() {
|
|
logfn = logflags.MinidumpLogger().Infof
|
|
}
|
|
|
|
mdmp, err := minidump.Open(minidumpPath, logfn)
|
|
if err != nil {
|
|
if _, isNotAMinidump := err.(minidump.ErrNotAMinidump); isNotAMinidump {
|
|
return nil, ErrUnrecognizedFormat
|
|
}
|
|
return nil, err
|
|
}
|
|
|
|
memory := &splicedMemory{}
|
|
|
|
for i := range mdmp.MemoryRanges {
|
|
m := &mdmp.MemoryRanges[i]
|
|
memory.Add(m, uintptr(m.Addr), uintptr(len(m.Data)))
|
|
}
|
|
|
|
p := &process{
|
|
mem: memory,
|
|
Threads: map[int]*thread{},
|
|
bi: proc.NewBinaryInfo("windows", "amd64"),
|
|
breakpoints: proc.NewBreakpointMap(),
|
|
pid: int(mdmp.Pid),
|
|
}
|
|
|
|
for i := range mdmp.Threads {
|
|
th := &mdmp.Threads[i]
|
|
p.Threads[int(th.ID)] = &thread{&windowsAMD64Thread{th}, p, proc.CommonThread{}}
|
|
if p.currentThread == nil {
|
|
p.currentThread = p.Threads[int(th.ID)]
|
|
}
|
|
}
|
|
return p, nil
|
|
}
|
|
|
|
type windowsAMD64Thread struct {
|
|
th *minidump.Thread
|
|
}
|
|
|
|
func (th *windowsAMD64Thread) pid() int {
|
|
return int(th.th.ID)
|
|
}
|
|
|
|
func (th *windowsAMD64Thread) registers() (proc.Registers, error) {
|
|
return winutil.NewAMD64Registers(&th.th.Context, th.th.TEB), nil
|
|
}
|