Documentation ¶
Overview ¶
Package builder contains the Builder type to build replay payloads.
Index ¶
- Constants
- Variables
- type Builder
- func (b *Builder) AllocateMemory(size uint64) value.Pointer
- func (b *Builder) AllocateTemporaryMemory(size uint64) value.Pointer
- func (b *Builder) BeginCommand(cmdID, threadID uint64)
- func (b *Builder) Buffer(count int) value.Pointer
- func (b *Builder) Build(ctx context.Context) (gapir.Payload, PostDataHandler, NotificationHandler, FenceReadyRequestCallback, ...)
- func (b *Builder) Call(f FunctionInfo)
- func (b *Builder) Clone(index int)
- func (b *Builder) CommitCommand(ctx context.Context, optimise bool)
- func (b *Builder) Copy(size uint64)
- func (b *Builder) Export(ctx context.Context) (gapir.Payload, error)
- func (b *Builder) GetMappedTarget(ptr value.Pointer) (value.Pointer, error)
- func (b *Builder) GetNotificationID() uint64
- func (b *Builder) JumpLabel(label uint32)
- func (b *Builder) JumpNZ(label uint32)
- func (b *Builder) JumpZ(label uint32)
- func (b *Builder) Load(ty protocol.Type, addr value.Pointer)
- func (b *Builder) MapMemory(rng memory.Range)
- func (b *Builder) Memcpy(target value.Pointer, src value.Pointer, size uint64)
- func (b *Builder) MemoryLayout() *device.MemoryLayout
- func (b *Builder) MemoryRanges() MappedMemoryRangeList
- func (b *Builder) Notification(ID uint64, addr value.Pointer, size uint64)
- func (b *Builder) Pop(count uint32)
- func (b *Builder) Post(addr value.Pointer, size uint64, p Postback)
- func (b *Builder) Push(val value.Value)
- func (b *Builder) RegisterFenceReadyRequestCallback(fenceID uint32, callback FenceReadyRequestCallback) error
- func (b *Builder) RegisterNotificationReader(notificationID uint64, reader NotificationReader) error
- func (b *Builder) RegisterReplayStatusReader(ctx context.Context, r *status.Replay) error
- func (b *Builder) ReserveMemory(rng memory.Range)
- func (b *Builder) RevertCommand(err error)
- func (b *Builder) Store(addr value.Pointer)
- func (b *Builder) StorePointer(idx value.PointerIndex, ptr value.Pointer)
- func (b *Builder) Strcpy(maxCount uint64)
- func (b *Builder) String(s string) value.Pointer
- func (b *Builder) Sub(num int32)
- func (b *Builder) UnmapMemory(rng memory.Range)
- func (b *Builder) Wait(ID uint32)
- func (b *Builder) Write(rng memory.Range, resourceID id.ID)
- type FenceReadyRequestCallback
- type FunctionInfo
- type MappedMemoryRangeList
- func (l *MappedMemoryRangeList) Copy(to, from, count int)
- func (l *MappedMemoryRangeList) GetSpan(index int) interval.U64Span
- func (l *MappedMemoryRangeList) Length() int
- func (l *MappedMemoryRangeList) New(index int, span interval.U64Span)
- func (l *MappedMemoryRangeList) Resize(length int)
- func (l *MappedMemoryRangeList) SetSpan(index int, span interval.U64Span)
- type NotificationHandler
- type NotificationReader
- type PostDataHandler
- type Postback
Constants ¶
const ( // IssuesNotificationID is the Notification ID reserved for issues report. // The ID needs to be kept in sync with |kIssuesNotificationId| defined in // `gapir/cc/grpc_replay_service.cpp`. IssuesNotificationID = uint64(0) // ReplayProgressNotificationID is the Notification ID reserved for replay // status information transfer. // The ID needs to be kept in sync with |kReplayProgressNotificationID| // defined in `gapir/cc/grpc_replay_service.cpp`. ReplayProgressNotificationID = uint64(1) // The value used to initialize nextNotificationID. Need to be increased as // well when more notification id are reserved for special use. InitialNextNotificationID = uint64(2) )
const ErrInvalidResource = fault.Const("Invaid resource")
Variables ¶
var ErrReplayNotExecuted = errors.New("replay was canceled")
ErrReplayNotExecuted indicate the replay request was canceled.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct { // Remappings is a map of a arbitrary keys to pointers. Typically, this is // used as a map of observed values to values that are only known at replay // execution time, such as driver generated handles. // The Remappings field is not accessed by the Builder and can be used in any // way the developer requires. Remappings map[interface{}]value.Pointer // contains filtered or unexported fields }
Builder is used to build the Payload to send to the replay virtual machine. The builder has a number of methods for mutating the virtual machine stack, invoking functions and posting back data.
func New ¶
func New(memoryLayout *device.MemoryLayout, dependent *Builder) *Builder
New returns a newly constructed Builder configured to replay on a target with the specified MemoryLayout.
func (*Builder) AllocateMemory ¶
AllocateMemory allocates and returns a pointer to a block of memory in the volatile address-space big enough to hold size bytes. The memory will be allocated for the entire replay duration and cannot be freed.
func (*Builder) AllocateTemporaryMemory ¶
AllocateTemporaryMemory allocates and returns a pointer to a block of memory in the temporary volatile address-space big enough to hold size bytes. The memory block will be freed on the next call to CommitCommand/AbortCommand, upon which reading or writing to this memory will result in undefined behavior. TODO: REMOVE
func (*Builder) BeginCommand ¶
BeginCommand should be called before building any replay instructions.
func (*Builder) Buffer ¶
Buffer returns a pointer to a block of memory in holding the count number of previously pushed values. If all the values are constant, then the buffer will be held in the constant address-space, otherwise the buffer will be built in the temporary address-space.
func (*Builder) Build ¶
func (b *Builder) Build(ctx context.Context) (gapir.Payload, PostDataHandler, NotificationHandler, FenceReadyRequestCallback, error)
Build compiles the replay instructions, returning a Payload that can be sent to the replay virtual-machine and a PostDataHandler for interpreting the responses.
func (*Builder) Call ¶
func (b *Builder) Call(f FunctionInfo)
Call will invoke the function f, popping all parameter values previously pushed to the stack with Push, starting with the first parameter. If f has a non-void return type, after invoking the function the return value of the function will be pushed on to the stack.
func (*Builder) Clone ¶
Clone makes a copy of the n-th element from the top of the stack and pushes the copy to the top of the stack.
func (*Builder) CommitCommand ¶
CommitCommand should be called after emitting the commands to replay a single command. CommitCommand frees all temporary allocated memory and clears the stack.
func (*Builder) Copy ¶
Copy pops the target address and then the source address from the top of the stack, and then copies Count bytes from source to target.
func (*Builder) Export ¶
Export compiles the replay instructions, returning a Payload that can be sent to the replay virtual-machine.
func (*Builder) GetMappedTarget ¶
GetMappedTarget gets current mapped memory's target address pointer in the builder. The input |ptr| is the start of the mapped memory range. Returns the target address on success and error otherwise.
func (*Builder) GetNotificationID ¶
GetNotificationID returns the next available notification ID that identifies a notification.
func (*Builder) JumpLabel ¶
JumpLabel adds a jump label to the instructions so that later can jump to that label and start execution from this label.
func (*Builder) JumpNZ ¶
JumpNZ jumps to the instruction specified label if the value on top of the stack is not zero. Otherwise it will be be a Nop.
func (*Builder) JumpZ ¶
JumpZ jumps to the instruction specified label if the value on top of the stack is zero. Otherwise it will be be a Nop.
func (*Builder) Load ¶
Load loads the value of type ty from addr and then pushes the loaded value to the top of the stack.
func (*Builder) MapMemory ¶
MapMemory maps the memory range rng relative to the absolute pointer that is on the top of the stack. Any ObservedPointers that are used while the pointer is mapped will be automatically adjusted to the remapped address. The mapped memory range can be unmapped with a call to UnmapMemory.
func (*Builder) MemoryLayout ¶
func (b *Builder) MemoryLayout() *device.MemoryLayout
MemoryLayout returns the memory layout for the target replay device.
func (*Builder) MemoryRanges ¶
func (b *Builder) MemoryRanges() MappedMemoryRangeList
func (*Builder) Notification ¶
Notification asks the GAPIR to stream back the size bytes from addr. The |ID| will be sent back as well to help identify which reader will process the notification. A Notification reader must be registered to read the data the from the stream.
func (*Builder) Post ¶
Post posts size bytes from addr to the decoder d. The decoder d must consume all size bytes before returning; failure to do this will corrupt all subsequent postbacks.
func (*Builder) RegisterFenceReadyRequestCallback ¶
func (b *Builder) RegisterFenceReadyRequestCallback(fenceID uint32, callback FenceReadyRequestCallback) error
func (*Builder) RegisterNotificationReader ¶
func (b *Builder) RegisterNotificationReader(notificationID uint64, reader NotificationReader) error
RegisterNotificationReader registers a notification reader for a specific notificationID. Returns error if the notificationID has already been registered.
func (*Builder) RegisterReplayStatusReader ¶
RegisterReplayStatusReader create and register a NotificationReader, which is used to decode and handle replay status information sent from GAPIR.
func (*Builder) ReserveMemory ¶
ReserveMemory adds rng as a memory range that needs allocating for replay.
func (*Builder) RevertCommand ¶
RevertCommand reverts all the instructions since the last call to BeginCommand. Any postbacks issued since the last call to BeginCommand will be called with the error err and a nil decoder.
func (*Builder) Store ¶
Store pops the value from the top of the stack and writes the value to addr.
func (*Builder) StorePointer ¶
func (b *Builder) StorePointer(idx value.PointerIndex, ptr value.Pointer)
StorePointer writes ptr to the target pointer index. Pointers are stored in a separate address space and can only be loaded using PointerIndex values.
func (*Builder) Strcpy ¶
Strcpy pops the source address then the target address from the top of the stack, and then copies at most maxCount-1 bytes from source to target. If maxCount is greater than the source string length, then the target will be padded with 0s. The destination buffer will always be 0-terminated.
func (*Builder) String ¶
String returns a pointer to a block of memory in the constant address-space holding the string s. The string will be stored with a null-terminating byte.
func (*Builder) Sub ¶
Sub pops the value from top of stack, substracts by num and pushes back the result to the top of the stack.
func (*Builder) UnmapMemory ¶
UnmapMemory unmaps the memory range rng that was previously mapped with a call to MapMemory. If the memory range is not exactly a range previously mapped with a call to MapMemory then this function panics.
type FenceReadyRequestCallback ¶
type FenceReadyRequestCallback func(p *gapir.FenceReadyRequest)
type FunctionInfo ¶
type FunctionInfo struct { ApiIndex uint8 // The index of the API this function belongs to. ID uint16 // The unique identifier for the function. ReturnType protocol.Type // The returns type of the function. Parameters int // The number of parameters for the function. }
FunctionInfo holds the information about a function that can be called by the replay virtual-machine.
type MappedMemoryRangeList ¶
type MappedMemoryRangeList []mappedMemoryRange
MappedMemoryRangeList represents a bunch of mapped memory ranges, and the location that they are stored in the heap.
func (*MappedMemoryRangeList) Copy ¶
func (l *MappedMemoryRangeList) Copy(to, from, count int)
Copy performs a copy of ranges within the MappedMemoryRangeList.
func (*MappedMemoryRangeList) GetSpan ¶
func (l *MappedMemoryRangeList) GetSpan(index int) interval.U64Span
GetSpan returns the span of the range with the specified index in the MappedMemoryRangeList.
func (*MappedMemoryRangeList) Length ¶
func (l *MappedMemoryRangeList) Length() int
Length returns the number of ranges in the MappedMemoryRangeList.
func (*MappedMemoryRangeList) New ¶
func (l *MappedMemoryRangeList) New(index int, span interval.U64Span)
New replaces specified index in the MappedMemoryRangeList.
func (*MappedMemoryRangeList) Resize ¶
func (l *MappedMemoryRangeList) Resize(length int)
Resize resizes the MappedMemoryRangeList to the specified length.
type NotificationHandler ¶
type NotificationHandler func(p *gapir.Notification)
NotificationHandler handles the original Notification messages from the replay virtual machine.
type NotificationReader ¶
type NotificationReader func(p gapir.Notification)
NotificationReader reads a given copy of notification message received from the replay virtual machine.
type PostDataHandler ¶
PostDataHandler handles the original PostData messages, which may contains multiple pieces of post back data issued by multiple POST instructions, from the replay virual machine.