tools/perf/util/trace-event-scripting.c
Source file repositories/reference/linux-study-clean/tools/perf/util/trace-event-scripting.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/trace-event-scripting.c- Extension
.c- Size
- 10039 bytes
- Lines
- 411
- 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
stdio.hstdlib.hstring.herrno.hevent-parse.hdebug.hevent.htrace-event.hevsel.hlinux/perf_event.hlinux/zalloc.hutil/sample.h
Detected Declarations
struct script_specfunction script_spec__addfunction script_spec_registerfunction script_spec__for_eachfunction list_for_each_entryfunction scripting_context__updatefunction flush_script_unsupportedfunction stop_script_unsupportedfunction process_event_unsupportedfunction python_start_script_unsupportedfunction python_generate_script_unsupportedfunction register_python_scriptingfunction setup_python_scriptingfunction setup_python_scriptingfunction print_perl_unsupported_msgfunction perl_start_script_unsupportedfunction perl_generate_script_unsupportedfunction register_perl_scriptingfunction setup_perl_scriptingfunction setup_perl_scriptingfunction sample_flags_to_namefunction perf_sample__sprintf_flags
Annotated Snippet
struct script_spec {
struct list_head node;
struct scripting_ops *ops;
char spec[];
};
static LIST_HEAD(script_specs);
static struct script_spec *script_spec__new(const char *spec,
struct scripting_ops *ops)
{
struct script_spec *s = malloc(sizeof(*s) + strlen(spec) + 1);
if (s != NULL) {
strcpy(s->spec, spec);
s->ops = ops;
}
return s;
}
static void script_spec__add(struct script_spec *s)
{
list_add_tail(&s->node, &script_specs);
}
static struct script_spec *script_spec__find(const char *spec)
{
struct script_spec *s;
list_for_each_entry(s, &script_specs, node)
if (strcasecmp(s->spec, spec) == 0)
return s;
return NULL;
}
static int script_spec_register(const char *spec, struct scripting_ops *ops)
{
struct script_spec *s;
s = script_spec__find(spec);
if (s)
return -1;
s = script_spec__new(spec, ops);
if (!s)
return -1;
script_spec__add(s);
return 0;
}
struct scripting_ops *script_spec__lookup(const char *spec)
{
struct script_spec *s = script_spec__find(spec);
if (!s)
return NULL;
return s->ops;
}
int script_spec__for_each(int (*cb)(struct scripting_ops *ops, const char *spec))
{
struct script_spec *s;
int ret = 0;
list_for_each_entry(s, &script_specs, node) {
ret = cb(s->ops, s->spec);
if (ret)
break;
}
return ret;
}
void scripting_context__update(struct scripting_context *c,
union perf_event *event,
struct perf_sample *sample,
struct evsel *evsel,
struct addr_location *al,
struct addr_location *addr_al)
{
#ifdef HAVE_LIBTRACEEVENT
const struct tep_event *tp_format = evsel__tp_format(evsel);
c->pevent = tp_format ? tp_format->tep : NULL;
#else
c->pevent = NULL;
#endif
c->event_data = sample->raw_data;
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`, `errno.h`, `event-parse.h`, `debug.h`, `event.h`, `trace-event.h`.
- Detected declarations: `struct script_spec`, `function script_spec__add`, `function script_spec_register`, `function script_spec__for_each`, `function list_for_each_entry`, `function scripting_context__update`, `function flush_script_unsupported`, `function stop_script_unsupported`, `function process_event_unsupported`, `function python_start_script_unsupported`.
- 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.