tools/perf/util/scripting-engines/trace-event-perl.c

Source file repositories/reference/linux-study-clean/tools/perf/util/scripting-engines/trace-event-perl.c

File Facts

System
Linux kernel
Corpus path
tools/perf/util/scripting-engines/trace-event-perl.c
Extension
.c
Size
19244 bytes
Lines
774
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 (!hv_stores(elem, "ip", newSVuv(node->ip))) {
			hv_undef(elem);
			goto exit;
		}

		if (node->ms.sym) {
			HV *sym = newHV();
			if (!sym) {
				hv_undef(elem);
				goto exit;
			}
			if (!hv_stores(sym, "start",   newSVuv(node->ms.sym->start)) ||
			    !hv_stores(sym, "end",     newSVuv(node->ms.sym->end)) ||
			    !hv_stores(sym, "binding", newSVuv(node->ms.sym->binding)) ||
			    !hv_stores(sym, "name",    newSVpvn(node->ms.sym->name,
								node->ms.sym->namelen)) ||
			    !hv_stores(elem, "sym",    newRV_noinc((SV*)sym))) {
				hv_undef(sym);
				hv_undef(elem);
				goto exit;
			}
		}

		if (node->ms.map) {
			struct map *map = node->ms.map;
			struct dso *dso = map ? map__dso(map) : NULL;
			const char *dsoname = "[unknown]";

			if (dso) {
				if (symbol_conf.show_kernel_path && dso__long_name(dso))
					dsoname = dso__long_name(dso);
				else
					dsoname = dso__name(dso);
			}
			if (!hv_stores(elem, "dso", newSVpv(dsoname,0))) {
				hv_undef(elem);
				goto exit;
			}
		}

		callchain_cursor_advance(cursor);
		av_push(list, newRV_noinc((SV*)elem));
	}

exit:
	return newRV_noinc((SV*)list);
}

static void perl_process_tracepoint(struct perf_sample *sample,
				    struct evsel *evsel,
				    struct addr_location *al)
{
	struct thread *thread = al->thread;
	struct tep_event *event;
	struct tep_format_field *field;
	static char handler[256];
	unsigned long long val;
	unsigned long s, ns;
	int pid;
	int cpu = sample->cpu;
	void *data = sample->raw_data;
	unsigned long long nsecs = sample->time;
	const char *comm = thread__comm_str(thread);
	DECLARE_BITMAP(events_defined, TRACE_EVENT_TYPE_MAX);

	bitmap_zero(events_defined, TRACE_EVENT_TYPE_MAX);
	dSP;

	if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT)
		return;

	event = evsel__tp_format(evsel);
	if (!event) {
		pr_debug("ug! no event found for type %" PRIu64, (u64)evsel->core.attr.config);
		return;
	}

	pid = raw_field_value(event, "common_pid", data);

	sprintf(handler, "%s::%s", event->system, event->name);

	if (!__test_and_set_bit(event->id, events_defined))
		define_event_symbols(event, handler, event->print_fmt.args);

	s = nsecs / NSEC_PER_SEC;
	ns = nsecs - s * NSEC_PER_SEC;

	ENTER;
	SAVETMPS;
	PUSHMARK(SP);

Annotation

Implementation Notes