Changeset View
Standalone View
cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c
| Show All 29 Lines | |||||
| */ | */ | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <strings.h> | #include <strings.h> | ||||
| #include <errno.h> | #include <errno.h> | ||||
| #include <unistd.h> | #include <unistd.h> | ||||
| #include <dt_impl.h> | #include <dt_impl.h> | ||||
| #include <assert.h> | #include <assert.h> | ||||
| #include <dt_oformat.h> | |||||
| #ifdef illumos | #ifdef illumos | ||||
| #include <alloca.h> | #include <alloca.h> | ||||
| #else | #else | ||||
| #include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
| #include <libproc_compat.h> | #include <libproc_compat.h> | ||||
| #endif | #endif | ||||
| #include <limits.h> | #include <limits.h> | ||||
| ▲ Show 20 Lines • Show All 420 Lines • ▼ Show 20 Lines | if (errno == ENOENT) { | ||||
| */ | */ | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| return (dt_set_errno(dtp, errno)); | return (dt_set_errno(dtp, errno)); | ||||
| } | } | ||||
| if (buf->dtbd_drops != 0) { | if (buf->dtbd_drops != 0) { | ||||
| xo_open_instance("probes"); | |||||
| dt_oformat_drop(dtp, cpu); | |||||
| if (dt_handle_cpudrop(dtp, cpu, | if (dt_handle_cpudrop(dtp, cpu, | ||||
| DTRACEDROP_AGGREGATION, buf->dtbd_drops) == -1) | DTRACEDROP_AGGREGATION, buf->dtbd_drops) == -1) { | ||||
| xo_close_instance("probes"); | |||||
| return (-1); | return (-1); | ||||
| } | } | ||||
| xo_close_instance("probes"); | |||||
phil: Are you supporting "-o"? If so, do you need to use an explicit handle (and xo_open_instance_h… | |||||
Done Inline ActionsI've considered using xo_open_instance_h and the likes, however since all of the output would need to be redirected anyway I've decided to just defer it to libxo using xo_set_file to minimize book-keeping in dtrace_hdl. Do you think there would be any benefit to doing this explicitly from a libxo perspective? I can't really think of a use-case where I would want to partition the output in any way in libdtrace as it stands. domagoj.stolfa_gmail.com: I've considered using `xo_open_instance_h` and the likes, however since all of the output would… | |||||
| } | |||||
| if (buf->dtbd_size == 0) | if (buf->dtbd_size == 0) | ||||
| return (0); | return (0); | ||||
| if (hash->dtah_hash == NULL) { | if (hash->dtah_hash == NULL) { | ||||
| size_t size; | size_t size; | ||||
| hash->dtah_size = DTRACE_AHASHSIZE; | hash->dtah_size = DTRACE_AHASHSIZE; | ||||
| ▲ Show 20 Lines • Show All 1,636 Lines • ▼ Show 20 Lines | dtrace_aggregate_print(dtrace_hdl_t *dtp, FILE *fp, | ||||
| pd.dtpa_dtp = dtp; | pd.dtpa_dtp = dtp; | ||||
| pd.dtpa_fp = fp; | pd.dtpa_fp = fp; | ||||
| pd.dtpa_allunprint = 1; | pd.dtpa_allunprint = 1; | ||||
| if (func == NULL) | if (func == NULL) | ||||
| func = dtrace_aggregate_walk_sorted; | func = dtrace_aggregate_walk_sorted; | ||||
| if (dtp->dt_oformat) { | |||||
| if ((*func)(dtp, dt_format_agg, &pd) == -1) | |||||
| return (dt_set_errno(dtp, dtp->dt_errno)); | |||||
| } else { | |||||
Done Inline ActionsWhy is the flush call needed in this case but not the regular one? markj: Why is the flush call needed in this case but not the regular one? | |||||
Done Inline ActionsWhen we don't use libxo, we don't really care when the flush happens because it's not really meant to be read by a machine in a structured way. However, an explicit flush in the case of libxo should allow one to reliably read aggregation data from a pipe if running under something like Python, so that the data can be processed while DTrace is still running. At least that's the idea :). Do you think we should call xo_flush() in both cases? domagoj.stolfa_gmail.com: When we don't use libxo, we don't really care when the flush happens because it's not really… | |||||
Done Inline ActionsSo this fixes an actual problem you encountered? I don't quite understand what you mean by "reliably". The fact that we flush in one case but not the other just looks odd, I don't have an opinion on whether we should flush or not. If it's necessary to flush in one case but not the other, a comment should explain why. markj: So this fixes an actual problem you encountered? I don't quite understand what you mean by… | |||||
| if ((*func)(dtp, dt_print_agg, &pd) == -1) | if ((*func)(dtp, dt_print_agg, &pd) == -1) | ||||
| return (dt_set_errno(dtp, dtp->dt_errno)); | return (dt_set_errno(dtp, dtp->dt_errno)); | ||||
| } | |||||
| return (0); | return (0); | ||||
| } | } | ||||
| void | void | ||||
| dtrace_aggregate_clear(dtrace_hdl_t *dtp) | dtrace_aggregate_clear(dtrace_hdl_t *dtp) | ||||
| { | { | ||||
| dt_aggregate_t *agp = &dtp->dt_aggregate; | dt_aggregate_t *agp = &dtp->dt_aggregate; | ||||
| ▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines | |||||
Are you supporting "-o"? If so, do you need to use an explicit handle (and xo_open_instance_h, etc)? Or does the "-o" file get dup2'd to stdout, so this isn't needed?