return str_dom;
}
+static
+int save_pid_tracker(struct config_writer *writer,
+ struct ltt_session *sess, int domain)
+{
+ int ret = 0;
+ ssize_t nr_pids = 0, i;
+ int32_t *pids = NULL;
+
+ switch (domain) {
+ case LTTNG_DOMAIN_KERNEL:
+ {
+ nr_pids = kernel_list_tracker_pids(sess->kernel_session, &pids);
+ if (nr_pids < 0) {
+ ret = LTTNG_ERR_KERN_LIST_FAIL;
+ goto end;
+ }
+ break;
+ }
+ case LTTNG_DOMAIN_UST:
+ {
+ nr_pids = trace_ust_list_tracker_pids(sess->ust_session, &pids);
+ if (nr_pids < 0) {
+ ret = LTTNG_ERR_UST_LIST_FAIL;
+ goto end;
+ }
+ break;
+ }
+ case LTTNG_DOMAIN_JUL:
+ case LTTNG_DOMAIN_LOG4J:
+ case LTTNG_DOMAIN_PYTHON:
+ default:
+ ret = LTTNG_ERR_UNKNOWN_DOMAIN;
+ goto end;
+ }
+
+ /* Only create a pid_tracker if enabled or untrack all */
+ if (nr_pids != 1 || (nr_pids == 1 && pids[0] != -1)) {
+ ret = config_writer_open_element(writer,
+ config_element_pid_tracker);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+
+ ret = config_writer_open_element(writer,
+ config_element_targets);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+
+ for (i = 0; i < nr_pids; i++) {
+ ret = config_writer_open_element(writer,
+ config_element_target_pid);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+
+ ret = config_writer_write_element_unsigned_int(writer,
+ config_element_pid, pids[i]);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+
+ /* /pid_target */
+ ret = config_writer_close_element(writer);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+ }
+
+ /* /targets */
+ ret = config_writer_close_element(writer);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+
+ /* /pid_tracker */
+ ret = config_writer_close_element(writer);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+ }
+end:
+ free(pids);
+ return ret;
+}
+
static
int save_ust_domain(struct config_writer *writer,
struct ltt_session *session, enum lttng_domain_type domain)
goto end;
}
- /* /domain */
- ret = config_writer_close_element(writer);
- if (ret) {
- ret = LTTNG_ERR_SAVE_IO_FAIL;
- goto end;
- }
-
-end:
- return ret;
-}
-
-static
-int save_pid_tracker(struct config_writer *writer,
- struct ltt_session *sess, int domain)
-{
- int ret = 0;
- ssize_t nr_pids = 0, i;
- int32_t *pids = NULL;
-
- switch (domain) {
- case LTTNG_DOMAIN_KERNEL:
- {
- nr_pids = kernel_list_tracker_pids(sess->kernel_session, &pids);
- if (nr_pids < 0) {
- ret = LTTNG_ERR_KERN_LIST_FAIL;
- goto end;
- }
- break;
- }
- case LTTNG_DOMAIN_UST:
- {
- nr_pids = trace_ust_list_tracker_pids(sess->ust_session, &pids);
- if (nr_pids < 0) {
- ret = LTTNG_ERR_UST_LIST_FAIL;
- goto end;
- }
- break;
- }
- case LTTNG_DOMAIN_JUL:
- case LTTNG_DOMAIN_LOG4J:
- case LTTNG_DOMAIN_PYTHON:
- default:
- ret = LTTNG_ERR_UNKNOWN_DOMAIN;
- goto end;
- }
-
- /* Only create a pid_tracker if enabled or untrack all */
- if (nr_pids != 1 || (nr_pids == 1 && pids[0] != -1)) {
+ if (domain == LTTNG_DOMAIN_UST) {
ret = config_writer_open_element(writer,
- config_element_pid_tracker);
+ config_element_trackers);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_open_element(writer,
- config_element_targets);
+ ret = save_pid_tracker(writer, session, LTTNG_DOMAIN_UST);
if (ret) {
- ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- for (i = 0; i < nr_pids; i++) {
- ret = config_writer_open_element(writer,
- config_element_target_pid);
- if (ret) {
- ret = LTTNG_ERR_SAVE_IO_FAIL;
- goto end;
- }
-
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_pid, pids[i]);
- if (ret) {
- ret = LTTNG_ERR_SAVE_IO_FAIL;
- goto end;
- }
-
- /* /pid_target */
- ret = config_writer_close_element(writer);
- if (ret) {
- ret = LTTNG_ERR_SAVE_IO_FAIL;
- goto end;
- }
- }
-
- /* /targets */
+ /* /trackers */
ret = config_writer_close_element(writer);
if (ret) {
- ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
+ }
- /* /pid_tracker */
- ret = config_writer_close_element(writer);
- if (ret) {
- ret = LTTNG_ERR_SAVE_IO_FAIL;
- goto end;
- }
+ /* /domain */
+ ret = config_writer_close_element(writer);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
}
+
end:
- free(pids);
return ret;
}
goto end;
}
- ret = config_writer_open_element(writer,
- config_element_trackers);
- if (ret) {
- ret = LTTNG_ERR_SAVE_IO_FAIL;
- goto end;
- }
-
- ret = save_pid_tracker(writer, session, LTTNG_DOMAIN_UST);
- if (ret) {
- goto end;
- }
-
- /* /trackers */
- ret = config_writer_close_element(writer);
- if (ret) {
- goto end;
- }
-
ret = save_ust_domain(writer, session, LTTNG_DOMAIN_JUL);
if (ret) {
goto end;