tools/perf/util/unwind-libunwind-local.c
Source file repositories/reference/linux-study-clean/tools/perf/util/unwind-libunwind-local.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/unwind-libunwind-local.c- Extension
.c- Size
- 19814 bytes
- Lines
- 832
- 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
elf.herrno.hgelf.hfcntl.hinttypes.hstring.hunistd.hsys/mman.hlinux/list.hlibunwind.hlibunwind-ptrace.hcallchain.hthread.hsession.hperf_regs.hunwind.hmap.hsymbol.hdebug.hasm/bug.hdso.h
Detected Declarations
struct unwind_infostruct table_entrystruct eh_frame_hdrstruct read_unwind_spec_eh_frame_maps_cb_argsfunction __dw_read_encoded_valuefunction elf_section_address_and_offsetfunction elf_section_offsetfunction elf_base_addressfunction elf_is_execfunction unwind_spec_ehframefunction read_unwind_spec_eh_frame_maps_cbfunction read_unwind_spec_eh_framefunction read_unwind_spec_debug_framefunction find_proc_infofunction access_fpregfunction get_dyn_info_list_addrfunction resumefunction get_proc_namefunction access_dso_memfunction access_memfunction access_regfunction put_unwind_infofunction entryfunction display_errorfunction _unwind__prepare_accessfunction _unwind__flush_accessfunction _unwind__finish_accessfunction get_entriesfunction _unwind__get_entries
Annotated Snippet
struct unwind_info {
struct perf_sample *sample;
struct machine *machine;
struct thread *thread;
bool best_effort;
};
#define dw_read(ptr, type, end) ({ \
type *__p = (type *) ptr; \
type __v; \
if ((__p + 1) > (type *) end) \
return -EINVAL; \
__v = *__p++; \
ptr = (typeof(ptr)) __p; \
__v; \
})
static int __dw_read_encoded_value(u8 **p, u8 *end, u64 *val,
u8 encoding)
{
u8 *cur = *p;
*val = 0;
switch (encoding) {
case DW_EH_PE_omit:
*val = 0;
goto out;
case DW_EH_PE_ptr:
*val = dw_read(cur, unsigned long, end);
goto out;
default:
break;
}
switch (encoding & DW_EH_PE_APPL_MASK) {
case DW_EH_PE_absptr:
break;
case DW_EH_PE_pcrel:
*val = (unsigned long) cur;
break;
default:
return -EINVAL;
}
if ((encoding & 0x07) == 0x00)
encoding |= DW_EH_PE_udata4;
switch (encoding & DW_EH_PE_FORMAT_MASK) {
case DW_EH_PE_sdata4:
*val += dw_read(cur, s32, end);
break;
case DW_EH_PE_udata4:
*val += dw_read(cur, u32, end);
break;
case DW_EH_PE_sdata8:
*val += dw_read(cur, s64, end);
break;
case DW_EH_PE_udata8:
*val += dw_read(cur, u64, end);
break;
default:
return -EINVAL;
}
out:
*p = cur;
return 0;
}
#define dw_read_encoded_value(ptr, end, enc) ({ \
u64 __v; \
if (__dw_read_encoded_value(&ptr, end, &__v, enc)) { \
return -EINVAL; \
} \
__v; \
})
static int elf_section_address_and_offset(int fd, const char *name, u64 *address, u64 *offset)
{
Elf *elf;
GElf_Ehdr ehdr;
GElf_Shdr shdr;
int ret = -1;
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
if (elf == NULL)
return -1;
if (gelf_getehdr(elf, &ehdr) == NULL)
goto out_err;
Annotation
- Immediate include surface: `elf.h`, `errno.h`, `gelf.h`, `fcntl.h`, `inttypes.h`, `string.h`, `unistd.h`, `sys/mman.h`.
- Detected declarations: `struct unwind_info`, `struct table_entry`, `struct eh_frame_hdr`, `struct read_unwind_spec_eh_frame_maps_cb_args`, `function __dw_read_encoded_value`, `function elf_section_address_and_offset`, `function elf_section_offset`, `function elf_base_address`, `function elf_is_exec`, `function unwind_spec_ehframe`.
- 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.