-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proc/native: support core dumping on FreeBSD
- Loading branch information
a
committed
Mar 15, 2023
1 parent
a9d699b
commit ec9288e
Showing
4 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package native | ||
|
||
import ( | ||
"errors" | ||
"unsafe" | ||
|
||
"github.com/go-delve/delve/pkg/elfwriter" | ||
"github.com/go-delve/delve/pkg/proc" | ||
) | ||
|
||
/* | ||
#include <sys/types.h> | ||
#include <sys/user.h> | ||
#include <libutil.h> | ||
*/ | ||
import "C" | ||
|
||
func (p *nativeProcess) MemoryMap() ([]proc.MemoryMapEntry, error) { | ||
var cnt C.int | ||
vmentries := C.kinfo_getvmmap(C.int(p.pid), &cnt) | ||
if vmentries == nil { | ||
return nil, errors.New("kinfo_getvmmap call failed") | ||
} | ||
r := make([]proc.MemoryMapEntry, 0, int(cnt)) | ||
base := uintptr(unsafe.Pointer(vmentries)) | ||
sz := unsafe.Sizeof(C.struct_kinfo_vmentry{}) | ||
for i := 0; i < int(cnt); i++ { | ||
vmentry := (*C.struct_kinfo_vmentry)(unsafe.Pointer(base + sz*uintptr(i))) | ||
switch vmentry.kve_type { | ||
case C.KVME_TYPE_DEFAULT, C.KVME_TYPE_VNODE, C.KVME_TYPE_SWAP, C.KVME_TYPE_PHYS: | ||
r = append(r, proc.MemoryMapEntry{ | ||
Addr: uint64(vmentry.kve_start), | ||
Size: uint64(vmentry.kve_end - vmentry.kve_start), | ||
|
||
Read: vmentry.kve_protection&C.KVME_PROT_READ != 0, | ||
Write: vmentry.kve_protection&C.KVME_PROT_WRITE != 0, | ||
Exec: vmentry.kve_protection&C.KVME_PROT_EXEC != 0, | ||
}) | ||
} | ||
} | ||
return r, nil | ||
} | ||
|
||
func (p *nativeProcess) DumpProcessNotes(notes []elfwriter.Note, threadDone func()) (threadsDone bool, notesout []elfwriter.Note, err error) { | ||
return false, notes, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters