Changeset View
Changeset View
Standalone View
Standalone View
cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c
| Show All 37 Lines | |||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <unistd.h> | #include <unistd.h> | ||||
| #include <limits.h> | #include <limits.h> | ||||
| #include <errno.h> | #include <errno.h> | ||||
| #include <fcntl.h> | #include <fcntl.h> | ||||
| #include <dt_impl.h> | #include <dt_impl.h> | ||||
| #include <dt_string.h> | #include <dt_string.h> | ||||
| #include <dt_oformat.h> | |||||
| static int | static int | ||||
| dt_opt_agg(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) | dt_opt_agg(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) | ||||
| { | { | ||||
| dt_aggregate_t *agp = &dtp->dt_aggregate; | dt_aggregate_t *agp = &dtp->dt_aggregate; | ||||
| if (arg != NULL) | if (arg != NULL) | ||||
| return (dt_set_errno(dtp, EDT_BADOPTVAL)); | return (dt_set_errno(dtp, EDT_BADOPTVAL)); | ||||
| ▲ Show 20 Lines • Show All 665 Lines • ▼ Show 20 Lines | dt_opt_size(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) | ||||
| if (arg != NULL && dt_optval_parse(arg, &val) != 0) | if (arg != NULL && dt_optval_parse(arg, &val) != 0) | ||||
| return (dt_set_errno(dtp, EDT_BADOPTVAL)); | return (dt_set_errno(dtp, EDT_BADOPTVAL)); | ||||
| dtp->dt_options[option] = val; | dtp->dt_options[option] = val; | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| static int | static int | ||||
| dt_opt_oformat(dtrace_hdl_t *dtp, const char *arg, uintptr_t option __unused) | |||||
| { | |||||
| if (arg == NULL) | |||||
| return (dt_set_errno(dtp, EDT_BADOPTVAL)); | |||||
| if (xo_set_options(NULL, arg) < 0) | |||||
| return (dt_set_errno(dtp, EDT_BADOPTVAL)); | |||||
| return (dtrace_oformat_configure(dtp)); | |||||
| } | |||||
| static int | |||||
| dt_opt_rate(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) | dt_opt_rate(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) | ||||
| { | { | ||||
| char *end; | char *end; | ||||
phil: Will you be supporting the "csv" encoder? This is another reason to let xo_set_options handle… | |||||
Done Inline ActionsThat's a good point, thanks. I'll change this code to make use of xo_set_options and largely defer the handling of it to libxo. I think I still need to keep the plaintext define around for some bits around libdtrace, but a lot of the other stuff can be cleaned up that way. domagoj.stolfa_gmail.com: That's a good point, thanks. I'll change this code to make use of `xo_set_options` and largely… | |||||
Done Inline ActionsAnd after calling xo_set_options, you can do something like: is_plain_text = (xo_get_style(NULL) == XO_STYLE_TEXT); to set your own flag. phil: And after calling xo_set_options, you can do something like:
is_plain_text = (xo_get_style… | |||||
| int i; | int i; | ||||
| dtrace_optval_t mul = 1, val = 0; | dtrace_optval_t mul = 1, val = 0; | ||||
| const struct { | const struct { | ||||
| char *name; | char *name; | ||||
| hrtime_t mul; | hrtime_t mul; | ||||
| } suffix[] = { | } suffix[] = { | ||||
| { "ns", NANOSEC / NANOSEC }, | { "ns", NANOSEC / NANOSEC }, | ||||
| ▲ Show 20 Lines • Show All 303 Lines • ▼ Show 20 Lines | static const dt_option_t _dtrace_rtoptions[] = { | ||||
| { "cleanrate", dt_opt_rate, DTRACEOPT_CLEANRATE }, | { "cleanrate", dt_opt_rate, DTRACEOPT_CLEANRATE }, | ||||
| { "cpu", dt_opt_runtime, DTRACEOPT_CPU }, | { "cpu", dt_opt_runtime, DTRACEOPT_CPU }, | ||||
| { "destructive", dt_opt_runtime, DTRACEOPT_DESTRUCTIVE }, | { "destructive", dt_opt_runtime, DTRACEOPT_DESTRUCTIVE }, | ||||
| { "dynvarsize", dt_opt_size, DTRACEOPT_DYNVARSIZE }, | { "dynvarsize", dt_opt_size, DTRACEOPT_DYNVARSIZE }, | ||||
| { "grabanon", dt_opt_runtime, DTRACEOPT_GRABANON }, | { "grabanon", dt_opt_runtime, DTRACEOPT_GRABANON }, | ||||
| { "jstackframes", dt_opt_runtime, DTRACEOPT_JSTACKFRAMES }, | { "jstackframes", dt_opt_runtime, DTRACEOPT_JSTACKFRAMES }, | ||||
| { "jstackstrsize", dt_opt_size, DTRACEOPT_JSTACKSTRSIZE }, | { "jstackstrsize", dt_opt_size, DTRACEOPT_JSTACKSTRSIZE }, | ||||
| { "nspec", dt_opt_runtime, DTRACEOPT_NSPEC }, | { "nspec", dt_opt_runtime, DTRACEOPT_NSPEC }, | ||||
| { "oformat", dt_opt_oformat, 0 }, | |||||
| { "specsize", dt_opt_size, DTRACEOPT_SPECSIZE }, | { "specsize", dt_opt_size, DTRACEOPT_SPECSIZE }, | ||||
| { "stackframes", dt_opt_runtime, DTRACEOPT_STACKFRAMES }, | { "stackframes", dt_opt_runtime, DTRACEOPT_STACKFRAMES }, | ||||
| { "statusrate", dt_opt_rate, DTRACEOPT_STATUSRATE }, | { "statusrate", dt_opt_rate, DTRACEOPT_STATUSRATE }, | ||||
| { "strsize", dt_opt_strsize, DTRACEOPT_STRSIZE }, | { "strsize", dt_opt_strsize, DTRACEOPT_STRSIZE }, | ||||
| { "ustackframes", dt_opt_runtime, DTRACEOPT_USTACKFRAMES }, | { "ustackframes", dt_opt_runtime, DTRACEOPT_USTACKFRAMES }, | ||||
| { "temporal", dt_opt_runtime, DTRACEOPT_TEMPORAL }, | { "temporal", dt_opt_runtime, DTRACEOPT_TEMPORAL }, | ||||
| { NULL, NULL, 0 } | { NULL, NULL, 0 } | ||||
| }; | }; | ||||
| ▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines | |||||
Will you be supporting the "csv" encoder? This is another reason to let xo_set_options handle your option processing for you: new encoders are automatically supported.