if (count_wallclock) {
/* wall clock time spent while in syscall */
ts_sub(&wts, syscall_exiting_ts, &tcp->etime);
- ts_sub(&wts, &wts, &overhead);
} else {
/* system CPU time spent while in syscall */
- ts_sub(&wts, &tcp->dtime, &overhead);
+ ts_sub(&wts, &tcp->stime, &tcp->ltime);
}
+ ts_sub(&wts, &wts, &overhead);
ts_add(&cc->time, &cc->time, ts_max(&wts, &zero_ts));
}
const struct_sysent *s_prev_ent; /* for "resuming interrupted SYSCALL" msg */
struct inject_opts *inject_vec[SUPPORTED_PERSONALITIES];
struct timespec stime; /* System time usage as of last process wait */
- struct timespec dtime; /* Delta for system time usage */
- struct timespec etime; /* Syscall entry time */
+ struct timespec ltime; /* System time usage as of last syscall entry */
+ struct timespec atime; /* System time right after attach */
+ struct timespec etime; /* Syscall entry time (CLOCK_MONOTONIC) */
struct timespec delay_expiration_time; /* When does the delay end */
struct mmap_cache_t *mmap_cache;
if (tcp->pid == 0)
return;
+ if (cflag && debug_flag) {
+ struct timespec dt;
+
+ ts_sub(&dt, &tcp->stime, &tcp->atime);
+ debug_func_msg("pid %d: %.9f seconds of system time spent "
+ "since attach", tcp->pid, ts_float(&dt));
+ }
+
int p;
for (p = 0; p < SUPPORTED_PERSONALITIES; ++p)
free(tcp->inject_vec[p]);
if ((tcp->flags & TCB_GRABBED) && (get_scno(tcp) == 1))
tcp->s_prev_ent = tcp->s_ent;
+
+ if (cflag) {
+ tcp->atime = tcp->stime;
+ }
}
static void
}
if (cflag) {
- struct timespec stime = {
- .tv_sec = ru.ru_stime.tv_sec,
- .tv_nsec = ru.ru_stime.tv_usec * 1000
- };
- ts_sub(&tcp->dtime, &stime, &tcp->stime);
- tcp->stime = stime;
+ tcp->stime.tv_sec = ru.ru_stime.tv_sec;
+ tcp->stime.tv_nsec = ru.ru_stime.tv_usec * 1000;
}
tcb_wait_tab_check_size(wait_tab_pos);
{
tcp->flags |= TCB_INSYSCALL;
tcp->sys_func_rval = res;
+
/* Measure the entrance time as late as possible to avoid errors. */
if ((Tflag || cflag) && !filtered(tcp))
clock_gettime(CLOCK_MONOTONIC, &tcp->etime);
+
+ /* Start tracking system time */
+ if (cflag) {
+ if (debug_flag) {
+ struct timespec dt;
+
+ ts_sub(&dt, &tcp->stime, &tcp->ltime);
+
+ if (ts_nz(&dt))
+ debug_func_msg("pid %d: %.9f seconds of system "
+ "time spent since the last "
+ "syscall exit",
+ tcp->pid, ts_float(&dt));
+ }
+
+ tcp->ltime = tcp->stime;
+ }
}
/* Returns:
tcp->flags &= ~(TCB_INSYSCALL | TCB_TAMPERED | TCB_INJECT_DELAY_EXIT);
tcp->sys_func_rval = 0;
free_tcb_priv_data(tcp);
+
+ if (cflag)
+ tcp->ltime = tcp->stime;
}
bool