This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
forked from Code-Hex/vz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.go
65 lines (52 loc) · 1.76 KB
/
debug.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//go:build darwin && debug
// +build darwin,debug
package vz
/*
#cgo darwin CFLAGS: -mmacosx-version-min=11 -x objective-c -fno-objc-arc
#cgo darwin LDFLAGS: -lobjc -framework Foundation -framework Virtualization
# include "virtualization_debug.h"
*/
import "C"
import (
"runtime"
"github.com/lima-vm/vz/v4/internal/objc"
)
// DebugStubConfiguration is an interface to debug configuration.
type DebugStubConfiguration interface {
objc.NSObject
debugStubConfiguration()
}
type baseDebugStubConfiguration struct{}
func (*baseDebugStubConfiguration) debugStubConfiguration() {}
// GDBDebugStubConfiguration is a configuration for gdb debugging.
type GDBDebugStubConfiguration struct {
*pointer
*baseDebugStubConfiguration
}
var _ DebugStubConfiguration = (*GDBDebugStubConfiguration)(nil)
// NewGDBDebugStubConfiguration creates a new GDB debug confiuration.
//
// This API is not officially published and is subject to change without notice.
//
// This is only supported on macOS 11 and newer, error will
// be returned on older versions.
func NewGDBDebugStubConfiguration(port uint32) (*GDBDebugStubConfiguration, error) {
if err := macOSAvailable(11); err != nil {
return nil, err
}
config := &GDBDebugStubConfiguration{
pointer: objc.NewPointer(
C.newVZGDBDebugStubConfiguration(C.uint32_t(port)),
),
}
objc.SetFinalizer(config, func(self *GDBDebugStubConfiguration) {
objc.Release(self)
})
return config, nil
}
// SetDebugStubVirtualMachineConfiguration sets debug stub configuration. Empty by default.
//
// This API is not officially published and is subject to change without notice.
func (v *VirtualMachineConfiguration) SetDebugStubVirtualMachineConfiguration(dc DebugStubConfiguration) {
C.setDebugStubVZVirtualMachineConfiguration(objc.Ptr(v), objc.Ptr(dc))
}