Update hcsshim to v0.12.3

Signed-off-by: Kirtana Ashok <kiashok@microsoft.com>
This commit is contained in:
Kirtana Ashok
2024-04-19 15:26:47 -07:00
parent 6e0dc9f50f
commit a6a82c1023
111 changed files with 700 additions and 15536 deletions

View File

@@ -6,7 +6,8 @@ package etw
import (
"bytes"
"encoding/binary"
"syscall"
"golang.org/x/sys/windows"
)
// eventData maintains a buffer which builds up the data for an ETW event. It
@@ -69,6 +70,6 @@ func (ed *eventData) writeUint64(value uint64) {
}
// writeFiletime appends a FILETIME to the buffer.
func (ed *eventData) writeFiletime(value syscall.Filetime) {
func (ed *eventData) writeFiletime(value windows.Filetime) {
_ = binary.Write(&ed.buffer, binary.LittleEndian, value)
}

View File

@@ -1,7 +1,7 @@
//go:build windows
package etw
import "fmt"
// Channel represents the ETW logging channel that is used. It can be used by
// event consumers to give an event special treatment.
type Channel uint8
@@ -19,7 +19,11 @@ const (
// will always be collected.
type Level uint8
var _ fmt.Stringer = Level(0)
// Predefined ETW log levels from winmeta.xml in the Windows SDK.
//
//go:generate go run golang.org/x/tools/cmd/stringer -type=Level -trimprefix=Level
const (
LevelAlways Level = iota
LevelCritical
@@ -32,7 +36,11 @@ const (
// Opcode represents the operation that the event indicates is being performed.
type Opcode uint8
var _ fmt.Stringer = Opcode(0)
// Predefined ETW opcodes from winmeta.xml in the Windows SDK.
//
//go:generate go run golang.org/x/tools/cmd/stringer -type=Opcode -trimprefix=Opcode
const (
// OpcodeInfo indicates an informational event.
OpcodeInfo Opcode = iota
@@ -46,7 +54,7 @@ const (
OpcodeDCStop
)
// EventDescriptor represents various metadata for an ETW event.
// eventDescriptor represents various metadata for an ETW event.
type eventDescriptor struct {
id uint16
version uint8
@@ -57,7 +65,7 @@ type eventDescriptor struct {
keyword uint64
}
// NewEventDescriptor returns an EventDescriptor initialized for use with
// newEventDescriptor returns an EventDescriptor initialized for use with
// TraceLogging.
func newEventDescriptor() *eventDescriptor {
// Standard TraceLogging events default to the TraceLogging channel, and
@@ -68,7 +76,7 @@ func newEventDescriptor() *eventDescriptor {
}
}
// Identity returns the identity of the event. If the identity is not 0, it
// identity returns the identity of the event. If the identity is not 0, it
// should uniquely identify the other event metadata (contained in
// EventDescriptor, and field metadata). Only the lower 24 bits of this value
// are relevant.
@@ -78,7 +86,7 @@ func (ed *eventDescriptor) identity() uint32 {
return (uint32(ed.version) << 16) | uint32(ed.id)
}
// SetIdentity sets the identity of the event. If the identity is not 0, it
// setIdentity sets the identity of the event. If the identity is not 0, it
// should uniquely identify the other event metadata (contained in
// EventDescriptor, and field metadata). Only the lower 24 bits of this value
// are relevant.

View File

@@ -7,9 +7,10 @@ import (
"fmt"
"math"
"reflect"
"syscall"
"time"
"unsafe"
"golang.org/x/sys/windows"
)
// FieldOpt defines the option function type that can be passed to
@@ -56,6 +57,14 @@ func StringField(name string, value string) FieldOpt {
}
}
// JSONStringField adds a JSON-encoded string field to the event.
func JSONStringField(name string, value string) FieldOpt {
return func(em *eventMetadata, ed *eventData) {
em.writeField(name, inTypeANSIString, outTypeJSON, 0)
ed.writeString(value)
}
}
// StringArray adds an array of string to the event.
func StringArray(name string, values []string) FieldOpt {
return func(em *eventMetadata, ed *eventData) {
@@ -389,7 +398,7 @@ func Struct(name string, opts ...FieldOpt) FieldOpt {
func Time(name string, value time.Time) FieldOpt {
return func(em *eventMetadata, ed *eventData) {
em.writeField(name, inTypeFileTime, outTypeDateTimeUTC, 0)
ed.writeFiletime(syscall.NsecToFiletime(value.UTC().UnixNano()))
ed.writeFiletime(windows.NsecToFiletime(value.UTC().UnixNano()))
}
}
@@ -498,7 +507,7 @@ func SmartField(name string, v interface{}) FieldOpt {
case reflect.Float32:
return SmartField(name, float32(rv.Float()))
case reflect.Float64:
return SmartField(name, float64(rv.Float())) //nolint:unconvert // make look consistent
return SmartField(name, float64(rv.Float()))
case reflect.String:
return SmartField(name, rv.String())
case reflect.Struct:

View File

@@ -0,0 +1,28 @@
// Code generated by "stringer -type=Level -trimprefix=Level"; DO NOT EDIT.
package etw
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[LevelAlways-0]
_ = x[LevelCritical-1]
_ = x[LevelError-2]
_ = x[LevelWarning-3]
_ = x[LevelInfo-4]
_ = x[LevelVerbose-5]
}
const _Level_name = "AlwaysCriticalErrorWarningInfoVerbose"
var _Level_index = [...]uint8{0, 6, 14, 19, 26, 30, 37}
func (i Level) String() string {
if i >= Level(len(_Level_index)-1) {
return "Level(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _Level_name[_Level_index[i]:_Level_index[i+1]]
}

View File

@@ -0,0 +1,27 @@
// Code generated by "stringer -type=Opcode -trimprefix=Opcode"; DO NOT EDIT.
package etw
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[OpcodeInfo-0]
_ = x[OpcodeStart-1]
_ = x[OpcodeStop-2]
_ = x[OpcodeDCStart-3]
_ = x[OpcodeDCStop-4]
}
const _Opcode_name = "InfoStartStopDCStartDCStop"
var _Opcode_index = [...]uint8{0, 4, 9, 13, 20, 26}
func (i Opcode) String() string {
if i >= Opcode(len(_Opcode_index)-1) {
return "Opcode(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _Opcode_name[_Opcode_index[i]:_Opcode_index[i+1]]
}

View File

@@ -33,9 +33,6 @@ func errnoErr(e syscall.Errno) error {
case errnoERROR_IO_PENDING:
return errERROR_IO_PENDING
}
// TODO: add more here, after collecting data on the common
// error values see on Windows. (perhaps when running
// all.bat?)
return e
}
@@ -49,7 +46,7 @@ var (
)
func eventRegister(providerId *windows.GUID, callback uintptr, callbackContext uintptr, providerHandle *providerHandle) (win32err error) {
r0, _, _ := syscall.Syscall6(procEventRegister.Addr(), 4, uintptr(unsafe.Pointer(providerId)), uintptr(callback), uintptr(callbackContext), uintptr(unsafe.Pointer(providerHandle)), 0, 0)
r0, _, _ := syscall.SyscallN(procEventRegister.Addr(), uintptr(unsafe.Pointer(providerId)), uintptr(callback), uintptr(callbackContext), uintptr(unsafe.Pointer(providerHandle)))
if r0 != 0 {
win32err = syscall.Errno(r0)
}
@@ -57,7 +54,7 @@ func eventRegister(providerId *windows.GUID, callback uintptr, callbackContext u
}
func eventSetInformation_64(providerHandle providerHandle, class eventInfoClass, information uintptr, length uint32) (win32err error) {
r0, _, _ := syscall.Syscall6(procEventSetInformation.Addr(), 4, uintptr(providerHandle), uintptr(class), uintptr(information), uintptr(length), 0, 0)
r0, _, _ := syscall.SyscallN(procEventSetInformation.Addr(), uintptr(providerHandle), uintptr(class), uintptr(information), uintptr(length))
if r0 != 0 {
win32err = syscall.Errno(r0)
}
@@ -65,7 +62,7 @@ func eventSetInformation_64(providerHandle providerHandle, class eventInfoClass,
}
func eventSetInformation_32(providerHandle_low uint32, providerHandle_high uint32, class eventInfoClass, information uintptr, length uint32) (win32err error) {
r0, _, _ := syscall.Syscall6(procEventSetInformation.Addr(), 5, uintptr(providerHandle_low), uintptr(providerHandle_high), uintptr(class), uintptr(information), uintptr(length), 0)
r0, _, _ := syscall.SyscallN(procEventSetInformation.Addr(), uintptr(providerHandle_low), uintptr(providerHandle_high), uintptr(class), uintptr(information), uintptr(length))
if r0 != 0 {
win32err = syscall.Errno(r0)
}
@@ -73,7 +70,7 @@ func eventSetInformation_32(providerHandle_low uint32, providerHandle_high uint3
}
func eventUnregister_64(providerHandle providerHandle) (win32err error) {
r0, _, _ := syscall.Syscall(procEventUnregister.Addr(), 1, uintptr(providerHandle), 0, 0)
r0, _, _ := syscall.SyscallN(procEventUnregister.Addr(), uintptr(providerHandle))
if r0 != 0 {
win32err = syscall.Errno(r0)
}
@@ -81,7 +78,7 @@ func eventUnregister_64(providerHandle providerHandle) (win32err error) {
}
func eventUnregister_32(providerHandle_low uint32, providerHandle_high uint32) (win32err error) {
r0, _, _ := syscall.Syscall(procEventUnregister.Addr(), 2, uintptr(providerHandle_low), uintptr(providerHandle_high), 0)
r0, _, _ := syscall.SyscallN(procEventUnregister.Addr(), uintptr(providerHandle_low), uintptr(providerHandle_high))
if r0 != 0 {
win32err = syscall.Errno(r0)
}
@@ -89,7 +86,7 @@ func eventUnregister_32(providerHandle_low uint32, providerHandle_high uint32) (
}
func eventWriteTransfer_64(providerHandle providerHandle, descriptor *eventDescriptor, activityID *windows.GUID, relatedActivityID *windows.GUID, dataDescriptorCount uint32, dataDescriptors *eventDataDescriptor) (win32err error) {
r0, _, _ := syscall.Syscall6(procEventWriteTransfer.Addr(), 6, uintptr(providerHandle), uintptr(unsafe.Pointer(descriptor)), uintptr(unsafe.Pointer(activityID)), uintptr(unsafe.Pointer(relatedActivityID)), uintptr(dataDescriptorCount), uintptr(unsafe.Pointer(dataDescriptors)))
r0, _, _ := syscall.SyscallN(procEventWriteTransfer.Addr(), uintptr(providerHandle), uintptr(unsafe.Pointer(descriptor)), uintptr(unsafe.Pointer(activityID)), uintptr(unsafe.Pointer(relatedActivityID)), uintptr(dataDescriptorCount), uintptr(unsafe.Pointer(dataDescriptors)))
if r0 != 0 {
win32err = syscall.Errno(r0)
}
@@ -97,7 +94,7 @@ func eventWriteTransfer_64(providerHandle providerHandle, descriptor *eventDescr
}
func eventWriteTransfer_32(providerHandle_low uint32, providerHandle_high uint32, descriptor *eventDescriptor, activityID *windows.GUID, relatedActivityID *windows.GUID, dataDescriptorCount uint32, dataDescriptors *eventDataDescriptor) (win32err error) {
r0, _, _ := syscall.Syscall9(procEventWriteTransfer.Addr(), 7, uintptr(providerHandle_low), uintptr(providerHandle_high), uintptr(unsafe.Pointer(descriptor)), uintptr(unsafe.Pointer(activityID)), uintptr(unsafe.Pointer(relatedActivityID)), uintptr(dataDescriptorCount), uintptr(unsafe.Pointer(dataDescriptors)), 0, 0)
r0, _, _ := syscall.SyscallN(procEventWriteTransfer.Addr(), uintptr(providerHandle_low), uintptr(providerHandle_high), uintptr(unsafe.Pointer(descriptor)), uintptr(unsafe.Pointer(activityID)), uintptr(unsafe.Pointer(relatedActivityID)), uintptr(dataDescriptorCount), uintptr(unsafe.Pointer(dataDescriptors)))
if r0 != 0 {
win32err = syscall.Errno(r0)
}