tools/perf/tests/sample-parsing.c

Source file repositories/reference/linux-study-clean/tools/perf/tests/sample-parsing.c

File Facts

System
Linux kernel
Corpus path
tools/perf/tests/sample-parsing.c
Extension
.c
Size
11546 bytes
Lines
461
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if (read_format & PERF_FORMAT_GROUP) {
			for (i = 0; i < s1->read.group.nr; i++) {
				/* FIXME: check values without LOST */
				if (read_format & PERF_FORMAT_LOST)
					MCOMP(read.group.values[i]);
			}
		} else {
			COMP(read.one.id);
			if (read_format & PERF_FORMAT_LOST)
				COMP(read.one.lost);
		}
	}

	if (type & PERF_SAMPLE_CALLCHAIN) {
		COMP(callchain->nr);
		for (i = 0; i < s1->callchain->nr; i++)
			COMP(callchain->ips[i]);
	}

	if (type & PERF_SAMPLE_RAW) {
		COMP(raw_size);
		if (memcmp(s1->raw_data, s2->raw_data, s1->raw_size)) {
			pr_debug("Samples differ at 'raw_data'\n");
			return false;
		}
	}

	if (type & PERF_SAMPLE_BRANCH_STACK) {
		COMP(branch_stack->nr);
		COMP(branch_stack->hw_idx);
		for (i = 0; i < s1->branch_stack->nr; i++) {
			if (needs_swap)
				return ((host_is_bigendian()) ?
					(FLAG(s2).value == BS_EXPECTED_BE) :
					(FLAG(s2).value == BS_EXPECTED_LE));
			else
				MCOMP(branch_stack->entries[i]);
		}
	}

	if (type & PERF_SAMPLE_REGS_USER) {
		struct regs_dump *s1_regs = perf_sample__user_regs(s1);
		struct regs_dump *s2_regs = perf_sample__user_regs(s2);
		size_t sz = hweight_long(s1_regs->mask) * sizeof(u64);

		COMP(user_regs->mask);
		COMP(user_regs->abi);
		if (s1_regs->abi &&
		    (!s1_regs->regs || !s2_regs->regs ||
		     memcmp(s1_regs->regs, s2_regs->regs, sz))) {
			pr_debug("Samples differ at 'user_regs'\n");
			return false;
		}
	}

	if (type & PERF_SAMPLE_STACK_USER) {
		COMP(user_stack.size);
		if (memcmp(s1->user_stack.data, s2->user_stack.data,
			   s1->user_stack.size)) {
			pr_debug("Samples differ at 'user_stack'\n");
			return false;
		}
	}

	if (type & PERF_SAMPLE_WEIGHT)
		COMP(weight);

	if (type & PERF_SAMPLE_WEIGHT_STRUCT) {
		COMP(weight);
		COMP(ins_lat);
		COMP(weight3);
	}

	if (type & PERF_SAMPLE_DATA_SRC)
		COMP(data_src);

	if (type & PERF_SAMPLE_TRANSACTION)
		COMP(transaction);

	if (type & PERF_SAMPLE_REGS_INTR) {
		struct regs_dump *s1_regs = perf_sample__intr_regs(s1);
		struct regs_dump *s2_regs = perf_sample__intr_regs(s2);
		size_t sz = hweight_long(s1_regs->mask) * sizeof(u64);

		COMP(intr_regs->mask);
		COMP(intr_regs->abi);
		if (s1_regs->abi &&
		    (!s1_regs->regs || !s2_regs->regs ||
		     memcmp(s1_regs->regs, s2_regs->regs, sz))) {
			pr_debug("Samples differ at 'intr_regs'\n");

Annotation

Implementation Notes