X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fconfig%2Fsession-config.c;h=c2ae5e1201fb0cf0b4ef51c438ee74d48fe6d86f;hp=5b5adbfc42afa3d761325cd1708ebf9c3e029b46;hb=499cbfa121fa1bc9ea78294f26b274b35fbc5e0a;hpb=c1e83fb4cecbb43353e4e1d2092b0516b50a5c26 diff --git a/src/common/config/session-config.c b/src/common/config/session-config.c index 5b5adbfc4..c2ae5e120 100644 --- a/src/common/config/session-config.c +++ b/src/common/config/session-config.c @@ -90,16 +90,16 @@ const char * const config_element_symbol_name = "symbol_name"; const char * const config_element_address = "address"; const char * const config_element_offset = "offset"; -const char * const config_element_userspace_probe_lookup = "lookup_method"; -const char * const config_element_userspace_probe_lookup_function_default = "DEFAULT"; -const char * const config_element_userspace_probe_lookup_function_elf = "ELF"; -const char * const config_element_userspace_probe_lookup_tracepoint_sdt = "SDT"; -const char * const config_element_userspace_probe_location_binary_path = "binary_path"; -const char * const config_element_userspace_probe_function_attributes = "userspace_probe_function_attributes"; -const char * const config_element_userspace_probe_function_location_function_name = "function_name"; -const char * const config_element_userspace_probe_tracepoint_attributes = "userspace_probe_tracepoint_attributes"; -const char * const config_element_userspace_probe_tracepoint_location_provider_name = "provider_name"; -const char * const config_element_userspace_probe_tracepoint_location_probe_name = "probe_name"; +LTTNG_HIDDEN const char * const config_element_userspace_probe_lookup = "lookup_method"; +LTTNG_HIDDEN const char * const config_element_userspace_probe_lookup_function_default = "DEFAULT"; +LTTNG_HIDDEN const char * const config_element_userspace_probe_lookup_function_elf = "ELF"; +LTTNG_HIDDEN const char * const config_element_userspace_probe_lookup_tracepoint_sdt = "SDT"; +LTTNG_HIDDEN const char * const config_element_userspace_probe_location_binary_path = "binary_path"; +LTTNG_HIDDEN const char * const config_element_userspace_probe_function_attributes = "userspace_probe_function_attributes"; +LTTNG_HIDDEN const char * const config_element_userspace_probe_function_location_function_name = "function_name"; +LTTNG_HIDDEN const char * const config_element_userspace_probe_tracepoint_attributes = "userspace_probe_tracepoint_attributes"; +LTTNG_HIDDEN const char * const config_element_userspace_probe_tracepoint_location_provider_name = "provider_name"; +LTTNG_HIDDEN const char * const config_element_userspace_probe_tracepoint_location_probe_name = "probe_name"; const char * const config_element_name = "name"; const char * const config_element_enabled = "enabled"; @@ -177,7 +177,7 @@ const char * const config_loglevel_type_single = "SINGLE"; const char * const config_event_type_all = "ALL"; const char * const config_event_type_tracepoint = "TRACEPOINT"; const char * const config_event_type_probe = "PROBE"; -const char * const config_event_type_userspace_probe = "USERSPACE_PROBE"; +LTTNG_HIDDEN const char * const config_event_type_userspace_probe = "USERSPACE_PROBE"; const char * const config_event_type_function = "FUNCTION"; const char * const config_event_type_function_entry = "FUNCTION_ENTRY"; const char * const config_event_type_noop = "NOOP"; @@ -205,6 +205,25 @@ LTTNG_HIDDEN const char * const config_event_context_need_reschedule = "NEED_RES LTTNG_HIDDEN const char * const config_event_context_migratable = "MIGRATABLE"; LTTNG_HIDDEN const char * const config_event_context_callstack_user= "CALLSTACK_USER"; LTTNG_HIDDEN const char * const config_event_context_callstack_kernel = "CALLSTACK_KERNEL"; +LTTNG_HIDDEN const char * const config_event_context_cgroup_ns = "CGROUP_NS"; +LTTNG_HIDDEN const char * const config_event_context_ipc_ns = "IPC_NS"; +LTTNG_HIDDEN const char * const config_event_context_mnt_ns = "MNT_NS"; +LTTNG_HIDDEN const char * const config_event_context_net_ns = "NET_NS"; +LTTNG_HIDDEN const char * const config_event_context_pid_ns = "PID_NS"; +LTTNG_HIDDEN const char * const config_event_context_user_ns = "USER_NS"; +LTTNG_HIDDEN const char * const config_event_context_uts_ns = "UTS_NS"; +LTTNG_HIDDEN const char * const config_event_context_uid = "UID"; +LTTNG_HIDDEN const char * const config_event_context_euid = "EUID"; +LTTNG_HIDDEN const char * const config_event_context_suid = "SUID"; +LTTNG_HIDDEN const char * const config_event_context_gid = "GID"; +LTTNG_HIDDEN const char * const config_event_context_egid = "EGID"; +LTTNG_HIDDEN const char * const config_event_context_sgid = "SGID"; +LTTNG_HIDDEN const char * const config_event_context_vuid = "VUID"; +LTTNG_HIDDEN const char * const config_event_context_veuid = "VEUID"; +LTTNG_HIDDEN const char * const config_event_context_vsuid = "VSUID"; +LTTNG_HIDDEN const char * const config_event_context_vgid = "VGID"; +LTTNG_HIDDEN const char * const config_event_context_vegid = "VEGID"; +LTTNG_HIDDEN const char * const config_event_context_vsgid = "VSGID"; /* Deprecated symbols */ const char * const config_element_perf; @@ -250,7 +269,7 @@ int config_get_section_entries(const char *override_path, const char *section, config_entry_handler_cb handler, void *user_data) { int ret = 0; - char *path; + const char *path; FILE *config_file = NULL; struct handler_filter_args filter = { section, handler, user_data }; @@ -1047,6 +1066,63 @@ int get_context_type(xmlChar *context_type) } else if (!strcmp((char *) context_type, config_event_context_callstack_kernel)) { ret = LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL; + } else if (!strcmp((char *) context_type, + config_event_context_cgroup_ns)) { + ret = LTTNG_EVENT_CONTEXT_CGROUP_NS; + } else if (!strcmp((char *) context_type, + config_event_context_ipc_ns)) { + ret = LTTNG_EVENT_CONTEXT_IPC_NS; + } else if (!strcmp((char *) context_type, + config_event_context_mnt_ns)) { + ret = LTTNG_EVENT_CONTEXT_MNT_NS; + } else if (!strcmp((char *) context_type, + config_event_context_net_ns)) { + ret = LTTNG_EVENT_CONTEXT_NET_NS; + } else if (!strcmp((char *) context_type, + config_event_context_pid_ns)) { + ret = LTTNG_EVENT_CONTEXT_PID_NS; + } else if (!strcmp((char *) context_type, + config_event_context_user_ns)) { + ret = LTTNG_EVENT_CONTEXT_USER_NS; + } else if (!strcmp((char *) context_type, + config_event_context_uts_ns)) { + ret = LTTNG_EVENT_CONTEXT_UTS_NS; + } else if (!strcmp((char *) context_type, + config_event_context_uid)) { + ret = LTTNG_EVENT_CONTEXT_UID; + } else if (!strcmp((char *) context_type, + config_event_context_euid)) { + ret = LTTNG_EVENT_CONTEXT_EUID; + } else if (!strcmp((char *) context_type, + config_event_context_suid)) { + ret = LTTNG_EVENT_CONTEXT_SUID; + } else if (!strcmp((char *) context_type, + config_event_context_gid)) { + ret = LTTNG_EVENT_CONTEXT_GID; + } else if (!strcmp((char *) context_type, + config_event_context_egid)) { + ret = LTTNG_EVENT_CONTEXT_EGID; + } else if (!strcmp((char *) context_type, + config_event_context_sgid)) { + ret = LTTNG_EVENT_CONTEXT_SGID; + } else if (!strcmp((char *) context_type, + config_event_context_vuid)) { + ret = LTTNG_EVENT_CONTEXT_VUID; + } else if (!strcmp((char *) context_type, + config_event_context_veuid)) { + ret = LTTNG_EVENT_CONTEXT_VEUID; + } else if (!strcmp((char *) context_type, + config_event_context_vsuid)) { + ret = LTTNG_EVENT_CONTEXT_VSUID; + } else if (!strcmp((char *) context_type, + config_event_context_vgid)) { + ret = LTTNG_EVENT_CONTEXT_VGID; + } else if (!strcmp((char *) context_type, + config_event_context_vegid)) { + ret = LTTNG_EVENT_CONTEXT_VEGID; + } else if (!strcmp((char *) context_type, + config_event_context_vsgid)) { + ret = LTTNG_EVENT_CONTEXT_VSGID; } else { goto error; } @@ -1479,9 +1555,8 @@ struct lttng_userspace_probe_location * process_userspace_probe_function_attribute_node( xmlNodePtr attribute_node) { - xmlChar *content; xmlNodePtr function_attribute_node; - char *function_name = NULL, *binary_path = NULL, *lookup_method_name; + char *function_name = NULL, *binary_path = NULL; struct lttng_userspace_probe_location *location = NULL; struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL; @@ -1499,42 +1574,23 @@ process_userspace_probe_function_attribute_node( /* Handle function name, binary path and lookup method. */ if (!strcmp((const char *) function_attribute_node->name, config_element_userspace_probe_function_location_function_name)) { - content = xmlNodeGetContent(function_attribute_node); - if (!content) { - goto error; - } - - function_name = lttng_strndup((char *) content, LTTNG_SYMBOL_NAME_LEN); - free(content); + function_name = (char *) xmlNodeGetContent(function_attribute_node); if (!function_name) { - PERROR("Error duplicating function name"); goto error; } } else if (!strcmp((const char *) function_attribute_node->name, config_element_userspace_probe_location_binary_path)) { - content = xmlNodeGetContent(function_attribute_node); - if (!content) { - goto error; - } - - binary_path = lttng_strndup((char *) content, LTTNG_PATH_MAX); - free(content); + binary_path = (char *) xmlNodeGetContent(function_attribute_node); if (!binary_path) { - PERROR("Error duplicating binary path"); goto error; } } else if (!strcmp((const char *) function_attribute_node->name, config_element_userspace_probe_lookup)) { - content = xmlNodeGetContent(function_attribute_node); - if (!content) { - goto error; - } + char *lookup_method_name; - lookup_method_name = lttng_strndup((char *) content, - CONFIG_USERSPACE_PROBE_LOOKUP_METHOD_NAME_MAX_LEN); - free(content); + lookup_method_name = (char *) xmlNodeGetContent( + function_attribute_node); if (!lookup_method_name) { - PERROR("Error duplicating lookup method name"); goto error; } @@ -1547,12 +1603,13 @@ process_userspace_probe_function_attribute_node( lookup_method = lttng_userspace_probe_location_lookup_method_function_elf_create(); if (!lookup_method) { PERROR("Error creating function default/ELF lookup method"); - free(lookup_method_name); - goto error; } } else { - WARN("Unknown function lookup method."); - free(lookup_method_name); + WARN("Unknown function lookup method"); + } + + free(lookup_method_name); + if (!lookup_method) { goto error; } } else { @@ -1561,20 +1618,19 @@ process_userspace_probe_function_attribute_node( /* Check if all the necessary fields were found. */ if (binary_path && function_name && lookup_method) { + /* Ownership of lookup_method is transferred. */ location = lttng_userspace_probe_location_function_create( binary_path, function_name, lookup_method); - goto end; + lookup_method = NULL; + goto error; } } error: + lttng_userspace_probe_location_lookup_method_destroy(lookup_method); free(binary_path); free(function_name); - if (lookup_method) { - lttng_userspace_probe_location_lookup_method_destroy(lookup_method); - } -end: return location; } @@ -1583,9 +1639,7 @@ struct lttng_userspace_probe_location * process_userspace_probe_tracepoint_attribute_node( xmlNodePtr attribute_node) { - xmlChar *content; xmlNodePtr tracepoint_attribute_node; - char *lookup_method_name = NULL; char *probe_name = NULL, *provider_name = NULL, *binary_path = NULL; struct lttng_userspace_probe_location *location = NULL; struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL; @@ -1602,58 +1656,29 @@ process_userspace_probe_tracepoint_attribute_node( tracepoint_attribute_node)) { if (!strcmp((const char *) tracepoint_attribute_node->name, config_element_userspace_probe_tracepoint_location_probe_name)) { - content = xmlNodeGetContent(tracepoint_attribute_node); - if (!content) { - goto error; - } - - probe_name = lttng_strndup((char*) content, LTTNG_SYMBOL_NAME_LEN); - free(content); + probe_name = (char *) xmlNodeGetContent(tracepoint_attribute_node); if (!probe_name) { - PERROR("Error duplicating probe name"); goto error; } } else if (!strcmp((const char *) tracepoint_attribute_node->name, config_element_userspace_probe_tracepoint_location_provider_name)) { - content = xmlNodeGetContent(tracepoint_attribute_node); - if (!content) { - goto error; - } - - provider_name = lttng_strndup((char*) content, LTTNG_SYMBOL_NAME_LEN); - free(content); + provider_name = (char *) xmlNodeGetContent(tracepoint_attribute_node); if (!provider_name) { - PERROR("Error duplicating provider name"); goto error; } } else if (!strcmp((const char *) tracepoint_attribute_node->name, config_element_userspace_probe_location_binary_path)) { - content = xmlNodeGetContent(tracepoint_attribute_node); - if (!content) { - goto error; - } - - binary_path = lttng_strndup((char*) content, LTTNG_PATH_MAX); - - free(content); - + binary_path = (char *) xmlNodeGetContent(tracepoint_attribute_node); if (!binary_path) { - PERROR("Error duplicating binary path"); goto error; } } else if (!strcmp((const char *) tracepoint_attribute_node->name, config_element_userspace_probe_lookup)) { - content = xmlNodeGetContent(tracepoint_attribute_node); - if (!content) { - goto error; - } - - lookup_method_name = lttng_strndup((char *) content, - CONFIG_USERSPACE_PROBE_LOOKUP_METHOD_NAME_MAX_LEN); - free(content); + char *lookup_method_name; + lookup_method_name = (char *) xmlNodeGetContent( + tracepoint_attribute_node); if (!lookup_method_name) { - PERROR("Error duplicating lookup method name"); goto error; } @@ -1663,35 +1688,36 @@ process_userspace_probe_tracepoint_attribute_node( lttng_userspace_probe_location_lookup_method_tracepoint_sdt_create(); if (!lookup_method) { PERROR("Error creating tracepoint SDT lookup method"); - free(lookup_method_name); - goto error; } } else { - WARN("Unknown tracepoint lookup method."); + WARN("Unknown tracepoint lookup method"); + } + + free(lookup_method_name); + if (!lookup_method) { goto error; } } else { - WARN("Unknown tracepoint attribute."); + WARN("Unknown tracepoint attribute"); goto error; } /* Check if all the necessary fields were found. */ if (binary_path && provider_name && probe_name && lookup_method) { + /* Ownership of lookup_method is transferred. */ location = lttng_userspace_probe_location_tracepoint_create( binary_path, provider_name, probe_name, lookup_method); - goto end; + lookup_method = NULL; + goto error; } } error: + lttng_userspace_probe_location_lookup_method_destroy(lookup_method); free(binary_path); - free(probe_name); free(provider_name); - if (lookup_method) { - lttng_userspace_probe_location_lookup_method_destroy(lookup_method); - } -end: + free(probe_name); return location; } @@ -2103,6 +2129,7 @@ end: free(exclusions[i]); } + lttng_event_destroy(event); free(exclusions); free(filter_expression); return ret; @@ -3581,7 +3608,7 @@ int config_load_session(const char *path, const char *session_name, } if (!path) { - char *home_path; + const char *home_path; const char *sys_path; /* Try home path */