public override Task <WatchAddressResponse> WatchAddress(WatchAddressRequest request,
                                                                 ServerCallContext context)
        {
            if (!_targetStore.TryGetValue(request.Target.Id, out RemoteTarget target))
            {
                ErrorUtils.ThrowError(StatusCode.Internal,
                                      "Could not find target in store: " + request.Target.Id);
            }

            var          response   = new WatchAddressResponse();
            SbWatchpoint watchpoint = target.WatchAddress(
                request.Address, request.Size, request.Read, request.Write, out SbError error);

            response.Error = new GrpcSbError {
                Success = error.Success(),
                Error   = error.GetCString(),
            };
            if (watchpoint != null)
            {
                response.Watchpoint = new GrpcSbWatchpoint {
                    Id = _watchpointStore.AddObject(watchpoint),
                };
            }
            return(Task.FromResult(response));
        }
Ejemplo n.º 2
0
        public SbWatchpoint WatchAddress(long address, ulong size, bool read, bool write,
                                         out SbError error)
        {
            WatchAddressResponse response = null;

            error = null;
            if (connection.InvokeRpc(() =>
            {
                response = client.WatchAddress(
                    new WatchAddressRequest
                {
                    Target = grpcSbTarget,
                    Address = address,
                    Size = size,
                    Read = read,
                    Write = write
                });
            }))
            {
                error = errorFactory.Create(response.Error);
                if (response.Watchpoint != null && response.Watchpoint.Id != 0)
                {
                    return(watchpointFactory.Create(connection, response.Watchpoint));
                }
                return(null);
            }
            var grpcError = new GrpcSbError
            {
                Success = false,
                Error   = "Rpc error while calling WatchAddress."
            };

            error = errorFactory.Create(grpcError);
            return(null);
        }