
The repository is being switched from the personal account github.com/derekparker/delve to the organization account github.com/go-delve/delve. This patch updates imports and docs, while preserving things which should not be changed such as my name in the CHANGELOG and in TODO comments.
61 lines
1.5 KiB
Go
61 lines
1.5 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"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func readAMD64Minidump(minidumpPath, exePath string) (*Process, error) {
|
|
var logfn func(string, ...interface{})
|
|
if logflags.Minidump() {
|
|
logfn = logrus.WithFields(logrus.Fields{"layer": "core", "kind": "minidump"}).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(floatingPoint bool) (proc.Registers, error) {
|
|
return winutil.NewAMD64Registers(&th.th.Context, th.th.TEB, floatingPoint), nil
|
|
}
|