Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
update wasi-go to v0.3.2
Browse files Browse the repository at this point in the history
Signed-off-by: Achille Roussel <[email protected]>
  • Loading branch information
achille-roussel committed Jun 5, 2023
1 parent 17623f1 commit 8d79c58
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 31 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3
github.com/google/uuid v1.3.0
github.com/klauspost/compress v1.16.5
github.com/stealthrocket/wasi-go v0.3.2-0.20230604190248-9463acc8381d
github.com/stealthrocket/wasi-go v0.3.2
github.com/stealthrocket/wazergo v0.19.0
github.com/stealthrocket/wzprof v0.1.5
github.com/tetratelabs/wazero v1.1.1-0.20230522055633-256b7a4bf970
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ github.com/stealthrocket/wasi-go v0.3.2-0.20230604180758-b724aaba60ad h1:5v+GFNF
github.com/stealthrocket/wasi-go v0.3.2-0.20230604180758-b724aaba60ad/go.mod h1:LBhZHvAroNNQTejkVTMJZ01ssj3jXF+3Lkbru4cTzGQ=
github.com/stealthrocket/wasi-go v0.3.2-0.20230604190248-9463acc8381d h1:MSwJU5X7hpy64tJezvNs57qVOH3yjCMbv6Xlg1jqPaE=
github.com/stealthrocket/wasi-go v0.3.2-0.20230604190248-9463acc8381d/go.mod h1:LBhZHvAroNNQTejkVTMJZ01ssj3jXF+3Lkbru4cTzGQ=
github.com/stealthrocket/wasi-go v0.3.2-0.20230605001215-37616feebb15 h1:kMeRG7sDa39KtH3z0wuVz0djquExJoc+uIVNtec2GQA=
github.com/stealthrocket/wasi-go v0.3.2-0.20230605001215-37616feebb15/go.mod h1:LBhZHvAroNNQTejkVTMJZ01ssj3jXF+3Lkbru4cTzGQ=
github.com/stealthrocket/wasi-go v0.3.2 h1:69jmfwmWPGgL6U5aSFrSIKq9ea3WuqFfHuq9bizx0ZE=
github.com/stealthrocket/wasi-go v0.3.2/go.mod h1:LBhZHvAroNNQTejkVTMJZ01ssj3jXF+3Lkbru4cTzGQ=
github.com/stealthrocket/wazergo v0.19.0 h1:0ZBya2fBURvV+I2hGl0vcuQ8dgoUvllxQ7aYlZSA5nI=
github.com/stealthrocket/wazergo v0.19.0/go.mod h1:riI0hxw4ndZA5e6z7PesHg2BtTftcZaMxRcoiGGipTs=
github.com/stealthrocket/wzprof v0.1.5 h1:abEwQF9KtqV7UQ0hWk7431vul9/FxOg1eRCqwEKo9/4=
Expand Down
2 changes: 1 addition & 1 deletion internal/debug/nettrace/nettrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ func (r *EventReader) Read(events []Event) (n int, err error) {
r.sockets[fd] = socket

case wasicall.SockBind:
fd, addr, errno, err := r.codec.DecodeSockBind(record.FunctionCall)
fd, _, addr, errno, err := r.codec.DecodeSockBind(record.FunctionCall)
if err != nil {
return n, err
}
Expand Down
11 changes: 8 additions & 3 deletions internal/timemachine/wasicall/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -976,19 +976,24 @@ func (c *Codec) DecodeSockOpen(buffer []byte) (family ProtocolFamily, socketType
return
}

func (c *Codec) EncodeSockBind(buffer []byte, fd FD, addr SocketAddress, errno Errno) []byte {
func (c *Codec) EncodeSockBind(buffer []byte, fd FD, bind, addr SocketAddress, errno Errno) []byte {
buffer = encodeErrno(buffer, errno)
buffer = encodeFD(buffer, fd)
return encodeAddr(buffer, addr)
buffer = encodeAddr(buffer, bind)
buffer = encodeAddr(buffer, addr)
return buffer
}

func (c *Codec) DecodeSockBind(buffer []byte) (fd FD, addr SocketAddress, errno Errno, err error) {
func (c *Codec) DecodeSockBind(buffer []byte) (fd FD, bind, addr SocketAddress, errno Errno, err error) {
if errno, buffer, err = decodeErrno(buffer); err != nil {
return
}
if fd, buffer, err = decodeFD(buffer); err != nil {
return
}
if bind, _, err = decodeAddr(buffer); err != nil {
return
}
addr, _, err = decodeAddr(buffer)
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/timemachine/wasicall/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (s *exitSystem) SockOpen(ctx context.Context, family ProtocolFamily, socket
panic(s.newExitError())
}

func (s *exitSystem) SockBind(ctx context.Context, fd FD, addr SocketAddress) (errno Errno) {
func (s *exitSystem) SockBind(ctx context.Context, fd FD, bind SocketAddress) (addr SocketAddress, errno Errno) {
panic(s.newExitError())
}

Expand Down
10 changes: 5 additions & 5 deletions internal/timemachine/wasicall/fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,22 +414,22 @@ fallback:
return se.SockOpen(ctx, family, socketType, protocol, rightsBase, rightsInheriting)
}

func (f *FallbackSystem) SockBind(ctx context.Context, fd FD, addr SocketAddress) (errno Errno) {
func (f *FallbackSystem) SockBind(ctx context.Context, fd FD, bind SocketAddress) (addr SocketAddress, errno Errno) {
se, ok := f.System.(SocketsExtension)
if !ok {
goto fallback
}
errno = se.SockBind(ctx, fd, addr)
addr, errno = se.SockBind(ctx, fd, bind)
if errno == ENOSYS {
goto fallback
}
return errno
return addr, errno
fallback:
se, ok = f.secondary.(SocketsExtension)
if !ok {
return ENOSYS
return nil, ENOSYS
}
return se.SockBind(ctx, fd, addr)
return se.SockBind(ctx, fd, bind)
}

func (f *FallbackSystem) SockConnect(ctx context.Context, fd FD, peer SocketAddress) (addr SocketAddress, errno Errno) {
Expand Down
10 changes: 5 additions & 5 deletions internal/timemachine/wasicall/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,17 +545,17 @@ func (o *Observer) SockOpen(ctx context.Context, family ProtocolFamily, socketTy
return
}

func (o *Observer) SockBind(ctx context.Context, fd FD, addr SocketAddress) (errno Errno) {
func (o *Observer) SockBind(ctx context.Context, fd FD, bind SocketAddress) (addr SocketAddress, errno Errno) {
se, ok := o.System.(SocketsExtension)
if !ok {
return ENOSYS
return nil, ENOSYS
}
if o.before != nil {
o.before(ctx, &SockBindSyscall{fd, addr, errno})
o.before(ctx, &SockBindSyscall{fd, bind, addr, errno})
}
errno = se.SockBind(ctx, fd, addr)
addr, errno = se.SockBind(ctx, fd, bind)
if o.after != nil {
o.after(ctx, &SockBindSyscall{fd, addr, errno})
o.after(ctx, &SockBindSyscall{fd, bind, addr, errno})
}
return
}
Expand Down
4 changes: 2 additions & 2 deletions internal/timemachine/wasicall/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ func (r *Reader) ReadSyscall() (time.Time, Syscall, error) {
}
syscall = &SockOpenSyscall{family, socketType, protocol, rightsBase, rightsInheriting, fd, errno}
case SockBind:
fd, addr, errno, err := r.codec.DecodeSockBind(record.FunctionCall)
fd, bind, addr, errno, err := r.codec.DecodeSockBind(record.FunctionCall)
if err != nil {
return time.Time{}, nil, &DecodeError{record, err}
}
syscall = &SockBindSyscall{fd, addr, errno}
syscall = &SockBindSyscall{fd, bind, addr, errno}
case SockConnect:
fd, peer, addr, errno, err := r.codec.DecodeSockConnect(record.FunctionCall)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions internal/timemachine/wasicall/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,14 @@ func (r *Recorder) SockOpen(ctx context.Context, pf ProtocolFamily, socketType S
return fd, errno
}

func (r *Recorder) SockBind(ctx context.Context, fd FD, addr SocketAddress) Errno {
func (r *Recorder) SockBind(ctx context.Context, fd FD, bind SocketAddress) (SocketAddress, Errno) {
s, ok := r.system.(SocketsExtension)
if !ok {
return ENOSYS
return nil, ENOSYS
}
errno := s.SockBind(ctx, fd, addr)
r.record(SockBind, r.codec.EncodeSockBind(r.buffer[:0], fd, addr, errno))
return errno
addr, errno := s.SockBind(ctx, fd, bind)
r.record(SockBind, r.codec.EncodeSockBind(r.buffer[:0], fd, bind, addr, errno))
return addr, errno
}

func (r *Recorder) SockConnect(ctx context.Context, fd FD, peer SocketAddress) (SocketAddress, Errno) {
Expand Down
12 changes: 6 additions & 6 deletions internal/timemachine/wasicall/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -1172,12 +1172,12 @@ func (r *Replay) SockOpen(ctx context.Context, protocolFamily ProtocolFamily, so
return newfd, errno
}

func (r *Replay) SockBind(ctx context.Context, fd FD, addr SocketAddress) Errno {
func (r *Replay) SockBind(ctx context.Context, fd FD, bind SocketAddress) (SocketAddress, Errno) {
record, ok := r.readRecord(SockBind)
if !ok {
return ENOSYS
return nil, ENOSYS
}
recordFD, recordAddr, errno, err := r.codec.DecodeSockBind(record.FunctionCall)
recordFD, recordBind, recordAddr, errno, err := r.codec.DecodeSockBind(record.FunctionCall)
if err != nil {
panic(&DecodeError{record, err})
}
Expand All @@ -1186,14 +1186,14 @@ func (r *Replay) SockBind(ctx context.Context, fd FD, addr SocketAddress) Errno
if fd != recordFD {
mismatch = append(mismatch, &UnexpectedSyscallParamError{SockBind, "fd", fd, recordFD})
}
if addr != recordAddr {
mismatch = append(mismatch, &UnexpectedSyscallParamError{SockBind, "addr", addr, recordAddr})
if bind != recordBind {
mismatch = append(mismatch, &UnexpectedSyscallParamError{SockBind, "bind", bind, recordBind})
}
if len(mismatch) > 0 {
panic(errors.Join(mismatch...))
}
}
return errno
return recordAddr, errno
}

func (r *Replay) SockConnect(ctx context.Context, fd FD, peer SocketAddress) (SocketAddress, Errno) {
Expand Down
5 changes: 3 additions & 2 deletions internal/timemachine/wasicall/syscall.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,14 @@ func (s *SockOpenSyscall) private() {}

type SockBindSyscall struct {
FD FD
Bind SocketAddress
Addr SocketAddress
Errno Errno
}

func (s *SockBindSyscall) ID() SyscallID { return SockBind }
func (s *SockBindSyscall) Params() []any { return []any{s.FD, s.Addr} }
func (s *SockBindSyscall) Results() []any { return []any{s.Errno} }
func (s *SockBindSyscall) Params() []any { return []any{s.FD, s.Bind} }
func (s *SockBindSyscall) Results() []any { return []any{s.Addr, s.Errno} }
func (s *SockBindSyscall) Error() Errno { return s.Errno }
func (s *SockBindSyscall) private() {}

Expand Down

0 comments on commit 8d79c58

Please sign in to comment.