tools/perf/util/dlfilter.c
Source file repositories/reference/linux-study-clean/tools/perf/util/dlfilter.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/dlfilter.c- Extension
.c- Size
- 14210 bytes
- Lines
- 663
- 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
dlfcn.hstdlib.hstring.hdirent.hsubcmd/exec-cmd.hlinux/zalloc.hlinux/build_bug.hlinux/kernel.hlinux/string.hdebug.hevent.hevsel.hdso.hmap.hthread.htrace-event.hsymbol.hsrcline.hdlfilter.h../include/perf/perf_dlfilter.h
Detected Declarations
function Copyrightfunction has_privfunction dlfilter__resolve_addressfunction dlfilter__al_cleanupfunction code_readfunction dlfilter__object_codefunction dlfilter__initfunction dlfilter__exitfunction dlfilter__openfunction dlfilter__closefunction dlfilter__freefunction dlfilter__startfunction dlfilter__stopfunction dlfilter__cleanupfunction dlfilter__do_filter_eventfunction get_filter_descfunction list_filtersfunction list_available_dlfilters
Annotated Snippet
if (thread__maps(al->thread)) {
struct machine *machine = maps__machine(thread__maps(al->thread));
if (machine)
perf_sample__fetch_insn(d->sample, al->thread, machine);
}
}
if (!d->sample->insn_len)
return NULL;
*len = d->sample->insn_len;
return (__u8 *)d->sample->insn;
}
static const char *dlfilter__srcline(void *ctx, __u32 *line_no)
{
struct dlfilter *d = (struct dlfilter *)ctx;
struct addr_location *al;
unsigned int line = 0;
char *srcfile = NULL;
struct map *map;
struct dso *dso;
u64 addr;
if (!d->ctx_valid || !line_no)
return NULL;
al = get_al(d);
if (!al)
return NULL;
map = al->map;
addr = al->addr;
dso = map ? map__dso(map) : NULL;
if (dso)
srcfile = get_srcline_split(dso, map__rip_2objdump(map, addr), &line);
*line_no = line;
return srcfile;
}
static struct perf_event_attr *dlfilter__attr(void *ctx)
{
struct dlfilter *d = (struct dlfilter *)ctx;
if (!d->ctx_valid)
return NULL;
return &d->evsel->core.attr;
}
static __s32 code_read(__u64 ip, struct map *map, struct machine *machine, void *buf, __u32 len)
{
u64 offset = map__map_ip(map, ip);
if (ip + len >= map__end(map))
len = map__end(map) - ip;
return dso__data_read_offset(map__dso(map), machine, offset, buf, len);
}
static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len)
{
struct dlfilter *d = (struct dlfilter *)ctx;
struct addr_location *al;
struct addr_location a;
__s32 ret;
if (!d->ctx_valid)
return -1;
al = get_al(d);
if (!al)
return -1;
if (al->map && ip >= map__start(al->map) && ip < map__end(al->map) &&
machine__kernel_ip(d->machine, ip) == machine__kernel_ip(d->machine, d->sample->ip))
return code_read(ip, al->map, d->machine, buf, len);
addr_location__init(&a);
thread__find_map_fb(al->thread, d->sample->cpumode, ip, &a);
ret = a.map ? code_read(ip, a.map, d->machine, buf, len) : -1;
addr_location__exit(&a);
return ret;
Annotation
- Immediate include surface: `dlfcn.h`, `stdlib.h`, `string.h`, `dirent.h`, `subcmd/exec-cmd.h`, `linux/zalloc.h`, `linux/build_bug.h`, `linux/kernel.h`.
- Detected declarations: `function Copyright`, `function has_priv`, `function dlfilter__resolve_address`, `function dlfilter__al_cleanup`, `function code_read`, `function dlfilter__object_code`, `function dlfilter__init`, `function dlfilter__exit`, `function dlfilter__open`, `function dlfilter__close`.
- 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.