(void)klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET); if (read(memf, (char *)tcp_debug, sizeof(tcp_debug)) != sizeof(tcp_debug)) { perror("trpt: tcp_debug"); exit(3); }
if (kvm_read(kd, nl[N_TCP_DEBUG].n_value, (char *)tcp_debug, sizeof(tcp_debug)) != sizeof(tcp_debug)) errx(3, "tcp_debug: %s", kvm_geterr(kd));
dotrace(tcpcb)	register caddr_t tcpcb;{	register struct tcp_debug *td;	register int i;	int prev_debx = tcp_debx;again:	if (--tcp_debx < 0)		tcp_debx = TCP_NDEBUG - 1;	for (i = prev_debx % TCP_NDEBUG; i < TCP_NDEBUG; i++) {		td = &tcp_debug[i];		if (tcpcb && td->td_tcb != tcpcb)			continue;		ntime = ntohl(td->td_time);		tcp_trace(td->td_act, td->td_ostate, td->td_tcb, &td->td_cb,		    &td->td_ti, td->td_req);		if (i == tcp_debx)			goto done;	}	for (i = 0; i <= tcp_debx % TCP_NDEBUG; i++) {		td = &tcp_debug[i];		if (tcpcb && td->td_tcb != tcpcb)			continue;		ntime = ntohl(td->td_time);		tcp_trace(td->td_act, td->td_ostate, td->td_tcb, &td->td_cb,		    &td->td_ti, td->td_req);	}done:	if (follow) {		prev_debx = tcp_debx + 1;		if (prev_debx >= TCP_NDEBUG)			prev_debx = 0;		do {			sleep(1);			(void)klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET);			if (read(memf, (char *)&tcp_debx, sizeof(tcp_debx)) !=			    sizeof(tcp_debx)) {				perror("trpt: tcp_debx");				exit(3);			}		} while (tcp_debx == prev_debx);		(void)klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET);		if (read(memf, (char *)tcp_debug, sizeof(tcp_debug)) !=		    sizeof(tcp_debug)) {			perror("trpt: tcp_debug");			exit(3);		}		goto again;	}}