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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
inttypes.hstdio.hstdlib.hstring.hctype.herrno.hlinux/bitmap.hlinux/time64.hevent-parse.hstdbool.hEXTERN.hperl.h../callchain.h../dso.h../machine.h../map.h../symbol.h../thread.h../event.h../trace-event.h../evsel.h../debug.h
Detected Declarations
function xs_initfunction define_symbolic_valuefunction define_symbolic_valuesfunction define_symbolic_fieldfunction define_flag_valuefunction define_flag_valuesfunction define_flag_fieldfunction define_event_symbolsfunction perl_process_tracepointfunction perl_process_event_genericfunction perl_process_eventfunction run_start_subfunction perl_start_scriptfunction perl_flush_scriptfunction perl_stop_scriptfunction perl_generate_script
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
- Immediate include surface: `inttypes.h`, `stdio.h`, `stdlib.h`, `string.h`, `ctype.h`, `errno.h`, `linux/bitmap.h`, `linux/time64.h`.
- Detected declarations: `function xs_init`, `function define_symbolic_value`, `function define_symbolic_values`, `function define_symbolic_field`, `function define_flag_value`, `function define_flag_values`, `function define_flag_field`, `function define_event_symbols`, `function perl_process_tracepoint`, `function perl_process_event_generic`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.