tools/perf/util/evsel_fprintf.c
Source file repositories/reference/linux-study-clean/tools/perf/util/evsel_fprintf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/evsel_fprintf.c- Extension
.c- Size
- 6764 bytes
- Lines
- 259
- 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.hstdbool.hutil/evlist.hevsel.hutil/evsel_fprintf.hutil/event.hcallchain.hmap.hstrlist.hsymbol.hsrcline.hdso.hevent-parse.h
Detected Declarations
function comma_fprintffunction __print_attr__fprintffunction evsel__fprintffunction sample__fprintf_callchainfunction sample__fprintf_sym
Annotated Snippet
if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) {
printed += comma_fprintf(fp, &first, " (not a tracepoint)");
goto out;
}
tp_format = evsel__tp_format(evsel);
field = tp_format ? tp_format->format.fields : NULL;
if (field == NULL) {
printed += comma_fprintf(fp, &first, " (no trace field)");
goto out;
}
printed += comma_fprintf(fp, &first, " trace_fields: %s", field->name);
field = field->next;
while (field) {
printed += comma_fprintf(fp, &first, "%s", field->name);
field = field->next;
}
}
#endif
out:
fputc('\n', fp);
return ++printed;
}
int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
unsigned int print_opts, struct callchain_cursor *cursor,
struct strlist *bt_stop_list, FILE *fp)
{
int printed = 0;
struct callchain_cursor_node *node;
int print_ip = print_opts & EVSEL__PRINT_IP;
int print_sym = print_opts & EVSEL__PRINT_SYM;
int print_dso = print_opts & EVSEL__PRINT_DSO;
int print_dsoff = print_opts & EVSEL__PRINT_DSOFF;
int print_symoffset = print_opts & EVSEL__PRINT_SYMOFFSET;
int print_oneline = print_opts & EVSEL__PRINT_ONELINE;
int print_srcline = print_opts & EVSEL__PRINT_SRCLINE;
int print_unknown_as_addr = print_opts & EVSEL__PRINT_UNKNOWN_AS_ADDR;
int print_arrow = print_opts & EVSEL__PRINT_CALLCHAIN_ARROW;
int print_skip_ignored = print_opts & EVSEL__PRINT_SKIP_IGNORED;
char s = print_oneline ? ' ' : '\t';
bool first = true;
if (cursor == NULL)
return fprintf(fp, "<not enough memory for the callchain cursor>%s", print_oneline ? "" : "\n");
if (sample->callchain) {
callchain_cursor_commit(cursor);
while (1) {
struct symbol *sym;
struct map *map;
u64 addr = 0;
node = callchain_cursor_current(cursor);
if (!node)
break;
sym = node->ms.sym;
map = node->ms.map;
if (sym && sym->ignore && print_skip_ignored)
goto next;
printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
if (print_arrow && !first)
printed += fprintf(fp, " <-");
if (map)
addr = map__map_ip(map, node->ip);
if (print_ip)
printed += fprintf(fp, "%c%16" PRIx64, s, node->ip);
if (print_sym) {
struct addr_location node_al;
addr_location__init(&node_al);
printed += fprintf(fp, " ");
node_al.addr = addr;
node_al.map = map__get(map);
if (sample->deferred_callchain &&
sample->deferred_cookie == node->ip) {
printed += fprintf(fp, "(cookie)");
} else if (print_symoffset) {
printed += __symbol__fprintf_symname_offs(sym, &node_al,
Annotation
- Immediate include surface: `inttypes.h`, `stdio.h`, `stdbool.h`, `util/evlist.h`, `evsel.h`, `util/evsel_fprintf.h`, `util/event.h`, `callchain.h`.
- Detected declarations: `function comma_fprintf`, `function __print_attr__fprintf`, `function evsel__fprintf`, `function sample__fprintf_callchain`, `function sample__fprintf_sym`.
- 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.