/** Return pointer to tracebuffer event. * @param position of event in tracebuffer: * 0 is last event, 1 the event before and so on * @return pointer to tracebuffer event * * event with idx == 0 is the last event queued in * event with idx == 1 is the event before */ PUBLIC static Tb_entry* Jdb_tbuf::unfiltered_lookup(Mword idx) { if (!event_valid(idx)) return 0; Tb_entry_union *e = _tbuf_act - idx - 1; if (e < buffer()) e += _max_entries; return e; }
static void cpu_op(perf_cpu_t *cpu, pfn_pf_event_op_t op) { if (!event_valid(cpu)) { return; } if (op(cpu) != 0) { /* * ioctl is failed. It might be the CPU is offline or other * error occurred. */ pf_resource_free(cpu); } }
void event_unbind_cookie(event_id_t ev, void *cookie) { event_t *prev = NULL, *e, *next; if (!(event_valid(ev))) return; for(e = events[ev]; e != NULL; prev=e, e = next) { next = e->next; if (e->cookie == cookie) { event_destroy(e); if (prev == NULL) events[ev] = next; else prev->next = next; } } }
void event_unbind(event_id_t ev, event_handler_t *handler) { event_t *prev = NULL, *e, *next; if (!(event_valid(ev))) return; for(e = events[ev]; e != NULL; prev=e, e = next) { next = e->next; if (e->handler == handler) { event_destroy(e); if (prev == NULL) events[ev] = next; else prev->next = next; } } }
void event_bind(event_id_t ev, event_handler_t *handler, void *user_data, void *cookie) { event_t *e; if (!(event_valid(ev))) return; e = malloc(sizeof(event_t)); e->handler = handler; e->cookie = cookie; e->user_data = user_data; /* insert the new event in front of the list */ e->next = events[ev]; events[ev] = e; }
static int cpu_profiling_smpl(perf_cpu_t *cpu, void *arg) { pf_profiling_rec_t *record; track_proc_t *proc; track_lwp_t *lwp; node_t *node; count_value_t diff; int i, j, record_num; if (!event_valid(cpu)) { return (0); } /* * The record is grouped by pid/tid. */ pf_profiling_record(cpu, s_profiling_recbuf, &record_num); if (record_num == 0) { return (0); } if ((node = node_by_cpu(cpu->cpuid)) == NULL) { return (0); } countval_diff_base(cpu, &s_profiling_recbuf[0]); for (i = 1; i < record_num; i++) { record = &s_profiling_recbuf[i]; countval_diff(cpu, record, &diff); if ((proc = proc_find(record->pid)) == NULL) { return (0); } if ((lwp = proc_lwp_find(proc, record->tid)) == NULL) { proc_refcount_dec(proc); return (0); } pthread_mutex_lock(&proc->mutex); for (j = 0; j < COUNT_NUM; j++) { if (!s_partpause_enabled) { proc_countval_update(proc, cpu->cpuid, j, diff.counts[j]); lwp_countval_update(lwp, cpu->cpuid, j, diff.counts[j]); node_countval_update(node, j, diff.counts[j]); } if ((record->ip_num > 0) && (diff.counts[j] >= g_sample_period[j][g_precise])) { /* * The event is overflowed. The call-chain represents * the context when event is overflowed. */ chain_add(&proc->count_chain, j, diff.counts[j], record->ips, record->ip_num); chain_add(&lwp->count_chain, j, diff.counts[j], record->ips, record->ip_num); } } pthread_mutex_unlock(&proc->mutex); lwp_refcount_dec(lwp); proc_refcount_dec(proc); } return (0); }