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

trace: allow arg1 to represent a string



This requires changing arg1_is_ptr to arg1_type.
We will use this to print the first 8 characters of
a blobfs filename when collecting event trace data.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I1b321d99145e82b42dcf6d901ce9d6298158edae

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452259


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarZiye Yang <ziye.yang@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent e60cf7e4
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -109,6 +109,13 @@ print_uint64(const char *arg_string, uint64_t arg)
	printf("%-7.7s%-16jd ", arg_string, arg);
}

static void
print_string(const char *arg_string, uint64_t arg)
{
	char *str = (char *)&arg;
	printf("%-7.7s%.8s ", arg_string, str);
}

static void
print_size(uint32_t size)
{
@@ -132,17 +139,23 @@ print_float(const char *arg_string, float arg)
}

static void
print_arg(bool arg_is_ptr, const char *arg_string, uint64_t arg)
print_arg(uint8_t arg_type, const char *arg_string, uint64_t arg)
{
	if (arg_string[0] == 0) {
		printf("%24s", "");
		return;
	}

	if (arg_is_ptr) {
	switch (arg_type) {
	case SPDK_TRACE_ARG_TYPE_PTR:
		print_ptr(arg_string, arg);
	} else {
		break;
	case SPDK_TRACE_ARG_TYPE_INT:
		print_uint64(arg_string, arg);
		break;
	case SPDK_TRACE_ARG_TYPE_STR:
		print_string(arg_string, arg);
		break;
	}
}

@@ -176,7 +189,7 @@ print_event(struct spdk_trace_entry *e, uint64_t tsc_rate,
	printf("%-*s ", (int)sizeof(d->name), d->name);
	print_size(e->size);

	print_arg(d->arg1_is_ptr, d->arg1_name, e->arg1);
	print_arg(d->arg1_type, d->arg1_name, e->arg1);
	if (d->new_object) {
		print_object_id(d->object_type, stats->index[e->object_id]);
	} else if (d->object_type != OBJECT_NONE) {
@@ -195,7 +208,7 @@ print_event(struct spdk_trace_entry *e, uint64_t tsc_rate,
			printf("id:    N/A");
		}
	} else if (e->object_id != 0) {
		print_arg(true, "object: ", e->object_id);
		print_arg(SPDK_TRACE_ARG_TYPE_PTR, "object: ", e->object_id);
	}
	printf("\n");
}
+7 −3
Original line number Diff line number Diff line
@@ -76,6 +76,10 @@ struct spdk_trace_object {
#define SPDK_TRACE_MAX_TPOINT_ID (SPDK_TRACE_MAX_GROUP_ID * 64)
#define SPDK_TPOINT_ID(group, tpoint)	((group * 64) + tpoint)

#define SPDK_TRACE_ARG_TYPE_INT 0
#define SPDK_TRACE_ARG_TYPE_PTR 1
#define SPDK_TRACE_ARG_TYPE_STR 2

struct spdk_trace_tpoint {
	char		name[44];
	char		short_name[4];
@@ -83,7 +87,7 @@ struct spdk_trace_tpoint {
	uint8_t		owner_type;
	uint8_t		object_type;
	uint8_t		new_object;
	uint8_t		arg1_is_ptr;
	uint8_t		arg1_type;
	uint8_t		reserved;
	char		arg1_name[8];
};
@@ -331,13 +335,13 @@ void spdk_trace_register_object(uint8_t type, char id_prefix);
 * \param owner_type Owner type for the tpoint.
 * \param object_type Object type for the tpoint.
 * \param new_object New object for the tpoint.
 * \param arg1_is_ptr This argument indicates whether argument1 is a pointer.
 * \param arg1_type Type of arg1.
 * \param arg1_name Name of argument.
 */
void spdk_trace_register_description(const char *name, const char *short_name,
				     uint16_t tpoint_id, uint8_t owner_type,
				     uint8_t object_type, uint8_t new_object,
				     uint8_t arg1_is_ptr, const char *arg1_name);
				     uint8_t arg1_type, const char *arg1_name);

struct spdk_trace_register_fn *spdk_trace_get_first_register_fn(void);

+2 −2
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ void
spdk_trace_register_description(const char *name, const char *short_name,
				uint16_t tpoint_id, uint8_t owner_type,
				uint8_t object_type, uint8_t new_object,
				uint8_t arg1_is_ptr, const char *arg1_name)
				uint8_t arg1_type, const char *arg1_name)
{
	struct spdk_trace_tpoint *tpoint;

@@ -256,7 +256,7 @@ spdk_trace_register_description(const char *name, const char *short_name,
	tpoint->object_type = object_type;
	tpoint->owner_type = owner_type;
	tpoint->new_object = new_object;
	tpoint->arg1_is_ptr = arg1_is_ptr;
	tpoint->arg1_type = arg1_type;
	snprintf(tpoint->arg1_name, sizeof(tpoint->arg1_name), "%s", arg1_name);
}

+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ DEFINE_STUB_V(spdk_trace_register_object, (uint8_t type, char id_prefix));
DEFINE_STUB_V(spdk_trace_register_description, (const char *name, const char *short_name,
		uint16_t tpoint_id, uint8_t owner_type,
		uint8_t object_type, uint8_t new_object,
		uint8_t arg1_is_ptr, const char *arg1_name));
		uint8_t arg1_type, const char *arg1_name));
DEFINE_STUB_V(_spdk_trace_record, (uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id,
				   uint32_t size, uint64_t object_id, uint64_t arg1));
DEFINE_STUB(spdk_notify_send, uint64_t, (const char *type, const char *ctx), 0);
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ DEFINE_STUB_V(spdk_trace_register_object, (uint8_t type, char id_prefix));
DEFINE_STUB_V(spdk_trace_register_description, (const char *name, const char *short_name,
		uint16_t tpoint_id, uint8_t owner_type,
		uint8_t object_type, uint8_t new_object,
		uint8_t arg1_is_ptr, const char *arg1_name));
		uint8_t arg1_type, const char *arg1_name));
DEFINE_STUB_V(_spdk_trace_record, (uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id,
				   uint32_t size, uint64_t object_id, uint64_t arg1));
DEFINE_STUB(spdk_notify_send, uint64_t, (const char *type, const char *ctx), 0);
Loading