mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 01:27:16 +08:00
pkg/proc,service: support linux/386 (#1884)
Implement debugging function for 386 on linux with reference to AMD64. There are a few remaining problems that need to be solved in another time. 1. The stacktrace of cgo are not exactly as expected. 2. Not implement `core` for now. 3. Not implement `call` for now. Can't not find `runtime·debugCallV1` or similar function in $GOROOT/src/runtime/asm_386.s. Update #20
This commit is contained in:
@ -118,24 +118,29 @@ func readLinuxCore(corePath, exePath string) (*Process, error) {
|
||||
return nil, err
|
||||
}
|
||||
memory := buildMemory(coreFile, exeELF, exe, notes)
|
||||
entryPoint := findEntryPoint(notes)
|
||||
|
||||
// TODO support 386
|
||||
var bi *proc.BinaryInfo
|
||||
switch machineType {
|
||||
case EM_X86_64:
|
||||
bi = proc.NewBinaryInfo("linux", "amd64")
|
||||
case EM_AARCH64:
|
||||
bi = proc.NewBinaryInfo("linux", "arm64")
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported machine type")
|
||||
}
|
||||
|
||||
entryPoint := findEntryPoint(notes, bi.Arch.PtrSize())
|
||||
|
||||
p := &Process{
|
||||
mem: memory,
|
||||
Threads: map[int]*Thread{},
|
||||
entryPoint: entryPoint,
|
||||
bi: bi,
|
||||
breakpoints: proc.NewBreakpointMap(),
|
||||
}
|
||||
|
||||
switch machineType {
|
||||
case EM_X86_64:
|
||||
p.bi = proc.NewBinaryInfo("linux", "amd64")
|
||||
linuxThreadsFromNotes(p, notes, machineType)
|
||||
case EM_AARCH64:
|
||||
p.bi = proc.NewBinaryInfo("linux", "arm64")
|
||||
linuxThreadsFromNotes(p, notes, machineType)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported machine type")
|
||||
}
|
||||
linuxThreadsFromNotes(p, notes, machineType)
|
||||
return p, nil
|
||||
}
|
||||
|
||||
@ -352,10 +357,10 @@ func buildMemory(core, exeELF *elf.File, exe io.ReaderAt, notes []*Note) proc.Me
|
||||
return memory
|
||||
}
|
||||
|
||||
func findEntryPoint(notes []*Note) uint64 {
|
||||
func findEntryPoint(notes []*Note, ptrSize int) uint64 {
|
||||
for _, note := range notes {
|
||||
if note.Type == NT_AUXV {
|
||||
return linutil.EntryPointFromAuxvAMD64(note.Desc.([]byte))
|
||||
return linutil.EntryPointFromAuxv(note.Desc.([]byte), ptrSize)
|
||||
}
|
||||
}
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user