Changeset View
Changeset View
Standalone View
Standalone View
cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| #include <libproc_compat.h> | #include <libproc_compat.h> | ||||
| #endif | #endif | ||||
| #include <assert.h> | #include <assert.h> | ||||
| #include <libgen.h> | #include <libgen.h> | ||||
| #include <limits.h> | #include <limits.h> | ||||
| #include <stdint.h> | #include <stdint.h> | ||||
| #include <dt_impl.h> | #include <dt_impl.h> | ||||
| #include <dt_oformat.h> | |||||
| static const struct { | static const struct { | ||||
| size_t dtps_offset; | size_t dtps_offset; | ||||
| size_t dtps_len; | size_t dtps_len; | ||||
| } dtrace_probespecs[] = { | } dtrace_probespecs[] = { | ||||
| { offsetof(dtrace_probedesc_t, dtpd_provider), DTRACE_PROVNAMELEN }, | { offsetof(dtrace_probedesc_t, dtpd_provider), DTRACE_PROVNAMELEN }, | ||||
| { offsetof(dtrace_probedesc_t, dtpd_mod), DTRACE_MODNAMELEN }, | { offsetof(dtrace_probedesc_t, dtpd_mod), DTRACE_MODNAMELEN }, | ||||
| { offsetof(dtrace_probedesc_t, dtpd_func), DTRACE_FUNCNAMELEN }, | { offsetof(dtrace_probedesc_t, dtpd_func), DTRACE_FUNCNAMELEN }, | ||||
| ▲ Show 20 Lines • Show All 925 Lines • ▼ Show 20 Lines | dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid, | ||||
| } else { | } else { | ||||
| (void) snprintf(c, sizeof (c), "0x%jx", (uintmax_t)addr); | (void) snprintf(c, sizeof (c), "0x%jx", (uintmax_t)addr); | ||||
| } | } | ||||
| dt_proc_unlock(dtp, P); | dt_proc_unlock(dtp, P); | ||||
| dt_proc_release(dtp, P); | dt_proc_release(dtp, P); | ||||
| return (dt_string2str(c, str, nbytes)); | return (dt_string2str(c, str, nbytes)); | ||||
| } | |||||
| int | |||||
| dtrace_oformat_configure(dtrace_hdl_t *dtp) | |||||
| { | |||||
| dtp->dt_oformat = xo_get_style(NULL) == XO_STYLE_TEXT ? | |||||
| DTRACE_OFORMAT_TEXT : | |||||
| DTRACE_OFORMAT_STRUCTURED; | |||||
| xo_set_flags(NULL, XOF_DTRT); | |||||
| return (0); | |||||
| } | |||||
| int | |||||
| dtrace_oformat(dtrace_hdl_t *dtp) | |||||
phil: Here you're assigning the output file for the default handle. Another approach would be to… | |||||
| { | |||||
| return (dtp->dt_oformat != DTRACE_OFORMAT_TEXT); | |||||
| } | |||||
| void | |||||
| dtrace_set_outfp(const FILE *ofp) | |||||
| { | |||||
| xo_set_file((FILE *)ofp); | |||||
| } | |||||
| void | |||||
| dtrace_oformat_setup(dtrace_hdl_t *dtp) | |||||
| { | |||||
| xo_open_container("dtrace"); | |||||
| xo_open_list("probes"); | |||||
| } | |||||
| void | |||||
| dtrace_oformat_teardown(dtrace_hdl_t *dtp) | |||||
| { | |||||
| xo_close_list("probes"); | |||||
| xo_close_container("dtrace"); | |||||
| } | } | ||||
Here you're assigning the output file for the default handle. Another approach would be to make a new handle and use that explicitly. This is certainly a fine choice, but want to make you aware of the alternative and the impact of using the same handle. If you go this way, I'd definitely suggest calling xo_parse_args so all the normal behaviors are available using the normal --libxo options. Also means you can use xo_set_options as I mentioned above.