Commit e1eee2eb authored by Jim Harris's avatar Jim Harris
Browse files

event: always fail if invalid tpoint mask is specified



There were a few error cases that weren't caught
as errors, meaning the "invalid tpoint mask" string
wouldn't be printed.

But also change it so that when an invalid tpoint mask
is specified, it fails spdk_app_start and causes the
application to exit, rather than just silently
stopping processing of the tpoint group mask string.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I567a4eee740559914e089dca7d7c3865ed9ce35b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13986


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJacek Kalwas <jacek.kalwas@intel.com>
parent a68a12a4
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -343,6 +343,7 @@ app_setup_trace(struct spdk_app_opts *opts)
	uint64_t	tpoint_group_mask, tpoint_mask = -1ULL;
	char		*end = NULL, *tpoint_group_mask_str, *tpoint_group_str = NULL;
	char		*tp_g_str, *tpoint_group, *tpoints;
	bool		error_found = false;
	uint64_t	group_id;

	if (opts->shm_id >= 0) {
@@ -379,6 +380,7 @@ app_setup_trace(struct spdk_app_opts *opts)
			if (*end != '\0' || errno) {
				tpoint_group_mask = spdk_trace_create_tpoint_group_mask(tpoint_group);
				if (tpoint_group_mask == 0) {
					error_found = true;
					break;
				}
			}
@@ -388,12 +390,14 @@ app_setup_trace(struct spdk_app_opts *opts)
			if (!spdk_u64_is_pow2(tpoint_group_mask)) {
				SPDK_ERRLOG("Tpoint group mask: %s contains multiple tpoint groups.\n", tpoint_group);
				SPDK_ERRLOG("This is not supported, to prevent from activating tpoints by mistake.\n");
				error_found = true;
				break;
			}

			errno = 0;
			tpoint_mask = strtoull(tpoints, &end, 16);
			if (*end != '\0' || errno) {
				error_found = true;
				break;
			}
		} else {
@@ -402,6 +406,7 @@ app_setup_trace(struct spdk_app_opts *opts)
			if (*end != '\0' || errno) {
				tpoint_group_mask = spdk_trace_create_tpoint_group_mask(tpoint_group_str);
				if (tpoint_group_mask == 0) {
					error_found = true;
					break;
				}
			}
@@ -415,8 +420,9 @@ app_setup_trace(struct spdk_app_opts *opts)
		}
	}

	if (tpoint_group_str != NULL) {
	if (error_found) {
		SPDK_ERRLOG("invalid tpoint mask %s\n", opts->tpoint_group_mask);
		return -1;
	} else {
		SPDK_NOTICELOG("Tracepoint Group Mask %s specified.\n", opts->tpoint_group_mask);
		SPDK_NOTICELOG("Use 'spdk_trace -s %s %s %d' to capture a snapshot of events at runtime.\n",